diff --git a/message_media_messages/api_helper.py b/message_media_messages/api_helper.py index f6ad2dc..d6344b3 100644 --- a/message_media_messages/api_helper.py +++ b/message_media_messages/api_helper.py @@ -3,7 +3,6 @@ """ message_media_messages.api_helper - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ import re diff --git a/message_media_messages/configuration.py b/message_media_messages/configuration.py index 1997591..43478df 100644 --- a/message_media_messages/configuration.py +++ b/message_media_messages/configuration.py @@ -3,7 +3,6 @@ """ message_media_messages.configuration - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ import sys import logging diff --git a/message_media_messages/controllers/base_controller.py b/message_media_messages/controllers/base_controller.py index efedec0..717acec 100644 --- a/message_media_messages/controllers/base_controller.py +++ b/message_media_messages/controllers/base_controller.py @@ -3,7 +3,6 @@ """ message_media_messagescontrollers.base_controller - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ from ..api_helper import APIHelper diff --git a/message_media_messages/controllers/delivery_reports_controller.py b/message_media_messages/controllers/delivery_reports_controller.py index 3cb951d..ee7d18a 100644 --- a/message_media_messages/controllers/delivery_reports_controller.py +++ b/message_media_messages/controllers/delivery_reports_controller.py @@ -3,7 +3,6 @@ """ message_media_messages.controllers.delivery_reports_controller - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ import logging diff --git a/message_media_messages/controllers/messages_controller.py b/message_media_messages/controllers/messages_controller.py index e4296e8..8d8636c 100644 --- a/message_media_messages/controllers/messages_controller.py +++ b/message_media_messages/controllers/messages_controller.py @@ -3,7 +3,6 @@ """ message_media_messages.controllers.messages_controller - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ import logging diff --git a/message_media_messages/controllers/replies_controller.py b/message_media_messages/controllers/replies_controller.py index d787c43..6371e00 100644 --- a/message_media_messages/controllers/replies_controller.py +++ b/message_media_messages/controllers/replies_controller.py @@ -3,7 +3,6 @@ """ message_media_messages.controllers.replies_controller - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ import logging diff --git a/message_media_messages/decorators.py b/message_media_messages/decorators.py index 3762b39..78a0cb4 100644 --- a/message_media_messages/decorators.py +++ b/message_media_messages/decorators.py @@ -3,7 +3,6 @@ """ message_media_messages.decorators - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ class lazy_property(object): diff --git a/message_media_messages/exceptions/api_exception.py b/message_media_messages/exceptions/api_exception.py index 6c06110..5056c84 100644 --- a/message_media_messages/exceptions/api_exception.py +++ b/message_media_messages/exceptions/api_exception.py @@ -3,7 +3,6 @@ """ message_media_messages.exceptions.api_exception - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ class APIException(Exception): diff --git a/message_media_messages/http/auth/basic_auth.py b/message_media_messages/http/auth/basic_auth.py index 0fed749..4955afa 100644 --- a/message_media_messages/http/auth/basic_auth.py +++ b/message_media_messages/http/auth/basic_auth.py @@ -3,7 +3,6 @@ """ message_media_messages.http.auth.basic_auth - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ import base64 diff --git a/message_media_messages/http/http_call_back.py b/message_media_messages/http/http_call_back.py index 5e22208..265e9db 100644 --- a/message_media_messages/http/http_call_back.py +++ b/message_media_messages/http/http_call_back.py @@ -3,7 +3,6 @@ """ message_media_messages.http.http_call_back - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ class HttpCallBack(object): diff --git a/message_media_messages/http/http_client.py b/message_media_messages/http/http_client.py index 69be44f..8b6e16a 100644 --- a/message_media_messages/http/http_client.py +++ b/message_media_messages/http/http_client.py @@ -3,7 +3,6 @@ """ message_media_messages.http.http_client - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ from .http_request import HttpRequest diff --git a/message_media_messages/http/http_context.py b/message_media_messages/http/http_context.py index 1fbc311..932d7c5 100644 --- a/message_media_messages/http/http_context.py +++ b/message_media_messages/http/http_context.py @@ -3,7 +3,6 @@ """ message_media_messages.http.http_context - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ class HttpContext(object): diff --git a/message_media_messages/http/http_method_enum.py b/message_media_messages/http/http_method_enum.py index 0bd4b9f..e1ee398 100644 --- a/message_media_messages/http/http_method_enum.py +++ b/message_media_messages/http/http_method_enum.py @@ -3,7 +3,7 @@ """ message_media_messages.http.http_method_enum - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). + """ class HttpMethodEnum(object): diff --git a/message_media_messages/http/http_request.py b/message_media_messages/http/http_request.py index 0c668ba..d7a7564 100644 --- a/message_media_messages/http/http_request.py +++ b/message_media_messages/http/http_request.py @@ -3,7 +3,6 @@ """ message_media_messages.http.http_request - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ from ..api_helper import APIHelper diff --git a/message_media_messages/http/http_response.py b/message_media_messages/http/http_response.py index 4a34afc..b6b2aca 100644 --- a/message_media_messages/http/http_response.py +++ b/message_media_messages/http/http_response.py @@ -3,7 +3,6 @@ """ message_media_messages.http.http_response - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ class HttpResponse(object): diff --git a/message_media_messages/http/requests_client.py b/message_media_messages/http/requests_client.py index 5395f13..21610ed 100644 --- a/message_media_messages/http/requests_client.py +++ b/message_media_messages/http/requests_client.py @@ -3,7 +3,7 @@ """ message_media_messages.http.requests_client - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). + """ import requests diff --git a/message_media_messages/message_media_messages_client.py b/message_media_messages/message_media_messages_client.py index e12c0a4..affc4f1 100644 --- a/message_media_messages/message_media_messages_client.py +++ b/message_media_messages/message_media_messages_client.py @@ -3,7 +3,6 @@ """ message_media_messages.message_media_messages_client - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ from .decorators import lazy_property from .configuration import Configuration diff --git a/message_media_messages/models/cancel_scheduled_message_request.py b/message_media_messages/models/cancel_scheduled_message_request.py index 0269bcc..52cb050 100644 --- a/message_media_messages/models/cancel_scheduled_message_request.py +++ b/message_media_messages/models/cancel_scheduled_message_request.py @@ -3,7 +3,6 @@ """ message_media_messages.models.cancel_scheduled_message_request - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/check_delivery_reports_response.py b/message_media_messages/models/check_delivery_reports_response.py index 4648523..c37f506 100644 --- a/message_media_messages/models/check_delivery_reports_response.py +++ b/message_media_messages/models/check_delivery_reports_response.py @@ -3,7 +3,6 @@ """ message_media_messages.models.check_delivery_reports_response - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/check_replies_response.py b/message_media_messages/models/check_replies_response.py index 83877c4..1a0604b 100644 --- a/message_media_messages/models/check_replies_response.py +++ b/message_media_messages/models/check_replies_response.py @@ -3,7 +3,6 @@ """ message_media_messages.models.check_replies_response - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/confirm_delivery_reports_as_received_request.py b/message_media_messages/models/confirm_delivery_reports_as_received_request.py index 5539a52..7679d64 100644 --- a/message_media_messages/models/confirm_delivery_reports_as_received_request.py +++ b/message_media_messages/models/confirm_delivery_reports_as_received_request.py @@ -3,7 +3,6 @@ """ message_media_messages.models.confirm_delivery_reports_as_received_request - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/confirm_delivery_reports_as_received_request_11.py b/message_media_messages/models/confirm_delivery_reports_as_received_request_11.py index acc5b4e..fdb678d 100644 --- a/message_media_messages/models/confirm_delivery_reports_as_received_request_11.py +++ b/message_media_messages/models/confirm_delivery_reports_as_received_request_11.py @@ -3,7 +3,6 @@ """ message_media_messages.models.confirm_delivery_reports_as_received_request_11 - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/confirm_replies_as_received_request.py b/message_media_messages/models/confirm_replies_as_received_request.py index 4a393ad..059b5bc 100644 --- a/message_media_messages/models/confirm_replies_as_received_request.py +++ b/message_media_messages/models/confirm_replies_as_received_request.py @@ -3,7 +3,6 @@ """ message_media_messages.models.confirm_replies_as_received_request - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/confirm_replies_as_received_request_8.py b/message_media_messages/models/confirm_replies_as_received_request_8.py index d622597..44e240f 100644 --- a/message_media_messages/models/confirm_replies_as_received_request_8.py +++ b/message_media_messages/models/confirm_replies_as_received_request_8.py @@ -3,7 +3,6 @@ """ message_media_messages.models.confirm_replies_as_received_request_8 - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/send_messages_request.py b/message_media_messages/models/send_messages_request.py index 131d98f..a3bd739 100644 --- a/message_media_messages/models/send_messages_request.py +++ b/message_media_messages/models/send_messages_request.py @@ -3,7 +3,6 @@ """ message_media_messages.models.send_messages_request - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/message_media_messages/models/send_messages_response.py b/message_media_messages/models/send_messages_response.py index 30642fd..6c87b7c 100644 --- a/message_media_messages/models/send_messages_response.py +++ b/message_media_messages/models/send_messages_response.py @@ -3,7 +3,6 @@ """ message_media_messages.models.send_messages_response - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ) """ diff --git a/tests/controllers/controller_test_base.py b/tests/controllers/controller_test_base.py index 4fb68ee..4cb9ccf 100644 --- a/tests/controllers/controller_test_base.py +++ b/tests/controllers/controller_test_base.py @@ -3,7 +3,6 @@ """ tests.controllers.controller_test_base - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ import unittest diff --git a/tests/controllers/test_delivery_reports_controller.py b/tests/controllers/test_delivery_reports_controller.py index 99315c7..ee8d661 100644 --- a/tests/controllers/test_delivery_reports_controller.py +++ b/tests/controllers/test_delivery_reports_controller.py @@ -1,26 +1,25 @@ -# -*- coding: utf-8 -*- - -""" - tests.controllers.test_delivery_reports_controller - - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). -""" - -import jsonpickle -import dateutil.parser -from .controller_test_base import ControllerTestBase -from ..test_helper import TestHelper -from message_media_messages.api_helper import APIHelper -from message_media_messages.models.confirm_delivery_reports_as_received_request import ConfirmDeliveryReportsAsReceivedRequest - - -class DeliveryReportsControllerTests(ControllerTestBase): - - @classmethod - def setUpClass(cls): - super(DeliveryReportsControllerTests, cls).setUpClass() - cls.controller = cls.api_client.delivery_reports - +# -*- coding: utf-8 -*- + +""" + tests.controllers.test_delivery_reports_controller + +""" + +import jsonpickle +import dateutil.parser +from .controller_test_base import ControllerTestBase +from ..test_helper import TestHelper +from message_media_messages.api_helper import APIHelper +from message_media_messages.models.confirm_delivery_reports_as_received_request import ConfirmDeliveryReportsAsReceivedRequest + + +class DeliveryReportsControllerTests(ControllerTestBase): + + @classmethod + def setUpClass(cls): + super(DeliveryReportsControllerTests, cls).setUpClass() + cls.controller = cls.api_client.delivery_reports + # Check for any delivery reports that have been received. #Delivery reports are a notification of the change in status of a message as it is being processed. #Each request to the check delivery reports endpoint will return any delivery reports received that @@ -85,27 +84,27 @@ def setUpClass(cls): #2. Process each delivery report #3. Confirm all processed delivery reports using the confirm delivery reports endpoint #*Note: It is recommended to use the Webhooks feature to receive reply messages rather than - #polling the check delivery reports endpoint.* - def test_check_delivery_reports_1(self): - - # Perform the API call through the SDK function - result = self.controller.get_check_delivery_reports() - - # Test response code - self.assertEquals(self.response_catcher.response.status_code, 200) - - # Test headers - expected_headers = {} - expected_headers['content-type'] = None - - self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) - - - # Test whether the captured response is as we expected - self.assertIsNotNone(result) - self.assertEqual('{ "delivery_reports": [ { "callback_url": "https://my.callback.url.com", "delivery_report_id": "01e1fa0a-6e27-4945-9cdb-18644b4de043", "source_number": "+61491570157", "date_received": "2017-05-20T06:30:37.642Z", "status": "enroute", "delay": 0, "submitted_date": "2017-05-20T06:30:37.639Z", "original_text": "My first message!", "message_id": "d781dcab-d9d8-4fb2-9e03-872f07ae94ba", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "metadata": { "key1": "value1", "key2": "value2" } }, { "callback_url": "https://my.callback.url.com", "delivery_report_id": "0edf9022-7ccc-43e6-acab-480e93e98c1b", "source_number": "+61491570158", "date_received": "2017-05-21T01:46:42.579Z", "status": "enroute", "delay": 0, "submitted_date": "2017-05-21T01:46:42.574Z", "original_text": "My second message!", "message_id": "fbb3b3f5-b702-4d8b-ab44-65b2ee39a281", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "metadata": { "key1": "value1", "key2": "value2" } } ]}', self.response_catcher.response.raw_body) - - + #polling the check delivery reports endpoint.* + def test_check_delivery_reports_1(self): + + # Perform the API call through the SDK function + result = self.controller.get_check_delivery_reports() + + # Test response code + self.assertEquals(self.response_catcher.response.status_code, 200) + + # Test headers + expected_headers = {} + expected_headers['content-type'] = None + + self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) + + + # Test whether the captured response is as we expected + self.assertIsNotNone(result) + self.assertEqual('{ "delivery_reports": [ { "callback_url": "https://my.callback.url.com", "delivery_report_id": "01e1fa0a-6e27-4945-9cdb-18644b4de043", "source_number": "+61491570157", "date_received": "2017-05-20T06:30:37.642Z", "status": "enroute", "delay": 0, "submitted_date": "2017-05-20T06:30:37.639Z", "original_text": "My first message!", "message_id": "d781dcab-d9d8-4fb2-9e03-872f07ae94ba", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "metadata": { "key1": "value1", "key2": "value2" } }, { "callback_url": "https://my.callback.url.com", "delivery_report_id": "0edf9022-7ccc-43e6-acab-480e93e98c1b", "source_number": "+61491570158", "date_received": "2017-05-21T01:46:42.579Z", "status": "enroute", "delay": 0, "submitted_date": "2017-05-21T01:46:42.574Z", "original_text": "My second message!", "message_id": "fbb3b3f5-b702-4d8b-ab44-65b2ee39a281", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "metadata": { "key1": "value1", "key2": "value2" } } ]}', self.response_catcher.response.raw_body) + + # Mark a delivery report as confirmed so it is no longer return in check delivery reports requests. #The confirm delivery reports endpoint is intended to be used in conjunction with the check delivery #reports endpoint to allow for robust processing of delivery reports. Once one or more delivery @@ -121,24 +120,24 @@ def test_check_delivery_reports_1(self): # ] #} #``` - #Up to 100 delivery reports can be confirmed in a single confirm delivery reports request. - def test_confirm_delivery_reports_as_received_1(self): - # Parameters for the API call - body = APIHelper.json_deserialize(( - '{"delivery_report_ids":["011dcead-6988-4ad6-a1c7-6b6c68ea628d","3487b3fa-65' - '86-4979-a233-2d1b095c7718","ba28e94b-c83d-4759-98e7-ff9c7edb87a1"]}' - ), ConfirmDeliveryReportsAsReceivedRequest.from_dictionary) - - # Perform the API call through the SDK function - result = self.controller.create_confirm_delivery_reports_as_received(body) - - # Test response code - self.assertEquals(self.response_catcher.response.status_code, 202) - - # Test headers - expected_headers = {} - expected_headers['content-type'] = None - - self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) - - + #Up to 100 delivery reports can be confirmed in a single confirm delivery reports request. + def test_confirm_delivery_reports_as_received_1(self): + # Parameters for the API call + body = APIHelper.json_deserialize(( + '{"delivery_report_ids":["011dcead-6988-4ad6-a1c7-6b6c68ea628d","3487b3fa-65' + '86-4979-a233-2d1b095c7718","ba28e94b-c83d-4759-98e7-ff9c7edb87a1"]}' + ), ConfirmDeliveryReportsAsReceivedRequest.from_dictionary) + + # Perform the API call through the SDK function + result = self.controller.create_confirm_delivery_reports_as_received(body) + + # Test response code + self.assertEquals(self.response_catcher.response.status_code, 202) + + # Test headers + expected_headers = {} + expected_headers['content-type'] = None + + self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) + + diff --git a/tests/controllers/test_messages_controller.py b/tests/controllers/test_messages_controller.py index eacbad5..5919ebf 100644 --- a/tests/controllers/test_messages_controller.py +++ b/tests/controllers/test_messages_controller.py @@ -1,26 +1,25 @@ -# -*- coding: utf-8 -*- - -""" - tests.controllers.test_messages_controller - - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). -""" - -import jsonpickle -import dateutil.parser -from .controller_test_base import ControllerTestBase -from ..test_helper import TestHelper -from message_media_messages.api_helper import APIHelper -from message_media_messages.models.send_messages_request import SendMessagesRequest - - -class MessagesControllerTests(ControllerTestBase): - - @classmethod - def setUpClass(cls): - super(MessagesControllerTests, cls).setUpClass() - cls.controller = cls.api_client.messages - +# -*- coding: utf-8 -*- + +""" + tests.controllers.test_messages_controller + +""" + +import jsonpickle +import dateutil.parser +from .controller_test_base import ControllerTestBase +from ..test_helper import TestHelper +from message_media_messages.api_helper import APIHelper +from message_media_messages.models.send_messages_request import SendMessagesRequest + + +class MessagesControllerTests(ControllerTestBase): + + @classmethod + def setUpClass(cls): + super(MessagesControllerTests, cls).setUpClass() + cls.controller = cls.api_client.messages + # Submit one or more (up to 100 per request) SMS or text to voice messages for delivery. #The most basic message has the following structure: #```json @@ -82,37 +81,37 @@ def setUpClass(cls): #```queued```. See the Delivery Reports section of this documentation for more information on message #statues. #*Note: when sending multiple messages in a request, all messages must be valid for the request to be successful. - #If any messages in the request are invalid, no messages will be sent.* - def test_send_messages_1(self): - # Parameters for the API call - body = APIHelper.json_deserialize(( - '{"messages":[{"callback_url":"https://my.callback.url.com","content":"My fi' - 'rst message","destination_number":"+61491570156","delivery_report":true,"fo' - 'rmat":"SMS","message_expiry_timestamp":"2016-11-03T11:49:02.807Z","metadata' - '":{"key1":"value1","key2":"value2"},"scheduled":"2016-11-03T11:49:02.807Z",' - '"source_number":"+61491570157","source_number_type":"INTERNATIONAL"},{"call' - 'back_url":"https://my.callback.url.com","content":"My second message","dest' - 'ination_number":"+61491570158","delivery_report":true,"format":"SMS","messa' - 'ge_expiry_timestamp":"2016-11-03T11:49:02.807Z","metadata":{"key1":"value1"' - ',"key2":"value2"},"scheduled":"2016-11-03T11:49:02.807Z","source_number":"+' - '61491570159","source_number_type":"INTERNATIONAL"}]}' - ), SendMessagesRequest.from_dictionary) - - # Perform the API call through the SDK function - result = self.controller.create_send_messages(body) - - # Test response code - self.assertEquals(self.response_catcher.response.status_code, 202) - - # Test headers - expected_headers = {} - expected_headers['content-type'] = None - - self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) - - - # Test whether the captured response is as we expected - self.assertIsNotNone(result) - self.assertEqual('{ "messages": [ { "message_id": "04fe9a97-a579-43c5-bb1a-58ed29bf0a6a", "callback_url": "https://my.url.com", "status": "delivered", "content": "My first message", "destination_number": "+61491570156", "delivery_report": true, "format": "SMS", "message_expiry_timestamp": "2016-11-03T11:49:02.807Z", "metadata": { "key1": "value1", "key2": "value2" }, "scheduled": "2016-11-03T11:49:02.807Z", "source_number": "+61491570157", "source_number_type": "INTERNATIONAL" } ]}', self.response_catcher.response.raw_body) - - + #If any messages in the request are invalid, no messages will be sent.* + def test_send_messages_1(self): + # Parameters for the API call + body = APIHelper.json_deserialize(( + '{"messages":[{"callback_url":"https://my.callback.url.com","content":"My fi' + 'rst message","destination_number":"+61491570156","delivery_report":true,"fo' + 'rmat":"SMS","message_expiry_timestamp":"2016-11-03T11:49:02.807Z","metadata' + '":{"key1":"value1","key2":"value2"},"scheduled":"2016-11-03T11:49:02.807Z",' + '"source_number":"+61491570157","source_number_type":"INTERNATIONAL"},{"call' + 'back_url":"https://my.callback.url.com","content":"My second message","dest' + 'ination_number":"+61491570158","delivery_report":true,"format":"SMS","messa' + 'ge_expiry_timestamp":"2016-11-03T11:49:02.807Z","metadata":{"key1":"value1"' + ',"key2":"value2"},"scheduled":"2016-11-03T11:49:02.807Z","source_number":"+' + '61491570159","source_number_type":"INTERNATIONAL"}]}' + ), SendMessagesRequest.from_dictionary) + + # Perform the API call through the SDK function + result = self.controller.create_send_messages(body) + + # Test response code + self.assertEquals(self.response_catcher.response.status_code, 202) + + # Test headers + expected_headers = {} + expected_headers['content-type'] = None + + self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) + + + # Test whether the captured response is as we expected + self.assertIsNotNone(result) + self.assertEqual('{ "messages": [ { "message_id": "04fe9a97-a579-43c5-bb1a-58ed29bf0a6a", "callback_url": "https://my.url.com", "status": "delivered", "content": "My first message", "destination_number": "+61491570156", "delivery_report": true, "format": "SMS", "message_expiry_timestamp": "2016-11-03T11:49:02.807Z", "metadata": { "key1": "value1", "key2": "value2" }, "scheduled": "2016-11-03T11:49:02.807Z", "source_number": "+61491570157", "source_number_type": "INTERNATIONAL" } ]}', self.response_catcher.response.raw_body) + + diff --git a/tests/controllers/test_replies_controller.py b/tests/controllers/test_replies_controller.py index 985390a..5c8f344 100644 --- a/tests/controllers/test_replies_controller.py +++ b/tests/controllers/test_replies_controller.py @@ -1,26 +1,25 @@ -# -*- coding: utf-8 -*- - -""" - tests.controllers.test_replies_controller - - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). -""" - -import jsonpickle -import dateutil.parser -from .controller_test_base import ControllerTestBase -from ..test_helper import TestHelper -from message_media_messages.api_helper import APIHelper -from message_media_messages.models.confirm_replies_as_received_request import ConfirmRepliesAsReceivedRequest - - -class RepliesControllerTests(ControllerTestBase): - - @classmethod - def setUpClass(cls): - super(RepliesControllerTests, cls).setUpClass() - cls.controller = cls.api_client.replies - +# -*- coding: utf-8 -*- + +""" + tests.controllers.test_replies_controller + +""" + +import jsonpickle +import dateutil.parser +from .controller_test_base import ControllerTestBase +from ..test_helper import TestHelper +from message_media_messages.api_helper import APIHelper +from message_media_messages.models.confirm_replies_as_received_request import ConfirmRepliesAsReceivedRequest + + +class RepliesControllerTests(ControllerTestBase): + + @classmethod + def setUpClass(cls): + super(RepliesControllerTests, cls).setUpClass() + cls.controller = cls.api_client.replies + # Mark a reply message as confirmed so it is no longer returned in check replies requests. #The confirm replies endpoint is intended to be used in conjunction with the check replies endpoint #to allow for robust processing of reply messages. Once one or more reply messages have been processed @@ -36,27 +35,27 @@ def setUpClass(cls): # ] #} #``` - #Up to 100 replies can be confirmed in a single confirm replies request. - def test_confirm_replies_as_received_1(self): - # Parameters for the API call - body = APIHelper.json_deserialize(( - '{"reply_ids":["011dcead-6988-4ad6-a1c7-6b6c68ea628d","3487b3fa-6586-4979-a2' - '33-2d1b095c7718","ba28e94b-c83d-4759-98e7-ff9c7edb87a1"]}' - ), ConfirmRepliesAsReceivedRequest.from_dictionary) - - # Perform the API call through the SDK function - result = self.controller.create_confirm_replies_as_received(body) - - # Test response code - self.assertEquals(self.response_catcher.response.status_code, 202) - - # Test headers - expected_headers = {} - expected_headers['content-type'] = None - - self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) - - + #Up to 100 replies can be confirmed in a single confirm replies request. + def test_confirm_replies_as_received_1(self): + # Parameters for the API call + body = APIHelper.json_deserialize(( + '{"reply_ids":["011dcead-6988-4ad6-a1c7-6b6c68ea628d","3487b3fa-6586-4979-a2' + '33-2d1b095c7718","ba28e94b-c83d-4759-98e7-ff9c7edb87a1"]}' + ), ConfirmRepliesAsReceivedRequest.from_dictionary) + + # Perform the API call through the SDK function + result = self.controller.create_confirm_replies_as_received(body) + + # Test response code + self.assertEquals(self.response_catcher.response.status_code, 202) + + # Test headers + expected_headers = {} + expected_headers['content-type'] = None + + self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) + + # Check for any replies that have been received. #Replies are messages that have been sent from a handset in response to a message sent by an #application or messages that have been sent from a handset to a inbound number associated with @@ -122,24 +121,24 @@ def test_confirm_replies_as_received_1(self): #2. Process each reply message #3. Confirm all processed reply messages using the confirm replies endpoint #*Note: It is recommended to use the Webhooks feature to receive reply messages rather than polling - #the check replies endpoint.* - def test_check_replies_1(self): - - # Perform the API call through the SDK function - result = self.controller.get_check_replies() - - # Test response code - self.assertEquals(self.response_catcher.response.status_code, 200) - - # Test headers - expected_headers = {} - expected_headers['content-type'] = None - - self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) - - - # Test whether the captured response is as we expected - self.assertIsNotNone(result) - self.assertEqual('{ "replies": [ { "metadata": { "key1": "value1", "key2": "value2" }, "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7", "reply_id": "a175e797-2b54-468b-9850-41a3eab32f74", "date_received": "2016-12-07T08:43:00.850Z", "callback_url": "https://my.callback.url.com", "destination_number": "+61491570156", "source_number": "+61491570157", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "content": "My first reply!" }, { "metadata": { "key1": "value1", "key2": "value2" }, "message_id": "8f2f5927-2e16-4f1c-bd43-47dbe2a77ae4", "reply_id": "3d8d53d8-01d3-45dd-8cfa-4dfc81600f7f", "date_received": "2016-12-07T08:43:00.850Z", "callback_url": "https://my.callback.url.com", "destination_number": "+61491570157", "source_number": "+61491570158", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "content": "My second reply!" } ]}', self.response_catcher.response.raw_body) - - + #the check replies endpoint.* + def test_check_replies_1(self): + + # Perform the API call through the SDK function + result = self.controller.get_check_replies() + + # Test response code + self.assertEquals(self.response_catcher.response.status_code, 200) + + # Test headers + expected_headers = {} + expected_headers['content-type'] = None + + self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) + + + # Test whether the captured response is as we expected + self.assertIsNotNone(result) + self.assertEqual('{ "replies": [ { "metadata": { "key1": "value1", "key2": "value2" }, "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7", "reply_id": "a175e797-2b54-468b-9850-41a3eab32f74", "date_received": "2016-12-07T08:43:00.850Z", "callback_url": "https://my.callback.url.com", "destination_number": "+61491570156", "source_number": "+61491570157", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "content": "My first reply!" }, { "metadata": { "key1": "value1", "key2": "value2" }, "message_id": "8f2f5927-2e16-4f1c-bd43-47dbe2a77ae4", "reply_id": "3d8d53d8-01d3-45dd-8cfa-4dfc81600f7f", "date_received": "2016-12-07T08:43:00.850Z", "callback_url": "https://my.callback.url.com", "destination_number": "+61491570157", "source_number": "+61491570158", "vendor_account_id": { "vendor_id": "MessageMedia", "account_id": "MyAccount" }, "content": "My second reply!" } ]}', self.response_catcher.response.raw_body) + + diff --git a/tests/http_response_catcher.py b/tests/http_response_catcher.py index 03ea1eb..7bf591d 100644 --- a/tests/http_response_catcher.py +++ b/tests/http_response_catcher.py @@ -3,7 +3,6 @@ """ tests.http_response_catcher - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ from message_media_messages.http.http_call_back import HttpCallBack diff --git a/tests/test_helper.py b/tests/test_helper.py index 7fb290b..83458b2 100644 --- a/tests/test_helper.py +++ b/tests/test_helper.py @@ -3,7 +3,6 @@ """ tests.test_helper - This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ). """ import os, tempfile, requests