Merge from Code Cleanup

e911_addr
Chris Lacina 7 years ago
parent 34bce89ef5
commit 988e1564c7
  1. 47
      flowroutenumbersandmessaging/controllers/messages_controller.py
  2. 6
      number_route_message_demo.py

@ -296,3 +296,50 @@ class MessagesController(BaseController):
body))
return self.handle_request_and_response(_request)
def set_did_level_dlr_callback(self, number_id, dlr_url):
"""Does a POST request to /v2/numbers/number_id/relationships/dlr_callback
Sets the callback url for all delivery receipts (dlrs) for the
specified did
Args:
number_id (integer): pk of the DID record
url (string): The callback url to be hit.
Returns:
mixed: Response from the API. ACCEPTED
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/{}/relationships/dlr_callback'.format(number_id)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/vnd.api+json',
'content-type': 'application/vnd.api+json; charset=utf-8'
}
body = {
'data': {
'attributes': {
'callback_url': dlr_url
}
}
}
# Prepare and execute request
_request = self.http_client.post(_query_url,
headers=_headers,
parameters=APIHelper.json_serialize(
body))
return self.handle_request_and_response(_request)

@ -13,7 +13,7 @@ print("Number/Route Management v2 & Messaging v2.1 Demo")
# Set up your api credentials and test mobile number for outbound SMS or MMS
# basic_auth_user_name = os.environ.get('FR_ACCESS_KEY')
# basic_auth_password = os.environ.get('FR_SECRET_KEY')
mobile_number = "4254664078"
mobile_number = "YOUR NUMBER HERE"
# Instantiate API client and create controllers for Numbers,
@ -254,6 +254,10 @@ dlr_url = 'http://example.com/dlr'
result = messages_controller.set_account_level_dlr_callback(dlr_url)
pprint.pprint(result)
print("\n---Set a DID Level DLR Callback URL")
dlr_url = 'http://example.com/did/dlr'
result = messages_controller.set_did_level_dlr_callback(number_id, dlr_url)
pprint.pprint(result)
# --------------------- Porting -----------------------------------------

Loading…
Cancel
Save