From c3f4283b7068a16e8dd7b2d7efa46f2ea43c3bd9 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Thu, 20 Nov 2025 10:38:16 -0500 Subject: [PATCH 1/3] SWI-8645 Fix Multi-Channel Messaging Schemas --- .openapi-generator/FILES | 28 +- README.md | 14 +- bandwidth.yml | 100 ++++-- docs/MultiChannelAction.md | 113 ++----- docs/MultiChannelApi.md | 2 +- ...md => MultiChannelChannelListMMSObject.md} | 6 +- ...ltiChannelChannelListMMSResponseObject.md} | 6 +- docs/MultiChannelChannelListObjectBase.md | 22 ++ docs/MultiChannelChannelListOwnerObject.md | 18 + docs/MultiChannelChannelListRBMObject.md | 24 ++ ...hannelChannelListRBMObjectAllOfContent.md} | 16 +- ...ultiChannelChannelListRBMResponseObject.md | 26 ++ docs/MultiChannelChannelListRequestObject.md | 24 ++ docs/MultiChannelChannelListResponseObject.md | 26 ++ docs/MultiChannelChannelListSMSObject.md | 24 ++ ...ultiChannelChannelListSMSResponseObject.md | 26 ++ docs/MultiChannelMessageRequest.md | 2 +- docs/MultiChannelMessageResponseData.md | 2 +- docs/RbmActionBase.md | 2 +- docs/RbmSuggestionResponse.md | 2 +- lib/bandwidth-sdk.rb | 14 +- .../models/multi_channel_action.rb | 97 ++++-- ... multi_channel_channel_list_mms_object.rb} | 15 +- ...annel_channel_list_mms_response_object.rb} | 11 +- .../multi_channel_channel_list_object_base.rb | 275 +++++++++++++++ ...multi_channel_channel_list_owner_object.rb | 220 ++++++++++++ .../multi_channel_channel_list_rbm_object.rb | 298 +++++++++++++++++ ...channel_list_rbm_object_all_of_content.rb} | 6 +- ...hannel_channel_list_rbm_response_object.rb | 316 ++++++++++++++++++ ...lti_channel_channel_list_request_object.rb | 104 ++++++ ...ti_channel_channel_list_response_object.rb | 104 ++++++ .../multi_channel_channel_list_sms_object.rb | 298 +++++++++++++++++ ...hannel_channel_list_sms_response_object.rb | 316 ++++++++++++++++++ .../models/multi_channel_message_request.rb | 2 +- .../multi_channel_message_response_data.rb | 2 +- 35 files changed, 2384 insertions(+), 177 deletions(-) rename docs/{MultiChannelChannelListObject.md => MultiChannelChannelListMMSObject.md} (74%) rename docs/{MultiChannelMessageResponseDataChannelListInner.md => MultiChannelChannelListMMSResponseObject.md} (75%) create mode 100644 docs/MultiChannelChannelListObjectBase.md create mode 100644 docs/MultiChannelChannelListOwnerObject.md create mode 100644 docs/MultiChannelChannelListRBMObject.md rename docs/{MultiChannelChannelListObjectContent.md => MultiChannelChannelListRBMObjectAllOfContent.md} (61%) create mode 100644 docs/MultiChannelChannelListRBMResponseObject.md create mode 100644 docs/MultiChannelChannelListRequestObject.md create mode 100644 docs/MultiChannelChannelListResponseObject.md create mode 100644 docs/MultiChannelChannelListSMSObject.md create mode 100644 docs/MultiChannelChannelListSMSResponseObject.md rename lib/bandwidth-sdk/models/{multi_channel_channel_list_object.rb => multi_channel_channel_list_mms_object.rb} (94%) rename lib/bandwidth-sdk/models/{multi_channel_message_response_data_channel_list_inner.rb => multi_channel_channel_list_mms_response_object.rb} (95%) create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb rename lib/bandwidth-sdk/models/{multi_channel_channel_list_object_content.rb => multi_channel_channel_list_rbm_object_all_of_content.rb} (96%) create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb create mode 100644 lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 8b6cec2d..2f0b52e6 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -102,14 +102,22 @@ docs/MmsMessageContentFile.md docs/MultiChannelAction.md docs/MultiChannelActionCalendarEvent.md docs/MultiChannelApi.md -docs/MultiChannelChannelListObject.md -docs/MultiChannelChannelListObjectContent.md +docs/MultiChannelChannelListMMSObject.md +docs/MultiChannelChannelListMMSResponseObject.md +docs/MultiChannelChannelListObjectBase.md +docs/MultiChannelChannelListOwnerObject.md +docs/MultiChannelChannelListRBMObject.md +docs/MultiChannelChannelListRBMObjectAllOfContent.md +docs/MultiChannelChannelListRBMResponseObject.md +docs/MultiChannelChannelListRequestObject.md +docs/MultiChannelChannelListResponseObject.md +docs/MultiChannelChannelListSMSObject.md +docs/MultiChannelChannelListSMSResponseObject.md docs/MultiChannelError.md docs/MultiChannelMessageChannelEnum.md docs/MultiChannelMessageContent.md docs/MultiChannelMessageRequest.md docs/MultiChannelMessageResponseData.md -docs/MultiChannelMessageResponseDataChannelListInner.md docs/OptInWorkflow.md docs/PageInfo.md docs/PhoneNumberLookupApi.md @@ -289,14 +297,22 @@ lib/bandwidth-sdk/models/mms_message_content.rb lib/bandwidth-sdk/models/mms_message_content_file.rb lib/bandwidth-sdk/models/multi_channel_action.rb lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb -lib/bandwidth-sdk/models/multi_channel_channel_list_object.rb -lib/bandwidth-sdk/models/multi_channel_channel_list_object_content.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb +lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb lib/bandwidth-sdk/models/multi_channel_error.rb lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb lib/bandwidth-sdk/models/multi_channel_message_content.rb lib/bandwidth-sdk/models/multi_channel_message_request.rb lib/bandwidth-sdk/models/multi_channel_message_response_data.rb -lib/bandwidth-sdk/models/multi_channel_message_response_data_channel_list_inner.rb lib/bandwidth-sdk/models/opt_in_workflow.rb lib/bandwidth-sdk/models/page_info.rb lib/bandwidth-sdk/models/priority_enum.rb diff --git a/README.md b/README.md index ea5a5e84..c95fdaf2 100644 --- a/README.md +++ b/README.md @@ -253,14 +253,22 @@ Class | Method | HTTP request | Description - [Bandwidth::MmsMessageContentFile](docs/MmsMessageContentFile.md) - [Bandwidth::MultiChannelAction](docs/MultiChannelAction.md) - [Bandwidth::MultiChannelActionCalendarEvent](docs/MultiChannelActionCalendarEvent.md) - - [Bandwidth::MultiChannelChannelListObject](docs/MultiChannelChannelListObject.md) - - [Bandwidth::MultiChannelChannelListObjectContent](docs/MultiChannelChannelListObjectContent.md) + - [Bandwidth::MultiChannelChannelListMMSObject](docs/MultiChannelChannelListMMSObject.md) + - [Bandwidth::MultiChannelChannelListMMSResponseObject](docs/MultiChannelChannelListMMSResponseObject.md) + - [Bandwidth::MultiChannelChannelListObjectBase](docs/MultiChannelChannelListObjectBase.md) + - [Bandwidth::MultiChannelChannelListOwnerObject](docs/MultiChannelChannelListOwnerObject.md) + - [Bandwidth::MultiChannelChannelListRBMObject](docs/MultiChannelChannelListRBMObject.md) + - [Bandwidth::MultiChannelChannelListRBMObjectAllOfContent](docs/MultiChannelChannelListRBMObjectAllOfContent.md) + - [Bandwidth::MultiChannelChannelListRBMResponseObject](docs/MultiChannelChannelListRBMResponseObject.md) + - [Bandwidth::MultiChannelChannelListRequestObject](docs/MultiChannelChannelListRequestObject.md) + - [Bandwidth::MultiChannelChannelListResponseObject](docs/MultiChannelChannelListResponseObject.md) + - [Bandwidth::MultiChannelChannelListSMSObject](docs/MultiChannelChannelListSMSObject.md) + - [Bandwidth::MultiChannelChannelListSMSResponseObject](docs/MultiChannelChannelListSMSResponseObject.md) - [Bandwidth::MultiChannelError](docs/MultiChannelError.md) - [Bandwidth::MultiChannelMessageChannelEnum](docs/MultiChannelMessageChannelEnum.md) - [Bandwidth::MultiChannelMessageContent](docs/MultiChannelMessageContent.md) - [Bandwidth::MultiChannelMessageRequest](docs/MultiChannelMessageRequest.md) - [Bandwidth::MultiChannelMessageResponseData](docs/MultiChannelMessageResponseData.md) - - [Bandwidth::MultiChannelMessageResponseDataChannelListInner](docs/MultiChannelMessageResponseDataChannelListInner.md) - [Bandwidth::OptInWorkflow](docs/OptInWorkflow.md) - [Bandwidth::PageInfo](docs/PageInfo.md) - [Bandwidth::PriorityEnum](docs/PriorityEnum.md) diff --git a/bandwidth.yml b/bandwidth.yml index 0c613484..6ee15ae1 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -2490,7 +2490,7 @@ components: $ref: '#/components/schemas/multiChannelAction' maxItems: 11 multiChannelAction: - oneOf: + anyOf: - $ref: '#/components/schemas/rbmActionBase' - $ref: '#/components/schemas/rbmActionDial' - $ref: '#/components/schemas/rbmActionViewLocation' @@ -2505,7 +2505,7 @@ components: CREATE_CALENDAR_EVENT: '#/components/schemas/multiChannelActionCalendarEvent' OPEN_URL: '#/components/schemas/rbmActionOpenUrl' REQUEST_LOCATION: '#/components/schemas/rbmActionBase' - multiChannelChannelListObject: + multiChannelChannelListObjectBase: type: object properties: from: @@ -2514,19 +2514,85 @@ components: $ref: '#/components/schemas/applicationId' channel: $ref: '#/components/schemas/multiChannelMessageChannelEnum' - content: - description: The content of the message. - oneOf: - - $ref: '#/components/schemas/rbmMessageContentText' - - $ref: '#/components/schemas/rbmMessageMedia' - - $ref: '#/components/schemas/rbmMessageContentRichCard' - - $ref: '#/components/schemas/smsMessageContent' - - $ref: '#/components/schemas/mmsMessageContent' required: - from - applicationId - channel + multiChannelChannelListRBMObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListObjectBase' + - type: object + properties: + content: + description: The content of the message. + oneOf: + - $ref: '#/components/schemas/rbmMessageContentText' + - $ref: '#/components/schemas/rbmMessageMedia' + - $ref: '#/components/schemas/rbmMessageContentRichCard' + required: - content + multiChannelChannelListSMSObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListObjectBase' + - type: object + properties: + content: + $ref: '#/components/schemas/smsMessageContent' + required: + - content + multiChannelChannelListMMSObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListObjectBase' + - type: object + properties: + content: + $ref: '#/components/schemas/mmsMessageContent' + required: + - content + multiChannelChannelListRBMResponseObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListRBMObject' + - $ref: '#/components/schemas/multiChannelChannelListOwnerObject' + multiChannelChannelListSMSResponseObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListSMSObject' + - $ref: '#/components/schemas/multiChannelChannelListOwnerObject' + multiChannelChannelListMMSResponseObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListMMSObject' + - $ref: '#/components/schemas/multiChannelChannelListOwnerObject' + multiChannelChannelListRequestObject: + anyOf: + - $ref: '#/components/schemas/multiChannelChannelListRBMObject' + - $ref: '#/components/schemas/multiChannelChannelListSMSObject' + - $ref: '#/components/schemas/multiChannelChannelListMMSObject' + discriminator: + propertyName: channel + mapping: + RBM: '#/components/schemas/multiChannelChannelListRBMObject' + SMS: '#/components/schemas/multiChannelChannelListSMSObject' + MMS: '#/components/schemas/multiChannelChannelListMMSObject' + multiChannelChannelListOwnerObject: + type: object + properties: + owner: + type: string + description: >- + The Bandwidth senderId associated with the message. Identical to + 'from'. + required: + - owner + multiChannelChannelListResponseObject: + anyOf: + - $ref: '#/components/schemas/multiChannelChannelListRBMResponseObject' + - $ref: '#/components/schemas/multiChannelChannelListSMSResponseObject' + - $ref: '#/components/schemas/multiChannelChannelListMMSResponseObject' + discriminator: + propertyName: channel + mapping: + RBM: '#/components/schemas/multiChannelChannelListRBMResponseObject' + SMS: '#/components/schemas/multiChannelChannelListSMSResponseObject' + MMS: '#/components/schemas/multiChannelChannelListMMSResponseObject' multiChannelMessageRequest: description: Multi-Channel Message Request type: object @@ -2540,7 +2606,7 @@ components: order they are listed. Once a message sends successfully, the others will be ignored. items: - $ref: '#/components/schemas/multiChannelChannelListObject' + $ref: '#/components/schemas/multiChannelChannelListRequestObject' maxItems: 4 tag: $ref: '#/components/schemas/tag' @@ -2573,17 +2639,7 @@ components: order they are listed. Once a message sends successfully, the others will be ignored. items: - allOf: - - $ref: '#/components/schemas/multiChannelChannelListObject' - - type: object - properties: - owner: - type: string - description: >- - The Bandwidth senderId associated with the message. - Identical to 'from'. - required: - - owner + $ref: '#/components/schemas/multiChannelChannelListResponseObject' maxItems: 4 tag: $ref: '#/components/schemas/tag' diff --git a/docs/MultiChannelAction.md b/docs/MultiChannelAction.md index 09330273..73481057 100644 --- a/docs/MultiChannelAction.md +++ b/docs/MultiChannelAction.md @@ -1,89 +1,40 @@ # Bandwidth::MultiChannelAction -## Class instance methods - -### `openapi_one_of` - -Returns the list of classes defined in oneOf. - -#### Example - -```ruby -require 'bandwidth-sdk' - -Bandwidth::MultiChannelAction.openapi_one_of -# => -# [ -# :'MultiChannelActionCalendarEvent', -# :'RbmActionBase', -# :'RbmActionDial', -# :'RbmActionOpenUrl', -# :'RbmActionViewLocation' -# ] -``` - -### `openapi_discriminator_name` - -Returns the discriminator's property name. - -#### Example - -```ruby -require 'bandwidth-sdk' - -Bandwidth::MultiChannelAction.openapi_discriminator_name -# => :'type' -``` - -### `openapi_discriminator_name` - -Returns the discriminator's mapping. - -#### Example - -```ruby -require 'bandwidth-sdk' - -Bandwidth::MultiChannelAction.openapi_discriminator_mapping -# => -# { -# :'CREATE_CALENDAR_EVENT' => :'MultiChannelActionCalendarEvent', -# :'DIAL_PHONE' => :'RbmActionDial', -# :'OPEN_URL' => :'RbmActionOpenUrl', -# :'REPLY' => :'RbmActionBase', -# :'REQUEST_LOCATION' => :'RbmActionBase', -# :'SHOW_LOCATION' => :'RbmActionViewLocation' -# } -``` - -### build - -Find the appropriate object from the `openapi_one_of` list and casts the data into it. - -#### Example +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | [**RbmActionTypeEnum**](RbmActionTypeEnum.md) | | | +| **text** | **String** | Displayed text for user to click | | +| **postback_data** | **String** | Base64 payload the customer receives when the reply is clicked. | | +| **phone_number** | **String** | The phone number to dial. Must be E164 format. | | +| **latitude** | **Float** | The latitude of the location. | | +| **longitude** | **Float** | The longitude of the location. | | +| **label** | **String** | The label of the location. | [optional] | +| **title** | **String** | The title of the event. | | +| **start_time** | **Time** | The start time of the event. | | +| **end_time** | **Time** | The end time of the event. | | +| **description** | **String** | The description of the event. | [optional] | +| **url** | **String** | The URL to open in browser. | | + +## Example ```ruby require 'bandwidth-sdk' -Bandwidth::MultiChannelAction.build(data) -# => # - -Bandwidth::MultiChannelAction.build(data_that_doesnt_match) -# => nil +instance = Bandwidth::MultiChannelAction.new( + type: null, + text: Hello world, + postback_data: U0dWc2JHOGdkMjl5YkdRPQ==, + phone_number: +15552223333, + latitude: 37.7749, + longitude: -122.4194, + label: San Francisco, + title: Meeting with John, + start_time: 2022-09-14T18:20:16Z, + end_time: 2022-09-14T18:20:16Z, + description: Discuss the new project, + url: https://dev.bandwidth.com +) ``` -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| **data** | **Mixed** | data to be matched against the list of oneOf items | - -#### Return type - -- `MultiChannelActionCalendarEvent` -- `RbmActionBase` -- `RbmActionDial` -- `RbmActionOpenUrl` -- `RbmActionViewLocation` -- `nil` (if no type matches) - diff --git a/docs/MultiChannelApi.md b/docs/MultiChannelApi.md index c4a5c449..0ad03b20 100644 --- a/docs/MultiChannelApi.md +++ b/docs/MultiChannelApi.md @@ -29,7 +29,7 @@ end api_instance = Bandwidth::MultiChannelApi.new account_id = '9900000' # String | Your Bandwidth Account ID. -multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new({to: '+15552223333', channel_list: [Bandwidth::MultiChannelChannelListObject.new({from: 'BandwidthRBM', application_id: '93de2206-9669-4e07-948d-329f4b722ee2', channel: Bandwidth::MultiChannelMessageChannelEnum::RBM, content: Bandwidth::MmsMessageContent.new})]}) # MultiChannelMessageRequest | +multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new({to: '+15552223333', channel_list: [Bandwidth::MultiChannelChannelListRequestObject.new({from: 'BandwidthRBM', application_id: '93de2206-9669-4e07-948d-329f4b722ee2', channel: Bandwidth::MultiChannelMessageChannelEnum::RBM, content: Bandwidth::MmsMessageContent.new})]}) # MultiChannelMessageRequest | begin # Create Multi-Channel Message diff --git a/docs/MultiChannelChannelListObject.md b/docs/MultiChannelChannelListMMSObject.md similarity index 74% rename from docs/MultiChannelChannelListObject.md rename to docs/MultiChannelChannelListMMSObject.md index 8b6929cf..8ad0b319 100644 --- a/docs/MultiChannelChannelListObject.md +++ b/docs/MultiChannelChannelListMMSObject.md @@ -1,4 +1,4 @@ -# Bandwidth::MultiChannelChannelListObject +# Bandwidth::MultiChannelChannelListMMSObject ## Properties @@ -7,14 +7,14 @@ | **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | | **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | | **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | -| **content** | [**MultiChannelChannelListObjectContent**](MultiChannelChannelListObjectContent.md) | | | +| **content** | [**MmsMessageContent**](MmsMessageContent.md) | | | ## Example ```ruby require 'bandwidth-sdk' -instance = Bandwidth::MultiChannelChannelListObject.new( +instance = Bandwidth::MultiChannelChannelListMMSObject.new( from: BandwidthRBM, application_id: 93de2206-9669-4e07-948d-329f4b722ee2, channel: null, diff --git a/docs/MultiChannelMessageResponseDataChannelListInner.md b/docs/MultiChannelChannelListMMSResponseObject.md similarity index 75% rename from docs/MultiChannelMessageResponseDataChannelListInner.md rename to docs/MultiChannelChannelListMMSResponseObject.md index b4400f07..36ff287f 100644 --- a/docs/MultiChannelMessageResponseDataChannelListInner.md +++ b/docs/MultiChannelChannelListMMSResponseObject.md @@ -1,4 +1,4 @@ -# Bandwidth::MultiChannelMessageResponseDataChannelListInner +# Bandwidth::MultiChannelChannelListMMSResponseObject ## Properties @@ -7,7 +7,7 @@ | **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | | **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | | **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | -| **content** | [**MultiChannelChannelListObjectContent**](MultiChannelChannelListObjectContent.md) | | | +| **content** | [**MmsMessageContent**](MmsMessageContent.md) | | | | **owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | ## Example @@ -15,7 +15,7 @@ ```ruby require 'bandwidth-sdk' -instance = Bandwidth::MultiChannelMessageResponseDataChannelListInner.new( +instance = Bandwidth::MultiChannelChannelListMMSResponseObject.new( from: BandwidthRBM, application_id: 93de2206-9669-4e07-948d-329f4b722ee2, channel: null, diff --git a/docs/MultiChannelChannelListObjectBase.md b/docs/MultiChannelChannelListObjectBase.md new file mode 100644 index 00000000..0b317352 --- /dev/null +++ b/docs/MultiChannelChannelListObjectBase.md @@ -0,0 +1,22 @@ +# Bandwidth::MultiChannelChannelListObjectBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListObjectBase.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null +) +``` + diff --git a/docs/MultiChannelChannelListOwnerObject.md b/docs/MultiChannelChannelListOwnerObject.md new file mode 100644 index 00000000..39ac3a0d --- /dev/null +++ b/docs/MultiChannelChannelListOwnerObject.md @@ -0,0 +1,18 @@ +# Bandwidth::MultiChannelChannelListOwnerObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListOwnerObject.new( + owner: null +) +``` + diff --git a/docs/MultiChannelChannelListRBMObject.md b/docs/MultiChannelChannelListRBMObject.md new file mode 100644 index 00000000..cfdfc56f --- /dev/null +++ b/docs/MultiChannelChannelListRBMObject.md @@ -0,0 +1,24 @@ +# Bandwidth::MultiChannelChannelListRBMObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | +| **content** | [**MultiChannelChannelListRBMObjectAllOfContent**](MultiChannelChannelListRBMObjectAllOfContent.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListRBMObject.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null, + content: null +) +``` + diff --git a/docs/MultiChannelChannelListObjectContent.md b/docs/MultiChannelChannelListRBMObjectAllOfContent.md similarity index 61% rename from docs/MultiChannelChannelListObjectContent.md rename to docs/MultiChannelChannelListRBMObjectAllOfContent.md index 67589dd6..8a769c53 100644 --- a/docs/MultiChannelChannelListObjectContent.md +++ b/docs/MultiChannelChannelListRBMObjectAllOfContent.md @@ -1,4 +1,4 @@ -# Bandwidth::MultiChannelChannelListObjectContent +# Bandwidth::MultiChannelChannelListRBMObjectAllOfContent ## Class instance methods @@ -11,14 +11,12 @@ Returns the list of classes defined in oneOf. ```ruby require 'bandwidth-sdk' -Bandwidth::MultiChannelChannelListObjectContent.openapi_one_of +Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.openapi_one_of # => # [ -# :'MmsMessageContent', # :'RbmMessageContentRichCard', # :'RbmMessageContentText', -# :'RbmMessageMedia', -# :'SmsMessageContent' +# :'RbmMessageMedia' # ] ``` @@ -31,10 +29,10 @@ Find the appropriate object from the `openapi_one_of` list and casts the data in ```ruby require 'bandwidth-sdk' -Bandwidth::MultiChannelChannelListObjectContent.build(data) -# => # +Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.build(data) +# => # -Bandwidth::MultiChannelChannelListObjectContent.build(data_that_doesnt_match) +Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.build(data_that_doesnt_match) # => nil ``` @@ -46,10 +44,8 @@ Bandwidth::MultiChannelChannelListObjectContent.build(data_that_doesnt_match) #### Return type -- `MmsMessageContent` - `RbmMessageContentRichCard` - `RbmMessageContentText` - `RbmMessageMedia` -- `SmsMessageContent` - `nil` (if no type matches) diff --git a/docs/MultiChannelChannelListRBMResponseObject.md b/docs/MultiChannelChannelListRBMResponseObject.md new file mode 100644 index 00000000..23afbc46 --- /dev/null +++ b/docs/MultiChannelChannelListRBMResponseObject.md @@ -0,0 +1,26 @@ +# Bandwidth::MultiChannelChannelListRBMResponseObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | +| **content** | [**MultiChannelChannelListRBMObjectAllOfContent**](MultiChannelChannelListRBMObjectAllOfContent.md) | | | +| **owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListRBMResponseObject.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null, + content: null, + owner: null +) +``` + diff --git a/docs/MultiChannelChannelListRequestObject.md b/docs/MultiChannelChannelListRequestObject.md new file mode 100644 index 00000000..efbaa067 --- /dev/null +++ b/docs/MultiChannelChannelListRequestObject.md @@ -0,0 +1,24 @@ +# Bandwidth::MultiChannelChannelListRequestObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | +| **content** | [**MmsMessageContent**](MmsMessageContent.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListRequestObject.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null, + content: null +) +``` + diff --git a/docs/MultiChannelChannelListResponseObject.md b/docs/MultiChannelChannelListResponseObject.md new file mode 100644 index 00000000..701d09dc --- /dev/null +++ b/docs/MultiChannelChannelListResponseObject.md @@ -0,0 +1,26 @@ +# Bandwidth::MultiChannelChannelListResponseObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | +| **content** | [**MmsMessageContent**](MmsMessageContent.md) | | | +| **owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListResponseObject.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null, + content: null, + owner: null +) +``` + diff --git a/docs/MultiChannelChannelListSMSObject.md b/docs/MultiChannelChannelListSMSObject.md new file mode 100644 index 00000000..96a5212b --- /dev/null +++ b/docs/MultiChannelChannelListSMSObject.md @@ -0,0 +1,24 @@ +# Bandwidth::MultiChannelChannelListSMSObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | +| **content** | [**SmsMessageContent**](SmsMessageContent.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListSMSObject.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null, + content: null +) +``` + diff --git a/docs/MultiChannelChannelListSMSResponseObject.md b/docs/MultiChannelChannelListSMSResponseObject.md new file mode 100644 index 00000000..80ca9e7a --- /dev/null +++ b/docs/MultiChannelChannelListSMSResponseObject.md @@ -0,0 +1,26 @@ +# Bandwidth::MultiChannelChannelListSMSResponseObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +| **application_id** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +| **channel** | [**MultiChannelMessageChannelEnum**](MultiChannelMessageChannelEnum.md) | | | +| **content** | [**SmsMessageContent**](SmsMessageContent.md) | | | +| **owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MultiChannelChannelListSMSResponseObject.new( + from: BandwidthRBM, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + channel: null, + content: null, + owner: null +) +``` + diff --git a/docs/MultiChannelMessageRequest.md b/docs/MultiChannelMessageRequest.md index b4ad43c1..88596dbf 100644 --- a/docs/MultiChannelMessageRequest.md +++ b/docs/MultiChannelMessageRequest.md @@ -5,7 +5,7 @@ | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | | **to** | **String** | The phone number the message should be sent to in E164 format. | | -| **channel_list** | [**Array<MultiChannelChannelListObject>**](MultiChannelChannelListObject.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | +| **channel_list** | [**Array<MultiChannelChannelListRequestObject>**](MultiChannelChannelListRequestObject.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | | **tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | | **priority** | [**PriorityEnum**](PriorityEnum.md) | | [optional] | | **expiration** | **Time** | A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future. | [optional] | diff --git a/docs/MultiChannelMessageResponseData.md b/docs/MultiChannelMessageResponseData.md index a3fa6267..24a2331b 100644 --- a/docs/MultiChannelMessageResponseData.md +++ b/docs/MultiChannelMessageResponseData.md @@ -8,7 +8,7 @@ | **time** | **Time** | The time the message was received by the Bandwidth API. | | | **direction** | [**MessageDirectionEnum**](MessageDirectionEnum.md) | | | | **to** | **Array<String>** | The destination phone number(s) of the message, in E164 format. | | -| **channel_list** | [**Array<MultiChannelMessageResponseDataChannelListInner>**](MultiChannelMessageResponseDataChannelListInner.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | +| **channel_list** | [**Array<MultiChannelChannelListResponseObject>**](MultiChannelChannelListResponseObject.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | | **tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | | **priority** | [**PriorityEnum**](PriorityEnum.md) | | [optional] | | **expiration** | **Time** | A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future. | [optional] | diff --git a/docs/RbmActionBase.md b/docs/RbmActionBase.md index 10add779..a9d2ac13 100644 --- a/docs/RbmActionBase.md +++ b/docs/RbmActionBase.md @@ -16,7 +16,7 @@ require 'bandwidth-sdk' instance = Bandwidth::RbmActionBase.new( type: null, text: Hello world, - postback_data: [B@1d33e72e + postback_data: [B@7d5d77a6 ) ``` diff --git a/docs/RbmSuggestionResponse.md b/docs/RbmSuggestionResponse.md index 9f7bac91..2e23eabf 100644 --- a/docs/RbmSuggestionResponse.md +++ b/docs/RbmSuggestionResponse.md @@ -14,7 +14,7 @@ require 'bandwidth-sdk' instance = Bandwidth::RbmSuggestionResponse.new( text: Yes, I would like to proceed, - postback_data: [B@1d33e72e + postback_data: [B@7d5d77a6 ) ``` diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index 152aa571..4947a5d8 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -109,14 +109,22 @@ require 'bandwidth-sdk/models/mms_message_content_file' require 'bandwidth-sdk/models/multi_channel_action' require 'bandwidth-sdk/models/multi_channel_action_calendar_event' -require 'bandwidth-sdk/models/multi_channel_channel_list_object' -require 'bandwidth-sdk/models/multi_channel_channel_list_object_content' +require 'bandwidth-sdk/models/multi_channel_channel_list_mms_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_mms_response_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_object_base' +require 'bandwidth-sdk/models/multi_channel_channel_list_owner_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_rbm_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content' +require 'bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_request_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_response_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_sms_object' +require 'bandwidth-sdk/models/multi_channel_channel_list_sms_response_object' require 'bandwidth-sdk/models/multi_channel_error' require 'bandwidth-sdk/models/multi_channel_message_channel_enum' require 'bandwidth-sdk/models/multi_channel_message_content' require 'bandwidth-sdk/models/multi_channel_message_request' require 'bandwidth-sdk/models/multi_channel_message_response_data' -require 'bandwidth-sdk/models/multi_channel_message_response_data_channel_list_inner' require 'bandwidth-sdk/models/opt_in_workflow' require 'bandwidth-sdk/models/page_info' require 'bandwidth-sdk/models/priority_enum' diff --git a/lib/bandwidth-sdk/models/multi_channel_action.rb b/lib/bandwidth-sdk/models/multi_channel_action.rb index a45d8e56..2b71d865 100644 --- a/lib/bandwidth-sdk/models/multi_channel_action.rb +++ b/lib/bandwidth-sdk/models/multi_channel_action.rb @@ -16,8 +16,8 @@ module Bandwidth module MultiChannelAction class << self - # List of class defined in oneOf (OpenAPI v3) - def openapi_one_of + # List of class defined in anyOf (OpenAPI v3) + def openapi_any_of [ :'MultiChannelActionCalendarEvent', :'RbmActionBase', @@ -27,35 +27,80 @@ def openapi_one_of ] end - # Discriminator's property name (OpenAPI v3) - def openapi_discriminator_name - :'type' - end - - # Discriminator's mapping (OpenAPI v3) - def openapi_discriminator_mapping - { - :'CREATE_CALENDAR_EVENT' => :'MultiChannelActionCalendarEvent', - :'DIAL_PHONE' => :'RbmActionDial', - :'OPEN_URL' => :'RbmActionOpenUrl', - :'REPLY' => :'RbmActionBase', - :'REQUEST_LOCATION' => :'RbmActionBase', - :'SHOW_LOCATION' => :'RbmActionViewLocation' - } - end - # Builds the object - # @param [Mixed] Data to be matched against the list of oneOf items + # @param [Mixed] Data to be matched against the list of anyOf items # @return [Object] Returns the model or the data itself def build(data) - discriminator_value = data[openapi_discriminator_name] - return nil if discriminator_value.nil? - - klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym] - return nil unless klass + # Go through the list of anyOf items and attempt to identify the appropriate one. + # Note: + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_any_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end - Bandwidth.const_get(klass).build_from_hash(data) + openapi_any_of.include?(:AnyType) ? data : nil end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = Bandwidth.const_get(klass) + if const + if const.respond_to?(:openapi_any_of) # nested anyOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end end end end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb similarity index 94% rename from lib/bandwidth-sdk/models/multi_channel_channel_list_object.rb rename to lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb index 196f3a35..0c88d652 100644 --- a/lib/bandwidth-sdk/models/multi_channel_channel_list_object.rb +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb @@ -14,7 +14,7 @@ require 'time' module Bandwidth - class MultiChannelChannelListObject + class MultiChannelChannelListMMSObject # The sender ID of the message. This could be an alphanumeric sender ID. attr_accessor :from @@ -68,7 +68,7 @@ def self.openapi_types :'from' => :'String', :'application_id' => :'String', :'channel' => :'MultiChannelMessageChannelEnum', - :'content' => :'MultiChannelChannelListObjectContent' + :'content' => :'MmsMessageContent' } end @@ -78,17 +78,24 @@ def self.openapi_nullable ]) end + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'MultiChannelChannelListObjectBase' + ] + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListObject` initialize method' + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListMMSObject` initialize method' end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListMMSObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } diff --git a/lib/bandwidth-sdk/models/multi_channel_message_response_data_channel_list_inner.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb similarity index 95% rename from lib/bandwidth-sdk/models/multi_channel_message_response_data_channel_list_inner.rb rename to lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb index 743727ce..b99ff2f1 100644 --- a/lib/bandwidth-sdk/models/multi_channel_message_response_data_channel_list_inner.rb +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb @@ -14,7 +14,7 @@ require 'time' module Bandwidth - class MultiChannelMessageResponseDataChannelListInner + class MultiChannelChannelListMMSResponseObject # The sender ID of the message. This could be an alphanumeric sender ID. attr_accessor :from @@ -72,7 +72,7 @@ def self.openapi_types :'from' => :'String', :'application_id' => :'String', :'channel' => :'MultiChannelMessageChannelEnum', - :'content' => :'MultiChannelChannelListObjectContent', + :'content' => :'MmsMessageContent', :'owner' => :'String' } end @@ -86,7 +86,8 @@ def self.openapi_nullable # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ - :'MultiChannelChannelListObject' + :'MultiChannelChannelListMMSObject', + :'MultiChannelChannelListOwnerObject' ] end @@ -94,13 +95,13 @@ def self.openapi_all_of # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelMessageResponseDataChannelListInner` initialize method' + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListMMSResponseObject` initialize method' end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelMessageResponseDataChannelListInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListMMSResponseObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb new file mode 100644 index 00000000..6d4b1146 --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb @@ -0,0 +1,275 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MultiChannelChannelListObjectBase + # The sender ID of the message. This could be an alphanumeric sender ID. + attr_accessor :from + + # The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + attr_accessor :application_id + + attr_accessor :channel + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'application_id' => :'applicationId', + :'channel' => :'channel' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'String', + :'application_id' => :'String', + :'channel' => :'MultiChannelMessageChannelEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListObjectBase` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListObjectBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @from.nil? + return false if @application_id.nil? + return false if @channel.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + application_id == o.application_id && + channel == o.channel + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, application_id, channel].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb new file mode 100644 index 00000000..00e437e8 --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb @@ -0,0 +1,220 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MultiChannelChannelListOwnerObject + # The Bandwidth senderId associated with the message. Identical to 'from'. + attr_accessor :owner + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'owner' => :'owner' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'owner' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListOwnerObject` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListOwnerObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @owner.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + owner == o.owner + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [owner].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb new file mode 100644 index 00000000..f26514a8 --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb @@ -0,0 +1,298 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MultiChannelChannelListRBMObject + # The sender ID of the message. This could be an alphanumeric sender ID. + attr_accessor :from + + # The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + attr_accessor :application_id + + attr_accessor :channel + + attr_accessor :content + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'application_id' => :'applicationId', + :'channel' => :'channel', + :'content' => :'content' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'String', + :'application_id' => :'String', + :'channel' => :'MultiChannelMessageChannelEnum', + :'content' => :'MultiChannelChannelListRBMObjectAllOfContent' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'MultiChannelChannelListObjectBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListRBMObject` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListRBMObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'content') + self.content = attributes[:'content'] + else + self.content = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @content.nil? + invalid_properties.push('invalid value for "content", content cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @from.nil? + return false if @application_id.nil? + return false if @channel.nil? + return false if @content.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + application_id == o.application_id && + channel == o.channel && + content == o.content + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, application_id, channel, content].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_object_content.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb similarity index 96% rename from lib/bandwidth-sdk/models/multi_channel_channel_list_object_content.rb rename to lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb index c3fae305..99e7e8fe 100644 --- a/lib/bandwidth-sdk/models/multi_channel_channel_list_object_content.rb +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb @@ -15,16 +15,14 @@ module Bandwidth # The content of the message. - module MultiChannelChannelListObjectContent + module MultiChannelChannelListRBMObjectAllOfContent class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ - :'MmsMessageContent', :'RbmMessageContentRichCard', :'RbmMessageContentText', - :'RbmMessageMedia', - :'SmsMessageContent' + :'RbmMessageMedia' ] end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb new file mode 100644 index 00000000..0b69ccaf --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb @@ -0,0 +1,316 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MultiChannelChannelListRBMResponseObject + # The sender ID of the message. This could be an alphanumeric sender ID. + attr_accessor :from + + # The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + attr_accessor :application_id + + attr_accessor :channel + + attr_accessor :content + + # The Bandwidth senderId associated with the message. Identical to 'from'. + attr_accessor :owner + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'application_id' => :'applicationId', + :'channel' => :'channel', + :'content' => :'content', + :'owner' => :'owner' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'String', + :'application_id' => :'String', + :'channel' => :'MultiChannelMessageChannelEnum', + :'content' => :'MultiChannelChannelListRBMObjectAllOfContent', + :'owner' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'MultiChannelChannelListOwnerObject', + :'MultiChannelChannelListRBMObject' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListRBMResponseObject` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListRBMResponseObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'content') + self.content = attributes[:'content'] + else + self.content = nil + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @content.nil? + invalid_properties.push('invalid value for "content", content cannot be nil.') + end + + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @from.nil? + return false if @application_id.nil? + return false if @channel.nil? + return false if @content.nil? + return false if @owner.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + application_id == o.application_id && + channel == o.channel && + content == o.content && + owner == o.owner + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, application_id, channel, content, owner].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb new file mode 100644 index 00000000..92362082 --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb @@ -0,0 +1,104 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + module MultiChannelChannelListRequestObject + class << self + # List of class defined in anyOf (OpenAPI v3) + def openapi_any_of + [ + :'MultiChannelChannelListMMSObject', + :'MultiChannelChannelListRBMObject', + :'MultiChannelChannelListSMSObject' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of anyOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of anyOf items and attempt to identify the appropriate one. + # Note: + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_any_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_any_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = Bandwidth.const_get(klass) + if const + if const.respond_to?(:openapi_any_of) # nested anyOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb new file mode 100644 index 00000000..d31bbcfc --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb @@ -0,0 +1,104 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + module MultiChannelChannelListResponseObject + class << self + # List of class defined in anyOf (OpenAPI v3) + def openapi_any_of + [ + :'MultiChannelChannelListMMSResponseObject', + :'MultiChannelChannelListRBMResponseObject', + :'MultiChannelChannelListSMSResponseObject' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of anyOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of anyOf items and attempt to identify the appropriate one. + # Note: + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_any_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_any_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = Bandwidth.const_get(klass) + if const + if const.respond_to?(:openapi_any_of) # nested anyOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb new file mode 100644 index 00000000..678f93a9 --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb @@ -0,0 +1,298 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MultiChannelChannelListSMSObject + # The sender ID of the message. This could be an alphanumeric sender ID. + attr_accessor :from + + # The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + attr_accessor :application_id + + attr_accessor :channel + + attr_accessor :content + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'application_id' => :'applicationId', + :'channel' => :'channel', + :'content' => :'content' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'String', + :'application_id' => :'String', + :'channel' => :'MultiChannelMessageChannelEnum', + :'content' => :'SmsMessageContent' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'MultiChannelChannelListObjectBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListSMSObject` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListSMSObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'content') + self.content = attributes[:'content'] + else + self.content = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @content.nil? + invalid_properties.push('invalid value for "content", content cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @from.nil? + return false if @application_id.nil? + return false if @channel.nil? + return false if @content.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + application_id == o.application_id && + channel == o.channel && + content == o.content + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, application_id, channel, content].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb b/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb new file mode 100644 index 00000000..86c518bf --- /dev/null +++ b/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb @@ -0,0 +1,316 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.8.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MultiChannelChannelListSMSResponseObject + # The sender ID of the message. This could be an alphanumeric sender ID. + attr_accessor :from + + # The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + attr_accessor :application_id + + attr_accessor :channel + + attr_accessor :content + + # The Bandwidth senderId associated with the message. Identical to 'from'. + attr_accessor :owner + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'application_id' => :'applicationId', + :'channel' => :'channel', + :'content' => :'content', + :'owner' => :'owner' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'String', + :'application_id' => :'String', + :'channel' => :'MultiChannelMessageChannelEnum', + :'content' => :'SmsMessageContent', + :'owner' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'MultiChannelChannelListOwnerObject', + :'MultiChannelChannelListSMSObject' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListSMSResponseObject` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListSMSResponseObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'content') + self.content = attributes[:'content'] + else + self.content = nil + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @content.nil? + invalid_properties.push('invalid value for "content", content cannot be nil.') + end + + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @from.nil? + return false if @application_id.nil? + return false if @channel.nil? + return false if @content.nil? + return false if @owner.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + application_id == o.application_id && + channel == o.channel && + content == o.content && + owner == o.owner + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, application_id, channel, content, owner].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/multi_channel_message_request.rb b/lib/bandwidth-sdk/models/multi_channel_message_request.rb index 942b7e4f..0aac7430 100644 --- a/lib/bandwidth-sdk/models/multi_channel_message_request.rb +++ b/lib/bandwidth-sdk/models/multi_channel_message_request.rb @@ -72,7 +72,7 @@ def self.acceptable_attributes def self.openapi_types { :'to' => :'String', - :'channel_list' => :'Array', + :'channel_list' => :'Array', :'tag' => :'String', :'priority' => :'PriorityEnum', :'expiration' => :'Time' diff --git a/lib/bandwidth-sdk/models/multi_channel_message_response_data.rb b/lib/bandwidth-sdk/models/multi_channel_message_response_data.rb index d87c37c6..5b18789c 100644 --- a/lib/bandwidth-sdk/models/multi_channel_message_response_data.rb +++ b/lib/bandwidth-sdk/models/multi_channel_message_response_data.rb @@ -86,7 +86,7 @@ def self.openapi_types :'time' => :'Time', :'direction' => :'MessageDirectionEnum', :'to' => :'Array', - :'channel_list' => :'Array', + :'channel_list' => :'Array', :'tag' => :'String', :'priority' => :'PriorityEnum', :'expiration' => :'Time' From 427f2260969dbcb66b36be39326c2d66792f2952 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Thu, 20 Nov 2025 10:53:16 -0500 Subject: [PATCH 2/3] api unit tests --- spec/unit/api/multi_channel_api_spec.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/unit/api/multi_channel_api_spec.rb b/spec/unit/api/multi_channel_api_spec.rb index 112a8663..885ee414 100644 --- a/spec/unit/api/multi_channel_api_spec.rb +++ b/spec/unit/api/multi_channel_api_spec.rb @@ -22,7 +22,7 @@ # Create Multi-Channel Message describe 'create_multi_channel_message' do it 'creates a multi channel message' do - message_body = Bandwidth::MultiChannelChannelListObject.new( + message_body = Bandwidth::MultiChannelChannelListSMSObject.new( from: BW_NUMBER, application_id: BW_MESSAGING_APPLICATION_ID, channel: Bandwidth::MultiChannelMessageChannelEnum::SMS, @@ -30,6 +30,7 @@ text: 'Hello, this is a test message.', ) ) + multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new( to: USER_NUMBER, channel_list: [message_body], @@ -42,7 +43,17 @@ expect(status_code).to eq(202) expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse) - end if false # skip because prism can't handle a oneOf with differing required fields + expect(data.links).to be_instance_of(Array) + expect(data.data).to be_instance_of(Bandwidth::MultiChannelMessageResponseData) + expect(data.data.id).to be_instance_of(String) + expect(data.data.time).to be_instance_of(Time) + expect(data.data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars) + expect(data.data.to).to be_instance_of(Array) + expect(data.data.tag).to be_instance_of(String) + expect(data.data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars) + expect(data.data.expiration).to be_instance_of(Time) + expect(data.data.channel_list).to be_instance_of(Array) + end it 'causes an ArgumentError for a missing account_id' do expect { From ac4d510a7f5a8a747fe4e42721997e7a117f5b42 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Thu, 20 Nov 2025 11:08:21 -0500 Subject: [PATCH 3/3] api smoke test --- spec/smoke/multi_channel_api_spec.rb | 147 ++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 23 deletions(-) diff --git a/spec/smoke/multi_channel_api_spec.rb b/spec/smoke/multi_channel_api_spec.rb index 8f81da42..faf663d5 100644 --- a/spec/smoke/multi_channel_api_spec.rb +++ b/spec/smoke/multi_channel_api_spec.rb @@ -10,29 +10,130 @@ @expiration_time = (Time.now + 60).round.to_datetime.rfc3339 end - # Create Multi-Channel Message - describe 'create_multi_channel_message' do - it 'creates a multi channel message' do - message_body = Bandwidth::MultiChannelChannelListObject.new( - from: BW_NUMBER, - application_id: BW_MESSAGING_APPLICATION_ID, - channel: Bandwidth::MultiChannelMessageChannelEnum::RBM, - content: Bandwidth::RbmMessageContentText.new( - text: 'Hello, this is a test message.', + # Create Multi-Channel SMS Message + describe 'create_multi_channel_sms_message' do + it 'creates a multi channel sms message' do + message_body = Bandwidth::MultiChannelChannelListSMSObject.new( + from: BW_NUMBER, + application_id: BW_MESSAGING_APPLICATION_ID, + channel: Bandwidth::MultiChannelMessageChannelEnum::SMS, + content: Bandwidth::SmsMessageContent.new( + text: 'Hello, this is a test message.', + ) ) - ) - multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new( - to: USER_NUMBER, - channel_list: [message_body], - tag: 'tag', - priority: 'high', - expiration: @expiration_time, - ) - - data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request) - - expect(status_code).to eq(202) - expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse) - end if false # skip while still in beta + multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new( + to: USER_NUMBER, + channel_list: [message_body], + tag: 'tag', + priority: 'high', + expiration: @expiration_time, + ) + + data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request) + + expect(status_code).to eq(202) + p data.data + expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse) + expect(data.links).to be_instance_of(Array) + expect(data.data).to be_instance_of(Bandwidth::MultiChannelMessageResponseData) + expect(data.data.id).to be_instance_of(String) + expect(data.data.time).to be_instance_of(Time) + expect(data.data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars) + expect(data.data.to).to be_instance_of(Array) + expect(data.data.tag).to be_instance_of(String) + expect(data.data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars) + expect(data.data.expiration).to be_instance_of(Time) + expect(data.data.channel_list).to be_instance_of(Array) + # add more assertions once SDK supports discriminators + end + end + + # Create Multi-Channel MMS Message + describe 'create_multi_channel_mms_message' do + it 'creates a multi channel mms message' do + message_body = Bandwidth::MultiChannelChannelListMMSObject.new( + from: BW_NUMBER, + application_id: BW_MESSAGING_APPLICATION_ID, + channel: Bandwidth::MultiChannelMessageChannelEnum::MMS, + content: Bandwidth::MmsMessageContent.new( + media: [ + Bandwidth::MmsMessageContentFile.new( + file_url: 'https://example.com/image.jpg' + ) + ], + text: 'Hello, this is a test message.', + ) + ) + multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new( + to: USER_NUMBER, + channel_list: [message_body], + tag: 'tag', + priority: 'high', + expiration: @expiration_time, + ) + + data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request) + + expect(status_code).to eq(202) + p data.data + expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse) + expect(data.links).to be_instance_of(Array) + expect(data.data).to be_instance_of(Bandwidth::MultiChannelMessageResponseData) + expect(data.data.id).to be_instance_of(String) + expect(data.data.time).to be_instance_of(Time) + expect(data.data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars) + expect(data.data.to).to be_instance_of(Array) + expect(data.data.tag).to be_instance_of(String) + expect(data.data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars) + expect(data.data.expiration).to be_instance_of(Time) + expect(data.data.channel_list).to be_instance_of(Array) + # add more assertions once SDK supports discriminators + end + end + + # Create Multi-Channel RBM Message + describe 'create_multi_channel_rbm_message' do + it 'creates a multi channel rbm message' do + message_body = Bandwidth::MultiChannelChannelListRBMObject.new( + from: BW_NUMBER, + application_id: BW_MESSAGING_APPLICATION_ID, + channel: Bandwidth::MultiChannelMessageChannelEnum::RBM, + content: Bandwidth::RbmMessageContentText.new( + text: 'Hello, this is a test message.', + suggestions: [ + Bandwidth::RbmActionDial.new( + type: Bandwidth::RbmActionTypeEnum::DIAL_PHONE, + text: 'Call Us', + postback_data: 'abcdefg12345678', + phone_number: BW_NUMBER + ) + ] + ) + ) + multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new( + to: USER_NUMBER, + channel_list: [message_body], + tag: 'tag', + priority: 'high', + expiration: @expiration_time, + ) + + data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request) + + expect(status_code).to eq(202) + p data.data + expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse) + expect(data.links).to be_instance_of(Array) + expect(data.data).to be_instance_of(Bandwidth::MultiChannelMessageResponseData) + expect(data.data.id).to be_instance_of(String) + expect(data.data.time).to be_instance_of(Time) + expect(data.data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars) + expect(data.data.to).to be_instance_of(Array) + expect(data.data.tag).to be_instance_of(String) + expect(data.data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars) + expect(data.data.expiration).to be_instance_of(Time) + expect(data.data.channel_list).to be_instance_of(Array) + # add more assertions once SDK supports discriminators + end end end