Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more updates to sdk and tests
  • Loading branch information
ckoegel committed Jul 7, 2022
commit d525a6fd4a7c7c1442a72b4fb114865df119d478
9 changes: 6 additions & 3 deletions bandwidth.json
Original file line number Diff line number Diff line change
Expand Up @@ -2431,10 +2431,10 @@
"type": "string",
"description": "The priority specified by the user.",
"enum": [
"DEFAULT",
"HIGH"
"default",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backward compatibility issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean, the API currently returns these in lowercase

"high"
],
"example": "DEFAULT"
"example": "default"
},
"messageStatusEnum": {
"type": "string",
Expand Down Expand Up @@ -2563,16 +2563,19 @@
"attachmentCount": {
"type": "integer",
"description": "The number of attachments the message has.",
"nullable": true,
"example": 1
},
"recipientCount": {
"type": "integer",
"description": "The number of recipients the message has.",
"nullable": true,
"example": 1
},
"campaignClass": {
"type": "string",
"description": "The campaign class of the message if it has one.",
"nullable": true,
"example": "T"
}
}
Expand Down
24 changes: 12 additions & 12 deletions bandwidth/model/list_message_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def openapi_types():
'error_code': (int,), # noqa: E501
'receive_time': (str,), # noqa: E501
'carrier_name': (str,), # noqa: E501
'message_size': (int,), # noqa: E501
'message_size': (int, none_type,), # noqa: E501
'message_length': (int,), # noqa: E501
'attachment_count': (int,), # noqa: E501
'recipient_count': (int,), # noqa: E501
'campaign_class': (str,), # noqa: E501
'attachment_count': (int, none_type,), # noqa: E501
'recipient_count': (int, none_type,), # noqa: E501
'campaign_class': (str, none_type,), # noqa: E501
}

@cached_property
Expand Down Expand Up @@ -186,11 +186,11 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
error_code (int): The numeric error code of the message.. [optional] # noqa: E501
receive_time (str): The ISO 8601 datetime of the message.. [optional] # noqa: E501
carrier_name (str): The name of the carrier. Not currently supported for MMS coming soon.. [optional] # noqa: E501
message_size (int): The size of the message including message content and headers.. [optional] # noqa: E501
message_size (int, none_type): The size of the message including message content and headers.. [optional] # noqa: E501
message_length (int): The length of the message content.. [optional] # noqa: E501
attachment_count (int): The number of attachments the message has.. [optional] # noqa: E501
recipient_count (int): The number of recipients the message has.. [optional] # noqa: E501
campaign_class (str): The campaign class of the message if it has one.. [optional] # noqa: E501
attachment_count (int, none_type): The number of attachments the message has.. [optional] # noqa: E501
recipient_count (int, none_type): The number of recipients the message has.. [optional] # noqa: E501
campaign_class (str, none_type): The campaign class of the message if it has one.. [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down Expand Up @@ -287,11 +287,11 @@ def __init__(self, *args, **kwargs): # noqa: E501
error_code (int): The numeric error code of the message.. [optional] # noqa: E501
receive_time (str): The ISO 8601 datetime of the message.. [optional] # noqa: E501
carrier_name (str): The name of the carrier. Not currently supported for MMS coming soon.. [optional] # noqa: E501
message_size (int): The size of the message including message content and headers.. [optional] # noqa: E501
message_size (int, none_type): The size of the message including message content and headers.. [optional] # noqa: E501
message_length (int): The length of the message content.. [optional] # noqa: E501
attachment_count (int): The number of attachments the message has.. [optional] # noqa: E501
recipient_count (int): The number of recipients the message has.. [optional] # noqa: E501
campaign_class (str): The campaign class of the message if it has one.. [optional] # noqa: E501
attachment_count (int, none_type): The number of attachments the message has.. [optional] # noqa: E501
recipient_count (int, none_type): The number of recipients the message has.. [optional] # noqa: E501
campaign_class (str, none_type): The campaign class of the message if it has one.. [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down
8 changes: 4 additions & 4 deletions docs/ListMessageItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Name | Type | Description | Notes
**error_code** | **int** | The numeric error code of the message. | [optional]
**receive_time** | **str** | The ISO 8601 datetime of the message. | [optional]
**carrier_name** | **str** | The name of the carrier. Not currently supported for MMS coming soon. | [optional]
**message_size** | **int** | The size of the message including message content and headers. | [optional]
**message_size** | **int, none_type** | The size of the message including message content and headers. | [optional]
**message_length** | **int** | The length of the message content. | [optional]
**attachment_count** | **int** | The number of attachments the message has. | [optional]
**recipient_count** | **int** | The number of recipients the message has. | [optional]
**campaign_class** | **str** | The campaign class of the message if it has one. | [optional]
**attachment_count** | **int, none_type** | The number of attachments the message has. | [optional]
**recipient_count** | **int, none_type** | The number of recipients the message has. | [optional]
**campaign_class** | **str, none_type** | The campaign class of the message if it has one. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
127 changes: 61 additions & 66 deletions test/integration/test_messages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import unittest

import bandwidth
from bandwidth.api import messages_api
from bandwidth.api.messages_api import MessagesApi
from bandwidth.model.list_message_direction_enum import ListMessageDirectionEnum
from bandwidth.model.list_message_item import ListMessageItem
from bandwidth.model.message_request import MessageRequest
from bandwidth.model.message_status_enum import MessageStatusEnum
from bandwidth.model.message_type_enum import MessageTypeEnum
Expand All @@ -24,95 +26,88 @@
from bandwidth.model.message import Message
from bandwidth.model.messaging_request_error import MessagingRequestError

configuration = None

class TestMessagesApi(unittest.TestCase):
"""MessagesApi unit test stubs"""

def setUp(self):
self.api = MessagesApi() # noqa: E501
global configuration
configuration = bandwidth.Configuration(
username = os.environ.get('BW_USERNAME'),
password = os.environ.get('BW_PASSWORD')
)
api_client = bandwidth.ApiClient(configuration)
self.api_instance = messages_api.MessagesApi(api_client)
self.account_id = os.environ.get('BW_ACCOUNT_ID')

def tearDown(self):
pass

def test_create_message(self):
with bandwidth.ApiClient(configuration) as api_client:

api_instance = MessagesApi(api_client)
account_id = os.environ.get('BW_ACCOUNT_ID')
message_request = MessageRequest(
application_id=os.environ.get('BW_MESSAGING_APPLICATION_ID'),
to=[os.environ.get('USER_NUMBER')],
_from=os.environ.get('BW_NUMBER'),
text="python integration",
media=["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"],
tag="python integration tag",
priority=PriorityEnum("default"), #need to fix this enum
)
account_id = os.environ.get('BW_ACCOUNT_ID')
message_request = MessageRequest(
application_id=os.environ.get('BW_MESSAGING_APPLICATION_ID'),
to=[os.environ.get('USER_NUMBER')],
_from=os.environ.get('BW_NUMBER'),
text="python integration",
media=["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"],
tag="python integration tag",
priority=PriorityEnum("default"), #need to fix this enum
)

try:
api_response: Message = self.api_instance.create_message(account_id, message_request)
except bandwidth.ApiException as e:
print("Exception when calling MessagesApi->create_message: %s\n" % e)

try:
api_response: Message = api_instance.create_message(account_id, message_request)
except bandwidth.ApiException as e:
print("Exception when calling MessagesApi->create_message: %s\n" % e)

assert isinstance(api_response, Message)
assert api_response.application_id == message_request.application_id
assert api_response.to == message_request.to
assert api_response._from == message_request._from
assert api_response.text == message_request.text
assert api_response.media == message_request.media
assert api_response.tag == message_request.tag
assert api_response.priority == message_request.priority

pass
assert isinstance(api_response, Message)
assert api_response.application_id == message_request.application_id
assert api_response.to == message_request.to
assert api_response._from == message_request._from
assert api_response.text == message_request.text
assert api_response.media == message_request.media
assert api_response.tag == message_request.tag
assert api_response.priority == message_request.priority

pass

def test_list_messages_default(self):
with bandwidth.ApiClient(configuration) as api_client:
api_instance = MessagesApi(api_client)
account_id = os.environ.get('BW_ACCOUNT_ID')
message_direction = ListMessageDirectionEnum("OUTBOUND")

try:
api_response: MessagesList = api_instance.list_messages(account_id, message_direction=message_direction)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MessagesApi->list_messages: %s\n" % e)
account_id = os.environ.get('BW_ACCOUNT_ID')
message_direction = ListMessageDirectionEnum("OUTBOUND")

try:
api_response: MessagesList = self.api_instance.list_messages(account_id, message_direction=message_direction)
except bandwidth.ApiException as e:
print("Exception when calling MessagesApi->list_messages: %s\n" % e)

assert isinstance(api_response, MessagesList)
assert 0 == 1
assert isinstance(api_response.messages[0], ListMessageItem)
assert api_response.total_count > 0

pass

# May or may not want to do this if we can test message attributes well
# def test_list_messages_parameters(self):
# with bandwidth.ApiClient(configuration) as api_client:
# api_instance = MessagesApi(api_client)
# account_id = os.environ.get('BW_ACCOUNT_ID')
# message_id = "9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6"
# source_tn = "%2B15554443333"
# destination_tn = "%2B15554443333"
# message_status = MessageStatusEnum("RECEIVED")
# message_direction = MessageDirectionEnum("OUTBOUND")
# carrier_name = "Verizon"
# message_type = MessageTypeEnum("sms")
# error_code = 9902
# from_date_time = "2016-09-14T18:20:16.000Z"
# to_date_time = "2016-09-14T18:20:16.000Z"
# sort = "sourceTn:desc"
# page_token = "gdEewhcJLQRB5"
# limit = 50

# try:
# # List Messages
# api_response = api_instance.list_messages(account_id, message_id=message_id, source_tn=source_tn, destination_tn=destination_tn, message_status=message_status, message_direction=message_direction, carrier_name=carrier_name, message_type=message_type, error_code=error_code, from_date_time=from_date_time, to_date_time=to_date_time, sort=sort, page_token=page_token, limit=limit)
# print(api_response)
# except bandwidth.ApiException as e:
# print("Exception when calling MessagesApi->list_messages: %s\n" % e)

# account_id = os.environ.get('BW_ACCOUNT_ID')
# source_tn = "%2B15554443333"
# destination_tn = "%2B15554443333"
# message_status = MessageStatusEnum("RECEIVED")
# message_direction = ListMessageDirectionEnum("OUTBOUND")
# carrier_name = "Verizon"
# message_type = MessageTypeEnum("sms")
# error_code = 9902
# from_date_time = "2016-09-14T18:20:16.000Z"
# to_date_time = "2016-09-14T18:20:16.000Z"
# sort = "sourceTn:desc"
# page_token = "gdEewhcJLQRB5"
# limit = 50

# try:
# # List Messages
# api_response = self.api_instance.list_messages(account_id, source_tn=source_tn, destination_tn=destination_tn, message_status=message_status, message_direction=message_direction, carrier_name=carrier_name, message_type=message_type, error_code=error_code, from_date_time=from_date_time, to_date_time=to_date_time, sort=sort, page_token=page_token, limit=limit)
# print(api_response)
# except bandwidth.ApiException as e:
# print("Exception when calling MessagesApi->list_messages: %s\n" % e)

# pass

if __name__ == '__main__':
Expand Down