Applications¶
list_applications¶
-
Client.
list_applications
(size=None, **kwargs)¶ Get a list of user’s applications
Parameters: size (int) – Used for pagination to indicate the size of each page requested for querying a list of items. If no value is specified the default value is 25. (Maximum value 1000) Return type: types.GeneratorType Returns: list of applications Example: Fetch and print all applications:
apps = api.list_applications() print(list(apps))
Example: Iterate over all applications to find specific name:
apps = api.list_applications(size=20) app_name = "" while app_name != "MyAppName": my_app = next(apps) app_name = my_app["name"] print(my_app) ## { 'auto_answer': True, ## 'callback_http_method': 'get', ## 'id': 'a-asdf', ## 'incoming_call_url': 'https://test.com/callcallback/', ## 'incoming_message_url': 'https://test.com/msgcallback/', ## 'name': 'MyAppName' ## }
create_application¶
-
Client.
create_application
(name, incoming_call_url=None, incoming_call_url_callback_timeout=None, incoming_call_fallback_url=None, incoming_message_url=None, incoming_message_url_callback_timeout=None, incoming_message_fallback_url=None, callback_http_method=None, auto_answer=None, **kwargs)¶ Creates an application that can handle calls and messages for one of your phone number.
Parameters: - name (str) – A name you choose for this application (required).
- incoming_call_url (str) – A URL where call events will be sent for an inbound call.
- incoming_call_url_callback_timeout (str) – Determine how long should the platform wait for inconmingCallUrl’s response before timing out in milliseconds.
- incoming_call_fallback_url (str) – The URL used to send the callback event if the request to incomingCallUrl fails.
- incoming_message_url (str) – A URL where message events will be sent for an inbound SMS message
- incoming_message_url_callback_timeout (str) – Determine how long should the platform wait for incomingMessageUrl’s response before timing out in milliseconds.
- incoming_message_fallback_url (str) – The URL used to send the callback event if the request to incomingMessageUrl fails.
- callback_http_method (str) – Determine if the callback event should be sent via HTTP GET or HTTP POST. (If not set the default is HTTP POST)
- auto_answer (str) – Determines whether or not an incoming call should be automatically answered. Default value is ‘true’.
Return type: str
Returns: id of created application
Example: Create Application:
my_app_id = api.create_application( name = "MyFirstApp", incoming_call_url = "http://callback.com/calls", incoming_message_url = "http://callback.com/messages", callback_http_method = "GET") print(my_app_id) ## a-1232asf123 my_app = api.get_application(my_app_id) print(my_app) ## { 'auto_answer' : True, ## 'callback_http_method': 'get', ## 'id' : 'a-1232asf123', ## 'incoming_call_url' : 'http://callback.com/calls', ## 'incoming_message_url': 'http://callback.com/messages', ## 'incoming_sms_url' : 'http://callback.com/messages', ## 'name' : 'MyFirstApp2' ## } print(my_app["id"]) ## a-1232asf123
update_application¶
-
Client.
update_application
(app_id, name=None, incoming_call_url=None, incoming_call_url_callback_timeout=None, incoming_call_fallback_url=None, incoming_message_url=None, incoming_message_url_callback_timeout=None, incoming_message_fallback_url=None, callback_http_method=None, auto_answer=None, **kwargs)¶ Updates an application that can handle calls and messages for one of your phone number.
Parameters: - app_id (str) – The Id of the application to upate (a-123)
- name (str) – A name you choose for this application (required).
- incoming_call_url (str) – A URL where call events will be sent for an inbound call.
- incoming_call_url_callback_timeout (str) – Determine how long should the platform wait for inconmingCallUrl’s response before timing out in milliseconds.
- incoming_call_fallback_url (str) – The URL used to send the callback event if the request to incomingCallUrl fails.
- incoming_message_url (str) – A URL where message events will be sent for an inbound SMS message
- incoming_message_url_callback_timeout (str) – Determine how long should the platform wait for incomingMessageUrl’s response before timing out in milliseconds.
- incoming_message_fallback_url (str) – The URL used to send the callback event if the request to incomingMessageUrl fails.
- callback_http_method (str) – Determine if the callback event should be sent via HTTP GET or HTTP POST. (If not set the default is HTTP POST)
- auto_answer (str) – Determines whether or not an incoming call should be automatically answered. Default value is ‘true’.
Return type: str
Returns: id of created application
Example: Update Existing Application:
my_app_id = api.create_application( name = "MyFirstApp", incoming_call_url = "http://callback.com/calls", incoming_message_url = "http://callback.com/messages", callback_http_method = "GET") print(my_app_id) ## a-1232asf123 my_app = api.get_application(my_app_id) print(my_app) { 'auto_answer' : True, 'callbackHttpMethod': 'get', 'id' : 'a-1232asf123', 'incomingCallUrl' : 'http://callback.com/calls', 'incomingMessageUrl': 'http://callback.com/messages', 'incomingSmsUrl' : 'http://callback.com/messages', 'name' : 'MyFirstApp' } api.update_application(my_app_id, name = "My Updated App") my_app = api.get_application(my_app_id) print(my_app) { 'autoAnswer' : True, 'callbackHttpMethod': 'get', 'id' : 'a-1232asf123', 'incomingCallUrl' : 'http://callback.com/calls', 'incomingMessageUrl': 'http://callback.com/messages', 'incomingSmsUrl' : 'http://callback.com/messages', 'name' : 'My Updated App' }
get_application¶
-
Client.
get_application
(app_id)¶ Gets information about an application
Parameters: app_id (str) – id of an application Return type: dict Returns: application information Example: Fetch single application:
my_app = api.get_application(my_app_id) print(my_app) ## { 'auto_answer': True, ## 'callback_http_method': 'get', ## 'id': 'a-1232asf123', ## 'incoming_call_url': 'http://callback.com/calls', ## 'incoming_message_url': 'http://callback.com/messages', ## 'incoming_sms_url': 'http://callback.com/messages', ## 'name': 'MyFirstApp2' ## } print(my_app["id"]) ## a-1232asf123
delete_application¶
-
Client.
delete_application
(app_id)¶ Remove an application
Parameters: app_id (str) – id of an application Example: Delete single application:
api.delete_application('a-appId') try : api.get_application('a-appId') except CatapultException as err: print(err.message) ## The application a-appId could not be found