Skip to content

Commit

Permalink
Merge pull request #15 from Paul-weqe/add-auth-token-to-initialization
Browse files Browse the repository at this point in the history
Add auth_token in initializer for Bot()
  • Loading branch information
Paul-weqe authored Jun 14, 2020
2 parents 78878da + d78daef commit 3a6e131
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
17 changes: 13 additions & 4 deletions python_webex/v1/Bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@

class Bot(People, Room, Webhook, Message):

def __init__(self):
def __init__(self, auth_token=None):

# declare headers and how the token will be gotten from the system
self.URL = "https://api.ciscospark.com/"
self.auth_token = os.getenv("auth_token")

# looks for if the auth_token has been set in the initializer.
# If not, goes looks for the `auth_token` environment variable
self.auth_token = auth_token if auth_token else os.getenv("auth_token")


if self.auth_token == None:
sys.exit("'auth_token' not set in the environment variables")
print("The auth_token needs to be specified for us to identify the bot being specified.")
print("This can be done through: ")
print(" 1. specifying in the intiializer. Bot('auth_token')")
print(" 2. specifying in your environment vairiables. How environment variables are defined depends on your OS")
sys.exit()

self.headers = {
"Authorization": "Bearer " + self.auth_token,
Expand All @@ -37,7 +45,8 @@ def __init__(self):

}

# default attachment variable will hold the function that is supposed to be the default action whenever an attachment is sent to the bot
# default attachment variable will hold the function that is supposed to be the
# default action whenever an attachment is sent to the bot
self.default_attachment = None

# maps what will happen when a file is received with a particular type of text
Expand Down
3 changes: 0 additions & 3 deletions python_webex/v1/Card.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ def add_input_choiceset(
self, input_id: str, input_choices:list=[], input_is_multiselect: bool = False, input_value:str = None
):
self.check_if_id_exists(input_id)
print("*" * 70)
print(input_choices)
print("*" * 70)
element = {
"id": input_id,
"type": "Input.ChoiceSet",
Expand Down
10 changes: 6 additions & 4 deletions python_webex/v1/Message.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ def send_message(self, room_id=None, text=None, files=[]):
details on the rooms URL parameters can be found in https://developer.webex.com/docs/api/v1/messages/create-a-message
'files' is a list of the files(images, audios etc) you want to send to the user, if the user wants to attach files with the message
Arguments:
room_id => This is a
text => The text being sent in the message
files => A list of files you want to sell. Each element in the list is a directory path to the file. e.g files=['/this/is/my/path/this_image.jpg', 'this/is/my/second/path/this_pdf.pdf']
----
Arguments
@ room_id: string => This is the ID of the room you are sending the message to
@ text: string => The text being sent in the message
@ files: list of string => A list of files you want to sell. Each element in the list is a directory path to the file.
e.g files=['/this/is/my/path/this_image.jpg', 'this/is/my/second/path/this_pdf.pdf']
"""
if room_id == None:
sys.exit("'roomId' is a required field")
Expand Down

0 comments on commit 3a6e131

Please sign in to comment.