diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index a8d55bab..def298e0 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -21,6 +21,7 @@ docs/CallTranscriptionTrackEnum.md docs/CallbackMethodEnum.md docs/CallbackTypeEnum.md docs/CallsApi.md +docs/CardWidthEnum.md docs/CodeRequest.md docs/Conference.md docs/ConferenceCompletedCallback.md @@ -38,16 +39,19 @@ docs/CreateCall.md docs/CreateCallResponse.md docs/CreateLookupResponse.md docs/CreateMessageRequestError.md +docs/CreateMultiChannelMessageResponse.md docs/DeferredResult.md docs/DisconnectCallback.md docs/Diversion.md docs/DtmfCallback.md docs/Error.md +docs/ErrorObject.md docs/FailureWebhook.md docs/FieldError.md docs/FileFormatEnum.md docs/GatherCallback.md docs/InitiateCallback.md +docs/Link.md docs/LinksObject.md docs/ListMessageDirectionEnum.md docs/ListMessageItem.md @@ -76,10 +80,37 @@ docs/MfaApi.md docs/MfaForbiddenRequestError.md docs/MfaRequestError.md docs/MfaUnauthorizedRequestError.md +docs/MmsMessageContent.md +docs/MultiChannelAction.md +docs/MultiChannelActionCalendarEvent.md +docs/MultiChannelApi.md +docs/MultiChannelCallbackData.md +docs/MultiChannelChannelListObject.md +docs/MultiChannelChannelListObjectContent.md +docs/MultiChannelMessageCallbackData.md +docs/MultiChannelMessageChannelEnum.md +docs/MultiChannelMessageData.md +docs/MultiChannelMessageDirectionEnum.md +docs/MultiChannelMessageRequest.md +docs/MultiChannelStatusEnum.md docs/OptInWorkflow.md docs/PageInfo.md docs/PhoneNumberLookupApi.md docs/PriorityEnum.md +docs/RbmActionBase.md +docs/RbmActionDial.md +docs/RbmActionOpenUrl.md +docs/RbmActionTypeEnum.md +docs/RbmActionViewLocation.md +docs/RbmCardContent.md +docs/RbmCardContentMedia.md +docs/RbmMediaHeightEnum.md +docs/RbmMessageCarouselCard.md +docs/RbmMessageContentFile.md +docs/RbmMessageContentRichCard.md +docs/RbmMessageContentText.md +docs/RbmMessageMedia.md +docs/RbmStandaloneCard.md docs/RecordingAvailableCallback.md docs/RecordingCompleteCallback.md docs/RecordingStateEnum.md @@ -88,9 +119,10 @@ docs/RecordingTranscriptions.md docs/RecordingsApi.md docs/RedirectCallback.md docs/RedirectMethodEnum.md +docs/SmsMessageContent.md +docs/StandaloneCardOrientationEnum.md docs/StatisticsApi.md docs/StirShaken.md -docs/Tag.md docs/TelephoneNumber.md docs/TfvBasicAuthentication.md docs/TfvCallbackStatusEnum.md @@ -99,6 +131,7 @@ docs/TfvStatus.md docs/TfvStatusEnum.md docs/TfvSubmissionInfo.md docs/TfvSubmissionWrapper.md +docs/ThumbnailAlignmentEnum.md docs/TnLookupRequestError.md docs/TollFreeVerificationApi.md docs/TranscribeRecording.md @@ -152,6 +185,7 @@ src/main/java/com/bandwidth/sdk/api/ConferencesApi.java src/main/java/com/bandwidth/sdk/api/MediaApi.java src/main/java/com/bandwidth/sdk/api/MessagesApi.java src/main/java/com/bandwidth/sdk/api/MfaApi.java +src/main/java/com/bandwidth/sdk/api/MultiChannelApi.java src/main/java/com/bandwidth/sdk/api/PhoneNumberLookupApi.java src/main/java/com/bandwidth/sdk/api/RecordingsApi.java src/main/java/com/bandwidth/sdk/api/StatisticsApi.java @@ -179,6 +213,7 @@ src/main/java/com/bandwidth/sdk/model/CallTranscriptionResponse.java src/main/java/com/bandwidth/sdk/model/CallTranscriptionTrackEnum.java src/main/java/com/bandwidth/sdk/model/CallbackMethodEnum.java src/main/java/com/bandwidth/sdk/model/CallbackTypeEnum.java +src/main/java/com/bandwidth/sdk/model/CardWidthEnum.java src/main/java/com/bandwidth/sdk/model/CodeRequest.java src/main/java/com/bandwidth/sdk/model/Conference.java src/main/java/com/bandwidth/sdk/model/ConferenceCompletedCallback.java @@ -195,16 +230,19 @@ src/main/java/com/bandwidth/sdk/model/CreateCall.java src/main/java/com/bandwidth/sdk/model/CreateCallResponse.java src/main/java/com/bandwidth/sdk/model/CreateLookupResponse.java src/main/java/com/bandwidth/sdk/model/CreateMessageRequestError.java +src/main/java/com/bandwidth/sdk/model/CreateMultiChannelMessageResponse.java src/main/java/com/bandwidth/sdk/model/DeferredResult.java src/main/java/com/bandwidth/sdk/model/DisconnectCallback.java src/main/java/com/bandwidth/sdk/model/Diversion.java src/main/java/com/bandwidth/sdk/model/DtmfCallback.java src/main/java/com/bandwidth/sdk/model/Error.java +src/main/java/com/bandwidth/sdk/model/ErrorObject.java src/main/java/com/bandwidth/sdk/model/FailureWebhook.java src/main/java/com/bandwidth/sdk/model/FieldError.java src/main/java/com/bandwidth/sdk/model/FileFormatEnum.java src/main/java/com/bandwidth/sdk/model/GatherCallback.java src/main/java/com/bandwidth/sdk/model/InitiateCallback.java +src/main/java/com/bandwidth/sdk/model/Link.java src/main/java/com/bandwidth/sdk/model/LinksObject.java src/main/java/com/bandwidth/sdk/model/ListMessageDirectionEnum.java src/main/java/com/bandwidth/sdk/model/ListMessageItem.java @@ -230,9 +268,35 @@ src/main/java/com/bandwidth/sdk/model/MessagingRequestError.java src/main/java/com/bandwidth/sdk/model/MfaForbiddenRequestError.java src/main/java/com/bandwidth/sdk/model/MfaRequestError.java src/main/java/com/bandwidth/sdk/model/MfaUnauthorizedRequestError.java +src/main/java/com/bandwidth/sdk/model/MmsMessageContent.java +src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java +src/main/java/com/bandwidth/sdk/model/MultiChannelActionCalendarEvent.java +src/main/java/com/bandwidth/sdk/model/MultiChannelCallbackData.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java +src/main/java/com/bandwidth/sdk/model/MultiChannelMessageCallbackData.java +src/main/java/com/bandwidth/sdk/model/MultiChannelMessageChannelEnum.java +src/main/java/com/bandwidth/sdk/model/MultiChannelMessageData.java +src/main/java/com/bandwidth/sdk/model/MultiChannelMessageDirectionEnum.java +src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java +src/main/java/com/bandwidth/sdk/model/MultiChannelStatusEnum.java src/main/java/com/bandwidth/sdk/model/OptInWorkflow.java src/main/java/com/bandwidth/sdk/model/PageInfo.java src/main/java/com/bandwidth/sdk/model/PriorityEnum.java +src/main/java/com/bandwidth/sdk/model/RbmActionBase.java +src/main/java/com/bandwidth/sdk/model/RbmActionDial.java +src/main/java/com/bandwidth/sdk/model/RbmActionOpenUrl.java +src/main/java/com/bandwidth/sdk/model/RbmActionTypeEnum.java +src/main/java/com/bandwidth/sdk/model/RbmActionViewLocation.java +src/main/java/com/bandwidth/sdk/model/RbmCardContent.java +src/main/java/com/bandwidth/sdk/model/RbmCardContentMedia.java +src/main/java/com/bandwidth/sdk/model/RbmMediaHeightEnum.java +src/main/java/com/bandwidth/sdk/model/RbmMessageCarouselCard.java +src/main/java/com/bandwidth/sdk/model/RbmMessageContentFile.java +src/main/java/com/bandwidth/sdk/model/RbmMessageContentRichCard.java +src/main/java/com/bandwidth/sdk/model/RbmMessageContentText.java +src/main/java/com/bandwidth/sdk/model/RbmMessageMedia.java +src/main/java/com/bandwidth/sdk/model/RbmStandaloneCard.java src/main/java/com/bandwidth/sdk/model/RecordingAvailableCallback.java src/main/java/com/bandwidth/sdk/model/RecordingCompleteCallback.java src/main/java/com/bandwidth/sdk/model/RecordingStateEnum.java @@ -240,8 +304,9 @@ src/main/java/com/bandwidth/sdk/model/RecordingTranscriptionMetadata.java src/main/java/com/bandwidth/sdk/model/RecordingTranscriptions.java src/main/java/com/bandwidth/sdk/model/RedirectCallback.java src/main/java/com/bandwidth/sdk/model/RedirectMethodEnum.java +src/main/java/com/bandwidth/sdk/model/SmsMessageContent.java +src/main/java/com/bandwidth/sdk/model/StandaloneCardOrientationEnum.java src/main/java/com/bandwidth/sdk/model/StirShaken.java -src/main/java/com/bandwidth/sdk/model/Tag.java src/main/java/com/bandwidth/sdk/model/TelephoneNumber.java src/main/java/com/bandwidth/sdk/model/TfvBasicAuthentication.java src/main/java/com/bandwidth/sdk/model/TfvCallbackStatusEnum.java @@ -250,6 +315,7 @@ src/main/java/com/bandwidth/sdk/model/TfvStatus.java src/main/java/com/bandwidth/sdk/model/TfvStatusEnum.java src/main/java/com/bandwidth/sdk/model/TfvSubmissionInfo.java src/main/java/com/bandwidth/sdk/model/TfvSubmissionWrapper.java +src/main/java/com/bandwidth/sdk/model/ThumbnailAlignmentEnum.java src/main/java/com/bandwidth/sdk/model/TnLookupRequestError.java src/main/java/com/bandwidth/sdk/model/TranscribeRecording.java src/main/java/com/bandwidth/sdk/model/Transcription.java diff --git a/README.md b/README.md index 25ae43f1..3fe417a3 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ Class | Method | HTTP request | Description *MfaApi* | [**generateMessagingCode**](docs/MfaApi.md#generateMessagingCode) | **POST** /accounts/{accountId}/code/messaging | Messaging Authentication Code *MfaApi* | [**generateVoiceCode**](docs/MfaApi.md#generateVoiceCode) | **POST** /accounts/{accountId}/code/voice | Voice Authentication Code *MfaApi* | [**verifyCode**](docs/MfaApi.md#verifyCode) | **POST** /accounts/{accountId}/code/verify | Verify Authentication Code +*MultiChannelApi* | [**createMultiChannelMessage**](docs/MultiChannelApi.md#createMultiChannelMessage) | **POST** /users/{accountId}/messages/multiChannel | Create Multi-Channel Message *PhoneNumberLookupApi* | [**createLookup**](docs/PhoneNumberLookupApi.md#createLookup) | **POST** /accounts/{accountId}/tnlookup | Create Lookup *PhoneNumberLookupApi* | [**getLookupStatus**](docs/PhoneNumberLookupApi.md#getLookupStatus) | **GET** /accounts/{accountId}/tnlookup/{requestId} | Get Lookup Request Status *RecordingsApi* | [**deleteRecording**](docs/RecordingsApi.md#deleteRecording) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId} | Delete Recording @@ -190,6 +191,7 @@ Class | Method | HTTP request | Description - [CallTranscriptionTrackEnum](docs/CallTranscriptionTrackEnum.md) - [CallbackMethodEnum](docs/CallbackMethodEnum.md) - [CallbackTypeEnum](docs/CallbackTypeEnum.md) + - [CardWidthEnum](docs/CardWidthEnum.md) - [CodeRequest](docs/CodeRequest.md) - [Conference](docs/Conference.md) - [ConferenceCompletedCallback](docs/ConferenceCompletedCallback.md) @@ -206,16 +208,19 @@ Class | Method | HTTP request | Description - [CreateCallResponse](docs/CreateCallResponse.md) - [CreateLookupResponse](docs/CreateLookupResponse.md) - [CreateMessageRequestError](docs/CreateMessageRequestError.md) + - [CreateMultiChannelMessageResponse](docs/CreateMultiChannelMessageResponse.md) - [DeferredResult](docs/DeferredResult.md) - [DisconnectCallback](docs/DisconnectCallback.md) - [Diversion](docs/Diversion.md) - [DtmfCallback](docs/DtmfCallback.md) - [Error](docs/Error.md) + - [ErrorObject](docs/ErrorObject.md) - [FailureWebhook](docs/FailureWebhook.md) - [FieldError](docs/FieldError.md) - [FileFormatEnum](docs/FileFormatEnum.md) - [GatherCallback](docs/GatherCallback.md) - [InitiateCallback](docs/InitiateCallback.md) + - [Link](docs/Link.md) - [LinksObject](docs/LinksObject.md) - [ListMessageDirectionEnum](docs/ListMessageDirectionEnum.md) - [ListMessageItem](docs/ListMessageItem.md) @@ -241,9 +246,35 @@ Class | Method | HTTP request | Description - [MfaForbiddenRequestError](docs/MfaForbiddenRequestError.md) - [MfaRequestError](docs/MfaRequestError.md) - [MfaUnauthorizedRequestError](docs/MfaUnauthorizedRequestError.md) + - [MmsMessageContent](docs/MmsMessageContent.md) + - [MultiChannelAction](docs/MultiChannelAction.md) + - [MultiChannelActionCalendarEvent](docs/MultiChannelActionCalendarEvent.md) + - [MultiChannelCallbackData](docs/MultiChannelCallbackData.md) + - [MultiChannelChannelListObject](docs/MultiChannelChannelListObject.md) + - [MultiChannelChannelListObjectContent](docs/MultiChannelChannelListObjectContent.md) + - [MultiChannelMessageCallbackData](docs/MultiChannelMessageCallbackData.md) + - [MultiChannelMessageChannelEnum](docs/MultiChannelMessageChannelEnum.md) + - [MultiChannelMessageData](docs/MultiChannelMessageData.md) + - [MultiChannelMessageDirectionEnum](docs/MultiChannelMessageDirectionEnum.md) + - [MultiChannelMessageRequest](docs/MultiChannelMessageRequest.md) + - [MultiChannelStatusEnum](docs/MultiChannelStatusEnum.md) - [OptInWorkflow](docs/OptInWorkflow.md) - [PageInfo](docs/PageInfo.md) - [PriorityEnum](docs/PriorityEnum.md) + - [RbmActionBase](docs/RbmActionBase.md) + - [RbmActionDial](docs/RbmActionDial.md) + - [RbmActionOpenUrl](docs/RbmActionOpenUrl.md) + - [RbmActionTypeEnum](docs/RbmActionTypeEnum.md) + - [RbmActionViewLocation](docs/RbmActionViewLocation.md) + - [RbmCardContent](docs/RbmCardContent.md) + - [RbmCardContentMedia](docs/RbmCardContentMedia.md) + - [RbmMediaHeightEnum](docs/RbmMediaHeightEnum.md) + - [RbmMessageCarouselCard](docs/RbmMessageCarouselCard.md) + - [RbmMessageContentFile](docs/RbmMessageContentFile.md) + - [RbmMessageContentRichCard](docs/RbmMessageContentRichCard.md) + - [RbmMessageContentText](docs/RbmMessageContentText.md) + - [RbmMessageMedia](docs/RbmMessageMedia.md) + - [RbmStandaloneCard](docs/RbmStandaloneCard.md) - [RecordingAvailableCallback](docs/RecordingAvailableCallback.md) - [RecordingCompleteCallback](docs/RecordingCompleteCallback.md) - [RecordingStateEnum](docs/RecordingStateEnum.md) @@ -251,8 +282,9 @@ Class | Method | HTTP request | Description - [RecordingTranscriptions](docs/RecordingTranscriptions.md) - [RedirectCallback](docs/RedirectCallback.md) - [RedirectMethodEnum](docs/RedirectMethodEnum.md) + - [SmsMessageContent](docs/SmsMessageContent.md) + - [StandaloneCardOrientationEnum](docs/StandaloneCardOrientationEnum.md) - [StirShaken](docs/StirShaken.md) - - [Tag](docs/Tag.md) - [TelephoneNumber](docs/TelephoneNumber.md) - [TfvBasicAuthentication](docs/TfvBasicAuthentication.md) - [TfvCallbackStatusEnum](docs/TfvCallbackStatusEnum.md) @@ -261,6 +293,7 @@ Class | Method | HTTP request | Description - [TfvStatusEnum](docs/TfvStatusEnum.md) - [TfvSubmissionInfo](docs/TfvSubmissionInfo.md) - [TfvSubmissionWrapper](docs/TfvSubmissionWrapper.md) + - [ThumbnailAlignmentEnum](docs/ThumbnailAlignmentEnum.md) - [TnLookupRequestError](docs/TnLookupRequestError.md) - [TranscribeRecording](docs/TranscribeRecording.md) - [Transcription](docs/Transcription.md) diff --git a/api/openapi.yaml b/api/openapi.yaml index 5a90fb23..666c48c5 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -14,6 +14,7 @@ security: tags: - name: Messages - name: Media +- name: Multi-Channel - name: Calls - name: Conferences - name: Recordings @@ -699,6 +700,92 @@ paths: servers: - description: Production url: https://messaging.bandwidth.com/api/v2 + /users/{accountId}/messages/multiChannel: + post: + callbacks: + multiChannelCallback: + $ref: '#/components/callbacks/multiChannelMessageCallback' + description: Endpoint for sending Multi-Channel messages. + operationId: createMultiChannelMessage + parameters: + - description: Your Bandwidth Account ID. + example: "9900000" + explode: false + in: path + name: accountId + required: true + schema: + type: string + style: simple + requestBody: + $ref: '#/components/requestBodies/createMultiChannelMessageRequest' + responses: + "202": + content: + application/json: + schema: + $ref: '#/components/schemas/createMultiChannelMessageResponse' + description: Accepted + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/createMessageRequestError' + description: Bad Request + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Forbidden + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Not Found + "406": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Not Acceptable + "415": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Unsupported Media Type + "429": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Too Many Requests + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + description: Internal Server Error + summary: Create Multi-Channel Message + tags: + - Multi-Channel + x-badges: + - name: Beta + color: '#076EA8' + x-content-type: application/json + x-accepts: + - application/json + servers: + - description: Production + url: https://messaging.bandwidth.com/api/v2 /accounts/{accountId}/calls: get: description: |- @@ -5510,6 +5597,19 @@ components: responses: "200": description: OK + multiChannelMessageCallback: + '{multiChannelMessageCallbackUrl}': + post: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/multiChannelCallbackData' + description: Status Callback Payload + required: true + responses: + "204": + description: No Content tfVerificationStatus: your_url.com/webhookService: post: @@ -6366,6 +6466,12 @@ components: schema: $ref: '#/components/schemas/messageRequest' required: true + createMultiChannelMessageRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/multiChannelMessageRequest' + required: true uploadMediaRequest: content: application/json: @@ -6702,6 +6808,12 @@ components: schema: $ref: '#/components/schemas/message' description: Accepted + createMultiChannelMessageResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/createMultiChannelMessageResponse' + description: Accepted listMessagesResponse: content: application/json: @@ -7258,6 +7370,11 @@ components: $ref: '#/components/schemas/tfvError' description: Service Unavailable schemas: + applicationId: + description: The ID of the Application your from number or senderId is associated + with in the Bandwidth Phone Number Dashboard. + example: 93de2206-9669-4e07-948d-329f4b722ee2 + type: string callbackTypeEnum: description: | Indicates the type of the callback: @@ -7271,10 +7388,7 @@ components: example: message-delivered type: string priorityEnum: - description: |- - The priority specified by the user. - - Not supported on MMS. + description: The priority specified by the user. enum: - default - high @@ -7544,6 +7658,10 @@ components: - type title: CreateMessageRequestError type: object + messageId: + description: The ID of the message. + example: 1589228074636lm4k2je7j7jklbn2 + type: string media: example: contentLength: 0 @@ -7559,13 +7677,11 @@ components: title: Media type: object tag: - properties: - key: - type: string - value: - type: string + description: A custom string that will be included in callback events of the + message. Max 1024 characters. + example: custom string title: Tag - type: object + type: string deferredResult: properties: result: @@ -7574,6 +7690,13 @@ components: type: boolean title: DeferredResult type: object + expiration: + description: "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." + example: 2021-02-01T11:29:18-05:00 + format: date-time + type: string message: example: owner: "+15554443333" @@ -7650,7 +7773,9 @@ components: priority: $ref: '#/components/schemas/priorityEnum' expiration: - description: The expiration date-time set by the user. + description: "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." example: 2021-02-01T11:29:18-05:00 format: date-time type: string @@ -7704,13 +7829,14 @@ components: description: A custom string that will be included in callback events of the message. Max 1024 characters. example: custom string + title: Tag type: string priority: $ref: '#/components/schemas/priorityEnum' expiration: - description: |- - 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. - Not supported on MMS. + description: "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." example: 2021-02-01T11:29:18-05:00 format: date-time type: string @@ -7720,6 +7846,593 @@ components: - to title: MessageRequest type: object + messageText: + description: The contents of the text message. Must be 2048 characters or less. + example: Hello world + maxLength: 2048 + type: string + messageMedia: + description: |- + A list of URLs to include as media attachments as part of the message. + Each URL can be at most 4096 characters. + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + items: + format: uri + maxLength: 4096 + type: string + type: array + createMultiChannelMessageResponse: + example: + data: + channel: RBM + messageId: 1589228074636lm4k2je7j7jklbn2 + from: BandwidthRBM + time: 2025-01-01T18:20:16Z + to: "+15552223333" + tag: custom string + applicationId: 93de2206-9669-4e07-948d-329f4b722ee2 + status: DELIVERED + direction: OUTBOUND + links: + - rel: rel + href: href + - rel: rel + href: href + errors: + - code: code + message: message + - code: code + message: message + properties: + links: + items: + $ref: '#/components/schemas/link' + type: array + data: + $ref: '#/components/schemas/multiChannelMessageData' + errors: + items: + $ref: '#/components/schemas/errorObject' + type: array + type: object + multiChannelMessageChannelEnum: + description: The channel of the multi-channel message. + enum: + - RBM + - SMS + - MMS + example: RBM + type: string + multiChannelMessageDirectionEnum: + enum: + - INBOUND + - OUTBOUND + example: OUTBOUND + type: string + multiChannelSenderId: + description: The sender ID of the message. This could be an alphanumeric sender + ID. + example: BandwidthRBM + type: string + multiChannelDestination: + description: The phone number the message should be sent to in E164 format. + example: "+15552223333" + type: string + rbmMessageContentText: + properties: + text: + description: The text associated with the message. Must be 3270 characters + or less + example: Hello world + maxLength: 3270 + type: string + suggestions: + description: An array of suggested actions for the recipient. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 11 + type: array + required: + - text + title: RBM Text + type: object + rbmMediaHeightEnum: + description: The height of the media. + enum: + - SHORT + - MEDIUM + - TALL + example: SHORT + type: string + rbmMessageContentFile: + properties: + fileUrl: + description: The URL of the media file. 100MB is the maximum file size. + example: https://dev.bandwidth.com/images/bandwidth-logo.png + format: uri + maxLength: 1000 + type: string + thumbnailUrl: + description: The URL of the thumbnail image. Applies only to video file + media. + example: https://dev.bandwidth.com/images/bandwidth-logo.png + format: uri + maxLength: 1000 + type: string + required: + - fileUrl + title: RBM Rich Media File + type: object + rbmMessageMedia: + properties: + media: + $ref: '#/components/schemas/rbmMessageContentFile' + suggestions: + description: An array of suggested actions for the recipient. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 11 + type: array + required: + - media + title: RBM Media + type: object + rbmCardContent: + properties: + title: + description: The title of the card. Must be 200 characters or less. + example: Bandwidth + maxLength: 200 + type: string + description: + description: The description of the card. Must be 2000 characters or less. + example: Bandwidth is a communications platform as a service (CPaaS) company. + maxLength: 2000 + type: string + media: + $ref: '#/components/schemas/rbmCardContent_media' + suggestions: + description: An array of suggested actions for the recipient that will be + displayed on the rich card. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 4 + type: array + type: object + rbmStandaloneCard: + properties: + orientation: + $ref: '#/components/schemas/standaloneCardOrientationEnum' + thumbnailImageAlignment: + $ref: '#/components/schemas/thumbnailAlignmentEnum' + cardContent: + $ref: '#/components/schemas/rbmCardContent' + suggestions: + description: An array of suggested actions for the recipient. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 11 + type: array + required: + - cardContent + - orientation + - thumbnailImageAlignment + title: Standalone Card + type: object + standaloneCardOrientationEnum: + enum: + - HORIZONTAL + - VERTICAL + example: VERTICAL + type: string + thumbnailAlignmentEnum: + description: The alignment of the thumbnail image in the card. Only applicable + if the card using horizontal orientation. + enum: + - LEFT + - RIGHT + example: LEFT + type: string + rbmMessageCarouselCard: + properties: + cardWidth: + $ref: '#/components/schemas/cardWidthEnum' + cardContents: + items: + $ref: '#/components/schemas/rbmCardContent' + maxItems: 10 + type: array + suggestions: + description: An array of suggested actions for the recipient. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 11 + type: array + required: + - cardContents + - cardWidth + title: Carousel + type: object + cardWidthEnum: + enum: + - SMALL + - MEDIUM + example: SMALL + type: string + smsMessageContent: + properties: + text: + description: The contents of the text message. Must be 2048 characters or + less. + example: Hello world + maxLength: 2048 + type: string + required: + - text + title: SMS Text + type: object + mmsMessageContent: + properties: + text: + description: The contents of the text message. Must be 2048 characters or + less. + example: Hello world + maxLength: 2048 + type: string + media: + description: |- + A list of URLs to include as media attachments as part of the message. + Each URL can be at most 4096 characters. + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + items: + format: uri + maxLength: 4096 + type: string + type: array + title: MMS Message + type: object + rbmMessageContentRichCard: + oneOf: + - $ref: '#/components/schemas/rbmStandaloneCard' + - $ref: '#/components/schemas/rbmMessageCarouselCard' + title: RBM Rich Card + rbmActionTypeEnum: + enum: + - REPLY + - DIAL_PHONE + - SHOW_LOCATION + - CREATE_CALENDAR_EVENT + - OPEN_URL + - REQUEST_LOCATION + example: REPLY + type: string + rbmActionText: + description: Displayed text for user to click + example: Hello world + maxLength: 25 + title: Text + type: string + rbmActionPostBackData: + description: Base64 payload the customer receives when the reply is clicked. + example: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + format: byte + maxLength: 2048 + title: Post Back Data + type: string + rbmActionBase: + properties: + type: + $ref: '#/components/schemas/rbmActionTypeEnum' + text: + description: Displayed text for user to click + example: Hello world + maxLength: 25 + title: Text + type: string + postBackData: + description: Base64 payload the customer receives when the reply is clicked. + example: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + format: byte + maxLength: 2048 + title: Post Back Data + type: string + required: + - postBackData + - text + - type + type: object + rbmActionDial: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - properties: + phoneNumber: + description: The phone number to dial. Must be E164 format. + example: "+15552223333" + type: string + required: + - phoneNumber + title: Dial Phone + type: object + rbmActionViewLocation: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - properties: + latitude: + description: The latitude of the location. + example: "37.7749" + format: double + type: string + longitude: + description: The longitude of the location. + example: "-122.4194" + format: double + type: string + label: + description: The label of the location. + example: San Francisco + maxLength: 100 + type: string + required: + - latitude + - longitude + title: Show Location + type: object + multiChannelActionCalendarEvent: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - properties: + title: + description: The title of the event. + example: Meeting with John + maxLength: 100 + type: string + startTime: + description: The start time of the event. + example: 2022-09-14T18:20:16Z + format: date-time + type: string + endTime: + description: The end time of the event. + example: 2022-09-14T18:20:16Z + format: date-time + type: string + description: + description: The description of the event. + example: Discuss the new project + maxLength: 500 + type: string + required: + - endTime + - startTime + - title + title: Calendar Event + type: object + rbmActionOpenUrl: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - properties: + url: + description: The URL to open in browser. + example: https://dev.bandwidth.com + format: uri + maxLength: 2048 + type: string + required: + - url + title: Open URL + type: object + multiChannelFullActions: + description: An array of suggested actions for the recipient. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 11 + type: array + multiChannelAction: + discriminator: + mapping: + REPLY: '#/components/schemas/rbmActionBase' + DIAL_PHONE: '#/components/schemas/rbmActionDial' + SHOW_LOCATION: '#/components/schemas/rbmActionViewLocation' + CREATE_CALENDAR_EVENT: '#/components/schemas/multiChannelActionCalendarEvent' + OPEN_URL: '#/components/schemas/rbmActionOpenUrl' + REQUEST_LOCATION: '#/components/schemas/rbmActionBase' + propertyName: type + oneOf: + - $ref: '#/components/schemas/rbmActionBase' + - $ref: '#/components/schemas/rbmActionDial' + - $ref: '#/components/schemas/rbmActionViewLocation' + - $ref: '#/components/schemas/multiChannelActionCalendarEvent' + - $ref: '#/components/schemas/rbmActionOpenUrl' + multiChannelStatusEnum: + enum: + - QUEUED + - SENDING + - DELIVERED + - FAILED + example: DELIVERED + type: string + multiChannelChannelListObject: + properties: + from: + description: The sender ID of the message. This could be an alphanumeric + sender ID. + example: BandwidthRBM + type: string + applicationId: + description: The ID of the Application your from number or senderId is associated + with in the Bandwidth Phone Number Dashboard. + example: 93de2206-9669-4e07-948d-329f4b722ee2 + type: string + channel: + $ref: '#/components/schemas/multiChannelMessageChannelEnum' + content: + $ref: '#/components/schemas/multiChannelChannelListObject_content' + required: + - applicationId + - channel + - content + - from + type: object + multiChannelMessageRequest: + description: Multi-Channel Message Request + properties: + to: + description: The phone number the message should be sent to in E164 format. + example: "+15552223333" + type: string + channelList: + description: "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." + items: + $ref: '#/components/schemas/multiChannelChannelListObject' + maxItems: 4 + type: array + tag: + description: A custom string that will be included in callback events of + the message. Max 1024 characters. + example: custom string + title: Tag + type: string + priority: + $ref: '#/components/schemas/priorityEnum' + expiration: + description: "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." + example: 2021-02-01T11:29:18-05:00 + format: date-time + type: string + required: + - channelList + - to + type: object + multiChannelMessageCallbackData: + properties: + messageId: + description: The ID of the message. + example: 1589228074636lm4k2je7j7jklbn2 + type: string + status: + $ref: '#/components/schemas/multiChannelStatusEnum' + direction: + $ref: '#/components/schemas/multiChannelMessageDirectionEnum' + from: + description: The sender ID of the message. This could be an alphanumeric + sender ID. + example: BandwidthRBM + type: string + to: + description: The phone number the message should be sent to in E164 format. + example: "+15552223333" + type: string + applicationId: + description: The ID of the Application your from number or senderId is associated + with in the Bandwidth Phone Number Dashboard. + example: 93de2206-9669-4e07-948d-329f4b722ee2 + type: string + channel: + $ref: '#/components/schemas/multiChannelMessageChannelEnum' + tag: + description: A custom string that will be included in callback events of + the message. Max 1024 characters. + example: custom string + title: Tag + type: string + type: object + multiChannelMessageData: + example: + channel: RBM + messageId: 1589228074636lm4k2je7j7jklbn2 + from: BandwidthRBM + time: 2025-01-01T18:20:16Z + to: "+15552223333" + tag: custom string + applicationId: 93de2206-9669-4e07-948d-329f4b722ee2 + status: DELIVERED + direction: OUTBOUND + properties: + messageId: + description: The ID of the message. + example: 1589228074636lm4k2je7j7jklbn2 + type: string + status: + $ref: '#/components/schemas/multiChannelStatusEnum' + time: + description: The time the message was received by the Bandwidth API. + example: 2025-01-01T18:20:16Z + format: date-time + type: string + direction: + $ref: '#/components/schemas/multiChannelMessageDirectionEnum' + from: + description: The sender ID of the message. This could be an alphanumeric + sender ID. + example: BandwidthRBM + type: string + to: + description: The phone number the message should be sent to in E164 format. + example: "+15552223333" + type: string + applicationId: + description: The ID of the Application your from number or senderId is associated + with in the Bandwidth Phone Number Dashboard. + example: 93de2206-9669-4e07-948d-329f4b722ee2 + type: string + channel: + $ref: '#/components/schemas/multiChannelMessageChannelEnum' + tag: + description: A custom string that will be included in callback events of + the message. Max 1024 characters. + example: custom string + title: Tag + type: string + type: object + multiChannelCallbackData: + properties: + time: + description: The time of the callback event. + example: 2025-01-01T18:20:16Z + format: date-time + type: string + type: + $ref: '#/components/schemas/multiChannelStatusEnum' + to: + description: The phone number the message should be sent to in E164 format. + example: "+15552223333" + type: string + description: + example: Incoming message received + type: string + message: + $ref: '#/components/schemas/multiChannelMessageCallbackData' + type: object + link: + example: + rel: rel + href: href + properties: + rel: + type: string + href: + type: string + type: object + errorObject: + example: + code: code + message: message + properties: + code: + type: string + message: + type: string + type: object messageCallback: description: Message Callback Schema properties: @@ -10918,7 +11631,7 @@ components: description: The user account associated with the call. example: "9900000" type: string - applicationId: + applicationId1: description: The id of the application associated with the call. example: 04e88489-df02-4e34-a0ee-27a91849555f type: string @@ -12372,6 +13085,24 @@ components: nullable: true pattern: "^[ -~]{16,64}$" type: string + rbmCardContent_media: + properties: + height: + $ref: '#/components/schemas/rbmMediaHeightEnum' + file: + $ref: '#/components/schemas/rbmMessageContentFile' + required: + - file + - height + type: object + multiChannelChannelListObject_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' webhookSubscription_basicAuthentication: description: "Basic authentication credentials are not required, but if present,\ \ both username and password must be provided." diff --git a/bandwidth.yml b/bandwidth.yml index 8f3d160b..7990bbfd 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -12,6 +12,7 @@ security: tags: - name: Messages - name: Media + - name: Multi-Channel - name: Calls - name: Conferences - name: Recordings @@ -234,6 +235,43 @@ paths: statusCallback: $ref: '#/components/callbacks/statusCallback' servers: *ref_0 + /users/{accountId}/messages/multiChannel: + post: + summary: Create Multi-Channel Message + description: Endpoint for sending Multi-Channel messages. + operationId: createMultiChannelMessage + parameters: + - $ref: '#/components/parameters/accountId' + tags: + - Multi-Channel + requestBody: + $ref: '#/components/requestBodies/createMultiChannelMessageRequest' + responses: + '202': + $ref: '#/components/responses/createMultiChannelMessageResponse' + '400': + $ref: '#/components/responses/createMessageBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '406': + $ref: '#/components/responses/messagingNotAcceptableError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + callbacks: + multiChannelCallback: + $ref: '#/components/callbacks/multiChannelMessageCallback' + x-badges: + - name: Beta + color: '#076EA8' + servers: *ref_0 /accounts/{accountId}/calls: post: tags: @@ -1595,6 +1633,12 @@ paths: servers: *ref_4 components: schemas: + applicationId: + type: string + description: >- + The ID of the Application your from number or senderId is associated + with in the Bandwidth Phone Number Dashboard. + example: 93de2206-9669-4e07-948d-329f4b722ee2 callbackTypeEnum: type: string enum: @@ -1612,10 +1656,7 @@ components: example: message-delivered priorityEnum: type: string - description: |- - The priority specified by the user. - - Not supported on MMS. + description: The priority specified by the user. enum: - default - high @@ -1808,6 +1849,10 @@ components: required: - type - description + messageId: + type: string + description: The ID of the message. + example: 1589228074636lm4k2je7j7jklbn2 media: title: Media type: object @@ -1820,12 +1865,11 @@ components: type: string tag: title: Tag - type: object - properties: - key: - type: string - value: - type: string + type: string + description: >- + A custom string that will be included in callback events of the message. + Max 1024 characters. + example: custom string deferredResult: title: DeferredResult type: object @@ -1834,6 +1878,15 @@ components: type: object setOrExpired: type: boolean + expiration: + type: string + format: date-time + description: >- + 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. + example: '2021-02-01T11:29:18-05:00' message: title: Message type: object @@ -1898,10 +1951,7 @@ components: priority: $ref: '#/components/schemas/priorityEnum' expiration: - type: string - format: date-time - description: The expiration date-time set by the user. - example: '2021-02-01T11:29:18-05:00' + $ref: '#/components/schemas/expiration' messageRequest: title: MessageRequest type: object @@ -1937,44 +1987,490 @@ components: plus +, underscore _ and ampersand &. Alphanumeric Sender IDs must contain at least one letter. example: '+15551113333' + text: + $ref: '#/components/schemas/messageText' + media: + $ref: '#/components/schemas/messageMedia' + tag: + $ref: '#/components/schemas/tag' + priority: + $ref: '#/components/schemas/priorityEnum' + expiration: + $ref: '#/components/schemas/expiration' + messageText: + type: string + description: The contents of the text message. Must be 2048 characters or less. + maxLength: 2048 + example: Hello world + messageMedia: + type: array + items: + type: string + format: uri + maxLength: 4096 + description: |- + A list of URLs to include as media attachments as part of the message. + Each URL can be at most 4096 characters. + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + createMultiChannelMessageResponse: + type: object + properties: + links: + type: array + items: + $ref: '#/components/schemas/link' + data: + $ref: '#/components/schemas/multiChannelMessageData' + errors: + type: array + items: + $ref: '#/components/schemas/errorObject' + multiChannelMessageChannelEnum: + description: The channel of the multi-channel message. + type: string + enum: + - RBM + - SMS + - MMS + example: RBM + multiChannelMessageDirectionEnum: + type: string + enum: + - INBOUND + - OUTBOUND + example: OUTBOUND + multiChannelSenderId: + type: string + description: The sender ID of the message. This could be an alphanumeric sender ID. + example: BandwidthRBM + multiChannelDestination: + type: string + description: The phone number the message should be sent to in E164 format. + example: '+15552223333' + rbmMessageContentText: + title: RBM Text + type: object + properties: text: type: string - description: The contents of the text message. Must be 2048 characters or less. - maxLength: 2048 + description: >- + The text associated with the message. Must be 3270 characters or + less + maxLength: 3270 example: Hello world + suggestions: + $ref: '#/components/schemas/multiChannelFullActions' + required: + - text + rbmMediaHeightEnum: + type: string + description: The height of the media. + enum: + - SHORT + - MEDIUM + - TALL + example: SHORT + rbmMessageContentFile: + title: RBM Rich Media File + type: object + properties: + fileUrl: + type: string + format: uri + description: The URL of the media file. 100MB is the maximum file size. + example: https://dev.bandwidth.com/images/bandwidth-logo.png + maxLength: 1000 + thumbnailUrl: + type: string + format: uri + description: The URL of the thumbnail image. Applies only to video file media. + example: https://dev.bandwidth.com/images/bandwidth-logo.png + maxLength: 1000 + required: + - fileUrl + rbmMessageMedia: + title: RBM Media + type: object + properties: media: + $ref: '#/components/schemas/rbmMessageContentFile' + suggestions: + $ref: '#/components/schemas/multiChannelFullActions' + required: + - media + rbmCardContent: + type: object + properties: + title: + type: string + description: The title of the card. Must be 200 characters or less. + maxLength: 200 + example: Bandwidth + description: + type: string + description: The description of the card. Must be 2000 characters or less. + maxLength: 2000 + example: Bandwidth is a communications platform as a service (CPaaS) company. + media: + type: object + properties: + height: + $ref: '#/components/schemas/rbmMediaHeightEnum' + file: + $ref: '#/components/schemas/rbmMessageContentFile' + required: + - height + - file + suggestions: + description: >- + An array of suggested actions for the recipient that will be + displayed on the rich card. type: array items: - type: string - format: uri - maxLength: 4096 + $ref: '#/components/schemas/multiChannelAction' + maxItems: 4 + rbmStandaloneCard: + title: Standalone Card + type: object + properties: + orientation: + $ref: '#/components/schemas/standaloneCardOrientationEnum' + thumbnailImageAlignment: + $ref: '#/components/schemas/thumbnailAlignmentEnum' + cardContent: + $ref: '#/components/schemas/rbmCardContent' + suggestions: + $ref: '#/components/schemas/multiChannelFullActions' + required: + - orientation + - thumbnailImageAlignment + - cardContent + standaloneCardOrientationEnum: + type: string + enum: + - HORIZONTAL + - VERTICAL + example: VERTICAL + thumbnailAlignmentEnum: + type: string + description: >- + The alignment of the thumbnail image in the card. Only applicable if the + card using horizontal orientation. + enum: + - LEFT + - RIGHT + example: LEFT + rbmMessageCarouselCard: + title: Carousel + type: object + properties: + cardWidth: + $ref: '#/components/schemas/cardWidthEnum' + cardContents: + type: array + items: + $ref: '#/components/schemas/rbmCardContent' + maxItems: 10 + suggestions: + $ref: '#/components/schemas/multiChannelFullActions' + required: + - cardContents + - cardWidth + cardWidthEnum: + type: string + enum: + - SMALL + - MEDIUM + example: SMALL + smsMessageContent: + title: SMS Text + type: object + properties: + text: + $ref: '#/components/schemas/messageText' + required: + - text + mmsMessageContent: + title: MMS Message + type: object + properties: + text: + $ref: '#/components/schemas/messageText' + media: + $ref: '#/components/schemas/messageMedia' + rbmMessageContentRichCard: + title: RBM Rich Card + oneOf: + - $ref: '#/components/schemas/rbmStandaloneCard' + - $ref: '#/components/schemas/rbmMessageCarouselCard' + rbmActionTypeEnum: + type: string + enum: + - REPLY + - DIAL_PHONE + - SHOW_LOCATION + - CREATE_CALENDAR_EVENT + - OPEN_URL + - REQUEST_LOCATION + example: REPLY + rbmActionText: + title: Text + type: string + description: Displayed text for user to click + maxLength: 25 + example: Hello world + rbmActionPostBackData: + title: Post Back Data + type: string + format: byte + description: Base64 payload the customer receives when the reply is clicked. + maxLength: 2048 + example: SGVsbG8gd29ybGQ= + rbmActionBase: + type: object + properties: + type: + $ref: '#/components/schemas/rbmActionTypeEnum' + text: + $ref: '#/components/schemas/rbmActionText' + postBackData: + $ref: '#/components/schemas/rbmActionPostBackData' + required: + - text + - postBackData + - type + rbmActionDial: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - title: Dial Phone + type: object + properties: + phoneNumber: + type: string + description: The phone number to dial. Must be E164 format. + example: '+15552223333' + required: + - phoneNumber + rbmActionViewLocation: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - title: Show Location + type: object + properties: + latitude: + type: string + format: double + description: The latitude of the location. + example: '37.7749' + longitude: + type: string + format: double + description: The longitude of the location. + example: '-122.4194' + label: + type: string + description: The label of the location. + example: San Francisco + maxLength: 100 + required: + - latitude + - longitude + multiChannelActionCalendarEvent: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - title: Calendar Event + type: object + properties: + title: + type: string + description: The title of the event. + example: Meeting with John + maxLength: 100 + startTime: + type: string + format: date-time + description: The start time of the event. + example: 2022-09-14T18:20:16.000Z + endTime: + type: string + format: date-time + description: The end time of the event. + example: 2022-09-14T18:20:16.000Z + description: + type: string + description: The description of the event. + example: Discuss the new project + maxLength: 500 + required: + - title + - startTime + - endTime + rbmActionOpenUrl: + allOf: + - $ref: '#/components/schemas/rbmActionBase' + - title: Open URL + type: object + properties: + url: + type: string + format: uri + description: The URL to open in browser. + example: https://dev.bandwidth.com + maxLength: 2048 + required: + - url + multiChannelFullActions: + type: array + description: An array of suggested actions for the recipient. + items: + $ref: '#/components/schemas/multiChannelAction' + maxItems: 11 + multiChannelAction: + oneOf: + - $ref: '#/components/schemas/rbmActionBase' + - $ref: '#/components/schemas/rbmActionDial' + - $ref: '#/components/schemas/rbmActionViewLocation' + - $ref: '#/components/schemas/multiChannelActionCalendarEvent' + - $ref: '#/components/schemas/rbmActionOpenUrl' + discriminator: + propertyName: type + mapping: + REPLY: '#/components/schemas/rbmActionBase' + DIAL_PHONE: '#/components/schemas/rbmActionDial' + SHOW_LOCATION: '#/components/schemas/rbmActionViewLocation' + CREATE_CALENDAR_EVENT: '#/components/schemas/multiChannelActionCalendarEvent' + OPEN_URL: '#/components/schemas/rbmActionOpenUrl' + REQUEST_LOCATION: '#/components/schemas/rbmActionBase' + multiChannelStatusEnum: + type: string + enum: + - QUEUED + - SENDING + - DELIVERED + - FAILED + example: DELIVERED + multiChannelChannelListObject: + type: object + properties: + from: + $ref: '#/components/schemas/multiChannelSenderId' + applicationId: + $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 + - content + multiChannelMessageRequest: + description: Multi-Channel Message Request + type: object + properties: + to: + $ref: '#/components/schemas/multiChannelDestination' + channelList: + type: array description: >- - A list of URLs to include as media attachments as part of the - message. - - Each URL can be at most 4096 characters. - example: - - https://dev.bandwidth.com/images/bandwidth-logo.png - - https://dev.bandwidth.com/images/github_logo.png + 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. + items: + $ref: '#/components/schemas/multiChannelChannelListObject' + maxItems: 4 tag: - type: string - description: >- - A custom string that will be included in callback events of the - message. Max 1024 characters. - example: custom string + $ref: '#/components/schemas/tag' priority: $ref: '#/components/schemas/priorityEnum' expiration: + $ref: '#/components/schemas/expiration' + required: + - to + - channelList + multiChannelMessageCallbackData: + type: object + properties: + messageId: + $ref: '#/components/schemas/messageId' + status: + $ref: '#/components/schemas/multiChannelStatusEnum' + direction: + $ref: '#/components/schemas/multiChannelMessageDirectionEnum' + from: + $ref: '#/components/schemas/multiChannelSenderId' + to: + $ref: '#/components/schemas/multiChannelDestination' + applicationId: + $ref: '#/components/schemas/applicationId' + channel: + $ref: '#/components/schemas/multiChannelMessageChannelEnum' + tag: + $ref: '#/components/schemas/tag' + multiChannelMessageData: + type: object + properties: + messageId: + $ref: '#/components/schemas/messageId' + status: + $ref: '#/components/schemas/multiChannelStatusEnum' + time: + description: The time the message was received by the Bandwidth API. type: string format: date-time - description: >- - 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. - - Not supported on MMS. - example: '2021-02-01T11:29:18-05:00' + example: 2025-01-01T18:20:16.000Z + direction: + $ref: '#/components/schemas/multiChannelMessageDirectionEnum' + from: + $ref: '#/components/schemas/multiChannelSenderId' + to: + $ref: '#/components/schemas/multiChannelDestination' + applicationId: + $ref: '#/components/schemas/applicationId' + channel: + $ref: '#/components/schemas/multiChannelMessageChannelEnum' + tag: + $ref: '#/components/schemas/tag' + multiChannelCallbackData: + type: object + properties: + time: + description: The time of the callback event. + type: string + format: date-time + example: 2025-01-01T18:20:16.000Z + type: + $ref: '#/components/schemas/multiChannelStatusEnum' + to: + $ref: '#/components/schemas/multiChannelDestination' + description: + type: string + example: Incoming message received + message: + $ref: '#/components/schemas/multiChannelMessageCallbackData' + link: + type: object + properties: + rel: + type: string + href: + type: string + errorObject: + type: object + properties: + code: + type: string + message: + type: string messageCallback: description: Message Callback Schema type: object @@ -2796,7 +3292,7 @@ components: type: object properties: applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' accountId: $ref: '#/components/schemas/accountId' callId: @@ -3404,7 +3900,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3441,7 +3937,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3481,7 +3977,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3662,7 +4158,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3702,7 +4198,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3742,7 +4238,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3786,7 +4282,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3820,7 +4316,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3856,7 +4352,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3906,7 +4402,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3956,7 +4452,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -3994,7 +4490,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -4047,7 +4543,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -4086,7 +4582,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -4132,7 +4628,7 @@ components: accountId: $ref: '#/components/schemas/accountId' applicationId: - $ref: '#/components/schemas/applicationId' + $ref: '#/components/schemas/applicationId1' from: $ref: '#/components/schemas/from' to: @@ -4188,7 +4684,7 @@ components: type: string description: The user account associated with the call. example: '9900000' - applicationId: + applicationId1: type: string description: The id of the application associated with the call. example: 04e88489-df02-4e34-a0ee-27a91849555f @@ -5318,6 +5814,12 @@ components: application/json: schema: $ref: '#/components/schemas/message' + createMultiChannelMessageResponse: + description: Accepted + content: + application/json: + schema: + $ref: '#/components/schemas/createMultiChannelMessageResponse' listMessagesResponse: description: OK content: @@ -6577,6 +7079,12 @@ components: schema: $ref: '#/components/schemas/messageRequest' required: true + createMultiChannelMessageRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/multiChannelMessageRequest' + required: true uploadMediaRequest: content: application/json: @@ -6978,6 +7486,19 @@ components: responses: '200': description: OK + multiChannelMessageCallback: + '{multiChannelMessageCallbackUrl}': + post: + requestBody: + required: true + description: Status Callback Payload + content: + application/json: + schema: + $ref: '#/components/schemas/multiChannelCallbackData' + responses: + '204': + description: No Content tfVerificationStatus: your_url.com/webhookService: post: diff --git a/docs/CardWidthEnum.md b/docs/CardWidthEnum.md new file mode 100644 index 00000000..334ea7a3 --- /dev/null +++ b/docs/CardWidthEnum.md @@ -0,0 +1,13 @@ + + +# CardWidthEnum + +## Enum + + +* `SMALL` (value: `"SMALL"`) + +* `MEDIUM` (value: `"MEDIUM"`) + + + diff --git a/docs/CreateMultiChannelMessageResponse.md b/docs/CreateMultiChannelMessageResponse.md new file mode 100644 index 00000000..8f47b054 --- /dev/null +++ b/docs/CreateMultiChannelMessageResponse.md @@ -0,0 +1,15 @@ + + +# CreateMultiChannelMessageResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**links** | [**List<Link>**](Link.md) | | [optional] | +|**data** | [**MultiChannelMessageData**](MultiChannelMessageData.md) | | [optional] | +|**errors** | [**List<ErrorObject>**](ErrorObject.md) | | [optional] | + + + diff --git a/docs/ErrorObject.md b/docs/ErrorObject.md new file mode 100644 index 00000000..96683d54 --- /dev/null +++ b/docs/ErrorObject.md @@ -0,0 +1,14 @@ + + +# ErrorObject + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/docs/Link.md b/docs/Link.md new file mode 100644 index 00000000..049680c9 --- /dev/null +++ b/docs/Link.md @@ -0,0 +1,14 @@ + + +# Link + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**rel** | **String** | | [optional] | +|**href** | **String** | | [optional] | + + + diff --git a/docs/Message.md b/docs/Message.md index ef12c3ba..dcdfc80a 100644 --- a/docs/Message.md +++ b/docs/Message.md @@ -19,7 +19,7 @@ |**text** | **String** | The contents of the message. | [optional] | |**tag** | **String** | The custom string set by the user. | [optional] | |**priority** | **PriorityEnum** | | [optional] | -|**expiration** | **OffsetDateTime** | The expiration date-time set by the user. | [optional] | +|**expiration** | **OffsetDateTime** | 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/MessageRequest.md b/docs/MessageRequest.md index bc3ee310..e64e4d64 100644 --- a/docs/MessageRequest.md +++ b/docs/MessageRequest.md @@ -14,7 +14,7 @@ |**media** | **List<URI>** | A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters. | [optional] | |**tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | |**priority** | **PriorityEnum** | | [optional] | -|**expiration** | **OffsetDateTime** | 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. Not supported on MMS. | [optional] | +|**expiration** | **OffsetDateTime** | 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/MmsMessageContent.md b/docs/MmsMessageContent.md new file mode 100644 index 00000000..7263a845 --- /dev/null +++ b/docs/MmsMessageContent.md @@ -0,0 +1,14 @@ + + +# MmsMessageContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**text** | **String** | The contents of the text message. Must be 2048 characters or less. | [optional] | +|**media** | **List<URI>** | A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters. | [optional] | + + + diff --git a/docs/MultiChannelAction.md b/docs/MultiChannelAction.md new file mode 100644 index 00000000..e95d4f4c --- /dev/null +++ b/docs/MultiChannelAction.md @@ -0,0 +1,24 @@ + + +# MultiChannelAction + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **RbmActionTypeEnum** | | | +|**text** | **String** | Displayed text for user to click | | +|**postBackData** | **byte[]** | Base64 payload the customer receives when the reply is clicked. | | +|**phoneNumber** | **String** | The phone number to dial. Must be E164 format. | | +|**latitude** | **Double** | The latitude of the location. | | +|**longitude** | **Double** | The longitude of the location. | | +|**label** | **String** | The label of the location. | [optional] | +|**title** | **String** | The title of the event. | | +|**startTime** | **OffsetDateTime** | The start time of the event. | | +|**endTime** | **OffsetDateTime** | The end time of the event. | | +|**description** | **String** | The description of the event. | [optional] | +|**url** | **URI** | The URL to open in browser. | | + + + diff --git a/docs/MultiChannelActionCalendarEvent.md b/docs/MultiChannelActionCalendarEvent.md new file mode 100644 index 00000000..3976a327 --- /dev/null +++ b/docs/MultiChannelActionCalendarEvent.md @@ -0,0 +1,19 @@ + + +# MultiChannelActionCalendarEvent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **RbmActionTypeEnum** | | | +|**text** | **String** | Displayed text for user to click | | +|**postBackData** | **byte[]** | Base64 payload the customer receives when the reply is clicked. | | +|**title** | **String** | The title of the event. | | +|**startTime** | **OffsetDateTime** | The start time of the event. | | +|**endTime** | **OffsetDateTime** | The end time of the event. | | +|**description** | **String** | The description of the event. | [optional] | + + + diff --git a/docs/MultiChannelApi.md b/docs/MultiChannelApi.md new file mode 100644 index 00000000..065905ff --- /dev/null +++ b/docs/MultiChannelApi.md @@ -0,0 +1,87 @@ +# MultiChannelApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createMultiChannelMessage**](MultiChannelApi.md#createMultiChannelMessage) | **POST** /users/{accountId}/messages/multiChannel | Create Multi-Channel Message | + + + +# **createMultiChannelMessage** +> CreateMultiChannelMessageResponse createMultiChannelMessage(accountId, multiChannelMessageRequest) + +Create Multi-Channel Message + +Endpoint for sending Multi-Channel messages. + +### Example +```java +// Import classes: +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.auth.*; +import com.bandwidth.sdk.models.*; +import com.bandwidth.sdk.api.MultiChannelApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + // Configure HTTP basic authorization: Basic + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); + Basic.setUsername("YOUR USERNAME"); + Basic.setPassword("YOUR PASSWORD"); + + MultiChannelApi apiInstance = new MultiChannelApi(defaultClient); + String accountId = "9900000"; // String | Your Bandwidth Account ID. + MultiChannelMessageRequest multiChannelMessageRequest = new MultiChannelMessageRequest(); // MultiChannelMessageRequest | + try { + CreateMultiChannelMessageResponse result = apiInstance.createMultiChannelMessage(accountId, multiChannelMessageRequest); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MultiChannelApi#createMultiChannelMessage"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **accountId** | **String**| Your Bandwidth Account ID. | | +| **multiChannelMessageRequest** | [**MultiChannelMessageRequest**](MultiChannelMessageRequest.md)| | | + +### Return type + +[**CreateMultiChannelMessageResponse**](CreateMultiChannelMessageResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **202** | Accepted | - | +| **400** | Bad Request | - | +| **401** | Unauthorized | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **406** | Not Acceptable | - | +| **415** | Unsupported Media Type | - | +| **429** | Too Many Requests | - | +| **500** | Internal Server Error | - | + diff --git a/docs/MultiChannelCallbackData.md b/docs/MultiChannelCallbackData.md new file mode 100644 index 00000000..c9326865 --- /dev/null +++ b/docs/MultiChannelCallbackData.md @@ -0,0 +1,17 @@ + + +# MultiChannelCallbackData + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**time** | **OffsetDateTime** | The time of the callback event. | [optional] | +|**type** | **MultiChannelStatusEnum** | | [optional] | +|**to** | **String** | The phone number the message should be sent to in E164 format. | [optional] | +|**description** | **String** | | [optional] | +|**message** | [**MultiChannelMessageCallbackData**](MultiChannelMessageCallbackData.md) | | [optional] | + + + diff --git a/docs/MultiChannelChannelListObject.md b/docs/MultiChannelChannelListObject.md new file mode 100644 index 00000000..57d6da61 --- /dev/null +++ b/docs/MultiChannelChannelListObject.md @@ -0,0 +1,16 @@ + + +# MultiChannelChannelListObject + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | | +|**applicationId** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | | +|**channel** | **MultiChannelMessageChannelEnum** | | | +|**content** | [**MultiChannelChannelListObjectContent**](MultiChannelChannelListObjectContent.md) | | | + + + diff --git a/docs/MultiChannelChannelListObjectContent.md b/docs/MultiChannelChannelListObjectContent.md new file mode 100644 index 00000000..ec331be4 --- /dev/null +++ b/docs/MultiChannelChannelListObjectContent.md @@ -0,0 +1,21 @@ + + +# MultiChannelChannelListObjectContent + +The content of the message. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**text** | **String** | The contents of the text message. Must be 2048 characters or less. | | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] | +|**media** | **List<URI>** | A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters. | | +|**orientation** | **StandaloneCardOrientationEnum** | | | +|**thumbnailImageAlignment** | **ThumbnailAlignmentEnum** | | | +|**cardContent** | [**RbmCardContent**](RbmCardContent.md) | | | +|**cardWidth** | **CardWidthEnum** | | | +|**cardContents** | [**List<RbmCardContent>**](RbmCardContent.md) | | | + + + diff --git a/docs/MultiChannelMessageCallbackData.md b/docs/MultiChannelMessageCallbackData.md new file mode 100644 index 00000000..1c4ece86 --- /dev/null +++ b/docs/MultiChannelMessageCallbackData.md @@ -0,0 +1,20 @@ + + +# MultiChannelMessageCallbackData + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**messageId** | **String** | The ID of the message. | [optional] | +|**status** | **MultiChannelStatusEnum** | | [optional] | +|**direction** | **MultiChannelMessageDirectionEnum** | | [optional] | +|**from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | [optional] | +|**to** | **String** | The phone number the message should be sent to in E164 format. | [optional] | +|**applicationId** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | [optional] | +|**channel** | **MultiChannelMessageChannelEnum** | | [optional] | +|**tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | + + + diff --git a/docs/MultiChannelMessageChannelEnum.md b/docs/MultiChannelMessageChannelEnum.md new file mode 100644 index 00000000..f0f89c4c --- /dev/null +++ b/docs/MultiChannelMessageChannelEnum.md @@ -0,0 +1,15 @@ + + +# MultiChannelMessageChannelEnum + +## Enum + + +* `RBM` (value: `"RBM"`) + +* `SMS` (value: `"SMS"`) + +* `MMS` (value: `"MMS"`) + + + diff --git a/docs/MultiChannelMessageData.md b/docs/MultiChannelMessageData.md new file mode 100644 index 00000000..79f9c1b0 --- /dev/null +++ b/docs/MultiChannelMessageData.md @@ -0,0 +1,21 @@ + + +# MultiChannelMessageData + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**messageId** | **String** | The ID of the message. | [optional] | +|**status** | **MultiChannelStatusEnum** | | [optional] | +|**time** | **OffsetDateTime** | The time the message was received by the Bandwidth API. | [optional] | +|**direction** | **MultiChannelMessageDirectionEnum** | | [optional] | +|**from** | **String** | The sender ID of the message. This could be an alphanumeric sender ID. | [optional] | +|**to** | **String** | The phone number the message should be sent to in E164 format. | [optional] | +|**applicationId** | **String** | The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. | [optional] | +|**channel** | **MultiChannelMessageChannelEnum** | | [optional] | +|**tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | + + + diff --git a/docs/MultiChannelMessageDirectionEnum.md b/docs/MultiChannelMessageDirectionEnum.md new file mode 100644 index 00000000..fb2fb7ed --- /dev/null +++ b/docs/MultiChannelMessageDirectionEnum.md @@ -0,0 +1,13 @@ + + +# MultiChannelMessageDirectionEnum + +## Enum + + +* `INBOUND` (value: `"INBOUND"`) + +* `OUTBOUND` (value: `"OUTBOUND"`) + + + diff --git a/docs/MultiChannelMessageRequest.md b/docs/MultiChannelMessageRequest.md new file mode 100644 index 00000000..9d1e87e2 --- /dev/null +++ b/docs/MultiChannelMessageRequest.md @@ -0,0 +1,18 @@ + + +# MultiChannelMessageRequest + +Multi-Channel Message Request + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**to** | **String** | The phone number the message should be sent to in E164 format. | | +|**channelList** | [**List<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. | | +|**tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | +|**priority** | **PriorityEnum** | | [optional] | +|**expiration** | **OffsetDateTime** | 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/MultiChannelStatusEnum.md b/docs/MultiChannelStatusEnum.md new file mode 100644 index 00000000..92a12012 --- /dev/null +++ b/docs/MultiChannelStatusEnum.md @@ -0,0 +1,17 @@ + + +# MultiChannelStatusEnum + +## Enum + + +* `QUEUED` (value: `"QUEUED"`) + +* `SENDING` (value: `"SENDING"`) + +* `DELIVERED` (value: `"DELIVERED"`) + +* `FAILED` (value: `"FAILED"`) + + + diff --git a/docs/RbmActionBase.md b/docs/RbmActionBase.md new file mode 100644 index 00000000..dc89fee0 --- /dev/null +++ b/docs/RbmActionBase.md @@ -0,0 +1,15 @@ + + +# RbmActionBase + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **RbmActionTypeEnum** | | | +|**text** | **String** | Displayed text for user to click | | +|**postBackData** | **byte[]** | Base64 payload the customer receives when the reply is clicked. | | + + + diff --git a/docs/RbmActionDial.md b/docs/RbmActionDial.md new file mode 100644 index 00000000..20385ee3 --- /dev/null +++ b/docs/RbmActionDial.md @@ -0,0 +1,16 @@ + + +# RbmActionDial + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **RbmActionTypeEnum** | | | +|**text** | **String** | Displayed text for user to click | | +|**postBackData** | **byte[]** | Base64 payload the customer receives when the reply is clicked. | | +|**phoneNumber** | **String** | The phone number to dial. Must be E164 format. | | + + + diff --git a/docs/RbmActionOpenUrl.md b/docs/RbmActionOpenUrl.md new file mode 100644 index 00000000..c2b1ef1c --- /dev/null +++ b/docs/RbmActionOpenUrl.md @@ -0,0 +1,16 @@ + + +# RbmActionOpenUrl + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **RbmActionTypeEnum** | | | +|**text** | **String** | Displayed text for user to click | | +|**postBackData** | **byte[]** | Base64 payload the customer receives when the reply is clicked. | | +|**url** | **URI** | The URL to open in browser. | | + + + diff --git a/docs/RbmActionTypeEnum.md b/docs/RbmActionTypeEnum.md new file mode 100644 index 00000000..0353a85a --- /dev/null +++ b/docs/RbmActionTypeEnum.md @@ -0,0 +1,21 @@ + + +# RbmActionTypeEnum + +## Enum + + +* `REPLY` (value: `"REPLY"`) + +* `DIAL_PHONE` (value: `"DIAL_PHONE"`) + +* `SHOW_LOCATION` (value: `"SHOW_LOCATION"`) + +* `CREATE_CALENDAR_EVENT` (value: `"CREATE_CALENDAR_EVENT"`) + +* `OPEN_URL` (value: `"OPEN_URL"`) + +* `REQUEST_LOCATION` (value: `"REQUEST_LOCATION"`) + + + diff --git a/docs/RbmActionViewLocation.md b/docs/RbmActionViewLocation.md new file mode 100644 index 00000000..4d4b675d --- /dev/null +++ b/docs/RbmActionViewLocation.md @@ -0,0 +1,18 @@ + + +# RbmActionViewLocation + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **RbmActionTypeEnum** | | | +|**text** | **String** | Displayed text for user to click | | +|**postBackData** | **byte[]** | Base64 payload the customer receives when the reply is clicked. | | +|**latitude** | **Double** | The latitude of the location. | | +|**longitude** | **Double** | The longitude of the location. | | +|**label** | **String** | The label of the location. | [optional] | + + + diff --git a/docs/RbmCardContent.md b/docs/RbmCardContent.md new file mode 100644 index 00000000..46414305 --- /dev/null +++ b/docs/RbmCardContent.md @@ -0,0 +1,16 @@ + + +# RbmCardContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**title** | **String** | The title of the card. Must be 200 characters or less. | [optional] | +|**description** | **String** | The description of the card. Must be 2000 characters or less. | [optional] | +|**media** | [**RbmCardContentMedia**](RbmCardContentMedia.md) | | [optional] | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient that will be displayed on the rich card. | [optional] | + + + diff --git a/docs/RbmCardContentMedia.md b/docs/RbmCardContentMedia.md new file mode 100644 index 00000000..6ca87afb --- /dev/null +++ b/docs/RbmCardContentMedia.md @@ -0,0 +1,14 @@ + + +# RbmCardContentMedia + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**height** | **RbmMediaHeightEnum** | | | +|**_file** | [**RbmMessageContentFile**](RbmMessageContentFile.md) | | | + + + diff --git a/docs/RbmMediaHeightEnum.md b/docs/RbmMediaHeightEnum.md new file mode 100644 index 00000000..e4031168 --- /dev/null +++ b/docs/RbmMediaHeightEnum.md @@ -0,0 +1,15 @@ + + +# RbmMediaHeightEnum + +## Enum + + +* `SHORT` (value: `"SHORT"`) + +* `MEDIUM` (value: `"MEDIUM"`) + +* `TALL` (value: `"TALL"`) + + + diff --git a/docs/RbmMessageCarouselCard.md b/docs/RbmMessageCarouselCard.md new file mode 100644 index 00000000..9d1d3304 --- /dev/null +++ b/docs/RbmMessageCarouselCard.md @@ -0,0 +1,15 @@ + + +# RbmMessageCarouselCard + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cardWidth** | **CardWidthEnum** | | | +|**cardContents** | [**List<RbmCardContent>**](RbmCardContent.md) | | | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] | + + + diff --git a/docs/RbmMessageContentFile.md b/docs/RbmMessageContentFile.md new file mode 100644 index 00000000..e862ff10 --- /dev/null +++ b/docs/RbmMessageContentFile.md @@ -0,0 +1,14 @@ + + +# RbmMessageContentFile + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**fileUrl** | **URI** | The URL of the media file. 100MB is the maximum file size. | | +|**thumbnailUrl** | **URI** | The URL of the thumbnail image. Applies only to video file media. | [optional] | + + + diff --git a/docs/RbmMessageContentRichCard.md b/docs/RbmMessageContentRichCard.md new file mode 100644 index 00000000..52551728 --- /dev/null +++ b/docs/RbmMessageContentRichCard.md @@ -0,0 +1,18 @@ + + +# RbmMessageContentRichCard + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**orientation** | **StandaloneCardOrientationEnum** | | | +|**thumbnailImageAlignment** | **ThumbnailAlignmentEnum** | | | +|**cardContent** | [**RbmCardContent**](RbmCardContent.md) | | | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] | +|**cardWidth** | **CardWidthEnum** | | | +|**cardContents** | [**List<RbmCardContent>**](RbmCardContent.md) | | | + + + diff --git a/docs/RbmMessageContentText.md b/docs/RbmMessageContentText.md new file mode 100644 index 00000000..5af25904 --- /dev/null +++ b/docs/RbmMessageContentText.md @@ -0,0 +1,14 @@ + + +# RbmMessageContentText + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**text** | **String** | The text associated with the message. Must be 3270 characters or less | | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] | + + + diff --git a/docs/RbmMessageMedia.md b/docs/RbmMessageMedia.md new file mode 100644 index 00000000..71abb236 --- /dev/null +++ b/docs/RbmMessageMedia.md @@ -0,0 +1,14 @@ + + +# RbmMessageMedia + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**media** | [**RbmMessageContentFile**](RbmMessageContentFile.md) | | | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] | + + + diff --git a/docs/RbmStandaloneCard.md b/docs/RbmStandaloneCard.md new file mode 100644 index 00000000..140aa93a --- /dev/null +++ b/docs/RbmStandaloneCard.md @@ -0,0 +1,16 @@ + + +# RbmStandaloneCard + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**orientation** | **StandaloneCardOrientationEnum** | | | +|**thumbnailImageAlignment** | **ThumbnailAlignmentEnum** | | | +|**cardContent** | [**RbmCardContent**](RbmCardContent.md) | | | +|**suggestions** | [**List<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] | + + + diff --git a/docs/SmsMessageContent.md b/docs/SmsMessageContent.md new file mode 100644 index 00000000..ebf1332f --- /dev/null +++ b/docs/SmsMessageContent.md @@ -0,0 +1,13 @@ + + +# SmsMessageContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**text** | **String** | The contents of the text message. Must be 2048 characters or less. | | + + + diff --git a/docs/StandaloneCardOrientationEnum.md b/docs/StandaloneCardOrientationEnum.md new file mode 100644 index 00000000..cd16f222 --- /dev/null +++ b/docs/StandaloneCardOrientationEnum.md @@ -0,0 +1,13 @@ + + +# StandaloneCardOrientationEnum + +## Enum + + +* `HORIZONTAL` (value: `"HORIZONTAL"`) + +* `VERTICAL` (value: `"VERTICAL"`) + + + diff --git a/docs/ThumbnailAlignmentEnum.md b/docs/ThumbnailAlignmentEnum.md new file mode 100644 index 00000000..636755cf --- /dev/null +++ b/docs/ThumbnailAlignmentEnum.md @@ -0,0 +1,13 @@ + + +# ThumbnailAlignmentEnum + +## Enum + + +* `LEFT` (value: `"LEFT"`) + +* `RIGHT` (value: `"RIGHT"`) + + + diff --git a/src/main/java/com/bandwidth/sdk/JSON.java b/src/main/java/com/bandwidth/sdk/JSON.java index e34980af..8991b626 100644 --- a/src/main/java/com/bandwidth/sdk/JSON.java +++ b/src/main/java/com/bandwidth/sdk/JSON.java @@ -58,6 +58,26 @@ public class JSON { @SuppressWarnings("unchecked") public static GsonBuilder createGson() { GsonFireBuilder fireBuilder = new GsonFireBuilder() + .registerTypeSelector(com.bandwidth.sdk.model.MultiChannelAction.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("CREATE_CALENDAR_EVENT", com.bandwidth.sdk.model.MultiChannelActionCalendarEvent.class); + classByDiscriminatorValue.put("DIAL_PHONE", com.bandwidth.sdk.model.RbmActionDial.class); + classByDiscriminatorValue.put("OPEN_URL", com.bandwidth.sdk.model.RbmActionOpenUrl.class); + classByDiscriminatorValue.put("REPLY", com.bandwidth.sdk.model.RbmActionBase.class); + classByDiscriminatorValue.put("REQUEST_LOCATION", com.bandwidth.sdk.model.RbmActionBase.class); + classByDiscriminatorValue.put("SHOW_LOCATION", com.bandwidth.sdk.model.RbmActionViewLocation.class); + classByDiscriminatorValue.put("multiChannelActionCalendarEvent", com.bandwidth.sdk.model.MultiChannelActionCalendarEvent.class); + classByDiscriminatorValue.put("rbmActionBase", com.bandwidth.sdk.model.RbmActionBase.class); + classByDiscriminatorValue.put("rbmActionDial", com.bandwidth.sdk.model.RbmActionDial.class); + classByDiscriminatorValue.put("rbmActionOpenUrl", com.bandwidth.sdk.model.RbmActionOpenUrl.class); + classByDiscriminatorValue.put("rbmActionViewLocation", com.bandwidth.sdk.model.RbmActionViewLocation.class); + classByDiscriminatorValue.put("multiChannelAction", com.bandwidth.sdk.model.MultiChannelAction.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "type")); + } + }) ; GsonBuilder builder = fireBuilder.createGsonBuilder(); return builder; @@ -119,15 +139,18 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateCallResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateLookupResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateMessageRequestError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateMultiChannelMessageResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.DeferredResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.DisconnectCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Diversion.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.DtmfCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Error.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ErrorObject.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.FailureWebhook.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.FieldError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.GatherCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.InitiateCallback.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Link.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.LinksObject.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ListMessageItem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.LookupRequest.CustomTypeAdapterFactory()); @@ -147,15 +170,36 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MfaForbiddenRequestError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MfaRequestError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MfaUnauthorizedRequestError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MmsMessageContent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelAction.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelActionCalendarEvent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelCallbackData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListObjectContent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageCallbackData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.OptInWorkflow.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.PageInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmActionBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmActionDial.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmActionOpenUrl.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmActionViewLocation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmCardContent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmCardContentMedia.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmMessageCarouselCard.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmMessageContentFile.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmMessageContentRichCard.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmMessageContentText.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmMessageMedia.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmStandaloneCard.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RecordingAvailableCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RecordingCompleteCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RecordingTranscriptionMetadata.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RecordingTranscriptions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RedirectCallback.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.SmsMessageContent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.StirShaken.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Tag.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.TelephoneNumber.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.TfvBasicAuthentication.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.TfvError.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/bandwidth/sdk/api/MultiChannelApi.java b/src/main/java/com/bandwidth/sdk/api/MultiChannelApi.java new file mode 100644 index 00000000..cfc0c59e --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/api/MultiChannelApi.java @@ -0,0 +1,247 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.api; + +import com.bandwidth.sdk.ApiCallback; +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.ApiResponse; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.Pair; +import com.bandwidth.sdk.ProgressRequestBody; +import com.bandwidth.sdk.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.bandwidth.sdk.model.CreateMessageRequestError; +import com.bandwidth.sdk.model.CreateMultiChannelMessageResponse; +import com.bandwidth.sdk.model.MessagingRequestError; +import com.bandwidth.sdk.model.MultiChannelMessageRequest; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MultiChannelApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public MultiChannelApi() { + this(Configuration.getDefaultApiClient()); + } + + public MultiChannelApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createMultiChannelMessage + * @param accountId Your Bandwidth Account ID. (required) + * @param multiChannelMessageRequest (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -
+ */ + public okhttp3.Call createMultiChannelMessageCall(String accountId, MultiChannelMessageRequest multiChannelMessageRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://messaging.bandwidth.com/api/v2" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = multiChannelMessageRequest; + + // create path and map variables + String localVarPath = "/users/{accountId}/messages/multiChannel" + .replace("{" + "accountId" + "}", localVarApiClient.escapeString(accountId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Basic" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createMultiChannelMessageValidateBeforeCall(String accountId, MultiChannelMessageRequest multiChannelMessageRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException("Missing the required parameter 'accountId' when calling createMultiChannelMessage(Async)"); + } + + // verify the required parameter 'multiChannelMessageRequest' is set + if (multiChannelMessageRequest == null) { + throw new ApiException("Missing the required parameter 'multiChannelMessageRequest' when calling createMultiChannelMessage(Async)"); + } + + return createMultiChannelMessageCall(accountId, multiChannelMessageRequest, _callback); + + } + + /** + * Create Multi-Channel Message + * Endpoint for sending Multi-Channel messages. + * @param accountId Your Bandwidth Account ID. (required) + * @param multiChannelMessageRequest (required) + * @return CreateMultiChannelMessageResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -
+ */ + public CreateMultiChannelMessageResponse createMultiChannelMessage(String accountId, MultiChannelMessageRequest multiChannelMessageRequest) throws ApiException { + ApiResponse localVarResp = createMultiChannelMessageWithHttpInfo(accountId, multiChannelMessageRequest); + return localVarResp.getData(); + } + + /** + * Create Multi-Channel Message + * Endpoint for sending Multi-Channel messages. + * @param accountId Your Bandwidth Account ID. (required) + * @param multiChannelMessageRequest (required) + * @return ApiResponse<CreateMultiChannelMessageResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -
+ */ + public ApiResponse createMultiChannelMessageWithHttpInfo(String accountId, MultiChannelMessageRequest multiChannelMessageRequest) throws ApiException { + okhttp3.Call localVarCall = createMultiChannelMessageValidateBeforeCall(accountId, multiChannelMessageRequest, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Multi-Channel Message (asynchronously) + * Endpoint for sending Multi-Channel messages. + * @param accountId Your Bandwidth Account ID. (required) + * @param multiChannelMessageRequest (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
202 Accepted -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
406 Not Acceptable -
415 Unsupported Media Type -
429 Too Many Requests -
500 Internal Server Error -
+ */ + public okhttp3.Call createMultiChannelMessageAsync(String accountId, MultiChannelMessageRequest multiChannelMessageRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createMultiChannelMessageValidateBeforeCall(accountId, multiChannelMessageRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/bandwidth/sdk/model/CardWidthEnum.java b/src/main/java/com/bandwidth/sdk/model/CardWidthEnum.java new file mode 100644 index 00000000..760212bf --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/CardWidthEnum.java @@ -0,0 +1,78 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets cardWidthEnum + */ +@JsonAdapter(CardWidthEnum.Adapter.class) +public enum CardWidthEnum { + + SMALL("SMALL"), + + MEDIUM("MEDIUM"); + + private String value; + + CardWidthEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CardWidthEnum fromValue(String value) { + for (CardWidthEnum b : CardWidthEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CardWidthEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CardWidthEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CardWidthEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + CardWidthEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/CreateMultiChannelMessageResponse.java b/src/main/java/com/bandwidth/sdk/model/CreateMultiChannelMessageResponse.java new file mode 100644 index 00000000..d8eaba08 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/CreateMultiChannelMessageResponse.java @@ -0,0 +1,391 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.ErrorObject; +import com.bandwidth.sdk.model.Link; +import com.bandwidth.sdk.model.MultiChannelMessageData; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * CreateMultiChannelMessageResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class CreateMultiChannelMessageResponse { + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + @javax.annotation.Nullable + private List links = new ArrayList<>(); + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nullable + private MultiChannelMessageData data; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nullable + private List errors = new ArrayList<>(); + + public CreateMultiChannelMessageResponse() { + } + + public CreateMultiChannelMessageResponse links(@javax.annotation.Nullable List links) { + this.links = links; + return this; + } + + public CreateMultiChannelMessageResponse addLinksItem(Link linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * @return links + */ + @javax.annotation.Nullable + public List getLinks() { + return links; + } + + public void setLinks(@javax.annotation.Nullable List links) { + this.links = links; + } + + + public CreateMultiChannelMessageResponse data(@javax.annotation.Nullable MultiChannelMessageData data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nullable + public MultiChannelMessageData getData() { + return data; + } + + public void setData(@javax.annotation.Nullable MultiChannelMessageData data) { + this.data = data; + } + + + public CreateMultiChannelMessageResponse errors(@javax.annotation.Nullable List errors) { + this.errors = errors; + return this; + } + + public CreateMultiChannelMessageResponse addErrorsItem(ErrorObject errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nullable List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateMultiChannelMessageResponse instance itself + */ + public CreateMultiChannelMessageResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateMultiChannelMessageResponse createMultiChannelMessageResponse = (CreateMultiChannelMessageResponse) o; + return Objects.equals(this.links, createMultiChannelMessageResponse.links) && + Objects.equals(this.data, createMultiChannelMessageResponse.data) && + Objects.equals(this.errors, createMultiChannelMessageResponse.errors)&& + Objects.equals(this.additionalProperties, createMultiChannelMessageResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(links, data, errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateMultiChannelMessageResponse {\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("links"); + openapiFields.add("data"); + openapiFields.add("errors"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateMultiChannelMessageResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateMultiChannelMessageResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateMultiChannelMessageResponse is not found in the empty JSON string", CreateMultiChannelMessageResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull()) { + JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); + if (jsonArraylinks != null) { + // ensure the json data is an array + if (!jsonObj.get("links").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString())); + } + + // validate the optional field `links` (array) + for (int i = 0; i < jsonArraylinks.size(); i++) { + Link.validateJsonElement(jsonArraylinks.get(i)); + }; + } + } + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + MultiChannelMessageData.validateJsonElement(jsonObj.get("data")); + } + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + ErrorObject.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateMultiChannelMessageResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateMultiChannelMessageResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateMultiChannelMessageResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateMultiChannelMessageResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateMultiChannelMessageResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateMultiChannelMessageResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateMultiChannelMessageResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateMultiChannelMessageResponse + * @throws IOException if the JSON string is invalid with respect to CreateMultiChannelMessageResponse + */ + public static CreateMultiChannelMessageResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateMultiChannelMessageResponse.class); + } + + /** + * Convert an instance of CreateMultiChannelMessageResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/ErrorObject.java b/src/main/java/com/bandwidth/sdk/model/ErrorObject.java new file mode 100644 index 00000000..31d3271e --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/ErrorObject.java @@ -0,0 +1,317 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * ErrorObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class ErrorObject { + public static final String SERIALIZED_NAME_CODE = "code"; + @SerializedName(SERIALIZED_NAME_CODE) + @javax.annotation.Nullable + private String code; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable + private String message; + + public ErrorObject() { + } + + public ErrorObject code(@javax.annotation.Nullable String code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + public String getCode() { + return code; + } + + public void setCode(@javax.annotation.Nullable String code) { + this.code = code; + } + + + public ErrorObject message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ErrorObject instance itself + */ + public ErrorObject putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorObject errorObject = (ErrorObject) o; + return Objects.equals(this.code, errorObject.code) && + Objects.equals(this.message, errorObject.message)&& + Objects.equals(this.additionalProperties, errorObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorObject {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("code"); + openapiFields.add("message"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ErrorObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ErrorObject is not found in the empty JSON string", ErrorObject.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) && !jsonObj.get("code").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorObject value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ErrorObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorObject instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ErrorObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorObject + * @throws IOException if the JSON string is invalid with respect to ErrorObject + */ + public static ErrorObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorObject.class); + } + + /** + * Convert an instance of ErrorObject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Link.java b/src/main/java/com/bandwidth/sdk/model/Link.java new file mode 100644 index 00000000..fa027d22 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Link.java @@ -0,0 +1,317 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * Link + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class Link { + public static final String SERIALIZED_NAME_REL = "rel"; + @SerializedName(SERIALIZED_NAME_REL) + @javax.annotation.Nullable + private String rel; + + public static final String SERIALIZED_NAME_HREF = "href"; + @SerializedName(SERIALIZED_NAME_HREF) + @javax.annotation.Nullable + private String href; + + public Link() { + } + + public Link rel(@javax.annotation.Nullable String rel) { + this.rel = rel; + return this; + } + + /** + * Get rel + * @return rel + */ + @javax.annotation.Nullable + public String getRel() { + return rel; + } + + public void setRel(@javax.annotation.Nullable String rel) { + this.rel = rel; + } + + + public Link href(@javax.annotation.Nullable String href) { + this.href = href; + return this; + } + + /** + * Get href + * @return href + */ + @javax.annotation.Nullable + public String getHref() { + return href; + } + + public void setHref(@javax.annotation.Nullable String href) { + this.href = href; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Link instance itself + */ + public Link putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Link link = (Link) o; + return Objects.equals(this.rel, link.rel) && + Objects.equals(this.href, link.href)&& + Objects.equals(this.additionalProperties, link.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Link {\n"); + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("rel"); + openapiFields.add("href"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Link + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Link.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Link is not found in the empty JSON string", Link.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("rel") != null && !jsonObj.get("rel").isJsonNull()) && !jsonObj.get("rel").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `rel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rel").toString())); + } + if ((jsonObj.get("href") != null && !jsonObj.get("href").isJsonNull()) && !jsonObj.get("href").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `href` to be a primitive type in the JSON string but got `%s`", jsonObj.get("href").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Link.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Link' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Link.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Link value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Link read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Link instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Link given an JSON string + * + * @param jsonString JSON string + * @return An instance of Link + * @throws IOException if the JSON string is invalid with respect to Link + */ + public static Link fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Link.class); + } + + /** + * Convert an instance of Link to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Message.java b/src/main/java/com/bandwidth/sdk/model/Message.java index 4e2bde24..6f31b41f 100644 --- a/src/main/java/com/bandwidth/sdk/model/Message.java +++ b/src/main/java/com/bandwidth/sdk/model/Message.java @@ -373,7 +373,7 @@ public Message expiration(@javax.annotation.Nullable OffsetDateTime expiration) } /** - * The expiration date-time set by the user. + * 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. * @return expiration */ @javax.annotation.Nullable diff --git a/src/main/java/com/bandwidth/sdk/model/MessageRequest.java b/src/main/java/com/bandwidth/sdk/model/MessageRequest.java index 3859eed6..3bdddf49 100644 --- a/src/main/java/com/bandwidth/sdk/model/MessageRequest.java +++ b/src/main/java/com/bandwidth/sdk/model/MessageRequest.java @@ -255,7 +255,7 @@ public MessageRequest expiration(@javax.annotation.Nullable OffsetDateTime expir } /** - * 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. Not supported on MMS. + * 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. * @return expiration */ @javax.annotation.Nullable diff --git a/src/main/java/com/bandwidth/sdk/model/MmsMessageContent.java b/src/main/java/com/bandwidth/sdk/model/MmsMessageContent.java new file mode 100644 index 00000000..75a7a2f9 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MmsMessageContent.java @@ -0,0 +1,329 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * MmsMessageContent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MmsMessageContent { + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nullable + private String text; + + public static final String SERIALIZED_NAME_MEDIA = "media"; + @SerializedName(SERIALIZED_NAME_MEDIA) + @javax.annotation.Nullable + private List media = new ArrayList<>(); + + public MmsMessageContent() { + } + + public MmsMessageContent text(@javax.annotation.Nullable String text) { + this.text = text; + return this; + } + + /** + * The contents of the text message. Must be 2048 characters or less. + * @return text + */ + @javax.annotation.Nullable + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nullable String text) { + this.text = text; + } + + + public MmsMessageContent media(@javax.annotation.Nullable List media) { + this.media = media; + return this; + } + + public MmsMessageContent addMediaItem(URI mediaItem) { + if (this.media == null) { + this.media = new ArrayList<>(); + } + this.media.add(mediaItem); + return this; + } + + /** + * A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters. + * @return media + */ + @javax.annotation.Nullable + public List getMedia() { + return media; + } + + public void setMedia(@javax.annotation.Nullable List media) { + this.media = media; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MmsMessageContent instance itself + */ + public MmsMessageContent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MmsMessageContent mmsMessageContent = (MmsMessageContent) o; + return Objects.equals(this.text, mmsMessageContent.text) && + Objects.equals(this.media, mmsMessageContent.media)&& + Objects.equals(this.additionalProperties, mmsMessageContent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(text, media, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MmsMessageContent {\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" media: ").append(toIndentedString(media)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("text"); + openapiFields.add("media"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MmsMessageContent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MmsMessageContent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MmsMessageContent is not found in the empty JSON string", MmsMessageContent.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("media") != null && !jsonObj.get("media").isJsonNull() && !jsonObj.get("media").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `media` to be an array in the JSON string but got `%s`", jsonObj.get("media").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MmsMessageContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MmsMessageContent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MmsMessageContent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MmsMessageContent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MmsMessageContent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MmsMessageContent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MmsMessageContent given an JSON string + * + * @param jsonString JSON string + * @return An instance of MmsMessageContent + * @throws IOException if the JSON string is invalid with respect to MmsMessageContent + */ + public static MmsMessageContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MmsMessageContent.class); + } + + /** + * Convert an instance of MmsMessageContent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java new file mode 100644 index 00000000..443e4e35 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java @@ -0,0 +1,413 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelActionCalendarEvent; +import com.bandwidth.sdk.model.RbmActionBase; +import com.bandwidth.sdk.model.RbmActionDial; +import com.bandwidth.sdk.model.RbmActionOpenUrl; +import com.bandwidth.sdk.model.RbmActionTypeEnum; +import com.bandwidth.sdk.model.RbmActionViewLocation; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.util.Arrays; + + + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; + +import com.bandwidth.sdk.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelAction extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(MultiChannelAction.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelAction.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelAction' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterRbmActionBase = gson.getDelegateAdapter(this, TypeToken.get(RbmActionBase.class)); + final TypeAdapter adapterRbmActionDial = gson.getDelegateAdapter(this, TypeToken.get(RbmActionDial.class)); + final TypeAdapter adapterRbmActionViewLocation = gson.getDelegateAdapter(this, TypeToken.get(RbmActionViewLocation.class)); + final TypeAdapter adapterMultiChannelActionCalendarEvent = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelActionCalendarEvent.class)); + final TypeAdapter adapterRbmActionOpenUrl = gson.getDelegateAdapter(this, TypeToken.get(RbmActionOpenUrl.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelAction value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `RbmActionBase` + if (value.getActualInstance() instanceof RbmActionBase) { + JsonElement element = adapterRbmActionBase.toJsonTree((RbmActionBase)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `RbmActionDial` + if (value.getActualInstance() instanceof RbmActionDial) { + JsonElement element = adapterRbmActionDial.toJsonTree((RbmActionDial)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `RbmActionViewLocation` + if (value.getActualInstance() instanceof RbmActionViewLocation) { + JsonElement element = adapterRbmActionViewLocation.toJsonTree((RbmActionViewLocation)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `MultiChannelActionCalendarEvent` + if (value.getActualInstance() instanceof MultiChannelActionCalendarEvent) { + JsonElement element = adapterMultiChannelActionCalendarEvent.toJsonTree((MultiChannelActionCalendarEvent)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `RbmActionOpenUrl` + if (value.getActualInstance() instanceof RbmActionOpenUrl) { + JsonElement element = adapterRbmActionOpenUrl.toJsonTree((RbmActionOpenUrl)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation"); + } + + @Override + public MultiChannelAction read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize RbmActionBase + try { + // validate the JSON object to see if any exception is thrown + RbmActionBase.validateJsonElement(jsonElement); + actualAdapter = adapterRbmActionBase; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmActionBase'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmActionBase failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmActionBase'", e); + } + // deserialize RbmActionDial + try { + // validate the JSON object to see if any exception is thrown + RbmActionDial.validateJsonElement(jsonElement); + actualAdapter = adapterRbmActionDial; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmActionDial'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmActionDial failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmActionDial'", e); + } + // deserialize RbmActionViewLocation + try { + // validate the JSON object to see if any exception is thrown + RbmActionViewLocation.validateJsonElement(jsonElement); + actualAdapter = adapterRbmActionViewLocation; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmActionViewLocation'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmActionViewLocation failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmActionViewLocation'", e); + } + // deserialize MultiChannelActionCalendarEvent + try { + // validate the JSON object to see if any exception is thrown + MultiChannelActionCalendarEvent.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelActionCalendarEvent; + match++; + log.log(Level.FINER, "Input data matches schema 'MultiChannelActionCalendarEvent'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for MultiChannelActionCalendarEvent failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelActionCalendarEvent'", e); + } + // deserialize RbmActionOpenUrl + try { + // validate the JSON object to see if any exception is thrown + RbmActionOpenUrl.validateJsonElement(jsonElement); + actualAdapter = adapterRbmActionOpenUrl; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmActionOpenUrl'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmActionOpenUrl failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmActionOpenUrl'", e); + } + + if (match == 1) { + MultiChannelAction ret = new MultiChannelAction(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for MultiChannelAction: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap>(); + + public MultiChannelAction() { + super("oneOf", Boolean.FALSE); + } + + public MultiChannelAction(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("RbmActionBase", RbmActionBase.class); + schemas.put("RbmActionDial", RbmActionDial.class); + schemas.put("RbmActionViewLocation", RbmActionViewLocation.class); + schemas.put("MultiChannelActionCalendarEvent", MultiChannelActionCalendarEvent.class); + schemas.put("RbmActionOpenUrl", RbmActionOpenUrl.class); + } + + @Override + public Map> getSchemas() { + return MultiChannelAction.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation + * + * It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof RbmActionBase) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RbmActionDial) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RbmActionViewLocation) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MultiChannelActionCalendarEvent) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RbmActionOpenUrl) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation"); + } + + /** + * Get the actual instance, which can be the following: + * MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation + * + * @return The actual instance (MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmActionBase`. If the actual instance is not `RbmActionBase`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmActionBase` + * @throws ClassCastException if the instance is not `RbmActionBase` + */ + public RbmActionBase getRbmActionBase() throws ClassCastException { + return (RbmActionBase)super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmActionDial`. If the actual instance is not `RbmActionDial`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmActionDial` + * @throws ClassCastException if the instance is not `RbmActionDial` + */ + public RbmActionDial getRbmActionDial() throws ClassCastException { + return (RbmActionDial)super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmActionViewLocation`. If the actual instance is not `RbmActionViewLocation`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmActionViewLocation` + * @throws ClassCastException if the instance is not `RbmActionViewLocation` + */ + public RbmActionViewLocation getRbmActionViewLocation() throws ClassCastException { + return (RbmActionViewLocation)super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelActionCalendarEvent`. If the actual instance is not `MultiChannelActionCalendarEvent`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelActionCalendarEvent` + * @throws ClassCastException if the instance is not `MultiChannelActionCalendarEvent` + */ + public MultiChannelActionCalendarEvent getMultiChannelActionCalendarEvent() throws ClassCastException { + return (MultiChannelActionCalendarEvent)super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmActionOpenUrl`. If the actual instance is not `RbmActionOpenUrl`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmActionOpenUrl` + * @throws ClassCastException if the instance is not `RbmActionOpenUrl` + */ + public RbmActionOpenUrl getRbmActionOpenUrl() throws ClassCastException { + return (RbmActionOpenUrl)super.getActualInstance(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelAction + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with RbmActionBase + try { + RbmActionBase.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmActionBase failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with RbmActionDial + try { + RbmActionDial.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmActionDial failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with RbmActionViewLocation + try { + RbmActionViewLocation.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmActionViewLocation failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with MultiChannelActionCalendarEvent + try { + MultiChannelActionCalendarEvent.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for MultiChannelActionCalendarEvent failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with RbmActionOpenUrl + try { + RbmActionOpenUrl.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmActionOpenUrl failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for MultiChannelAction with oneOf schemas: MultiChannelActionCalendarEvent, RbmActionBase, RbmActionDial, RbmActionOpenUrl, RbmActionViewLocation. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + } + } + + /** + * Create an instance of MultiChannelAction given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelAction + * @throws IOException if the JSON string is invalid with respect to MultiChannelAction + */ + public static MultiChannelAction fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelAction.class); + } + + /** + * Convert an instance of MultiChannelAction to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelActionCalendarEvent.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelActionCalendarEvent.java new file mode 100644 index 00000000..776b958e --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelActionCalendarEvent.java @@ -0,0 +1,472 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.RbmActionTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelActionCalendarEvent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelActionCalendarEvent { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private RbmActionTypeEnum type; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public static final String SERIALIZED_NAME_POST_BACK_DATA = "postBackData"; + @SerializedName(SERIALIZED_NAME_POST_BACK_DATA) + @javax.annotation.Nonnull + private byte[] postBackData; + + public static final String SERIALIZED_NAME_TITLE = "title"; + @SerializedName(SERIALIZED_NAME_TITLE) + @javax.annotation.Nonnull + private String title; + + public static final String SERIALIZED_NAME_START_TIME = "startTime"; + @SerializedName(SERIALIZED_NAME_START_TIME) + @javax.annotation.Nonnull + private OffsetDateTime startTime; + + public static final String SERIALIZED_NAME_END_TIME = "endTime"; + @SerializedName(SERIALIZED_NAME_END_TIME) + @javax.annotation.Nonnull + private OffsetDateTime endTime; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable + private String description; + + public MultiChannelActionCalendarEvent() { + } + + public MultiChannelActionCalendarEvent type(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public RbmActionTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + } + + + public MultiChannelActionCalendarEvent text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * Displayed text for user to click + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + + public MultiChannelActionCalendarEvent postBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + return this; + } + + /** + * Base64 payload the customer receives when the reply is clicked. + * @return postBackData + */ + @javax.annotation.Nonnull + public byte[] getPostBackData() { + return postBackData; + } + + public void setPostBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + } + + + public MultiChannelActionCalendarEvent title(@javax.annotation.Nonnull String title) { + this.title = title; + return this; + } + + /** + * The title of the event. + * @return title + */ + @javax.annotation.Nonnull + public String getTitle() { + return title; + } + + public void setTitle(@javax.annotation.Nonnull String title) { + this.title = title; + } + + + public MultiChannelActionCalendarEvent startTime(@javax.annotation.Nonnull OffsetDateTime startTime) { + this.startTime = startTime; + return this; + } + + /** + * The start time of the event. + * @return startTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getStartTime() { + return startTime; + } + + public void setStartTime(@javax.annotation.Nonnull OffsetDateTime startTime) { + this.startTime = startTime; + } + + + public MultiChannelActionCalendarEvent endTime(@javax.annotation.Nonnull OffsetDateTime endTime) { + this.endTime = endTime; + return this; + } + + /** + * The end time of the event. + * @return endTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getEndTime() { + return endTime; + } + + public void setEndTime(@javax.annotation.Nonnull OffsetDateTime endTime) { + this.endTime = endTime; + } + + + public MultiChannelActionCalendarEvent description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * The description of the event. + * @return description + */ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MultiChannelActionCalendarEvent instance itself + */ + public MultiChannelActionCalendarEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultiChannelActionCalendarEvent multiChannelActionCalendarEvent = (MultiChannelActionCalendarEvent) o; + return Objects.equals(this.type, multiChannelActionCalendarEvent.type) && + Objects.equals(this.text, multiChannelActionCalendarEvent.text) && + Arrays.equals(this.postBackData, multiChannelActionCalendarEvent.postBackData) && + Objects.equals(this.title, multiChannelActionCalendarEvent.title) && + Objects.equals(this.startTime, multiChannelActionCalendarEvent.startTime) && + Objects.equals(this.endTime, multiChannelActionCalendarEvent.endTime) && + Objects.equals(this.description, multiChannelActionCalendarEvent.description)&& + Objects.equals(this.additionalProperties, multiChannelActionCalendarEvent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, text, Arrays.hashCode(postBackData), title, startTime, endTime, description, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelActionCalendarEvent {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" postBackData: ").append(toIndentedString(postBackData)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); + sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("text"); + openapiFields.add("postBackData"); + openapiFields.add("title"); + openapiFields.add("startTime"); + openapiFields.add("endTime"); + openapiFields.add("description"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("text"); + openapiRequiredFields.add("postBackData"); + openapiRequiredFields.add("title"); + openapiRequiredFields.add("startTime"); + openapiRequiredFields.add("endTime"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelActionCalendarEvent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelActionCalendarEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MultiChannelActionCalendarEvent is not found in the empty JSON string", MultiChannelActionCalendarEvent.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelActionCalendarEvent.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + RbmActionTypeEnum.validateJsonElement(jsonObj.get("type")); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + if (!jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelActionCalendarEvent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelActionCalendarEvent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelActionCalendarEvent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelActionCalendarEvent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MultiChannelActionCalendarEvent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelActionCalendarEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MultiChannelActionCalendarEvent given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelActionCalendarEvent + * @throws IOException if the JSON string is invalid with respect to MultiChannelActionCalendarEvent + */ + public static MultiChannelActionCalendarEvent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelActionCalendarEvent.class); + } + + /** + * Convert an instance of MultiChannelActionCalendarEvent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelCallbackData.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelCallbackData.java new file mode 100644 index 00000000..208dc46b --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelCallbackData.java @@ -0,0 +1,409 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelMessageCallbackData; +import com.bandwidth.sdk.model.MultiChannelStatusEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelCallbackData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelCallbackData { + public static final String SERIALIZED_NAME_TIME = "time"; + @SerializedName(SERIALIZED_NAME_TIME) + @javax.annotation.Nullable + private OffsetDateTime time; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nullable + private MultiChannelStatusEnum type; + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + @javax.annotation.Nullable + private String to; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable + private String description; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable + private MultiChannelMessageCallbackData message; + + public MultiChannelCallbackData() { + } + + public MultiChannelCallbackData time(@javax.annotation.Nullable OffsetDateTime time) { + this.time = time; + return this; + } + + /** + * The time of the callback event. + * @return time + */ + @javax.annotation.Nullable + public OffsetDateTime getTime() { + return time; + } + + public void setTime(@javax.annotation.Nullable OffsetDateTime time) { + this.time = time; + } + + + public MultiChannelCallbackData type(@javax.annotation.Nullable MultiChannelStatusEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + public MultiChannelStatusEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nullable MultiChannelStatusEnum type) { + this.type = type; + } + + + public MultiChannelCallbackData to(@javax.annotation.Nullable String to) { + this.to = to; + return this; + } + + /** + * The phone number the message should be sent to in E164 format. + * @return to + */ + @javax.annotation.Nullable + public String getTo() { + return to; + } + + public void setTo(@javax.annotation.Nullable String to) { + this.to = to; + } + + + public MultiChannelCallbackData description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + */ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + + public MultiChannelCallbackData message(@javax.annotation.Nullable MultiChannelMessageCallbackData message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + public MultiChannelMessageCallbackData getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable MultiChannelMessageCallbackData message) { + this.message = message; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MultiChannelCallbackData instance itself + */ + public MultiChannelCallbackData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultiChannelCallbackData multiChannelCallbackData = (MultiChannelCallbackData) o; + return Objects.equals(this.time, multiChannelCallbackData.time) && + Objects.equals(this.type, multiChannelCallbackData.type) && + Objects.equals(this.to, multiChannelCallbackData.to) && + Objects.equals(this.description, multiChannelCallbackData.description) && + Objects.equals(this.message, multiChannelCallbackData.message)&& + Objects.equals(this.additionalProperties, multiChannelCallbackData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(time, type, to, description, message, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelCallbackData {\n"); + sb.append(" time: ").append(toIndentedString(time)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("time"); + openapiFields.add("type"); + openapiFields.add("to"); + openapiFields.add("description"); + openapiFields.add("message"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelCallbackData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelCallbackData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MultiChannelCallbackData is not found in the empty JSON string", MultiChannelCallbackData.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `type` + if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) { + MultiChannelStatusEnum.validateJsonElement(jsonObj.get("type")); + } + if ((jsonObj.get("to") != null && !jsonObj.get("to").isJsonNull()) && !jsonObj.get("to").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("to").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + // validate the optional field `message` + if (jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) { + MultiChannelMessageCallbackData.validateJsonElement(jsonObj.get("message")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelCallbackData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelCallbackData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelCallbackData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelCallbackData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MultiChannelCallbackData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelCallbackData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MultiChannelCallbackData given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelCallbackData + * @throws IOException if the JSON string is invalid with respect to MultiChannelCallbackData + */ + public static MultiChannelCallbackData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelCallbackData.class); + } + + /** + * Convert an instance of MultiChannelCallbackData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObject.java new file mode 100644 index 00000000..61ef22fd --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObject.java @@ -0,0 +1,388 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; +import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelChannelListObject { + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + @javax.annotation.Nonnull + private String from; + + public static final String SERIALIZED_NAME_APPLICATION_ID = "applicationId"; + @SerializedName(SERIALIZED_NAME_APPLICATION_ID) + @javax.annotation.Nonnull + private String applicationId; + + public static final String SERIALIZED_NAME_CHANNEL = "channel"; + @SerializedName(SERIALIZED_NAME_CHANNEL) + @javax.annotation.Nonnull + private MultiChannelMessageChannelEnum channel; + + public static final String SERIALIZED_NAME_CONTENT = "content"; + @SerializedName(SERIALIZED_NAME_CONTENT) + @javax.annotation.Nonnull + private MultiChannelChannelListObjectContent content; + + public MultiChannelChannelListObject() { + } + + public MultiChannelChannelListObject from(@javax.annotation.Nonnull String from) { + this.from = from; + return this; + } + + /** + * The sender ID of the message. This could be an alphanumeric sender ID. + * @return from + */ + @javax.annotation.Nonnull + public String getFrom() { + return from; + } + + public void setFrom(@javax.annotation.Nonnull String from) { + this.from = from; + } + + + public MultiChannelChannelListObject applicationId(@javax.annotation.Nonnull String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + * @return applicationId + */ + @javax.annotation.Nonnull + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(@javax.annotation.Nonnull String applicationId) { + this.applicationId = applicationId; + } + + + public MultiChannelChannelListObject channel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum channel) { + this.channel = channel; + return this; + } + + /** + * Get channel + * @return channel + */ + @javax.annotation.Nonnull + public MultiChannelMessageChannelEnum getChannel() { + return channel; + } + + public void setChannel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum channel) { + this.channel = channel; + } + + + public MultiChannelChannelListObject content(@javax.annotation.Nonnull MultiChannelChannelListObjectContent content) { + this.content = content; + return this; + } + + /** + * Get content + * @return content + */ + @javax.annotation.Nonnull + public MultiChannelChannelListObjectContent getContent() { + return content; + } + + public void setContent(@javax.annotation.Nonnull MultiChannelChannelListObjectContent content) { + this.content = content; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MultiChannelChannelListObject instance itself + */ + public MultiChannelChannelListObject putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultiChannelChannelListObject multiChannelChannelListObject = (MultiChannelChannelListObject) o; + return Objects.equals(this.from, multiChannelChannelListObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListObject.channel) && + Objects.equals(this.content, multiChannelChannelListObject.content)&& + Objects.equals(this.additionalProperties, multiChannelChannelListObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, applicationId, channel, content, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListObject {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("from"); + openapiFields.add("applicationId"); + openapiFields.add("channel"); + openapiFields.add("content"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("from"); + openapiRequiredFields.add("applicationId"); + openapiRequiredFields.add("channel"); + openapiRequiredFields.add("content"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelChannelListObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MultiChannelChannelListObject is not found in the empty JSON string", MultiChannelChannelListObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + if (!jsonObj.get("applicationId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `applicationId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("applicationId").toString())); + } + // validate the required field `channel` + MultiChannelMessageChannelEnum.validateJsonElement(jsonObj.get("channel")); + // validate the required field `content` + MultiChannelChannelListObjectContent.validateJsonElement(jsonObj.get("content")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListObject value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MultiChannelChannelListObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListObject instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MultiChannelChannelListObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListObject + */ + public static MultiChannelChannelListObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListObject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java new file mode 100644 index 00000000..c7106409 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java @@ -0,0 +1,418 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.CardWidthEnum; +import com.bandwidth.sdk.model.MmsMessageContent; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.bandwidth.sdk.model.RbmCardContent; +import com.bandwidth.sdk.model.RbmMessageContentRichCard; +import com.bandwidth.sdk.model.RbmMessageContentText; +import com.bandwidth.sdk.model.RbmMessageMedia; +import com.bandwidth.sdk.model.SmsMessageContent; +import com.bandwidth.sdk.model.StandaloneCardOrientationEnum; +import com.bandwidth.sdk.model.ThumbnailAlignmentEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; + +import com.bandwidth.sdk.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelChannelListObjectContent extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(MultiChannelChannelListObjectContent.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListObjectContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListObjectContent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterRbmMessageContentText = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageContentText.class)); + final TypeAdapter adapterRbmMessageMedia = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageMedia.class)); + final TypeAdapter adapterRbmMessageContentRichCard = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageContentRichCard.class)); + final TypeAdapter adapterSmsMessageContent = gson.getDelegateAdapter(this, TypeToken.get(SmsMessageContent.class)); + final TypeAdapter adapterMmsMessageContent = gson.getDelegateAdapter(this, TypeToken.get(MmsMessageContent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListObjectContent value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `RbmMessageContentText` + if (value.getActualInstance() instanceof RbmMessageContentText) { + JsonElement element = adapterRbmMessageContentText.toJsonTree((RbmMessageContentText)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `RbmMessageMedia` + if (value.getActualInstance() instanceof RbmMessageMedia) { + JsonElement element = adapterRbmMessageMedia.toJsonTree((RbmMessageMedia)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `RbmMessageContentRichCard` + if (value.getActualInstance() instanceof RbmMessageContentRichCard) { + JsonElement element = adapterRbmMessageContentRichCard.toJsonTree((RbmMessageContentRichCard)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `SmsMessageContent` + if (value.getActualInstance() instanceof SmsMessageContent) { + JsonElement element = adapterSmsMessageContent.toJsonTree((SmsMessageContent)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `MmsMessageContent` + if (value.getActualInstance() instanceof MmsMessageContent) { + JsonElement element = adapterMmsMessageContent.toJsonTree((MmsMessageContent)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent"); + } + + @Override + public MultiChannelChannelListObjectContent read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize RbmMessageContentText + try { + // validate the JSON object to see if any exception is thrown + RbmMessageContentText.validateJsonElement(jsonElement); + actualAdapter = adapterRbmMessageContentText; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmMessageContentText'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmMessageContentText failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmMessageContentText'", e); + } + // deserialize RbmMessageMedia + try { + // validate the JSON object to see if any exception is thrown + RbmMessageMedia.validateJsonElement(jsonElement); + actualAdapter = adapterRbmMessageMedia; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmMessageMedia'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmMessageMedia failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmMessageMedia'", e); + } + // deserialize RbmMessageContentRichCard + try { + // validate the JSON object to see if any exception is thrown + RbmMessageContentRichCard.validateJsonElement(jsonElement); + actualAdapter = adapterRbmMessageContentRichCard; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmMessageContentRichCard'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmMessageContentRichCard failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmMessageContentRichCard'", e); + } + // deserialize SmsMessageContent + try { + // validate the JSON object to see if any exception is thrown + SmsMessageContent.validateJsonElement(jsonElement); + actualAdapter = adapterSmsMessageContent; + match++; + log.log(Level.FINER, "Input data matches schema 'SmsMessageContent'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for SmsMessageContent failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'SmsMessageContent'", e); + } + // deserialize MmsMessageContent + try { + // validate the JSON object to see if any exception is thrown + MmsMessageContent.validateJsonElement(jsonElement); + actualAdapter = adapterMmsMessageContent; + match++; + log.log(Level.FINER, "Input data matches schema 'MmsMessageContent'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for MmsMessageContent failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MmsMessageContent'", e); + } + + if (match == 1) { + MultiChannelChannelListObjectContent ret = new MultiChannelChannelListObjectContent(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for MultiChannelChannelListObjectContent: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap>(); + + public MultiChannelChannelListObjectContent() { + super("oneOf", Boolean.FALSE); + } + + public MultiChannelChannelListObjectContent(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("RbmMessageContentText", RbmMessageContentText.class); + schemas.put("RbmMessageMedia", RbmMessageMedia.class); + schemas.put("RbmMessageContentRichCard", RbmMessageContentRichCard.class); + schemas.put("SmsMessageContent", SmsMessageContent.class); + schemas.put("MmsMessageContent", MmsMessageContent.class); + } + + @Override + public Map> getSchemas() { + return MultiChannelChannelListObjectContent.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent + * + * It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof RbmMessageContentText) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RbmMessageMedia) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RbmMessageContentRichCard) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof SmsMessageContent) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MmsMessageContent) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent"); + } + + /** + * Get the actual instance, which can be the following: + * MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent + * + * @return The actual instance (MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmMessageContentText`. If the actual instance is not `RbmMessageContentText`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmMessageContentText` + * @throws ClassCastException if the instance is not `RbmMessageContentText` + */ + public RbmMessageContentText getRbmMessageContentText() throws ClassCastException { + return (RbmMessageContentText)super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmMessageMedia`. If the actual instance is not `RbmMessageMedia`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmMessageMedia` + * @throws ClassCastException if the instance is not `RbmMessageMedia` + */ + public RbmMessageMedia getRbmMessageMedia() throws ClassCastException { + return (RbmMessageMedia)super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmMessageContentRichCard`. If the actual instance is not `RbmMessageContentRichCard`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmMessageContentRichCard` + * @throws ClassCastException if the instance is not `RbmMessageContentRichCard` + */ + public RbmMessageContentRichCard getRbmMessageContentRichCard() throws ClassCastException { + return (RbmMessageContentRichCard)super.getActualInstance(); + } + + /** + * Get the actual instance of `SmsMessageContent`. If the actual instance is not `SmsMessageContent`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `SmsMessageContent` + * @throws ClassCastException if the instance is not `SmsMessageContent` + */ + public SmsMessageContent getSmsMessageContent() throws ClassCastException { + return (SmsMessageContent)super.getActualInstance(); + } + + /** + * Get the actual instance of `MmsMessageContent`. If the actual instance is not `MmsMessageContent`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MmsMessageContent` + * @throws ClassCastException if the instance is not `MmsMessageContent` + */ + public MmsMessageContent getMmsMessageContent() throws ClassCastException { + return (MmsMessageContent)super.getActualInstance(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelChannelListObjectContent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with RbmMessageContentText + try { + RbmMessageContentText.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmMessageContentText failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with RbmMessageMedia + try { + RbmMessageMedia.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmMessageMedia failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with RbmMessageContentRichCard + try { + RbmMessageContentRichCard.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmMessageContentRichCard failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with SmsMessageContent + try { + SmsMessageContent.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for SmsMessageContent failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with MmsMessageContent + try { + MmsMessageContent.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for MmsMessageContent failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for MultiChannelChannelListObjectContent with oneOf schemas: MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + } + } + + /** + * Create an instance of MultiChannelChannelListObjectContent given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListObjectContent + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListObjectContent + */ + public static MultiChannelChannelListObjectContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListObjectContent.class); + } + + /** + * Convert an instance of MultiChannelChannelListObjectContent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageCallbackData.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageCallbackData.java new file mode 100644 index 00000000..a0019733 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageCallbackData.java @@ -0,0 +1,503 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; +import com.bandwidth.sdk.model.MultiChannelMessageDirectionEnum; +import com.bandwidth.sdk.model.MultiChannelStatusEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelMessageCallbackData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelMessageCallbackData { + public static final String SERIALIZED_NAME_MESSAGE_ID = "messageId"; + @SerializedName(SERIALIZED_NAME_MESSAGE_ID) + @javax.annotation.Nullable + private String messageId; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable + private MultiChannelStatusEnum status; + + public static final String SERIALIZED_NAME_DIRECTION = "direction"; + @SerializedName(SERIALIZED_NAME_DIRECTION) + @javax.annotation.Nullable + private MultiChannelMessageDirectionEnum direction; + + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + @javax.annotation.Nullable + private String from; + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + @javax.annotation.Nullable + private String to; + + public static final String SERIALIZED_NAME_APPLICATION_ID = "applicationId"; + @SerializedName(SERIALIZED_NAME_APPLICATION_ID) + @javax.annotation.Nullable + private String applicationId; + + public static final String SERIALIZED_NAME_CHANNEL = "channel"; + @SerializedName(SERIALIZED_NAME_CHANNEL) + @javax.annotation.Nullable + private MultiChannelMessageChannelEnum channel; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public MultiChannelMessageCallbackData() { + } + + public MultiChannelMessageCallbackData messageId(@javax.annotation.Nullable String messageId) { + this.messageId = messageId; + return this; + } + + /** + * The ID of the message. + * @return messageId + */ + @javax.annotation.Nullable + public String getMessageId() { + return messageId; + } + + public void setMessageId(@javax.annotation.Nullable String messageId) { + this.messageId = messageId; + } + + + public MultiChannelMessageCallbackData status(@javax.annotation.Nullable MultiChannelStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nullable + public MultiChannelStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nullable MultiChannelStatusEnum status) { + this.status = status; + } + + + public MultiChannelMessageCallbackData direction(@javax.annotation.Nullable MultiChannelMessageDirectionEnum direction) { + this.direction = direction; + return this; + } + + /** + * Get direction + * @return direction + */ + @javax.annotation.Nullable + public MultiChannelMessageDirectionEnum getDirection() { + return direction; + } + + public void setDirection(@javax.annotation.Nullable MultiChannelMessageDirectionEnum direction) { + this.direction = direction; + } + + + public MultiChannelMessageCallbackData from(@javax.annotation.Nullable String from) { + this.from = from; + return this; + } + + /** + * The sender ID of the message. This could be an alphanumeric sender ID. + * @return from + */ + @javax.annotation.Nullable + public String getFrom() { + return from; + } + + public void setFrom(@javax.annotation.Nullable String from) { + this.from = from; + } + + + public MultiChannelMessageCallbackData to(@javax.annotation.Nullable String to) { + this.to = to; + return this; + } + + /** + * The phone number the message should be sent to in E164 format. + * @return to + */ + @javax.annotation.Nullable + public String getTo() { + return to; + } + + public void setTo(@javax.annotation.Nullable String to) { + this.to = to; + } + + + public MultiChannelMessageCallbackData applicationId(@javax.annotation.Nullable String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + * @return applicationId + */ + @javax.annotation.Nullable + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(@javax.annotation.Nullable String applicationId) { + this.applicationId = applicationId; + } + + + public MultiChannelMessageCallbackData channel(@javax.annotation.Nullable MultiChannelMessageChannelEnum channel) { + this.channel = channel; + return this; + } + + /** + * Get channel + * @return channel + */ + @javax.annotation.Nullable + public MultiChannelMessageChannelEnum getChannel() { + return channel; + } + + public void setChannel(@javax.annotation.Nullable MultiChannelMessageChannelEnum channel) { + this.channel = channel; + } + + + public MultiChannelMessageCallbackData tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A custom string that will be included in callback events of the message. Max 1024 characters. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MultiChannelMessageCallbackData instance itself + */ + public MultiChannelMessageCallbackData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultiChannelMessageCallbackData multiChannelMessageCallbackData = (MultiChannelMessageCallbackData) o; + return Objects.equals(this.messageId, multiChannelMessageCallbackData.messageId) && + Objects.equals(this.status, multiChannelMessageCallbackData.status) && + Objects.equals(this.direction, multiChannelMessageCallbackData.direction) && + Objects.equals(this.from, multiChannelMessageCallbackData.from) && + Objects.equals(this.to, multiChannelMessageCallbackData.to) && + Objects.equals(this.applicationId, multiChannelMessageCallbackData.applicationId) && + Objects.equals(this.channel, multiChannelMessageCallbackData.channel) && + Objects.equals(this.tag, multiChannelMessageCallbackData.tag)&& + Objects.equals(this.additionalProperties, multiChannelMessageCallbackData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(messageId, status, direction, from, to, applicationId, channel, tag, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelMessageCallbackData {\n"); + sb.append(" messageId: ").append(toIndentedString(messageId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("messageId"); + openapiFields.add("status"); + openapiFields.add("direction"); + openapiFields.add("from"); + openapiFields.add("to"); + openapiFields.add("applicationId"); + openapiFields.add("channel"); + openapiFields.add("tag"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelMessageCallbackData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelMessageCallbackData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MultiChannelMessageCallbackData is not found in the empty JSON string", MultiChannelMessageCallbackData.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("messageId") != null && !jsonObj.get("messageId").isJsonNull()) && !jsonObj.get("messageId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `messageId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("messageId").toString())); + } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + MultiChannelStatusEnum.validateJsonElement(jsonObj.get("status")); + } + // validate the optional field `direction` + if (jsonObj.get("direction") != null && !jsonObj.get("direction").isJsonNull()) { + MultiChannelMessageDirectionEnum.validateJsonElement(jsonObj.get("direction")); + } + if ((jsonObj.get("from") != null && !jsonObj.get("from").isJsonNull()) && !jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + if ((jsonObj.get("to") != null && !jsonObj.get("to").isJsonNull()) && !jsonObj.get("to").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("to").toString())); + } + if ((jsonObj.get("applicationId") != null && !jsonObj.get("applicationId").isJsonNull()) && !jsonObj.get("applicationId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `applicationId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("applicationId").toString())); + } + // validate the optional field `channel` + if (jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull()) { + MultiChannelMessageChannelEnum.validateJsonElement(jsonObj.get("channel")); + } + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelMessageCallbackData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelMessageCallbackData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelMessageCallbackData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelMessageCallbackData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MultiChannelMessageCallbackData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelMessageCallbackData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MultiChannelMessageCallbackData given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelMessageCallbackData + * @throws IOException if the JSON string is invalid with respect to MultiChannelMessageCallbackData + */ + public static MultiChannelMessageCallbackData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelMessageCallbackData.class); + } + + /** + * Convert an instance of MultiChannelMessageCallbackData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageChannelEnum.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageChannelEnum.java new file mode 100644 index 00000000..3f7546c8 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageChannelEnum.java @@ -0,0 +1,80 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * The channel of the multi-channel message. + */ +@JsonAdapter(MultiChannelMessageChannelEnum.Adapter.class) +public enum MultiChannelMessageChannelEnum { + + RBM("RBM"), + + SMS("SMS"), + + MMS("MMS"); + + private String value; + + MultiChannelMessageChannelEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MultiChannelMessageChannelEnum fromValue(String value) { + for (MultiChannelMessageChannelEnum b : MultiChannelMessageChannelEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MultiChannelMessageChannelEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MultiChannelMessageChannelEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return MultiChannelMessageChannelEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + MultiChannelMessageChannelEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageData.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageData.java new file mode 100644 index 00000000..02184db2 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageData.java @@ -0,0 +1,531 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; +import com.bandwidth.sdk.model.MultiChannelMessageDirectionEnum; +import com.bandwidth.sdk.model.MultiChannelStatusEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelMessageData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelMessageData { + public static final String SERIALIZED_NAME_MESSAGE_ID = "messageId"; + @SerializedName(SERIALIZED_NAME_MESSAGE_ID) + @javax.annotation.Nullable + private String messageId; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable + private MultiChannelStatusEnum status; + + public static final String SERIALIZED_NAME_TIME = "time"; + @SerializedName(SERIALIZED_NAME_TIME) + @javax.annotation.Nullable + private OffsetDateTime time; + + public static final String SERIALIZED_NAME_DIRECTION = "direction"; + @SerializedName(SERIALIZED_NAME_DIRECTION) + @javax.annotation.Nullable + private MultiChannelMessageDirectionEnum direction; + + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + @javax.annotation.Nullable + private String from; + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + @javax.annotation.Nullable + private String to; + + public static final String SERIALIZED_NAME_APPLICATION_ID = "applicationId"; + @SerializedName(SERIALIZED_NAME_APPLICATION_ID) + @javax.annotation.Nullable + private String applicationId; + + public static final String SERIALIZED_NAME_CHANNEL = "channel"; + @SerializedName(SERIALIZED_NAME_CHANNEL) + @javax.annotation.Nullable + private MultiChannelMessageChannelEnum channel; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public MultiChannelMessageData() { + } + + public MultiChannelMessageData messageId(@javax.annotation.Nullable String messageId) { + this.messageId = messageId; + return this; + } + + /** + * The ID of the message. + * @return messageId + */ + @javax.annotation.Nullable + public String getMessageId() { + return messageId; + } + + public void setMessageId(@javax.annotation.Nullable String messageId) { + this.messageId = messageId; + } + + + public MultiChannelMessageData status(@javax.annotation.Nullable MultiChannelStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nullable + public MultiChannelStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nullable MultiChannelStatusEnum status) { + this.status = status; + } + + + public MultiChannelMessageData time(@javax.annotation.Nullable OffsetDateTime time) { + this.time = time; + return this; + } + + /** + * The time the message was received by the Bandwidth API. + * @return time + */ + @javax.annotation.Nullable + public OffsetDateTime getTime() { + return time; + } + + public void setTime(@javax.annotation.Nullable OffsetDateTime time) { + this.time = time; + } + + + public MultiChannelMessageData direction(@javax.annotation.Nullable MultiChannelMessageDirectionEnum direction) { + this.direction = direction; + return this; + } + + /** + * Get direction + * @return direction + */ + @javax.annotation.Nullable + public MultiChannelMessageDirectionEnum getDirection() { + return direction; + } + + public void setDirection(@javax.annotation.Nullable MultiChannelMessageDirectionEnum direction) { + this.direction = direction; + } + + + public MultiChannelMessageData from(@javax.annotation.Nullable String from) { + this.from = from; + return this; + } + + /** + * The sender ID of the message. This could be an alphanumeric sender ID. + * @return from + */ + @javax.annotation.Nullable + public String getFrom() { + return from; + } + + public void setFrom(@javax.annotation.Nullable String from) { + this.from = from; + } + + + public MultiChannelMessageData to(@javax.annotation.Nullable String to) { + this.to = to; + return this; + } + + /** + * The phone number the message should be sent to in E164 format. + * @return to + */ + @javax.annotation.Nullable + public String getTo() { + return to; + } + + public void setTo(@javax.annotation.Nullable String to) { + this.to = to; + } + + + public MultiChannelMessageData applicationId(@javax.annotation.Nullable String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * The ID of the Application your from number or senderId is associated with in the Bandwidth Phone Number Dashboard. + * @return applicationId + */ + @javax.annotation.Nullable + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(@javax.annotation.Nullable String applicationId) { + this.applicationId = applicationId; + } + + + public MultiChannelMessageData channel(@javax.annotation.Nullable MultiChannelMessageChannelEnum channel) { + this.channel = channel; + return this; + } + + /** + * Get channel + * @return channel + */ + @javax.annotation.Nullable + public MultiChannelMessageChannelEnum getChannel() { + return channel; + } + + public void setChannel(@javax.annotation.Nullable MultiChannelMessageChannelEnum channel) { + this.channel = channel; + } + + + public MultiChannelMessageData tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A custom string that will be included in callback events of the message. Max 1024 characters. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MultiChannelMessageData instance itself + */ + public MultiChannelMessageData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultiChannelMessageData multiChannelMessageData = (MultiChannelMessageData) o; + return Objects.equals(this.messageId, multiChannelMessageData.messageId) && + Objects.equals(this.status, multiChannelMessageData.status) && + Objects.equals(this.time, multiChannelMessageData.time) && + Objects.equals(this.direction, multiChannelMessageData.direction) && + Objects.equals(this.from, multiChannelMessageData.from) && + Objects.equals(this.to, multiChannelMessageData.to) && + Objects.equals(this.applicationId, multiChannelMessageData.applicationId) && + Objects.equals(this.channel, multiChannelMessageData.channel) && + Objects.equals(this.tag, multiChannelMessageData.tag)&& + Objects.equals(this.additionalProperties, multiChannelMessageData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(messageId, status, time, direction, from, to, applicationId, channel, tag, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelMessageData {\n"); + sb.append(" messageId: ").append(toIndentedString(messageId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" time: ").append(toIndentedString(time)).append("\n"); + sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("messageId"); + openapiFields.add("status"); + openapiFields.add("time"); + openapiFields.add("direction"); + openapiFields.add("from"); + openapiFields.add("to"); + openapiFields.add("applicationId"); + openapiFields.add("channel"); + openapiFields.add("tag"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelMessageData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelMessageData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MultiChannelMessageData is not found in the empty JSON string", MultiChannelMessageData.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("messageId") != null && !jsonObj.get("messageId").isJsonNull()) && !jsonObj.get("messageId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `messageId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("messageId").toString())); + } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + MultiChannelStatusEnum.validateJsonElement(jsonObj.get("status")); + } + // validate the optional field `direction` + if (jsonObj.get("direction") != null && !jsonObj.get("direction").isJsonNull()) { + MultiChannelMessageDirectionEnum.validateJsonElement(jsonObj.get("direction")); + } + if ((jsonObj.get("from") != null && !jsonObj.get("from").isJsonNull()) && !jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + if ((jsonObj.get("to") != null && !jsonObj.get("to").isJsonNull()) && !jsonObj.get("to").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("to").toString())); + } + if ((jsonObj.get("applicationId") != null && !jsonObj.get("applicationId").isJsonNull()) && !jsonObj.get("applicationId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `applicationId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("applicationId").toString())); + } + // validate the optional field `channel` + if (jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull()) { + MultiChannelMessageChannelEnum.validateJsonElement(jsonObj.get("channel")); + } + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelMessageData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelMessageData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelMessageData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelMessageData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MultiChannelMessageData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelMessageData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MultiChannelMessageData given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelMessageData + * @throws IOException if the JSON string is invalid with respect to MultiChannelMessageData + */ + public static MultiChannelMessageData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelMessageData.class); + } + + /** + * Convert an instance of MultiChannelMessageData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageDirectionEnum.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageDirectionEnum.java new file mode 100644 index 00000000..f548e871 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageDirectionEnum.java @@ -0,0 +1,78 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets multiChannelMessageDirectionEnum + */ +@JsonAdapter(MultiChannelMessageDirectionEnum.Adapter.class) +public enum MultiChannelMessageDirectionEnum { + + INBOUND("INBOUND"), + + OUTBOUND("OUTBOUND"); + + private String value; + + MultiChannelMessageDirectionEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MultiChannelMessageDirectionEnum fromValue(String value) { + for (MultiChannelMessageDirectionEnum b : MultiChannelMessageDirectionEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MultiChannelMessageDirectionEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MultiChannelMessageDirectionEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return MultiChannelMessageDirectionEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + MultiChannelMessageDirectionEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java new file mode 100644 index 00000000..613211c8 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java @@ -0,0 +1,434 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelChannelListObject; +import com.bandwidth.sdk.model.PriorityEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * Multi-Channel Message Request + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class MultiChannelMessageRequest { + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + @javax.annotation.Nonnull + private String to; + + public static final String SERIALIZED_NAME_CHANNEL_LIST = "channelList"; + @SerializedName(SERIALIZED_NAME_CHANNEL_LIST) + @javax.annotation.Nonnull + private List channelList = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public static final String SERIALIZED_NAME_PRIORITY = "priority"; + @SerializedName(SERIALIZED_NAME_PRIORITY) + @javax.annotation.Nullable + private PriorityEnum priority; + + public static final String SERIALIZED_NAME_EXPIRATION = "expiration"; + @SerializedName(SERIALIZED_NAME_EXPIRATION) + @javax.annotation.Nullable + private OffsetDateTime expiration; + + public MultiChannelMessageRequest() { + } + + public MultiChannelMessageRequest to(@javax.annotation.Nonnull String to) { + this.to = to; + return this; + } + + /** + * The phone number the message should be sent to in E164 format. + * @return to + */ + @javax.annotation.Nonnull + public String getTo() { + return to; + } + + public void setTo(@javax.annotation.Nonnull String to) { + this.to = to; + } + + + public MultiChannelMessageRequest channelList(@javax.annotation.Nonnull List channelList) { + this.channelList = channelList; + return this; + } + + public MultiChannelMessageRequest addChannelListItem(MultiChannelChannelListObject channelListItem) { + if (this.channelList == null) { + this.channelList = new ArrayList<>(); + } + this.channelList.add(channelListItem); + return this; + } + + /** + * 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. + * @return channelList + */ + @javax.annotation.Nonnull + public List getChannelList() { + return channelList; + } + + public void setChannelList(@javax.annotation.Nonnull List channelList) { + this.channelList = channelList; + } + + + public MultiChannelMessageRequest tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A custom string that will be included in callback events of the message. Max 1024 characters. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + + public MultiChannelMessageRequest priority(@javax.annotation.Nullable PriorityEnum priority) { + this.priority = priority; + return this; + } + + /** + * Get priority + * @return priority + */ + @javax.annotation.Nullable + public PriorityEnum getPriority() { + return priority; + } + + public void setPriority(@javax.annotation.Nullable PriorityEnum priority) { + this.priority = priority; + } + + + public MultiChannelMessageRequest expiration(@javax.annotation.Nullable OffsetDateTime expiration) { + this.expiration = expiration; + return this; + } + + /** + * 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. + * @return expiration + */ + @javax.annotation.Nullable + public OffsetDateTime getExpiration() { + return expiration; + } + + public void setExpiration(@javax.annotation.Nullable OffsetDateTime expiration) { + this.expiration = expiration; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MultiChannelMessageRequest instance itself + */ + public MultiChannelMessageRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultiChannelMessageRequest multiChannelMessageRequest = (MultiChannelMessageRequest) o; + return Objects.equals(this.to, multiChannelMessageRequest.to) && + Objects.equals(this.channelList, multiChannelMessageRequest.channelList) && + Objects.equals(this.tag, multiChannelMessageRequest.tag) && + Objects.equals(this.priority, multiChannelMessageRequest.priority) && + Objects.equals(this.expiration, multiChannelMessageRequest.expiration)&& + Objects.equals(this.additionalProperties, multiChannelMessageRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(to, channelList, tag, priority, expiration, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelMessageRequest {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" channelList: ").append(toIndentedString(channelList)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" priority: ").append(toIndentedString(priority)).append("\n"); + sb.append(" expiration: ").append(toIndentedString(expiration)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("to"); + openapiFields.add("channelList"); + openapiFields.add("tag"); + openapiFields.add("priority"); + openapiFields.add("expiration"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("to"); + openapiRequiredFields.add("channelList"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MultiChannelMessageRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelMessageRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MultiChannelMessageRequest is not found in the empty JSON string", MultiChannelMessageRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelMessageRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("to").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("to").toString())); + } + // ensure the json data is an array + if (!jsonObj.get("channelList").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `channelList` to be an array in the JSON string but got `%s`", jsonObj.get("channelList").toString())); + } + + JsonArray jsonArraychannelList = jsonObj.getAsJsonArray("channelList"); + // validate the required field `channelList` (array) + for (int i = 0; i < jsonArraychannelList.size(); i++) { + MultiChannelChannelListObject.validateJsonElement(jsonArraychannelList.get(i)); + }; + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + // validate the optional field `priority` + if (jsonObj.get("priority") != null && !jsonObj.get("priority").isJsonNull()) { + PriorityEnum.validateJsonElement(jsonObj.get("priority")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelMessageRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelMessageRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelMessageRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelMessageRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MultiChannelMessageRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelMessageRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MultiChannelMessageRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelMessageRequest + * @throws IOException if the JSON string is invalid with respect to MultiChannelMessageRequest + */ + public static MultiChannelMessageRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelMessageRequest.class); + } + + /** + * Convert an instance of MultiChannelMessageRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelStatusEnum.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelStatusEnum.java new file mode 100644 index 00000000..8a4eda18 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelStatusEnum.java @@ -0,0 +1,82 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets multiChannelStatusEnum + */ +@JsonAdapter(MultiChannelStatusEnum.Adapter.class) +public enum MultiChannelStatusEnum { + + QUEUED("QUEUED"), + + SENDING("SENDING"), + + DELIVERED("DELIVERED"), + + FAILED("FAILED"); + + private String value; + + MultiChannelStatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MultiChannelStatusEnum fromValue(String value) { + for (MultiChannelStatusEnum b : MultiChannelStatusEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MultiChannelStatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MultiChannelStatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return MultiChannelStatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + MultiChannelStatusEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/PriorityEnum.java b/src/main/java/com/bandwidth/sdk/model/PriorityEnum.java index 75f872e1..64cf09ed 100644 --- a/src/main/java/com/bandwidth/sdk/model/PriorityEnum.java +++ b/src/main/java/com/bandwidth/sdk/model/PriorityEnum.java @@ -24,7 +24,7 @@ import com.google.gson.stream.JsonWriter; /** - * The priority specified by the user. Not supported on MMS. + * The priority specified by the user. */ @JsonAdapter(PriorityEnum.Adapter.class) public enum PriorityEnum { diff --git a/src/main/java/com/bandwidth/sdk/model/RbmActionBase.java b/src/main/java/com/bandwidth/sdk/model/RbmActionBase.java new file mode 100644 index 00000000..eb52d415 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmActionBase.java @@ -0,0 +1,354 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.RbmActionTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmActionBase + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmActionBase { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private RbmActionTypeEnum type; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public static final String SERIALIZED_NAME_POST_BACK_DATA = "postBackData"; + @SerializedName(SERIALIZED_NAME_POST_BACK_DATA) + @javax.annotation.Nonnull + private byte[] postBackData; + + public RbmActionBase() { + } + + public RbmActionBase type(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public RbmActionTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + } + + + public RbmActionBase text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * Displayed text for user to click + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + + public RbmActionBase postBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + return this; + } + + /** + * Base64 payload the customer receives when the reply is clicked. + * @return postBackData + */ + @javax.annotation.Nonnull + public byte[] getPostBackData() { + return postBackData; + } + + public void setPostBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmActionBase instance itself + */ + public RbmActionBase putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmActionBase rbmActionBase = (RbmActionBase) o; + return Objects.equals(this.type, rbmActionBase.type) && + Objects.equals(this.text, rbmActionBase.text) && + Arrays.equals(this.postBackData, rbmActionBase.postBackData)&& + Objects.equals(this.additionalProperties, rbmActionBase.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, text, Arrays.hashCode(postBackData), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmActionBase {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" postBackData: ").append(toIndentedString(postBackData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("text"); + openapiFields.add("postBackData"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("text"); + openapiRequiredFields.add("postBackData"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmActionBase + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmActionBase.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmActionBase is not found in the empty JSON string", RbmActionBase.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmActionBase.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + RbmActionTypeEnum.validateJsonElement(jsonObj.get("type")); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmActionBase.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmActionBase' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmActionBase.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmActionBase value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmActionBase read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmActionBase instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmActionBase given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmActionBase + * @throws IOException if the JSON string is invalid with respect to RbmActionBase + */ + public static RbmActionBase fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmActionBase.class); + } + + /** + * Convert an instance of RbmActionBase to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmActionDial.java b/src/main/java/com/bandwidth/sdk/model/RbmActionDial.java new file mode 100644 index 00000000..744191b4 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmActionDial.java @@ -0,0 +1,385 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.RbmActionTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmActionDial + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmActionDial { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private RbmActionTypeEnum type; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public static final String SERIALIZED_NAME_POST_BACK_DATA = "postBackData"; + @SerializedName(SERIALIZED_NAME_POST_BACK_DATA) + @javax.annotation.Nonnull + private byte[] postBackData; + + public static final String SERIALIZED_NAME_PHONE_NUMBER = "phoneNumber"; + @SerializedName(SERIALIZED_NAME_PHONE_NUMBER) + @javax.annotation.Nonnull + private String phoneNumber; + + public RbmActionDial() { + } + + public RbmActionDial type(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public RbmActionTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + } + + + public RbmActionDial text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * Displayed text for user to click + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + + public RbmActionDial postBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + return this; + } + + /** + * Base64 payload the customer receives when the reply is clicked. + * @return postBackData + */ + @javax.annotation.Nonnull + public byte[] getPostBackData() { + return postBackData; + } + + public void setPostBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + } + + + public RbmActionDial phoneNumber(@javax.annotation.Nonnull String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + /** + * The phone number to dial. Must be E164 format. + * @return phoneNumber + */ + @javax.annotation.Nonnull + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(@javax.annotation.Nonnull String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmActionDial instance itself + */ + public RbmActionDial putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmActionDial rbmActionDial = (RbmActionDial) o; + return Objects.equals(this.type, rbmActionDial.type) && + Objects.equals(this.text, rbmActionDial.text) && + Arrays.equals(this.postBackData, rbmActionDial.postBackData) && + Objects.equals(this.phoneNumber, rbmActionDial.phoneNumber)&& + Objects.equals(this.additionalProperties, rbmActionDial.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, text, Arrays.hashCode(postBackData), phoneNumber, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmActionDial {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" postBackData: ").append(toIndentedString(postBackData)).append("\n"); + sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("text"); + openapiFields.add("postBackData"); + openapiFields.add("phoneNumber"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("text"); + openapiRequiredFields.add("postBackData"); + openapiRequiredFields.add("phoneNumber"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmActionDial + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmActionDial.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmActionDial is not found in the empty JSON string", RbmActionDial.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmActionDial.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + RbmActionTypeEnum.validateJsonElement(jsonObj.get("type")); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + if (!jsonObj.get("phoneNumber").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `phoneNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phoneNumber").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmActionDial.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmActionDial' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmActionDial.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmActionDial value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmActionDial read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmActionDial instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmActionDial given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmActionDial + * @throws IOException if the JSON string is invalid with respect to RbmActionDial + */ + public static RbmActionDial fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmActionDial.class); + } + + /** + * Convert an instance of RbmActionDial to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmActionOpenUrl.java b/src/main/java/com/bandwidth/sdk/model/RbmActionOpenUrl.java new file mode 100644 index 00000000..72875e55 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmActionOpenUrl.java @@ -0,0 +1,386 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.RbmActionTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmActionOpenUrl + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmActionOpenUrl { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private RbmActionTypeEnum type; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public static final String SERIALIZED_NAME_POST_BACK_DATA = "postBackData"; + @SerializedName(SERIALIZED_NAME_POST_BACK_DATA) + @javax.annotation.Nonnull + private byte[] postBackData; + + public static final String SERIALIZED_NAME_URL = "url"; + @SerializedName(SERIALIZED_NAME_URL) + @javax.annotation.Nonnull + private URI url; + + public RbmActionOpenUrl() { + } + + public RbmActionOpenUrl type(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public RbmActionTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + } + + + public RbmActionOpenUrl text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * Displayed text for user to click + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + + public RbmActionOpenUrl postBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + return this; + } + + /** + * Base64 payload the customer receives when the reply is clicked. + * @return postBackData + */ + @javax.annotation.Nonnull + public byte[] getPostBackData() { + return postBackData; + } + + public void setPostBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + } + + + public RbmActionOpenUrl url(@javax.annotation.Nonnull URI url) { + this.url = url; + return this; + } + + /** + * The URL to open in browser. + * @return url + */ + @javax.annotation.Nonnull + public URI getUrl() { + return url; + } + + public void setUrl(@javax.annotation.Nonnull URI url) { + this.url = url; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmActionOpenUrl instance itself + */ + public RbmActionOpenUrl putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmActionOpenUrl rbmActionOpenUrl = (RbmActionOpenUrl) o; + return Objects.equals(this.type, rbmActionOpenUrl.type) && + Objects.equals(this.text, rbmActionOpenUrl.text) && + Arrays.equals(this.postBackData, rbmActionOpenUrl.postBackData) && + Objects.equals(this.url, rbmActionOpenUrl.url)&& + Objects.equals(this.additionalProperties, rbmActionOpenUrl.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, text, Arrays.hashCode(postBackData), url, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmActionOpenUrl {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" postBackData: ").append(toIndentedString(postBackData)).append("\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("text"); + openapiFields.add("postBackData"); + openapiFields.add("url"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("text"); + openapiRequiredFields.add("postBackData"); + openapiRequiredFields.add("url"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmActionOpenUrl + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmActionOpenUrl.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmActionOpenUrl is not found in the empty JSON string", RbmActionOpenUrl.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmActionOpenUrl.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + RbmActionTypeEnum.validateJsonElement(jsonObj.get("type")); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmActionOpenUrl.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmActionOpenUrl' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmActionOpenUrl.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmActionOpenUrl value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmActionOpenUrl read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmActionOpenUrl instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmActionOpenUrl given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmActionOpenUrl + * @throws IOException if the JSON string is invalid with respect to RbmActionOpenUrl + */ + public static RbmActionOpenUrl fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmActionOpenUrl.class); + } + + /** + * Convert an instance of RbmActionOpenUrl to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmActionTypeEnum.java b/src/main/java/com/bandwidth/sdk/model/RbmActionTypeEnum.java new file mode 100644 index 00000000..77d1054c --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmActionTypeEnum.java @@ -0,0 +1,86 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets rbmActionTypeEnum + */ +@JsonAdapter(RbmActionTypeEnum.Adapter.class) +public enum RbmActionTypeEnum { + + REPLY("REPLY"), + + DIAL_PHONE("DIAL_PHONE"), + + SHOW_LOCATION("SHOW_LOCATION"), + + CREATE_CALENDAR_EVENT("CREATE_CALENDAR_EVENT"), + + OPEN_URL("OPEN_URL"), + + REQUEST_LOCATION("REQUEST_LOCATION"); + + private String value; + + RbmActionTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RbmActionTypeEnum fromValue(String value) { + for (RbmActionTypeEnum b : RbmActionTypeEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final RbmActionTypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RbmActionTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return RbmActionTypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + RbmActionTypeEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmActionViewLocation.java b/src/main/java/com/bandwidth/sdk/model/RbmActionViewLocation.java new file mode 100644 index 00000000..fba28d2e --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmActionViewLocation.java @@ -0,0 +1,446 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.RbmActionTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmActionViewLocation + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmActionViewLocation { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private RbmActionTypeEnum type; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public static final String SERIALIZED_NAME_POST_BACK_DATA = "postBackData"; + @SerializedName(SERIALIZED_NAME_POST_BACK_DATA) + @javax.annotation.Nonnull + private byte[] postBackData; + + public static final String SERIALIZED_NAME_LATITUDE = "latitude"; + @SerializedName(SERIALIZED_NAME_LATITUDE) + @javax.annotation.Nonnull + private Double latitude; + + public static final String SERIALIZED_NAME_LONGITUDE = "longitude"; + @SerializedName(SERIALIZED_NAME_LONGITUDE) + @javax.annotation.Nonnull + private Double longitude; + + public static final String SERIALIZED_NAME_LABEL = "label"; + @SerializedName(SERIALIZED_NAME_LABEL) + @javax.annotation.Nullable + private String label; + + public RbmActionViewLocation() { + } + + public RbmActionViewLocation type(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public RbmActionTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull RbmActionTypeEnum type) { + this.type = type; + } + + + public RbmActionViewLocation text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * Displayed text for user to click + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + + public RbmActionViewLocation postBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + return this; + } + + /** + * Base64 payload the customer receives when the reply is clicked. + * @return postBackData + */ + @javax.annotation.Nonnull + public byte[] getPostBackData() { + return postBackData; + } + + public void setPostBackData(@javax.annotation.Nonnull byte[] postBackData) { + this.postBackData = postBackData; + } + + + public RbmActionViewLocation latitude(@javax.annotation.Nonnull Double latitude) { + this.latitude = latitude; + return this; + } + + /** + * The latitude of the location. + * @return latitude + */ + @javax.annotation.Nonnull + public Double getLatitude() { + return latitude; + } + + public void setLatitude(@javax.annotation.Nonnull Double latitude) { + this.latitude = latitude; + } + + + public RbmActionViewLocation longitude(@javax.annotation.Nonnull Double longitude) { + this.longitude = longitude; + return this; + } + + /** + * The longitude of the location. + * @return longitude + */ + @javax.annotation.Nonnull + public Double getLongitude() { + return longitude; + } + + public void setLongitude(@javax.annotation.Nonnull Double longitude) { + this.longitude = longitude; + } + + + public RbmActionViewLocation label(@javax.annotation.Nullable String label) { + this.label = label; + return this; + } + + /** + * The label of the location. + * @return label + */ + @javax.annotation.Nullable + public String getLabel() { + return label; + } + + public void setLabel(@javax.annotation.Nullable String label) { + this.label = label; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmActionViewLocation instance itself + */ + public RbmActionViewLocation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmActionViewLocation rbmActionViewLocation = (RbmActionViewLocation) o; + return Objects.equals(this.type, rbmActionViewLocation.type) && + Objects.equals(this.text, rbmActionViewLocation.text) && + Arrays.equals(this.postBackData, rbmActionViewLocation.postBackData) && + Objects.equals(this.latitude, rbmActionViewLocation.latitude) && + Objects.equals(this.longitude, rbmActionViewLocation.longitude) && + Objects.equals(this.label, rbmActionViewLocation.label)&& + Objects.equals(this.additionalProperties, rbmActionViewLocation.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, text, Arrays.hashCode(postBackData), latitude, longitude, label, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmActionViewLocation {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" postBackData: ").append(toIndentedString(postBackData)).append("\n"); + sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n"); + sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n"); + sb.append(" label: ").append(toIndentedString(label)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("text"); + openapiFields.add("postBackData"); + openapiFields.add("latitude"); + openapiFields.add("longitude"); + openapiFields.add("label"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("text"); + openapiRequiredFields.add("postBackData"); + openapiRequiredFields.add("latitude"); + openapiRequiredFields.add("longitude"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmActionViewLocation + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmActionViewLocation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmActionViewLocation is not found in the empty JSON string", RbmActionViewLocation.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmActionViewLocation.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + RbmActionTypeEnum.validateJsonElement(jsonObj.get("type")); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + if (!jsonObj.get("latitude").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `latitude` to be a primitive type in the JSON string but got `%s`", jsonObj.get("latitude").toString())); + } + if (!jsonObj.get("longitude").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `longitude` to be a primitive type in the JSON string but got `%s`", jsonObj.get("longitude").toString())); + } + if ((jsonObj.get("label") != null && !jsonObj.get("label").isJsonNull()) && !jsonObj.get("label").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `label` to be a primitive type in the JSON string but got `%s`", jsonObj.get("label").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmActionViewLocation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmActionViewLocation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmActionViewLocation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmActionViewLocation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmActionViewLocation read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmActionViewLocation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmActionViewLocation given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmActionViewLocation + * @throws IOException if the JSON string is invalid with respect to RbmActionViewLocation + */ + public static RbmActionViewLocation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmActionViewLocation.class); + } + + /** + * Convert an instance of RbmActionViewLocation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmCardContent.java b/src/main/java/com/bandwidth/sdk/model/RbmCardContent.java new file mode 100644 index 00000000..fda67bec --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmCardContent.java @@ -0,0 +1,401 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.bandwidth.sdk.model.RbmCardContentMedia; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmCardContent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmCardContent { + public static final String SERIALIZED_NAME_TITLE = "title"; + @SerializedName(SERIALIZED_NAME_TITLE) + @javax.annotation.Nullable + private String title; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable + private String description; + + public static final String SERIALIZED_NAME_MEDIA = "media"; + @SerializedName(SERIALIZED_NAME_MEDIA) + @javax.annotation.Nullable + private RbmCardContentMedia media; + + public static final String SERIALIZED_NAME_SUGGESTIONS = "suggestions"; + @SerializedName(SERIALIZED_NAME_SUGGESTIONS) + @javax.annotation.Nullable + private List suggestions = new ArrayList<>(); + + public RbmCardContent() { + } + + public RbmCardContent title(@javax.annotation.Nullable String title) { + this.title = title; + return this; + } + + /** + * The title of the card. Must be 200 characters or less. + * @return title + */ + @javax.annotation.Nullable + public String getTitle() { + return title; + } + + public void setTitle(@javax.annotation.Nullable String title) { + this.title = title; + } + + + public RbmCardContent description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * The description of the card. Must be 2000 characters or less. + * @return description + */ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + + public RbmCardContent media(@javax.annotation.Nullable RbmCardContentMedia media) { + this.media = media; + return this; + } + + /** + * Get media + * @return media + */ + @javax.annotation.Nullable + public RbmCardContentMedia getMedia() { + return media; + } + + public void setMedia(@javax.annotation.Nullable RbmCardContentMedia media) { + this.media = media; + } + + + public RbmCardContent suggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + return this; + } + + public RbmCardContent addSuggestionsItem(MultiChannelAction suggestionsItem) { + if (this.suggestions == null) { + this.suggestions = new ArrayList<>(); + } + this.suggestions.add(suggestionsItem); + return this; + } + + /** + * An array of suggested actions for the recipient that will be displayed on the rich card. + * @return suggestions + */ + @javax.annotation.Nullable + public List getSuggestions() { + return suggestions; + } + + public void setSuggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmCardContent instance itself + */ + public RbmCardContent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmCardContent rbmCardContent = (RbmCardContent) o; + return Objects.equals(this.title, rbmCardContent.title) && + Objects.equals(this.description, rbmCardContent.description) && + Objects.equals(this.media, rbmCardContent.media) && + Objects.equals(this.suggestions, rbmCardContent.suggestions)&& + Objects.equals(this.additionalProperties, rbmCardContent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(title, description, media, suggestions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmCardContent {\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" media: ").append(toIndentedString(media)).append("\n"); + sb.append(" suggestions: ").append(toIndentedString(suggestions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("title"); + openapiFields.add("description"); + openapiFields.add("media"); + openapiFields.add("suggestions"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmCardContent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmCardContent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmCardContent is not found in the empty JSON string", RbmCardContent.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + // validate the optional field `media` + if (jsonObj.get("media") != null && !jsonObj.get("media").isJsonNull()) { + RbmCardContentMedia.validateJsonElement(jsonObj.get("media")); + } + if (jsonObj.get("suggestions") != null && !jsonObj.get("suggestions").isJsonNull()) { + JsonArray jsonArraysuggestions = jsonObj.getAsJsonArray("suggestions"); + if (jsonArraysuggestions != null) { + // ensure the json data is an array + if (!jsonObj.get("suggestions").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `suggestions` to be an array in the JSON string but got `%s`", jsonObj.get("suggestions").toString())); + } + + // validate the optional field `suggestions` (array) + for (int i = 0; i < jsonArraysuggestions.size(); i++) { + MultiChannelAction.validateJsonElement(jsonArraysuggestions.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmCardContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmCardContent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmCardContent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmCardContent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmCardContent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmCardContent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmCardContent given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmCardContent + * @throws IOException if the JSON string is invalid with respect to RbmCardContent + */ + public static RbmCardContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmCardContent.class); + } + + /** + * Convert an instance of RbmCardContent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmCardContentMedia.java b/src/main/java/com/bandwidth/sdk/model/RbmCardContentMedia.java new file mode 100644 index 00000000..e0e010b0 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmCardContentMedia.java @@ -0,0 +1,326 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.RbmMediaHeightEnum; +import com.bandwidth.sdk.model.RbmMessageContentFile; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmCardContentMedia + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmCardContentMedia { + public static final String SERIALIZED_NAME_HEIGHT = "height"; + @SerializedName(SERIALIZED_NAME_HEIGHT) + @javax.annotation.Nonnull + private RbmMediaHeightEnum height; + + public static final String SERIALIZED_NAME_FILE = "file"; + @SerializedName(SERIALIZED_NAME_FILE) + @javax.annotation.Nonnull + private RbmMessageContentFile _file; + + public RbmCardContentMedia() { + } + + public RbmCardContentMedia height(@javax.annotation.Nonnull RbmMediaHeightEnum height) { + this.height = height; + return this; + } + + /** + * Get height + * @return height + */ + @javax.annotation.Nonnull + public RbmMediaHeightEnum getHeight() { + return height; + } + + public void setHeight(@javax.annotation.Nonnull RbmMediaHeightEnum height) { + this.height = height; + } + + + public RbmCardContentMedia _file(@javax.annotation.Nonnull RbmMessageContentFile _file) { + this._file = _file; + return this; + } + + /** + * Get _file + * @return _file + */ + @javax.annotation.Nonnull + public RbmMessageContentFile getFile() { + return _file; + } + + public void setFile(@javax.annotation.Nonnull RbmMessageContentFile _file) { + this._file = _file; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmCardContentMedia instance itself + */ + public RbmCardContentMedia putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmCardContentMedia rbmCardContentMedia = (RbmCardContentMedia) o; + return Objects.equals(this.height, rbmCardContentMedia.height) && + Objects.equals(this._file, rbmCardContentMedia._file)&& + Objects.equals(this.additionalProperties, rbmCardContentMedia.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(height, _file, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmCardContentMedia {\n"); + sb.append(" height: ").append(toIndentedString(height)).append("\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("height"); + openapiFields.add("file"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("height"); + openapiRequiredFields.add("file"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmCardContentMedia + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmCardContentMedia.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmCardContentMedia is not found in the empty JSON string", RbmCardContentMedia.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmCardContentMedia.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `height` + RbmMediaHeightEnum.validateJsonElement(jsonObj.get("height")); + // validate the required field `file` + RbmMessageContentFile.validateJsonElement(jsonObj.get("file")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmCardContentMedia.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmCardContentMedia' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmCardContentMedia.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmCardContentMedia value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmCardContentMedia read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmCardContentMedia instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmCardContentMedia given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmCardContentMedia + * @throws IOException if the JSON string is invalid with respect to RbmCardContentMedia + */ + public static RbmCardContentMedia fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmCardContentMedia.class); + } + + /** + * Convert an instance of RbmCardContentMedia to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmMediaHeightEnum.java b/src/main/java/com/bandwidth/sdk/model/RbmMediaHeightEnum.java new file mode 100644 index 00000000..c31e67a4 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmMediaHeightEnum.java @@ -0,0 +1,80 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * The height of the media. + */ +@JsonAdapter(RbmMediaHeightEnum.Adapter.class) +public enum RbmMediaHeightEnum { + + SHORT("SHORT"), + + MEDIUM("MEDIUM"), + + TALL("TALL"); + + private String value; + + RbmMediaHeightEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RbmMediaHeightEnum fromValue(String value) { + for (RbmMediaHeightEnum b : RbmMediaHeightEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final RbmMediaHeightEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RbmMediaHeightEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return RbmMediaHeightEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + RbmMediaHeightEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmMessageCarouselCard.java b/src/main/java/com/bandwidth/sdk/model/RbmMessageCarouselCard.java new file mode 100644 index 00000000..fea64c1c --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmMessageCarouselCard.java @@ -0,0 +1,394 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.CardWidthEnum; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.bandwidth.sdk.model.RbmCardContent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmMessageCarouselCard + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmMessageCarouselCard { + public static final String SERIALIZED_NAME_CARD_WIDTH = "cardWidth"; + @SerializedName(SERIALIZED_NAME_CARD_WIDTH) + @javax.annotation.Nonnull + private CardWidthEnum cardWidth; + + public static final String SERIALIZED_NAME_CARD_CONTENTS = "cardContents"; + @SerializedName(SERIALIZED_NAME_CARD_CONTENTS) + @javax.annotation.Nonnull + private List cardContents = new ArrayList<>(); + + public static final String SERIALIZED_NAME_SUGGESTIONS = "suggestions"; + @SerializedName(SERIALIZED_NAME_SUGGESTIONS) + @javax.annotation.Nullable + private List suggestions = new ArrayList<>(); + + public RbmMessageCarouselCard() { + } + + public RbmMessageCarouselCard cardWidth(@javax.annotation.Nonnull CardWidthEnum cardWidth) { + this.cardWidth = cardWidth; + return this; + } + + /** + * Get cardWidth + * @return cardWidth + */ + @javax.annotation.Nonnull + public CardWidthEnum getCardWidth() { + return cardWidth; + } + + public void setCardWidth(@javax.annotation.Nonnull CardWidthEnum cardWidth) { + this.cardWidth = cardWidth; + } + + + public RbmMessageCarouselCard cardContents(@javax.annotation.Nonnull List cardContents) { + this.cardContents = cardContents; + return this; + } + + public RbmMessageCarouselCard addCardContentsItem(RbmCardContent cardContentsItem) { + if (this.cardContents == null) { + this.cardContents = new ArrayList<>(); + } + this.cardContents.add(cardContentsItem); + return this; + } + + /** + * Get cardContents + * @return cardContents + */ + @javax.annotation.Nonnull + public List getCardContents() { + return cardContents; + } + + public void setCardContents(@javax.annotation.Nonnull List cardContents) { + this.cardContents = cardContents; + } + + + public RbmMessageCarouselCard suggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + return this; + } + + public RbmMessageCarouselCard addSuggestionsItem(MultiChannelAction suggestionsItem) { + if (this.suggestions == null) { + this.suggestions = new ArrayList<>(); + } + this.suggestions.add(suggestionsItem); + return this; + } + + /** + * An array of suggested actions for the recipient. + * @return suggestions + */ + @javax.annotation.Nullable + public List getSuggestions() { + return suggestions; + } + + public void setSuggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmMessageCarouselCard instance itself + */ + public RbmMessageCarouselCard putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmMessageCarouselCard rbmMessageCarouselCard = (RbmMessageCarouselCard) o; + return Objects.equals(this.cardWidth, rbmMessageCarouselCard.cardWidth) && + Objects.equals(this.cardContents, rbmMessageCarouselCard.cardContents) && + Objects.equals(this.suggestions, rbmMessageCarouselCard.suggestions)&& + Objects.equals(this.additionalProperties, rbmMessageCarouselCard.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(cardWidth, cardContents, suggestions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmMessageCarouselCard {\n"); + sb.append(" cardWidth: ").append(toIndentedString(cardWidth)).append("\n"); + sb.append(" cardContents: ").append(toIndentedString(cardContents)).append("\n"); + sb.append(" suggestions: ").append(toIndentedString(suggestions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("cardWidth"); + openapiFields.add("cardContents"); + openapiFields.add("suggestions"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("cardWidth"); + openapiRequiredFields.add("cardContents"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmMessageCarouselCard + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmMessageCarouselCard.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmMessageCarouselCard is not found in the empty JSON string", RbmMessageCarouselCard.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmMessageCarouselCard.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `cardWidth` + CardWidthEnum.validateJsonElement(jsonObj.get("cardWidth")); + // ensure the json data is an array + if (!jsonObj.get("cardContents").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `cardContents` to be an array in the JSON string but got `%s`", jsonObj.get("cardContents").toString())); + } + + JsonArray jsonArraycardContents = jsonObj.getAsJsonArray("cardContents"); + // validate the required field `cardContents` (array) + for (int i = 0; i < jsonArraycardContents.size(); i++) { + RbmCardContent.validateJsonElement(jsonArraycardContents.get(i)); + }; + if (jsonObj.get("suggestions") != null && !jsonObj.get("suggestions").isJsonNull()) { + JsonArray jsonArraysuggestions = jsonObj.getAsJsonArray("suggestions"); + if (jsonArraysuggestions != null) { + // ensure the json data is an array + if (!jsonObj.get("suggestions").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `suggestions` to be an array in the JSON string but got `%s`", jsonObj.get("suggestions").toString())); + } + + // validate the optional field `suggestions` (array) + for (int i = 0; i < jsonArraysuggestions.size(); i++) { + MultiChannelAction.validateJsonElement(jsonArraysuggestions.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmMessageCarouselCard.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmMessageCarouselCard' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageCarouselCard.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmMessageCarouselCard value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmMessageCarouselCard read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmMessageCarouselCard instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmMessageCarouselCard given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmMessageCarouselCard + * @throws IOException if the JSON string is invalid with respect to RbmMessageCarouselCard + */ + public static RbmMessageCarouselCard fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmMessageCarouselCard.class); + } + + /** + * Convert an instance of RbmMessageCarouselCard to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmMessageContentFile.java b/src/main/java/com/bandwidth/sdk/model/RbmMessageContentFile.java new file mode 100644 index 00000000..71bd4263 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmMessageContentFile.java @@ -0,0 +1,326 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmMessageContentFile + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmMessageContentFile { + public static final String SERIALIZED_NAME_FILE_URL = "fileUrl"; + @SerializedName(SERIALIZED_NAME_FILE_URL) + @javax.annotation.Nonnull + private URI fileUrl; + + public static final String SERIALIZED_NAME_THUMBNAIL_URL = "thumbnailUrl"; + @SerializedName(SERIALIZED_NAME_THUMBNAIL_URL) + @javax.annotation.Nullable + private URI thumbnailUrl; + + public RbmMessageContentFile() { + } + + public RbmMessageContentFile fileUrl(@javax.annotation.Nonnull URI fileUrl) { + this.fileUrl = fileUrl; + return this; + } + + /** + * The URL of the media file. 100MB is the maximum file size. + * @return fileUrl + */ + @javax.annotation.Nonnull + public URI getFileUrl() { + return fileUrl; + } + + public void setFileUrl(@javax.annotation.Nonnull URI fileUrl) { + this.fileUrl = fileUrl; + } + + + public RbmMessageContentFile thumbnailUrl(@javax.annotation.Nullable URI thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + return this; + } + + /** + * The URL of the thumbnail image. Applies only to video file media. + * @return thumbnailUrl + */ + @javax.annotation.Nullable + public URI getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(@javax.annotation.Nullable URI thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmMessageContentFile instance itself + */ + public RbmMessageContentFile putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmMessageContentFile rbmMessageContentFile = (RbmMessageContentFile) o; + return Objects.equals(this.fileUrl, rbmMessageContentFile.fileUrl) && + Objects.equals(this.thumbnailUrl, rbmMessageContentFile.thumbnailUrl)&& + Objects.equals(this.additionalProperties, rbmMessageContentFile.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(fileUrl, thumbnailUrl, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmMessageContentFile {\n"); + sb.append(" fileUrl: ").append(toIndentedString(fileUrl)).append("\n"); + sb.append(" thumbnailUrl: ").append(toIndentedString(thumbnailUrl)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("fileUrl"); + openapiFields.add("thumbnailUrl"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("fileUrl"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmMessageContentFile + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmMessageContentFile.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmMessageContentFile is not found in the empty JSON string", RbmMessageContentFile.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmMessageContentFile.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("fileUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `fileUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fileUrl").toString())); + } + if ((jsonObj.get("thumbnailUrl") != null && !jsonObj.get("thumbnailUrl").isJsonNull()) && !jsonObj.get("thumbnailUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `thumbnailUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumbnailUrl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmMessageContentFile.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmMessageContentFile' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageContentFile.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmMessageContentFile value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmMessageContentFile read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmMessageContentFile instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmMessageContentFile given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmMessageContentFile + * @throws IOException if the JSON string is invalid with respect to RbmMessageContentFile + */ + public static RbmMessageContentFile fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmMessageContentFile.class); + } + + /** + * Convert an instance of RbmMessageContentFile to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmMessageContentRichCard.java b/src/main/java/com/bandwidth/sdk/model/RbmMessageContentRichCard.java new file mode 100644 index 00000000..9f6af6d1 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmMessageContentRichCard.java @@ -0,0 +1,282 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.CardWidthEnum; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.bandwidth.sdk.model.RbmCardContent; +import com.bandwidth.sdk.model.RbmMessageCarouselCard; +import com.bandwidth.sdk.model.RbmStandaloneCard; +import com.bandwidth.sdk.model.StandaloneCardOrientationEnum; +import com.bandwidth.sdk.model.ThumbnailAlignmentEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; + +import com.bandwidth.sdk.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmMessageContentRichCard extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(RbmMessageContentRichCard.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmMessageContentRichCard.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmMessageContentRichCard' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterRbmStandaloneCard = gson.getDelegateAdapter(this, TypeToken.get(RbmStandaloneCard.class)); + final TypeAdapter adapterRbmMessageCarouselCard = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageCarouselCard.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmMessageContentRichCard value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `RbmStandaloneCard` + if (value.getActualInstance() instanceof RbmStandaloneCard) { + JsonElement element = adapterRbmStandaloneCard.toJsonTree((RbmStandaloneCard)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `RbmMessageCarouselCard` + if (value.getActualInstance() instanceof RbmMessageCarouselCard) { + JsonElement element = adapterRbmMessageCarouselCard.toJsonTree((RbmMessageCarouselCard)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: RbmMessageCarouselCard, RbmStandaloneCard"); + } + + @Override + public RbmMessageContentRichCard read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize RbmStandaloneCard + try { + // validate the JSON object to see if any exception is thrown + RbmStandaloneCard.validateJsonElement(jsonElement); + actualAdapter = adapterRbmStandaloneCard; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmStandaloneCard'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmStandaloneCard failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmStandaloneCard'", e); + } + // deserialize RbmMessageCarouselCard + try { + // validate the JSON object to see if any exception is thrown + RbmMessageCarouselCard.validateJsonElement(jsonElement); + actualAdapter = adapterRbmMessageCarouselCard; + match++; + log.log(Level.FINER, "Input data matches schema 'RbmMessageCarouselCard'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for RbmMessageCarouselCard failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'RbmMessageCarouselCard'", e); + } + + if (match == 1) { + RbmMessageContentRichCard ret = new RbmMessageContentRichCard(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for RbmMessageContentRichCard: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap>(); + + public RbmMessageContentRichCard() { + super("oneOf", Boolean.FALSE); + } + + public RbmMessageContentRichCard(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("RbmStandaloneCard", RbmStandaloneCard.class); + schemas.put("RbmMessageCarouselCard", RbmMessageCarouselCard.class); + } + + @Override + public Map> getSchemas() { + return RbmMessageContentRichCard.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * RbmMessageCarouselCard, RbmStandaloneCard + * + * It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof RbmStandaloneCard) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof RbmMessageCarouselCard) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be RbmMessageCarouselCard, RbmStandaloneCard"); + } + + /** + * Get the actual instance, which can be the following: + * RbmMessageCarouselCard, RbmStandaloneCard + * + * @return The actual instance (RbmMessageCarouselCard, RbmStandaloneCard) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmStandaloneCard`. If the actual instance is not `RbmStandaloneCard`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmStandaloneCard` + * @throws ClassCastException if the instance is not `RbmStandaloneCard` + */ + public RbmStandaloneCard getRbmStandaloneCard() throws ClassCastException { + return (RbmStandaloneCard)super.getActualInstance(); + } + + /** + * Get the actual instance of `RbmMessageCarouselCard`. If the actual instance is not `RbmMessageCarouselCard`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `RbmMessageCarouselCard` + * @throws ClassCastException if the instance is not `RbmMessageCarouselCard` + */ + public RbmMessageCarouselCard getRbmMessageCarouselCard() throws ClassCastException { + return (RbmMessageCarouselCard)super.getActualInstance(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmMessageContentRichCard + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with RbmStandaloneCard + try { + RbmStandaloneCard.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmStandaloneCard failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with RbmMessageCarouselCard + try { + RbmMessageCarouselCard.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for RbmMessageCarouselCard failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for RbmMessageContentRichCard with oneOf schemas: RbmMessageCarouselCard, RbmStandaloneCard. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + } + } + + /** + * Create an instance of RbmMessageContentRichCard given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmMessageContentRichCard + * @throws IOException if the JSON string is invalid with respect to RbmMessageContentRichCard + */ + public static RbmMessageContentRichCard fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmMessageContentRichCard.class); + } + + /** + * Convert an instance of RbmMessageContentRichCard to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmMessageContentText.java b/src/main/java/com/bandwidth/sdk/model/RbmMessageContentText.java new file mode 100644 index 00000000..0f62bc31 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmMessageContentText.java @@ -0,0 +1,347 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmMessageContentText + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmMessageContentText { + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public static final String SERIALIZED_NAME_SUGGESTIONS = "suggestions"; + @SerializedName(SERIALIZED_NAME_SUGGESTIONS) + @javax.annotation.Nullable + private List suggestions = new ArrayList<>(); + + public RbmMessageContentText() { + } + + public RbmMessageContentText text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * The text associated with the message. Must be 3270 characters or less + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + + public RbmMessageContentText suggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + return this; + } + + public RbmMessageContentText addSuggestionsItem(MultiChannelAction suggestionsItem) { + if (this.suggestions == null) { + this.suggestions = new ArrayList<>(); + } + this.suggestions.add(suggestionsItem); + return this; + } + + /** + * An array of suggested actions for the recipient. + * @return suggestions + */ + @javax.annotation.Nullable + public List getSuggestions() { + return suggestions; + } + + public void setSuggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmMessageContentText instance itself + */ + public RbmMessageContentText putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmMessageContentText rbmMessageContentText = (RbmMessageContentText) o; + return Objects.equals(this.text, rbmMessageContentText.text) && + Objects.equals(this.suggestions, rbmMessageContentText.suggestions)&& + Objects.equals(this.additionalProperties, rbmMessageContentText.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(text, suggestions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmMessageContentText {\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" suggestions: ").append(toIndentedString(suggestions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("text"); + openapiFields.add("suggestions"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("text"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmMessageContentText + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmMessageContentText.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmMessageContentText is not found in the empty JSON string", RbmMessageContentText.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmMessageContentText.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + if (jsonObj.get("suggestions") != null && !jsonObj.get("suggestions").isJsonNull()) { + JsonArray jsonArraysuggestions = jsonObj.getAsJsonArray("suggestions"); + if (jsonArraysuggestions != null) { + // ensure the json data is an array + if (!jsonObj.get("suggestions").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `suggestions` to be an array in the JSON string but got `%s`", jsonObj.get("suggestions").toString())); + } + + // validate the optional field `suggestions` (array) + for (int i = 0; i < jsonArraysuggestions.size(); i++) { + MultiChannelAction.validateJsonElement(jsonArraysuggestions.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmMessageContentText.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmMessageContentText' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageContentText.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmMessageContentText value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmMessageContentText read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmMessageContentText instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmMessageContentText given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmMessageContentText + * @throws IOException if the JSON string is invalid with respect to RbmMessageContentText + */ + public static RbmMessageContentText fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmMessageContentText.class); + } + + /** + * Convert an instance of RbmMessageContentText to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmMessageMedia.java b/src/main/java/com/bandwidth/sdk/model/RbmMessageMedia.java new file mode 100644 index 00000000..ec5aa0e4 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmMessageMedia.java @@ -0,0 +1,347 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.bandwidth.sdk.model.RbmMessageContentFile; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmMessageMedia + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmMessageMedia { + public static final String SERIALIZED_NAME_MEDIA = "media"; + @SerializedName(SERIALIZED_NAME_MEDIA) + @javax.annotation.Nonnull + private RbmMessageContentFile media; + + public static final String SERIALIZED_NAME_SUGGESTIONS = "suggestions"; + @SerializedName(SERIALIZED_NAME_SUGGESTIONS) + @javax.annotation.Nullable + private List suggestions = new ArrayList<>(); + + public RbmMessageMedia() { + } + + public RbmMessageMedia media(@javax.annotation.Nonnull RbmMessageContentFile media) { + this.media = media; + return this; + } + + /** + * Get media + * @return media + */ + @javax.annotation.Nonnull + public RbmMessageContentFile getMedia() { + return media; + } + + public void setMedia(@javax.annotation.Nonnull RbmMessageContentFile media) { + this.media = media; + } + + + public RbmMessageMedia suggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + return this; + } + + public RbmMessageMedia addSuggestionsItem(MultiChannelAction suggestionsItem) { + if (this.suggestions == null) { + this.suggestions = new ArrayList<>(); + } + this.suggestions.add(suggestionsItem); + return this; + } + + /** + * An array of suggested actions for the recipient. + * @return suggestions + */ + @javax.annotation.Nullable + public List getSuggestions() { + return suggestions; + } + + public void setSuggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmMessageMedia instance itself + */ + public RbmMessageMedia putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmMessageMedia rbmMessageMedia = (RbmMessageMedia) o; + return Objects.equals(this.media, rbmMessageMedia.media) && + Objects.equals(this.suggestions, rbmMessageMedia.suggestions)&& + Objects.equals(this.additionalProperties, rbmMessageMedia.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(media, suggestions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmMessageMedia {\n"); + sb.append(" media: ").append(toIndentedString(media)).append("\n"); + sb.append(" suggestions: ").append(toIndentedString(suggestions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("media"); + openapiFields.add("suggestions"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("media"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmMessageMedia + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmMessageMedia.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmMessageMedia is not found in the empty JSON string", RbmMessageMedia.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmMessageMedia.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `media` + RbmMessageContentFile.validateJsonElement(jsonObj.get("media")); + if (jsonObj.get("suggestions") != null && !jsonObj.get("suggestions").isJsonNull()) { + JsonArray jsonArraysuggestions = jsonObj.getAsJsonArray("suggestions"); + if (jsonArraysuggestions != null) { + // ensure the json data is an array + if (!jsonObj.get("suggestions").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `suggestions` to be an array in the JSON string but got `%s`", jsonObj.get("suggestions").toString())); + } + + // validate the optional field `suggestions` (array) + for (int i = 0; i < jsonArraysuggestions.size(); i++) { + MultiChannelAction.validateJsonElement(jsonArraysuggestions.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmMessageMedia.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmMessageMedia' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmMessageMedia.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmMessageMedia value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmMessageMedia read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmMessageMedia instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmMessageMedia given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmMessageMedia + * @throws IOException if the JSON string is invalid with respect to RbmMessageMedia + */ + public static RbmMessageMedia fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmMessageMedia.class); + } + + /** + * Convert an instance of RbmMessageMedia to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/RbmStandaloneCard.java b/src/main/java/com/bandwidth/sdk/model/RbmStandaloneCard.java new file mode 100644 index 00000000..4c0665f3 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/RbmStandaloneCard.java @@ -0,0 +1,409 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.bandwidth.sdk.model.MultiChannelAction; +import com.bandwidth.sdk.model.RbmCardContent; +import com.bandwidth.sdk.model.StandaloneCardOrientationEnum; +import com.bandwidth.sdk.model.ThumbnailAlignmentEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * RbmStandaloneCard + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class RbmStandaloneCard { + public static final String SERIALIZED_NAME_ORIENTATION = "orientation"; + @SerializedName(SERIALIZED_NAME_ORIENTATION) + @javax.annotation.Nonnull + private StandaloneCardOrientationEnum orientation; + + public static final String SERIALIZED_NAME_THUMBNAIL_IMAGE_ALIGNMENT = "thumbnailImageAlignment"; + @SerializedName(SERIALIZED_NAME_THUMBNAIL_IMAGE_ALIGNMENT) + @javax.annotation.Nonnull + private ThumbnailAlignmentEnum thumbnailImageAlignment; + + public static final String SERIALIZED_NAME_CARD_CONTENT = "cardContent"; + @SerializedName(SERIALIZED_NAME_CARD_CONTENT) + @javax.annotation.Nonnull + private RbmCardContent cardContent; + + public static final String SERIALIZED_NAME_SUGGESTIONS = "suggestions"; + @SerializedName(SERIALIZED_NAME_SUGGESTIONS) + @javax.annotation.Nullable + private List suggestions = new ArrayList<>(); + + public RbmStandaloneCard() { + } + + public RbmStandaloneCard orientation(@javax.annotation.Nonnull StandaloneCardOrientationEnum orientation) { + this.orientation = orientation; + return this; + } + + /** + * Get orientation + * @return orientation + */ + @javax.annotation.Nonnull + public StandaloneCardOrientationEnum getOrientation() { + return orientation; + } + + public void setOrientation(@javax.annotation.Nonnull StandaloneCardOrientationEnum orientation) { + this.orientation = orientation; + } + + + public RbmStandaloneCard thumbnailImageAlignment(@javax.annotation.Nonnull ThumbnailAlignmentEnum thumbnailImageAlignment) { + this.thumbnailImageAlignment = thumbnailImageAlignment; + return this; + } + + /** + * Get thumbnailImageAlignment + * @return thumbnailImageAlignment + */ + @javax.annotation.Nonnull + public ThumbnailAlignmentEnum getThumbnailImageAlignment() { + return thumbnailImageAlignment; + } + + public void setThumbnailImageAlignment(@javax.annotation.Nonnull ThumbnailAlignmentEnum thumbnailImageAlignment) { + this.thumbnailImageAlignment = thumbnailImageAlignment; + } + + + public RbmStandaloneCard cardContent(@javax.annotation.Nonnull RbmCardContent cardContent) { + this.cardContent = cardContent; + return this; + } + + /** + * Get cardContent + * @return cardContent + */ + @javax.annotation.Nonnull + public RbmCardContent getCardContent() { + return cardContent; + } + + public void setCardContent(@javax.annotation.Nonnull RbmCardContent cardContent) { + this.cardContent = cardContent; + } + + + public RbmStandaloneCard suggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + return this; + } + + public RbmStandaloneCard addSuggestionsItem(MultiChannelAction suggestionsItem) { + if (this.suggestions == null) { + this.suggestions = new ArrayList<>(); + } + this.suggestions.add(suggestionsItem); + return this; + } + + /** + * An array of suggested actions for the recipient. + * @return suggestions + */ + @javax.annotation.Nullable + public List getSuggestions() { + return suggestions; + } + + public void setSuggestions(@javax.annotation.Nullable List suggestions) { + this.suggestions = suggestions; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RbmStandaloneCard instance itself + */ + public RbmStandaloneCard putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RbmStandaloneCard rbmStandaloneCard = (RbmStandaloneCard) o; + return Objects.equals(this.orientation, rbmStandaloneCard.orientation) && + Objects.equals(this.thumbnailImageAlignment, rbmStandaloneCard.thumbnailImageAlignment) && + Objects.equals(this.cardContent, rbmStandaloneCard.cardContent) && + Objects.equals(this.suggestions, rbmStandaloneCard.suggestions)&& + Objects.equals(this.additionalProperties, rbmStandaloneCard.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(orientation, thumbnailImageAlignment, cardContent, suggestions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RbmStandaloneCard {\n"); + sb.append(" orientation: ").append(toIndentedString(orientation)).append("\n"); + sb.append(" thumbnailImageAlignment: ").append(toIndentedString(thumbnailImageAlignment)).append("\n"); + sb.append(" cardContent: ").append(toIndentedString(cardContent)).append("\n"); + sb.append(" suggestions: ").append(toIndentedString(suggestions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("orientation"); + openapiFields.add("thumbnailImageAlignment"); + openapiFields.add("cardContent"); + openapiFields.add("suggestions"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("orientation"); + openapiRequiredFields.add("thumbnailImageAlignment"); + openapiRequiredFields.add("cardContent"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RbmStandaloneCard + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RbmStandaloneCard.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RbmStandaloneCard is not found in the empty JSON string", RbmStandaloneCard.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RbmStandaloneCard.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `orientation` + StandaloneCardOrientationEnum.validateJsonElement(jsonObj.get("orientation")); + // validate the required field `thumbnailImageAlignment` + ThumbnailAlignmentEnum.validateJsonElement(jsonObj.get("thumbnailImageAlignment")); + // validate the required field `cardContent` + RbmCardContent.validateJsonElement(jsonObj.get("cardContent")); + if (jsonObj.get("suggestions") != null && !jsonObj.get("suggestions").isJsonNull()) { + JsonArray jsonArraysuggestions = jsonObj.getAsJsonArray("suggestions"); + if (jsonArraysuggestions != null) { + // ensure the json data is an array + if (!jsonObj.get("suggestions").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `suggestions` to be an array in the JSON string but got `%s`", jsonObj.get("suggestions").toString())); + } + + // validate the optional field `suggestions` (array) + for (int i = 0; i < jsonArraysuggestions.size(); i++) { + MultiChannelAction.validateJsonElement(jsonArraysuggestions.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RbmStandaloneCard.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RbmStandaloneCard' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RbmStandaloneCard.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RbmStandaloneCard value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RbmStandaloneCard read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RbmStandaloneCard instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RbmStandaloneCard given an JSON string + * + * @param jsonString JSON string + * @return An instance of RbmStandaloneCard + * @throws IOException if the JSON string is invalid with respect to RbmStandaloneCard + */ + public static RbmStandaloneCard fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RbmStandaloneCard.class); + } + + /** + * Convert an instance of RbmStandaloneCard to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/SmsMessageContent.java b/src/main/java/com/bandwidth/sdk/model/SmsMessageContent.java new file mode 100644 index 00000000..50932ded --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/SmsMessageContent.java @@ -0,0 +1,295 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.bandwidth.sdk.JSON; + +/** + * SmsMessageContent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0") +public class SmsMessageContent { + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + @javax.annotation.Nonnull + private String text; + + public SmsMessageContent() { + } + + public SmsMessageContent text(@javax.annotation.Nonnull String text) { + this.text = text; + return this; + } + + /** + * The contents of the text message. Must be 2048 characters or less. + * @return text + */ + @javax.annotation.Nonnull + public String getText() { + return text; + } + + public void setText(@javax.annotation.Nonnull String text) { + this.text = text; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SmsMessageContent instance itself + */ + public SmsMessageContent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SmsMessageContent smsMessageContent = (SmsMessageContent) o; + return Objects.equals(this.text, smsMessageContent.text)&& + Objects.equals(this.additionalProperties, smsMessageContent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(text, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsMessageContent {\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("text"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("text"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SmsMessageContent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SmsMessageContent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SmsMessageContent is not found in the empty JSON string", SmsMessageContent.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SmsMessageContent.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SmsMessageContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SmsMessageContent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SmsMessageContent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SmsMessageContent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SmsMessageContent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SmsMessageContent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SmsMessageContent given an JSON string + * + * @param jsonString JSON string + * @return An instance of SmsMessageContent + * @throws IOException if the JSON string is invalid with respect to SmsMessageContent + */ + public static SmsMessageContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SmsMessageContent.class); + } + + /** + * Convert an instance of SmsMessageContent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/StandaloneCardOrientationEnum.java b/src/main/java/com/bandwidth/sdk/model/StandaloneCardOrientationEnum.java new file mode 100644 index 00000000..206705f6 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/StandaloneCardOrientationEnum.java @@ -0,0 +1,78 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets standaloneCardOrientationEnum + */ +@JsonAdapter(StandaloneCardOrientationEnum.Adapter.class) +public enum StandaloneCardOrientationEnum { + + HORIZONTAL("HORIZONTAL"), + + VERTICAL("VERTICAL"); + + private String value; + + StandaloneCardOrientationEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StandaloneCardOrientationEnum fromValue(String value) { + for (StandaloneCardOrientationEnum b : StandaloneCardOrientationEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StandaloneCardOrientationEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StandaloneCardOrientationEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StandaloneCardOrientationEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StandaloneCardOrientationEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/ThumbnailAlignmentEnum.java b/src/main/java/com/bandwidth/sdk/model/ThumbnailAlignmentEnum.java new file mode 100644 index 00000000..ee456b43 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/ThumbnailAlignmentEnum.java @@ -0,0 +1,78 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * The alignment of the thumbnail image in the card. Only applicable if the card using horizontal orientation. + */ +@JsonAdapter(ThumbnailAlignmentEnum.Adapter.class) +public enum ThumbnailAlignmentEnum { + + LEFT("LEFT"), + + RIGHT("RIGHT"); + + private String value; + + ThumbnailAlignmentEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ThumbnailAlignmentEnum fromValue(String value) { + for (ThumbnailAlignmentEnum b : ThumbnailAlignmentEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ThumbnailAlignmentEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ThumbnailAlignmentEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ThumbnailAlignmentEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ThumbnailAlignmentEnum.fromValue(value); + } +} +