|
|
|
@ -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) |