diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 7ff8da6b..760512b5 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -36,7 +36,7 @@ jobs: strategy: matrix: os: [windows-2022, windows-2025, ubuntu-22.04, ubuntu-24.04] - java-version: ["11", "17", "21"] + java-version: ["11", "17", "21", "25"] distribution: ["zulu", "temurin"] fail-fast: false steps: diff --git a/.gitignore b/.gitignore index c505dc80..5f642897 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +*.prefs + # build files **/target target diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 9bed5aad..33ee46ae 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -101,14 +101,22 @@ docs/MmsMessageContentFile.md docs/MultiChannelAction.md docs/MultiChannelActionCalendarEvent.md docs/MultiChannelApi.md -docs/MultiChannelChannelListObject.md -docs/MultiChannelChannelListObjectContent.md +docs/MultiChannelChannelListMMSObject.md +docs/MultiChannelChannelListMMSResponseObject.md +docs/MultiChannelChannelListObjectBase.md +docs/MultiChannelChannelListOwnerObject.md +docs/MultiChannelChannelListRBMObject.md +docs/MultiChannelChannelListRBMObjectAllOfContent.md +docs/MultiChannelChannelListRBMResponseObject.md +docs/MultiChannelChannelListRequestObject.md +docs/MultiChannelChannelListResponseObject.md +docs/MultiChannelChannelListSMSObject.md +docs/MultiChannelChannelListSMSResponseObject.md docs/MultiChannelError.md docs/MultiChannelMessageChannelEnum.md docs/MultiChannelMessageContent.md docs/MultiChannelMessageRequest.md docs/MultiChannelMessageResponseData.md -docs/MultiChannelMessageResponseDataChannelListInner.md docs/OptInWorkflow.md docs/PageInfo.md docs/PhoneNumberLookupApi.md @@ -310,14 +318,22 @@ src/main/java/com/bandwidth/sdk/model/MmsMessageContent.java src/main/java/com/bandwidth/sdk/model/MmsMessageContentFile.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/MultiChannelChannelListObject.java -src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSResponseObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectBase.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListOwnerObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMObjectAllOfContent.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMResponseObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRequestObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListResponseObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSObject.java +src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSResponseObject.java src/main/java/com/bandwidth/sdk/model/MultiChannelError.java src/main/java/com/bandwidth/sdk/model/MultiChannelMessageChannelEnum.java src/main/java/com/bandwidth/sdk/model/MultiChannelMessageContent.java src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseData.java -src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseDataChannelListInner.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 diff --git a/README.md b/README.md index 3cf94404..4edb5733 100644 --- a/README.md +++ b/README.md @@ -268,14 +268,22 @@ Class | Method | HTTP request | Description - [MmsMessageContentFile](docs/MmsMessageContentFile.md) - [MultiChannelAction](docs/MultiChannelAction.md) - [MultiChannelActionCalendarEvent](docs/MultiChannelActionCalendarEvent.md) - - [MultiChannelChannelListObject](docs/MultiChannelChannelListObject.md) - - [MultiChannelChannelListObjectContent](docs/MultiChannelChannelListObjectContent.md) + - [MultiChannelChannelListMMSObject](docs/MultiChannelChannelListMMSObject.md) + - [MultiChannelChannelListMMSResponseObject](docs/MultiChannelChannelListMMSResponseObject.md) + - [MultiChannelChannelListObjectBase](docs/MultiChannelChannelListObjectBase.md) + - [MultiChannelChannelListOwnerObject](docs/MultiChannelChannelListOwnerObject.md) + - [MultiChannelChannelListRBMObject](docs/MultiChannelChannelListRBMObject.md) + - [MultiChannelChannelListRBMObjectAllOfContent](docs/MultiChannelChannelListRBMObjectAllOfContent.md) + - [MultiChannelChannelListRBMResponseObject](docs/MultiChannelChannelListRBMResponseObject.md) + - [MultiChannelChannelListRequestObject](docs/MultiChannelChannelListRequestObject.md) + - [MultiChannelChannelListResponseObject](docs/MultiChannelChannelListResponseObject.md) + - [MultiChannelChannelListSMSObject](docs/MultiChannelChannelListSMSObject.md) + - [MultiChannelChannelListSMSResponseObject](docs/MultiChannelChannelListSMSResponseObject.md) - [MultiChannelError](docs/MultiChannelError.md) - [MultiChannelMessageChannelEnum](docs/MultiChannelMessageChannelEnum.md) - [MultiChannelMessageContent](docs/MultiChannelMessageContent.md) - [MultiChannelMessageRequest](docs/MultiChannelMessageRequest.md) - [MultiChannelMessageResponseData](docs/MultiChannelMessageResponseData.md) - - [MultiChannelMessageResponseDataChannelListInner](docs/MultiChannelMessageResponseDataChannelListInner.md) - [OptInWorkflow](docs/OptInWorkflow.md) - [PageInfo](docs/PageInfo.md) - [PriorityEnum](docs/PriorityEnum.md) diff --git a/api/openapi.yaml b/api/openapi.yaml index 4a984267..4cf1e9e2 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -9137,7 +9137,7 @@ components: - $ref: "#/components/schemas/rbmActionViewLocation" - $ref: "#/components/schemas/multiChannelActionCalendarEvent" - $ref: "#/components/schemas/rbmActionOpenUrl" - multiChannelChannelListObject: + multiChannelChannelListObjectBase: properties: from: description: The sender ID of the message. This could be an alphanumeric @@ -9151,14 +9151,109 @@ components: type: string channel: $ref: "#/components/schemas/multiChannelMessageChannelEnum" - content: - $ref: "#/components/schemas/multiChannelChannelListObject_content" required: - applicationId - channel - - content - from type: object + multiChannelChannelListRBMObject: + allOf: + - $ref: "#/components/schemas/multiChannelChannelListObjectBase" + - properties: + content: + $ref: "#/components/schemas/multiChannelChannelListRBMObject_allOf_content" + type: object + required: + - content + multiChannelChannelListSMSObject: + allOf: + - $ref: "#/components/schemas/multiChannelChannelListObjectBase" + - properties: + content: + $ref: "#/components/schemas/smsMessageContent" + type: object + required: + - content + multiChannelChannelListMMSObject: + allOf: + - $ref: "#/components/schemas/multiChannelChannelListObjectBase" + - properties: + content: + $ref: "#/components/schemas/mmsMessageContent" + type: object + required: + - content + multiChannelChannelListRBMResponseObject: + allOf: + - $ref: "#/components/schemas/multiChannelChannelListRBMObject" + - $ref: "#/components/schemas/multiChannelChannelListOwnerObject" + example: + owner: owner + channel: RBM + from: BandwidthRBM + applicationId: 93de2206-9669-4e07-948d-329f4b722ee2 + content: + suggestions: + - postbackData: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + text: Hello world + type: REPLY + - postbackData: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + text: Hello world + type: REPLY + - postbackData: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + text: Hello world + type: REPLY + - postbackData: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + text: Hello world + type: REPLY + - postbackData: !!binary |- + U0dWc2JHOGdkMjl5YkdRPQ== + text: Hello world + type: REPLY + text: Hello world + multiChannelChannelListSMSResponseObject: + allOf: + - $ref: "#/components/schemas/multiChannelChannelListSMSObject" + - $ref: "#/components/schemas/multiChannelChannelListOwnerObject" + multiChannelChannelListMMSResponseObject: + allOf: + - $ref: "#/components/schemas/multiChannelChannelListMMSObject" + - $ref: "#/components/schemas/multiChannelChannelListOwnerObject" + multiChannelChannelListRequestObject: + discriminator: + mapping: + RBM: "#/components/schemas/multiChannelChannelListRBMObject" + SMS: "#/components/schemas/multiChannelChannelListSMSObject" + MMS: "#/components/schemas/multiChannelChannelListMMSObject" + propertyName: channel + oneOf: + - $ref: "#/components/schemas/multiChannelChannelListRBMObject" + - $ref: "#/components/schemas/multiChannelChannelListSMSObject" + - $ref: "#/components/schemas/multiChannelChannelListMMSObject" + multiChannelChannelListOwnerObject: + properties: + owner: + description: The Bandwidth senderId associated with the message. Identical + to 'from'. + type: string + required: + - owner + type: object + multiChannelChannelListResponseObject: + anyOf: + - $ref: "#/components/schemas/multiChannelChannelListRBMResponseObject" + - $ref: "#/components/schemas/multiChannelChannelListSMSResponseObject" + - $ref: "#/components/schemas/multiChannelChannelListMMSResponseObject" + discriminator: + mapping: + RBM: "#/components/schemas/multiChannelChannelListRBMResponseObject" + SMS: "#/components/schemas/multiChannelChannelListSMSResponseObject" + MMS: "#/components/schemas/multiChannelChannelListMMSResponseObject" + propertyName: channel multiChannelMessageRequest: description: Multi-Channel Message Request properties: @@ -9171,7 +9266,7 @@ components: \ the order they are listed. Once a message sends successfully, the others\ \ will be ignored." items: - $ref: "#/components/schemas/multiChannelChannelListObject" + $ref: "#/components/schemas/multiChannelChannelListRequestObject" maxItems: 4 type: array tag: @@ -9338,7 +9433,7 @@ components: \ the order they are listed. Once a message sends successfully, the others\ \ will be ignored." items: - $ref: "#/components/schemas/multiChannelMessageResponseData_channelList_inner" + $ref: "#/components/schemas/multiChannelChannelListResponseObject" maxItems: 4 type: array tag: @@ -14674,53 +14769,12 @@ components: type: object required: - height - multiChannelChannelListObject_content: + multiChannelChannelListRBMObject_allOf_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" - multiChannelMessageResponseData_channelList_inner: - allOf: - - $ref: "#/components/schemas/multiChannelChannelListObject" - - properties: - owner: - description: The Bandwidth senderId associated with the message. Identical - to 'from'. - type: string - required: - - owner - type: object - example: - owner: owner - channel: RBM - from: BandwidthRBM - applicationId: 93de2206-9669-4e07-948d-329f4b722ee2 - content: - suggestions: - - postbackData: !!binary |- - U0dWc2JHOGdkMjl5YkdRPQ== - text: Hello world - type: REPLY - - postbackData: !!binary |- - U0dWc2JHOGdkMjl5YkdRPQ== - text: Hello world - type: REPLY - - postbackData: !!binary |- - U0dWc2JHOGdkMjl5YkdRPQ== - text: Hello world - type: REPLY - - postbackData: !!binary |- - U0dWc2JHOGdkMjl5YkdRPQ== - text: Hello world - type: REPLY - - postbackData: !!binary |- - U0dWc2JHOGdkMjl5YkdRPQ== - text: Hello world - type: REPLY - text: Hello world lookupErrorSchema_meta: example: code: 1001 diff --git a/bandwidth.yml b/bandwidth.yml index 0c613484..86fea255 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -2505,7 +2505,7 @@ components: CREATE_CALENDAR_EVENT: '#/components/schemas/multiChannelActionCalendarEvent' OPEN_URL: '#/components/schemas/rbmActionOpenUrl' REQUEST_LOCATION: '#/components/schemas/rbmActionBase' - multiChannelChannelListObject: + multiChannelChannelListObjectBase: type: object properties: from: @@ -2514,19 +2514,85 @@ components: $ref: '#/components/schemas/applicationId' channel: $ref: '#/components/schemas/multiChannelMessageChannelEnum' - content: - description: The content of the message. - oneOf: - - $ref: '#/components/schemas/rbmMessageContentText' - - $ref: '#/components/schemas/rbmMessageMedia' - - $ref: '#/components/schemas/rbmMessageContentRichCard' - - $ref: '#/components/schemas/smsMessageContent' - - $ref: '#/components/schemas/mmsMessageContent' required: - from - applicationId - channel + multiChannelChannelListRBMObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListObjectBase' + - type: object + properties: + content: + description: The content of the message. + oneOf: + - $ref: '#/components/schemas/rbmMessageContentText' + - $ref: '#/components/schemas/rbmMessageMedia' + - $ref: '#/components/schemas/rbmMessageContentRichCard' + required: - content + multiChannelChannelListSMSObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListObjectBase' + - type: object + properties: + content: + $ref: '#/components/schemas/smsMessageContent' + required: + - content + multiChannelChannelListMMSObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListObjectBase' + - type: object + properties: + content: + $ref: '#/components/schemas/mmsMessageContent' + required: + - content + multiChannelChannelListRBMResponseObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListRBMObject' + - $ref: '#/components/schemas/multiChannelChannelListOwnerObject' + multiChannelChannelListSMSResponseObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListSMSObject' + - $ref: '#/components/schemas/multiChannelChannelListOwnerObject' + multiChannelChannelListMMSResponseObject: + allOf: + - $ref: '#/components/schemas/multiChannelChannelListMMSObject' + - $ref: '#/components/schemas/multiChannelChannelListOwnerObject' + multiChannelChannelListRequestObject: + oneOf: + - $ref: '#/components/schemas/multiChannelChannelListRBMObject' + - $ref: '#/components/schemas/multiChannelChannelListSMSObject' + - $ref: '#/components/schemas/multiChannelChannelListMMSObject' + discriminator: + propertyName: channel + mapping: + RBM: '#/components/schemas/multiChannelChannelListRBMObject' + SMS: '#/components/schemas/multiChannelChannelListSMSObject' + MMS: '#/components/schemas/multiChannelChannelListMMSObject' + multiChannelChannelListOwnerObject: + type: object + properties: + owner: + type: string + description: >- + The Bandwidth senderId associated with the message. Identical to + 'from'. + required: + - owner + multiChannelChannelListResponseObject: + anyOf: + - $ref: '#/components/schemas/multiChannelChannelListRBMResponseObject' + - $ref: '#/components/schemas/multiChannelChannelListSMSResponseObject' + - $ref: '#/components/schemas/multiChannelChannelListMMSResponseObject' + discriminator: + propertyName: channel + mapping: + RBM: '#/components/schemas/multiChannelChannelListRBMResponseObject' + SMS: '#/components/schemas/multiChannelChannelListSMSResponseObject' + MMS: '#/components/schemas/multiChannelChannelListMMSResponseObject' multiChannelMessageRequest: description: Multi-Channel Message Request type: object @@ -2540,7 +2606,7 @@ components: order they are listed. Once a message sends successfully, the others will be ignored. items: - $ref: '#/components/schemas/multiChannelChannelListObject' + $ref: '#/components/schemas/multiChannelChannelListRequestObject' maxItems: 4 tag: $ref: '#/components/schemas/tag' @@ -2573,17 +2639,7 @@ components: order they are listed. Once a message sends successfully, the others will be ignored. items: - allOf: - - $ref: '#/components/schemas/multiChannelChannelListObject' - - type: object - properties: - owner: - type: string - description: >- - The Bandwidth senderId associated with the message. - Identical to 'from'. - required: - - owner + $ref: '#/components/schemas/multiChannelChannelListResponseObject' maxItems: 4 tag: $ref: '#/components/schemas/tag' diff --git a/custom_templates/libraries/okhttp-gson/anyof_model.mustache b/custom_templates/libraries/okhttp-gson/anyof_model.mustache new file mode 100644 index 00000000..ea6e0575 --- /dev/null +++ b/custom_templates/libraries/okhttp-gson/anyof_model.mustache @@ -0,0 +1,434 @@ + + +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 java.util.Locale; + +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 {{invokerPackage}}.JSON; + +{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{>xmlAnnotation}} +public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-implements}} implements {{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-implements}} { + private static final Logger log = Logger.getLogger({{classname}}.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!{{classname}}.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes '{{classname}}' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + {{#composedSchemas}} + {{#anyOf}} + {{^isArray}} + {{^vendorExtensions.x-duplicated-data-type}} + final TypeAdapter<{{{dataType}}}> adapter{{{dataType}}} = gson.getDelegateAdapter(this, TypeToken.get({{{dataType}}}.class)); + {{/vendorExtensions.x-duplicated-data-type}} + {{/isArray}} + {{#isArray}} + + final Type typeInstance{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}} = new TypeToken<{{{dataType}}}>(){}.getType(); + final TypeAdapter<{{{dataType}}}> adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}} = (TypeAdapter<{{{dataType}}}>) gson.getDelegateAdapter(this, TypeToken.get(typeInstance{{#sanitizeGeneric}}{{{dataType}}}{{/sanitizeGeneric}})); + {{/isArray}} + {{/anyOf}} + {{/composedSchemas}} + + return (TypeAdapter) new TypeAdapter<{{classname}}>() { + @Override + public void write(JsonWriter out, {{classname}} value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + {{#composedSchemas}} + {{#anyOf}} + {{^vendorExtensions.x-duplicated-data-type}} + // check if the actual instance is of the type `{{{dataType}}}` + if (value.getActualInstance() instanceof {{#isArray}}List{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}) { + {{#isPrimitiveType}} + JsonPrimitive primitive = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}.toJsonTree(({{{dataType}}})value.getActualInstance()).getAsJsonPrimitive(); + elementAdapter.write(out, primitive); + return; + {{/isPrimitiveType}} + {{^isPrimitiveType}} + {{#isArray}} + List list = (List) value.getActualInstance(); + if (!list.isEmpty() && list.get(0) instanceof {{{items.dataType}}}) { + JsonArray array = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}.toJsonTree(({{{dataType}}})value.getActualInstance()).getAsJsonArray(); + elementAdapter.write(out, array); + return; + } + {{/isArray}} + {{/isPrimitiveType}} + {{^isArray}} + {{^isPrimitiveType}} + JsonElement element = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}.toJsonTree(({{{dataType}}})value.getActualInstance()); + elementAdapter.write(out, element); + return; + {{/isPrimitiveType}} + {{/isArray}} + } + {{/vendorExtensions.x-duplicated-data-type}} + {{/anyOf}} + {{/composedSchemas}} + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}"); + } + + @Override + public {{classname}} read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + {{#useOneOfDiscriminatorLookup}} + {{#discriminator}} + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + // use discriminator value for faster oneOf lookup + {{classname}} new{{classname}} = new {{classname}}(); + if (jsonObject.get("{{{propertyBaseName}}}") == null) { + log.log(Level.WARNING, "Failed to lookup discriminator value for {{classname}} as `{{{propertyBaseName}}}` was not found in the payload or the payload is empty."); + } else { + // look up the discriminator value in the field `{{{propertyBaseName}}}` + switch (jsonObject.get("{{{propertyBaseName}}}").getAsString()) { + {{#mappedModels}} + case "{{{mappingName}}}": + deserialized = adapter{{modelName}}.fromJsonTree(jsonObject); + new{{classname}}.setActualInstance(deserialized); + return new{{classname}}; + {{/mappedModels}} + default: + log.log(Level.WARNING, String.format(Locale.ROOT, "Failed to lookup discriminator value `%s` for {{classname}}. Possible values:{{#mappedModels}} {{{mappingName}}}{{/mappedModels}}", jsonObject.get("{{{propertyBaseName}}}").getAsString())); + } + } + + {{/discriminator}} + {{/useOneOfDiscriminatorLookup}} + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + {{#composedSchemas}} + {{#anyOf}} + {{^vendorExtensions.x-duplicated-data-type}} + {{^hasVars}} + // deserialize {{{dataType}}} + try { + // validate the JSON object to see if any exception is thrown + {{^isArray}} + {{#isNumber}} + if (!jsonElement.getAsJsonPrimitive().isNumber()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + } + actualAdapter = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}; + {{/isNumber}} + {{^isNumber}} + {{#isPrimitiveType}} + if (!jsonElement.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString())); + } + actualAdapter = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}; + {{/isPrimitiveType}} + {{/isNumber}} + {{^isNumber}} + {{^isPrimitiveType}} + {{#isUuid}} + UUID.fromString(jsonElement.getAsString()); + {{/isUuid}} + {{^isUuid}} + {{{dataType}}}.validateJsonElement(jsonElement); + {{/isUuid}} + actualAdapter = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}; + {{/isPrimitiveType}} + {{/isNumber}} + {{/isArray}} + {{#isArray}} + if (!jsonElement.isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString())); + } + + JsonArray array = jsonElement.getAsJsonArray(); + // validate array items + for(JsonElement element : array) { + {{#items}} + {{#isNumber}} + if (!jsonElement.getAsJsonPrimitive().isNumber()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + } + {{/isNumber}} + {{^isNumber}} + {{#isPrimitiveType}} + if (!element.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected array items to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString())); + } + {{/isPrimitiveType}} + {{/isNumber}} + {{^isNumber}} + {{^isPrimitiveType}} + {{{dataType}}}.validateJsonElement(element); + {{/isPrimitiveType}} + {{/isNumber}} + {{/items}} + } + actualAdapter = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}; + {{/isArray}} + {{classname}} ret = new {{classname}}(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for {{{dataType}}} failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema '{{{dataType}}}'", e); + } + {{/hasVars}} + {{#hasVars}} + // deserialize {{{.}}} + try { + // validate the JSON object to see if any exception is thrown + {{.}}.validateJsonElement(jsonElement); + actualAdapter = adapter{{.}}; + {{classname}} ret = new {{classname}}(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for {{{.}}} failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema '{{{.}}}'", e); + } + {{/hasVars}} + {{/vendorExtensions.x-duplicated-data-type}} + {{/anyOf}} + {{/composedSchemas}} + + throw new IOException(String.format(Locale.ROOT, "Failed deserialization for {{classname}}: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map> schemas = new HashMap>(); + + public {{classname}}() { + super("anyOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}}); + } + + public {{classname}}(Object o) { + super("anyOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}}); + setActualInstance(o); + } + + static { + {{#composedSchemas}} + {{#anyOf}} + {{^vendorExtensions.x-duplicated-data-type}} + schemas.put("{{{dataType}}}", {{{baseType}}}.class); + {{/vendorExtensions.x-duplicated-data-type}} + {{/anyOf}} + {{/composedSchemas}} + } + + @Override + public Map> getSchemas() { + return {{classname}}.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}} + * + * It could be an instance of the 'anyOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + {{#isNullable}} + if (instance == null) { + super.setActualInstance(instance); + return; + } + + {{/isNullable}} + {{#composedSchemas}} + {{#anyOf}} + {{^vendorExtensions.x-duplicated-data-type}} + if (instance instanceof {{#isArray}}List{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}) { + {{#isArray}} + List list = (List) instance; + if (!list.isEmpty() && list.get(0) instanceof {{{items.dataType}}}) { + super.setActualInstance(instance); + return; + } + {{/isArray}} + {{^isArray}} + super.setActualInstance(instance); + return; + {{/isArray}} + } + + {{/vendorExtensions.x-duplicated-data-type}} + {{/anyOf}} + {{/composedSchemas}} + throw new RuntimeException("Invalid instance type. Must be {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}"); + } + + /** + * Get the actual instance, which can be the following: + * {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}} + * + * @return The actual instance ({{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + {{#composedSchemas}} + {{#anyOf}} + {{^vendorExtensions.x-duplicated-data-type-ignoring-erasure}} + /** + * Get the actual instance of `{{{dataType}}}`. If the actual instance is not `{{{dataType}}}`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `{{{dataType}}}` + * @throws ClassCastException if the instance is not `{{{dataType}}}` + */ + public {{{dataType}}} get{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}() throws ClassCastException { + return ({{{dataType}}})super.getActualInstance(); + } + + {{/vendorExtensions.x-duplicated-data-type-ignoring-erasure}} + {{/anyOf}} + {{/composedSchemas}} + /** + * 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 {{classname}} + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate anyOf schemas one by one + ArrayList errorMessages = new ArrayList<>(); + {{#composedSchemas}} + {{#anyOf}} + {{^vendorExtensions.x-duplicated-data-type}} + // validate the json string with {{{dataType}}} + try { + {{^hasVars}} + {{^isArray}} + {{#isNumber}} + if (!jsonElement.getAsJsonPrimitive().isNumber()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + } + {{/isNumber}} + {{^isNumber}} + {{#isPrimitiveType}} + if (!jsonElement.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString())); + } + {{/isPrimitiveType}} + {{/isNumber}} + {{^isNumber}} + {{^isPrimitiveType}} + {{#isUuid}} + UUID.fromString(jsonElement.getAsString()); + {{/isUuid}} + {{^isUuid}} + {{{dataType}}}.validateJsonElement(jsonElement); + {{/isUuid}} + {{/isPrimitiveType}} + {{/isNumber}} + {{/isArray}} + {{#isArray}} + if (!jsonElement.isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString())); + } + JsonArray array = jsonElement.getAsJsonArray(); + // validate array items + for(JsonElement element : array) { + {{#items}} + {{#isNumber}} + if (!jsonElement.getAsJsonPrimitive().isNumber()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + } + {{/isNumber}} + {{^isNumber}} + {{#isPrimitiveType}} + if (!element.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected array items to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString())); + } + {{/isPrimitiveType}} + {{/isNumber}} + {{^isNumber}} + {{^isPrimitiveType}} + {{{dataType}}}.validateJsonElement(element); + {{/isPrimitiveType}} + {{/isNumber}} + {{/items}} + } + {{/isArray}} + {{/hasVars}} + {{#hasVars}} + {{{.}}}.validateJsonElement(jsonElement); + return; + {{/hasVars}} + return; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for {{{dataType}}} failed with `%s`.", e.getMessage())); + // continue to the next one + } + {{/vendorExtensions.x-duplicated-data-type}} + {{/anyOf}} + {{/composedSchemas}} + throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for {{classname}} with anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + } + + /** + * Create an instance of {{classname}} given an JSON string + * + * @param jsonString JSON string + * @return An instance of {{classname}} + * @throws IOException if the JSON string is invalid with respect to {{classname}} + */ + public static {{{classname}}} fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, {{{classname}}}.class); + } + + /** + * Convert an instance of {{classname}} to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/docs/MultiChannelChannelListObject.md b/docs/MultiChannelChannelListMMSObject.md similarity index 75% rename from docs/MultiChannelChannelListObject.md rename to docs/MultiChannelChannelListMMSObject.md index 57d6da61..2a68d85f 100644 --- a/docs/MultiChannelChannelListObject.md +++ b/docs/MultiChannelChannelListMMSObject.md @@ -1,6 +1,6 @@ -# MultiChannelChannelListObject +# MultiChannelChannelListMMSObject ## Properties @@ -10,7 +10,7 @@ |**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) | | | +|**content** | [**MmsMessageContent**](MmsMessageContent.md) | | | diff --git a/docs/MultiChannelMessageResponseDataChannelListInner.md b/docs/MultiChannelChannelListMMSResponseObject.md similarity index 77% rename from docs/MultiChannelMessageResponseDataChannelListInner.md rename to docs/MultiChannelChannelListMMSResponseObject.md index d26414a8..1de95515 100644 --- a/docs/MultiChannelMessageResponseDataChannelListInner.md +++ b/docs/MultiChannelChannelListMMSResponseObject.md @@ -1,6 +1,6 @@ -# MultiChannelMessageResponseDataChannelListInner +# MultiChannelChannelListMMSResponseObject ## Properties @@ -10,7 +10,7 @@ |**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) | | | +|**content** | [**MmsMessageContent**](MmsMessageContent.md) | | | |**owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | diff --git a/docs/MultiChannelChannelListObjectBase.md b/docs/MultiChannelChannelListObjectBase.md new file mode 100644 index 00000000..63625632 --- /dev/null +++ b/docs/MultiChannelChannelListObjectBase.md @@ -0,0 +1,15 @@ + + +# MultiChannelChannelListObjectBase + + +## 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** | | | + + + diff --git a/docs/MultiChannelChannelListOwnerObject.md b/docs/MultiChannelChannelListOwnerObject.md new file mode 100644 index 00000000..327a4873 --- /dev/null +++ b/docs/MultiChannelChannelListOwnerObject.md @@ -0,0 +1,13 @@ + + +# MultiChannelChannelListOwnerObject + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + + + diff --git a/docs/MultiChannelChannelListRBMObject.md b/docs/MultiChannelChannelListRBMObject.md new file mode 100644 index 00000000..ad90bcbe --- /dev/null +++ b/docs/MultiChannelChannelListRBMObject.md @@ -0,0 +1,16 @@ + + +# MultiChannelChannelListRBMObject + + +## 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** | [**MultiChannelChannelListRBMObjectAllOfContent**](MultiChannelChannelListRBMObjectAllOfContent.md) | | | + + + diff --git a/docs/MultiChannelChannelListObjectContent.md b/docs/MultiChannelChannelListRBMObjectAllOfContent.md similarity index 73% rename from docs/MultiChannelChannelListObjectContent.md rename to docs/MultiChannelChannelListRBMObjectAllOfContent.md index 58b1c5f5..6ff58ab3 100644 --- a/docs/MultiChannelChannelListObjectContent.md +++ b/docs/MultiChannelChannelListRBMObjectAllOfContent.md @@ -1,6 +1,6 @@ -# MultiChannelChannelListObjectContent +# MultiChannelChannelListRBMObjectAllOfContent The content of the message. @@ -8,9 +8,9 @@ The content of the message. | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**text** | **String** | The contents of the text message. Must be 2048 characters or less. | | +|**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] | -|**media** | [**List<MmsMessageContentFile>**](MmsMessageContentFile.md) | | | +|**media** | [**RbmMessageContentFile**](RbmMessageContentFile.md) | | | |**orientation** | **StandaloneCardOrientationEnum** | | | |**thumbnailImageAlignment** | **ThumbnailAlignmentEnum** | | | |**cardContent** | [**RbmCardContent**](RbmCardContent.md) | | | diff --git a/docs/MultiChannelChannelListRBMResponseObject.md b/docs/MultiChannelChannelListRBMResponseObject.md new file mode 100644 index 00000000..6a46779b --- /dev/null +++ b/docs/MultiChannelChannelListRBMResponseObject.md @@ -0,0 +1,17 @@ + + +# MultiChannelChannelListRBMResponseObject + + +## 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** | [**MultiChannelChannelListRBMObjectAllOfContent**](MultiChannelChannelListRBMObjectAllOfContent.md) | | | +|**owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + + + diff --git a/docs/MultiChannelChannelListRequestObject.md b/docs/MultiChannelChannelListRequestObject.md new file mode 100644 index 00000000..097021c5 --- /dev/null +++ b/docs/MultiChannelChannelListRequestObject.md @@ -0,0 +1,16 @@ + + +# MultiChannelChannelListRequestObject + + +## 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** | [**MmsMessageContent**](MmsMessageContent.md) | | | + + + diff --git a/docs/MultiChannelChannelListResponseObject.md b/docs/MultiChannelChannelListResponseObject.md new file mode 100644 index 00000000..3983973a --- /dev/null +++ b/docs/MultiChannelChannelListResponseObject.md @@ -0,0 +1,17 @@ + + +# MultiChannelChannelListResponseObject + + +## 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** | [**MmsMessageContent**](MmsMessageContent.md) | | | +|**owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + + + diff --git a/docs/MultiChannelChannelListSMSObject.md b/docs/MultiChannelChannelListSMSObject.md new file mode 100644 index 00000000..1ffde1f0 --- /dev/null +++ b/docs/MultiChannelChannelListSMSObject.md @@ -0,0 +1,16 @@ + + +# MultiChannelChannelListSMSObject + + +## 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** | [**SmsMessageContent**](SmsMessageContent.md) | | | + + + diff --git a/docs/MultiChannelChannelListSMSResponseObject.md b/docs/MultiChannelChannelListSMSResponseObject.md new file mode 100644 index 00000000..84246b1e --- /dev/null +++ b/docs/MultiChannelChannelListSMSResponseObject.md @@ -0,0 +1,17 @@ + + +# MultiChannelChannelListSMSResponseObject + + +## 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** | [**SmsMessageContent**](SmsMessageContent.md) | | | +|**owner** | **String** | The Bandwidth senderId associated with the message. Identical to 'from'. | | + + + diff --git a/docs/MultiChannelMessageRequest.md b/docs/MultiChannelMessageRequest.md index 9d1e87e2..7c33d83b 100644 --- a/docs/MultiChannelMessageRequest.md +++ b/docs/MultiChannelMessageRequest.md @@ -9,7 +9,7 @@ Multi-Channel Message Request | 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. | | +|**channelList** | [**List<MultiChannelChannelListRequestObject>**](MultiChannelChannelListRequestObject.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | |**tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | |**priority** | **PriorityEnum** | | [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/MultiChannelMessageResponseData.md b/docs/MultiChannelMessageResponseData.md index b91e8678..8320fd14 100644 --- a/docs/MultiChannelMessageResponseData.md +++ b/docs/MultiChannelMessageResponseData.md @@ -12,7 +12,7 @@ The data returned in a multichannel message response. |**time** | **OffsetDateTime** | The time the message was received by the Bandwidth API. | | |**direction** | **MessageDirectionEnum** | | | |**to** | **Set<String>** | The destination phone number(s) of the message, in E164 format. | | -|**channelList** | [**List<MultiChannelMessageResponseDataChannelListInner>**](MultiChannelMessageResponseDataChannelListInner.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | +|**channelList** | [**List<MultiChannelChannelListResponseObject>**](MultiChannelChannelListResponseObject.md) | A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored. | | |**tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | |**priority** | **PriorityEnum** | | [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/openapi-config.yml b/openapi-config.yml index a7ef13f8..a70b8616 100644 --- a/openapi-config.yml +++ b/openapi-config.yml @@ -14,4 +14,5 @@ modelPackage: com.bandwidth.sdk.model library: okhttp-gson licenseName: MIT useEnumCaseInsensitive: true +useOneOfDiscriminatorLookup: true templateDir: custom_templates diff --git a/src/main/java/com/bandwidth/sdk/JSON.java b/src/main/java/com/bandwidth/sdk/JSON.java index f3bcd4e7..518e07dd 100644 --- a/src/main/java/com/bandwidth/sdk/JSON.java +++ b/src/main/java/com/bandwidth/sdk/JSON.java @@ -91,6 +91,30 @@ public Class getClassForEl return getClassByDiscriminator(classByDiscriminatorValue, getDiscriminatorValue(readElement, "type")); } + }) + .registerTypeSelector(com.bandwidth.sdk.model.MultiChannelChannelListRequestObject.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("MMS", com.bandwidth.sdk.model.MultiChannelChannelListMMSObject.class); + classByDiscriminatorValue.put("RBM", com.bandwidth.sdk.model.MultiChannelChannelListRBMObject.class); + classByDiscriminatorValue.put("SMS", com.bandwidth.sdk.model.MultiChannelChannelListSMSObject.class); + classByDiscriminatorValue.put("multiChannelChannelListRequestObject", com.bandwidth.sdk.model.MultiChannelChannelListRequestObject.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "channel")); + } + }) + .registerTypeSelector(com.bandwidth.sdk.model.MultiChannelChannelListResponseObject.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("MMS", com.bandwidth.sdk.model.MultiChannelChannelListMMSResponseObject.class); + classByDiscriminatorValue.put("RBM", com.bandwidth.sdk.model.MultiChannelChannelListRBMResponseObject.class); + classByDiscriminatorValue.put("SMS", com.bandwidth.sdk.model.MultiChannelChannelListSMSResponseObject.class); + classByDiscriminatorValue.put("multiChannelChannelListResponseObject", com.bandwidth.sdk.model.MultiChannelChannelListResponseObject.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "channel")); + } }) ; GsonBuilder builder = fireBuilder.createGsonBuilder(); @@ -198,13 +222,21 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MmsMessageContentFile.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.MultiChannelChannelListObject.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListObjectContent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListMMSObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListMMSResponseObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListObjectBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListOwnerObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListRBMObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListRBMObjectAllOfContent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListRBMResponseObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListRequestObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListResponseObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListSMSObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelChannelListSMSResponseObject.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageContent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageResponseData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageResponseDataChannelListInner.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()); diff --git a/src/main/java/com/bandwidth/sdk/model/Callback.java b/src/main/java/com/bandwidth/sdk/model/Callback.java index 09a4a4c7..b5caca4d 100644 --- a/src/main/java/com/bandwidth/sdk/model/Callback.java +++ b/src/main/java/com/bandwidth/sdk/model/Callback.java @@ -107,6 +107,48 @@ public Callback read(JsonReader in) throws IOException { Object deserialized = null; JsonElement jsonElement = elementAdapter.read(in); + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + // use discriminator value for faster oneOf lookup + Callback newCallback = new Callback(); + if (jsonObject.get("type") == null) { + log.log(Level.WARNING, "Failed to lookup discriminator value for Callback as `type` was not found in the payload or the payload is empty."); + } else { + // look up the discriminator value in the field `type` + switch (jsonObject.get("type").getAsString()) { + case "message-delivered": + deserialized = adapterStatusCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + case "message-failed": + deserialized = adapterStatusCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + case "message-read": + deserialized = adapterStatusCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + case "message-received": + deserialized = adapterInboundCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + case "message-sent": + deserialized = adapterStatusCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + case "request-location-response": + deserialized = adapterInboundCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + case "suggestion-response": + deserialized = adapterInboundCallback.fromJsonTree(jsonObject); + newCallback.setActualInstance(deserialized); + return newCallback; + default: + log.log(Level.WARNING, String.format(Locale.ROOT, "Failed to lookup discriminator value `%s` for Callback. Possible values: message-delivered message-failed message-read message-received message-sent request-location-response suggestion-response", jsonObject.get("type").getAsString())); + } + } + int match = 0; ArrayList errorMessages = new ArrayList<>(); TypeAdapter actualAdapter = elementAdapter; diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java index 6993c77e..7b7600cb 100644 --- a/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelAction.java @@ -131,6 +131,44 @@ public MultiChannelAction read(JsonReader in) throws IOException { Object deserialized = null; JsonElement jsonElement = elementAdapter.read(in); + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + // use discriminator value for faster oneOf lookup + MultiChannelAction newMultiChannelAction = new MultiChannelAction(); + if (jsonObject.get("type") == null) { + log.log(Level.WARNING, "Failed to lookup discriminator value for MultiChannelAction as `type` was not found in the payload or the payload is empty."); + } else { + // look up the discriminator value in the field `type` + switch (jsonObject.get("type").getAsString()) { + case "CREATE_CALENDAR_EVENT": + deserialized = adapterMultiChannelActionCalendarEvent.fromJsonTree(jsonObject); + newMultiChannelAction.setActualInstance(deserialized); + return newMultiChannelAction; + case "DIAL_PHONE": + deserialized = adapterRbmActionDial.fromJsonTree(jsonObject); + newMultiChannelAction.setActualInstance(deserialized); + return newMultiChannelAction; + case "OPEN_URL": + deserialized = adapterRbmActionOpenUrl.fromJsonTree(jsonObject); + newMultiChannelAction.setActualInstance(deserialized); + return newMultiChannelAction; + case "REPLY": + deserialized = adapterRbmActionBase.fromJsonTree(jsonObject); + newMultiChannelAction.setActualInstance(deserialized); + return newMultiChannelAction; + case "REQUEST_LOCATION": + deserialized = adapterRbmActionBase.fromJsonTree(jsonObject); + newMultiChannelAction.setActualInstance(deserialized); + return newMultiChannelAction; + case "SHOW_LOCATION": + deserialized = adapterRbmActionViewLocation.fromJsonTree(jsonObject); + newMultiChannelAction.setActualInstance(deserialized); + return newMultiChannelAction; + default: + log.log(Level.WARNING, String.format(Locale.ROOT, "Failed to lookup discriminator value `%s` for MultiChannelAction. Possible values: CREATE_CALENDAR_EVENT DIAL_PHONE OPEN_URL REPLY REQUEST_LOCATION SHOW_LOCATION", jsonObject.get("type").getAsString())); + } + } + int match = 0; ArrayList errorMessages = new ArrayList<>(); TypeAdapter actualAdapter = elementAdapter; diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSObject.java new file mode 100644 index 00000000..dfa6dd64 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSObject.java @@ -0,0 +1,382 @@ +/* + * 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 java.util.Locale; +import com.bandwidth.sdk.model.MmsMessageContent; +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 java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListMMSObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class MultiChannelChannelListMMSObject { + 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 MmsMessageContent content; + + public MultiChannelChannelListMMSObject() { + } + + public MultiChannelChannelListMMSObject 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 MultiChannelChannelListMMSObject 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 MultiChannelChannelListMMSObject 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 MultiChannelChannelListMMSObject content(@javax.annotation.Nonnull MmsMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * @return content + */ + @javax.annotation.Nonnull + public MmsMessageContent getContent() { + return content; + } + + public void setContent(@javax.annotation.Nonnull MmsMessageContent 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 MultiChannelChannelListMMSObject instance itself + */ + public MultiChannelChannelListMMSObject 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; + } + MultiChannelChannelListMMSObject multiChannelChannelListMMSObject = (MultiChannelChannelListMMSObject) o; + return Objects.equals(this.from, multiChannelChannelListMMSObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListMMSObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListMMSObject.channel) && + Objects.equals(this.content, multiChannelChannelListMMSObject.content)&& + Objects.equals(this.additionalProperties, multiChannelChannelListMMSObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, applicationId, channel, content, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListMMSObject {\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(Arrays.asList("from", "applicationId", "channel", "content")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("from", "applicationId", "channel", "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 MultiChannelChannelListMMSObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListMMSObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListMMSObject is not found in the empty JSON string", MultiChannelChannelListMMSObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListMMSObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "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` + MmsMessageContent.validateJsonElement(jsonObj.get("content")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListMMSObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListMMSObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListMMSObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListMMSObject 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 MultiChannelChannelListMMSObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListMMSObject 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(Locale.ROOT, "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 MultiChannelChannelListMMSObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListMMSObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListMMSObject + */ + public static MultiChannelChannelListMMSObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListMMSObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListMMSObject 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/MultiChannelChannelListMMSResponseObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSResponseObject.java new file mode 100644 index 00000000..87eb5cb6 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListMMSResponseObject.java @@ -0,0 +1,411 @@ +/* + * 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 java.util.Locale; +import com.bandwidth.sdk.model.MmsMessageContent; +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 java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListMMSResponseObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class MultiChannelChannelListMMSResponseObject { + 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 MmsMessageContent content; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + @javax.annotation.Nonnull + private String owner; + + public MultiChannelChannelListMMSResponseObject() { + } + + public MultiChannelChannelListMMSResponseObject 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 MultiChannelChannelListMMSResponseObject 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 MultiChannelChannelListMMSResponseObject 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 MultiChannelChannelListMMSResponseObject content(@javax.annotation.Nonnull MmsMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * @return content + */ + @javax.annotation.Nonnull + public MmsMessageContent getContent() { + return content; + } + + public void setContent(@javax.annotation.Nonnull MmsMessageContent content) { + this.content = content; + } + + + public MultiChannelChannelListMMSResponseObject owner(@javax.annotation.Nonnull String owner) { + this.owner = owner; + return this; + } + + /** + * The Bandwidth senderId associated with the message. Identical to 'from'. + * @return owner + */ + @javax.annotation.Nonnull + public String getOwner() { + return owner; + } + + public void setOwner(@javax.annotation.Nonnull String owner) { + this.owner = owner; + } + + /** + * 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 MultiChannelChannelListMMSResponseObject instance itself + */ + public MultiChannelChannelListMMSResponseObject 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; + } + MultiChannelChannelListMMSResponseObject multiChannelChannelListMMSResponseObject = (MultiChannelChannelListMMSResponseObject) o; + return Objects.equals(this.from, multiChannelChannelListMMSResponseObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListMMSResponseObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListMMSResponseObject.channel) && + Objects.equals(this.content, multiChannelChannelListMMSResponseObject.content) && + Objects.equals(this.owner, multiChannelChannelListMMSResponseObject.owner)&& + Objects.equals(this.additionalProperties, multiChannelChannelListMMSResponseObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, applicationId, channel, content, owner, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListMMSResponseObject {\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(" owner: ").append(toIndentedString(owner)).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(Arrays.asList("from", "applicationId", "channel", "content", "owner")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("from", "applicationId", "channel", "content", "owner")); + } + + /** + * 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 MultiChannelChannelListMMSResponseObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListMMSResponseObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListMMSResponseObject is not found in the empty JSON string", MultiChannelChannelListMMSResponseObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListMMSResponseObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "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` + MmsMessageContent.validateJsonElement(jsonObj.get("content")); + if (!jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListMMSResponseObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListMMSResponseObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListMMSResponseObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListMMSResponseObject 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 MultiChannelChannelListMMSResponseObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListMMSResponseObject 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(Locale.ROOT, "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 MultiChannelChannelListMMSResponseObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListMMSResponseObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListMMSResponseObject + */ + public static MultiChannelChannelListMMSResponseObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListMMSResponseObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListMMSResponseObject 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/MultiChannelChannelListObjectBase.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectBase.java new file mode 100644 index 00000000..a8f9ffa1 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectBase.java @@ -0,0 +1,353 @@ +/* + * 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 java.util.Locale; +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 java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListObjectBase + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class MultiChannelChannelListObjectBase { + 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 MultiChannelChannelListObjectBase() { + } + + public MultiChannelChannelListObjectBase 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 MultiChannelChannelListObjectBase 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 MultiChannelChannelListObjectBase 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; + } + + /** + * 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 MultiChannelChannelListObjectBase instance itself + */ + public MultiChannelChannelListObjectBase 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; + } + MultiChannelChannelListObjectBase multiChannelChannelListObjectBase = (MultiChannelChannelListObjectBase) o; + return Objects.equals(this.from, multiChannelChannelListObjectBase.from) && + Objects.equals(this.applicationId, multiChannelChannelListObjectBase.applicationId) && + Objects.equals(this.channel, multiChannelChannelListObjectBase.channel)&& + Objects.equals(this.additionalProperties, multiChannelChannelListObjectBase.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, applicationId, channel, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListObjectBase {\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(" 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(Arrays.asList("from", "applicationId", "channel")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("from", "applicationId", "channel")); + } + + /** + * 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 MultiChannelChannelListObjectBase + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListObjectBase.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListObjectBase is not found in the empty JSON string", MultiChannelChannelListObjectBase.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListObjectBase.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "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")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListObjectBase.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListObjectBase' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListObjectBase.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListObjectBase 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 MultiChannelChannelListObjectBase read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListObjectBase 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(Locale.ROOT, "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 MultiChannelChannelListObjectBase given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListObjectBase + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListObjectBase + */ + public static MultiChannelChannelListObjectBase fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListObjectBase.class); + } + + /** + * Convert an instance of MultiChannelChannelListObjectBase 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/MultiChannelChannelListOwnerObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListOwnerObject.java new file mode 100644 index 00000000..6c2deaae --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListOwnerObject.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 java.util.Locale; +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 java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListOwnerObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class MultiChannelChannelListOwnerObject { + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + @javax.annotation.Nonnull + private String owner; + + public MultiChannelChannelListOwnerObject() { + } + + public MultiChannelChannelListOwnerObject owner(@javax.annotation.Nonnull String owner) { + this.owner = owner; + return this; + } + + /** + * The Bandwidth senderId associated with the message. Identical to 'from'. + * @return owner + */ + @javax.annotation.Nonnull + public String getOwner() { + return owner; + } + + public void setOwner(@javax.annotation.Nonnull String owner) { + this.owner = owner; + } + + /** + * 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 MultiChannelChannelListOwnerObject instance itself + */ + public MultiChannelChannelListOwnerObject 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; + } + MultiChannelChannelListOwnerObject multiChannelChannelListOwnerObject = (MultiChannelChannelListOwnerObject) o; + return Objects.equals(this.owner, multiChannelChannelListOwnerObject.owner)&& + Objects.equals(this.additionalProperties, multiChannelChannelListOwnerObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(owner, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListOwnerObject {\n"); + sb.append(" owner: ").append(toIndentedString(owner)).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(Arrays.asList("owner")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("owner")); + } + + /** + * 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 MultiChannelChannelListOwnerObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListOwnerObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListOwnerObject is not found in the empty JSON string", MultiChannelChannelListOwnerObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListOwnerObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListOwnerObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListOwnerObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListOwnerObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListOwnerObject 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 MultiChannelChannelListOwnerObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListOwnerObject 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(Locale.ROOT, "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 MultiChannelChannelListOwnerObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListOwnerObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListOwnerObject + */ + public static MultiChannelChannelListOwnerObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListOwnerObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListOwnerObject 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/MultiChannelChannelListRBMObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMObject.java new file mode 100644 index 00000000..5fe3c1bc --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMObject.java @@ -0,0 +1,382 @@ +/* + * 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 java.util.Locale; +import com.bandwidth.sdk.model.MultiChannelChannelListRBMObjectAllOfContent; +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 java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListRBMObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class MultiChannelChannelListRBMObject { + 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 MultiChannelChannelListRBMObjectAllOfContent content; + + public MultiChannelChannelListRBMObject() { + } + + public MultiChannelChannelListRBMObject 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 MultiChannelChannelListRBMObject 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 MultiChannelChannelListRBMObject 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 MultiChannelChannelListRBMObject content(@javax.annotation.Nonnull MultiChannelChannelListRBMObjectAllOfContent content) { + this.content = content; + return this; + } + + /** + * Get content + * @return content + */ + @javax.annotation.Nonnull + public MultiChannelChannelListRBMObjectAllOfContent getContent() { + return content; + } + + public void setContent(@javax.annotation.Nonnull MultiChannelChannelListRBMObjectAllOfContent 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 MultiChannelChannelListRBMObject instance itself + */ + public MultiChannelChannelListRBMObject 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; + } + MultiChannelChannelListRBMObject multiChannelChannelListRBMObject = (MultiChannelChannelListRBMObject) o; + return Objects.equals(this.from, multiChannelChannelListRBMObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListRBMObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListRBMObject.channel) && + Objects.equals(this.content, multiChannelChannelListRBMObject.content)&& + Objects.equals(this.additionalProperties, multiChannelChannelListRBMObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, applicationId, channel, content, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListRBMObject {\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(Arrays.asList("from", "applicationId", "channel", "content")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("from", "applicationId", "channel", "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 MultiChannelChannelListRBMObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListRBMObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListRBMObject is not found in the empty JSON string", MultiChannelChannelListRBMObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListRBMObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "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` + MultiChannelChannelListRBMObjectAllOfContent.validateJsonElement(jsonObj.get("content")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListRBMObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListRBMObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListRBMObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListRBMObject 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 MultiChannelChannelListRBMObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListRBMObject 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(Locale.ROOT, "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 MultiChannelChannelListRBMObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListRBMObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListRBMObject + */ + public static MultiChannelChannelListRBMObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListRBMObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListRBMObject 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/MultiChannelChannelListRBMObjectAllOfContent.java similarity index 64% rename from src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java rename to src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMObjectAllOfContent.java index 88f124ae..a5880f45 100644 --- a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObjectContent.java +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMObjectAllOfContent.java @@ -16,14 +16,12 @@ import java.util.Objects; import java.util.Locale; import com.bandwidth.sdk.model.CardWidthEnum; -import com.bandwidth.sdk.model.MmsMessageContent; -import com.bandwidth.sdk.model.MmsMessageContentFile; import com.bandwidth.sdk.model.MultiChannelAction; import com.bandwidth.sdk.model.RbmCardContent; +import com.bandwidth.sdk.model.RbmMessageContentFile; 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; @@ -73,26 +71,24 @@ import com.bandwidth.sdk.JSON; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") -public class MultiChannelChannelListObjectContent extends AbstractOpenApiSchema { - private static final Logger log = Logger.getLogger(MultiChannelChannelListObjectContent.class.getName()); +public class MultiChannelChannelListRBMObjectAllOfContent extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(MultiChannelChannelListRBMObjectAllOfContent.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 + if (!MultiChannelChannelListRBMObjectAllOfContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListRBMObjectAllOfContent' 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() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, MultiChannelChannelListObjectContent value) throws IOException { + public void write(JsonWriter out, MultiChannelChannelListRBMObjectAllOfContent value) throws IOException { if (value == null || value.getActualInstance() == null) { elementAdapter.write(out, null); return; @@ -116,23 +112,11 @@ public void write(JsonWriter out, MultiChannelChannelListObjectContent value) th 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"); + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia"); } @Override - public MultiChannelChannelListObjectContent read(JsonReader in) throws IOException { + public MultiChannelChannelListRBMObjectAllOfContent read(JsonReader in) throws IOException { Object deserialized = null; JsonElement jsonElement = elementAdapter.read(in); @@ -176,38 +160,14 @@ public MultiChannelChannelListObjectContent read(JsonReader in) throws IOExcepti errorMessages.add(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "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(); + MultiChannelChannelListRBMObjectAllOfContent ret = new MultiChannelChannelListRBMObjectAllOfContent(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for MultiChannelChannelListObjectContent: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + throw new IOException(String.format(Locale.ROOT, "Failed deserialization for MultiChannelChannelListRBMObjectAllOfContent: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -216,11 +176,11 @@ public MultiChannelChannelListObjectContent read(JsonReader in) throws IOExcepti // store a list of schema names defined in oneOf public static final Map> schemas = new HashMap>(); - public MultiChannelChannelListObjectContent() { + public MultiChannelChannelListRBMObjectAllOfContent() { super("oneOf", Boolean.FALSE); } - public MultiChannelChannelListObjectContent(Object o) { + public MultiChannelChannelListRBMObjectAllOfContent(Object o) { super("oneOf", Boolean.FALSE); setActualInstance(o); } @@ -229,19 +189,17 @@ public MultiChannelChannelListObjectContent(Object o) { 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; + return MultiChannelChannelListRBMObjectAllOfContent.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 + * RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia * * It could be an instance of the 'oneOf' schemas. */ @@ -262,24 +220,14 @@ public void setActualInstance(Object 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"); + throw new RuntimeException("Invalid instance type. Must be RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia"); } /** * Get the actual instance, which can be the following: - * MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent + * RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia * - * @return The actual instance (MmsMessageContent, RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia, SmsMessageContent) + * @return The actual instance (RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia) */ @SuppressWarnings("unchecked") @Override @@ -320,33 +268,11 @@ public RbmMessageContentRichCard getRbmMessageContentRichCard() throws ClassCast 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 + * @throws IOException if the JSON Element is invalid with respect to MultiChannelChannelListRBMObjectAllOfContent */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { // validate oneOf schemas one by one @@ -376,40 +302,24 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti errorMessages.add(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "Deserialization for MmsMessageContent failed with `%s`.", e.getMessage())); - // continue to the next one - } if (validCount != 1) { - throw new IOException(String.format(Locale.ROOT, "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())); + throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for MultiChannelChannelListRBMObjectAllOfContent with oneOf schemas: RbmMessageContentRichCard, RbmMessageContentText, RbmMessageMedia. %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 + * Create an instance of MultiChannelChannelListRBMObjectAllOfContent 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 + * @return An instance of MultiChannelChannelListRBMObjectAllOfContent + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListRBMObjectAllOfContent */ - public static MultiChannelChannelListObjectContent fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MultiChannelChannelListObjectContent.class); + public static MultiChannelChannelListRBMObjectAllOfContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListRBMObjectAllOfContent.class); } /** - * Convert an instance of MultiChannelChannelListObjectContent to an JSON string + * Convert an instance of MultiChannelChannelListRBMObjectAllOfContent to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseDataChannelListInner.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMResponseObject.java similarity index 76% rename from src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseDataChannelListInner.java rename to src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMResponseObject.java index 5584f053..0037ea40 100644 --- a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseDataChannelListInner.java +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRBMResponseObject.java @@ -15,7 +15,7 @@ import java.util.Objects; import java.util.Locale; -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; +import com.bandwidth.sdk.model.MultiChannelChannelListRBMObjectAllOfContent; import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -50,10 +50,10 @@ import com.bandwidth.sdk.JSON; /** - * MultiChannelMessageResponseDataChannelListInner + * MultiChannelChannelListRBMResponseObject */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") -public class MultiChannelMessageResponseDataChannelListInner { +public class MultiChannelChannelListRBMResponseObject { public static final String SERIALIZED_NAME_FROM = "from"; @SerializedName(SERIALIZED_NAME_FROM) @javax.annotation.Nonnull @@ -72,17 +72,17 @@ public class MultiChannelMessageResponseDataChannelListInner { public static final String SERIALIZED_NAME_CONTENT = "content"; @SerializedName(SERIALIZED_NAME_CONTENT) @javax.annotation.Nonnull - private MultiChannelChannelListObjectContent content; + private MultiChannelChannelListRBMObjectAllOfContent content; public static final String SERIALIZED_NAME_OWNER = "owner"; @SerializedName(SERIALIZED_NAME_OWNER) @javax.annotation.Nonnull private String owner; - public MultiChannelMessageResponseDataChannelListInner() { + public MultiChannelChannelListRBMResponseObject() { } - public MultiChannelMessageResponseDataChannelListInner from(@javax.annotation.Nonnull String from) { + public MultiChannelChannelListRBMResponseObject from(@javax.annotation.Nonnull String from) { this.from = from; return this; } @@ -101,7 +101,7 @@ public void setFrom(@javax.annotation.Nonnull String from) { } - public MultiChannelMessageResponseDataChannelListInner applicationId(@javax.annotation.Nonnull String applicationId) { + public MultiChannelChannelListRBMResponseObject applicationId(@javax.annotation.Nonnull String applicationId) { this.applicationId = applicationId; return this; } @@ -120,7 +120,7 @@ public void setApplicationId(@javax.annotation.Nonnull String applicationId) { } - public MultiChannelMessageResponseDataChannelListInner channel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum channel) { + public MultiChannelChannelListRBMResponseObject channel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum channel) { this.channel = channel; return this; } @@ -139,7 +139,7 @@ public void setChannel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum } - public MultiChannelMessageResponseDataChannelListInner content(@javax.annotation.Nonnull MultiChannelChannelListObjectContent content) { + public MultiChannelChannelListRBMResponseObject content(@javax.annotation.Nonnull MultiChannelChannelListRBMObjectAllOfContent content) { this.content = content; return this; } @@ -149,16 +149,16 @@ public MultiChannelMessageResponseDataChannelListInner content(@javax.annotation * @return content */ @javax.annotation.Nonnull - public MultiChannelChannelListObjectContent getContent() { + public MultiChannelChannelListRBMObjectAllOfContent getContent() { return content; } - public void setContent(@javax.annotation.Nonnull MultiChannelChannelListObjectContent content) { + public void setContent(@javax.annotation.Nonnull MultiChannelChannelListRBMObjectAllOfContent content) { this.content = content; } - public MultiChannelMessageResponseDataChannelListInner owner(@javax.annotation.Nonnull String owner) { + public MultiChannelChannelListRBMResponseObject owner(@javax.annotation.Nonnull String owner) { this.owner = owner; return this; } @@ -189,9 +189,9 @@ public void setOwner(@javax.annotation.Nonnull String owner) { * * @param key name of the property * @param value value of the property - * @return the MultiChannelMessageResponseDataChannelListInner instance itself + * @return the MultiChannelChannelListRBMResponseObject instance itself */ - public MultiChannelMessageResponseDataChannelListInner putAdditionalProperty(String key, Object value) { + public MultiChannelChannelListRBMResponseObject putAdditionalProperty(String key, Object value) { if (this.additionalProperties == null) { this.additionalProperties = new HashMap(); } @@ -230,13 +230,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - MultiChannelMessageResponseDataChannelListInner multiChannelMessageResponseDataChannelListInner = (MultiChannelMessageResponseDataChannelListInner) o; - return Objects.equals(this.from, multiChannelMessageResponseDataChannelListInner.from) && - Objects.equals(this.applicationId, multiChannelMessageResponseDataChannelListInner.applicationId) && - Objects.equals(this.channel, multiChannelMessageResponseDataChannelListInner.channel) && - Objects.equals(this.content, multiChannelMessageResponseDataChannelListInner.content) && - Objects.equals(this.owner, multiChannelMessageResponseDataChannelListInner.owner)&& - Objects.equals(this.additionalProperties, multiChannelMessageResponseDataChannelListInner.additionalProperties); + MultiChannelChannelListRBMResponseObject multiChannelChannelListRBMResponseObject = (MultiChannelChannelListRBMResponseObject) o; + return Objects.equals(this.from, multiChannelChannelListRBMResponseObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListRBMResponseObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListRBMResponseObject.channel) && + Objects.equals(this.content, multiChannelChannelListRBMResponseObject.content) && + Objects.equals(this.owner, multiChannelChannelListRBMResponseObject.owner)&& + Objects.equals(this.additionalProperties, multiChannelChannelListRBMResponseObject.additionalProperties); } @Override @@ -247,7 +247,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class MultiChannelMessageResponseDataChannelListInner {\n"); + sb.append("class MultiChannelChannelListRBMResponseObject {\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"); @@ -285,17 +285,17 @@ private String toIndentedString(Object o) { * 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 MultiChannelMessageResponseDataChannelListInner + * @throws IOException if the JSON Element is invalid with respect to MultiChannelChannelListRBMResponseObject */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!MultiChannelMessageResponseDataChannelListInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelMessageResponseDataChannelListInner is not found in the empty JSON string", MultiChannelMessageResponseDataChannelListInner.openapiRequiredFields.toString())); + if (!MultiChannelChannelListRBMResponseObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListRBMResponseObject is not found in the empty JSON string", MultiChannelChannelListRBMResponseObject.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : MultiChannelMessageResponseDataChannelListInner.openapiRequiredFields) { + for (String requiredField : MultiChannelChannelListRBMResponseObject.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -310,7 +310,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the required field `channel` MultiChannelMessageChannelEnum.validateJsonElement(jsonObj.get("channel")); // validate the required field `content` - MultiChannelChannelListObjectContent.validateJsonElement(jsonObj.get("content")); + MultiChannelChannelListRBMObjectAllOfContent.validateJsonElement(jsonObj.get("content")); if (!jsonObj.get("owner").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); } @@ -320,16 +320,16 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!MultiChannelMessageResponseDataChannelListInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MultiChannelMessageResponseDataChannelListInner' and its subtypes + if (!MultiChannelChannelListRBMResponseObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListRBMResponseObject' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelMessageResponseDataChannelListInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListRBMResponseObject.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, MultiChannelMessageResponseDataChannelListInner value) throws IOException { + public void write(JsonWriter out, MultiChannelChannelListRBMResponseObject value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); obj.remove("additionalProperties"); // serialize additional properties @@ -357,12 +357,12 @@ else if (entry.getValue() instanceof Character) } @Override - public MultiChannelMessageResponseDataChannelListInner read(JsonReader in) throws IOException { + public MultiChannelChannelListRBMResponseObject read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); JsonObject jsonObj = jsonElement.getAsJsonObject(); // store additional fields in the deserialized instance - MultiChannelMessageResponseDataChannelListInner instance = thisAdapter.fromJsonTree(jsonObj); + MultiChannelChannelListRBMResponseObject instance = thisAdapter.fromJsonTree(jsonObj); for (Map.Entry entry : jsonObj.entrySet()) { if (!openapiFields.contains(entry.getKey())) { if (entry.getValue().isJsonPrimitive()) { // primitive type @@ -389,18 +389,18 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean()) } /** - * Create an instance of MultiChannelMessageResponseDataChannelListInner given an JSON string + * Create an instance of MultiChannelChannelListRBMResponseObject given an JSON string * * @param jsonString JSON string - * @return An instance of MultiChannelMessageResponseDataChannelListInner - * @throws IOException if the JSON string is invalid with respect to MultiChannelMessageResponseDataChannelListInner + * @return An instance of MultiChannelChannelListRBMResponseObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListRBMResponseObject */ - public static MultiChannelMessageResponseDataChannelListInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MultiChannelMessageResponseDataChannelListInner.class); + public static MultiChannelChannelListRBMResponseObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListRBMResponseObject.class); } /** - * Convert an instance of MultiChannelMessageResponseDataChannelListInner to an JSON string + * Convert an instance of MultiChannelChannelListRBMResponseObject to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRequestObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRequestObject.java new file mode 100644 index 00000000..01868e7e --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRequestObject.java @@ -0,0 +1,350 @@ +/* + * 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 java.util.Locale; +import com.bandwidth.sdk.model.MmsMessageContent; +import com.bandwidth.sdk.model.MultiChannelChannelListMMSObject; +import com.bandwidth.sdk.model.MultiChannelChannelListRBMObject; +import com.bandwidth.sdk.model.MultiChannelChannelListSMSObject; +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 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 java.util.Locale; + +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.17.0") +public class MultiChannelChannelListRequestObject extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(MultiChannelChannelListRequestObject.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListRequestObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListRequestObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterMultiChannelChannelListRBMObject = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListRBMObject.class)); + final TypeAdapter adapterMultiChannelChannelListSMSObject = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListSMSObject.class)); + final TypeAdapter adapterMultiChannelChannelListMMSObject = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListMMSObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListRequestObject value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `MultiChannelChannelListRBMObject` + if (value.getActualInstance() instanceof MultiChannelChannelListRBMObject) { + JsonElement element = adapterMultiChannelChannelListRBMObject.toJsonTree((MultiChannelChannelListRBMObject)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `MultiChannelChannelListSMSObject` + if (value.getActualInstance() instanceof MultiChannelChannelListSMSObject) { + JsonElement element = adapterMultiChannelChannelListSMSObject.toJsonTree((MultiChannelChannelListSMSObject)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `MultiChannelChannelListMMSObject` + if (value.getActualInstance() instanceof MultiChannelChannelListMMSObject) { + JsonElement element = adapterMultiChannelChannelListMMSObject.toJsonTree((MultiChannelChannelListMMSObject)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject"); + } + + @Override + public MultiChannelChannelListRequestObject read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + // use discriminator value for faster oneOf lookup + MultiChannelChannelListRequestObject newMultiChannelChannelListRequestObject = new MultiChannelChannelListRequestObject(); + if (jsonObject.get("channel") == null) { + log.log(Level.WARNING, "Failed to lookup discriminator value for MultiChannelChannelListRequestObject as `channel` was not found in the payload or the payload is empty."); + } else { + // look up the discriminator value in the field `channel` + switch (jsonObject.get("channel").getAsString()) { + case "MMS": + deserialized = adapterMultiChannelChannelListMMSObject.fromJsonTree(jsonObject); + newMultiChannelChannelListRequestObject.setActualInstance(deserialized); + return newMultiChannelChannelListRequestObject; + case "RBM": + deserialized = adapterMultiChannelChannelListRBMObject.fromJsonTree(jsonObject); + newMultiChannelChannelListRequestObject.setActualInstance(deserialized); + return newMultiChannelChannelListRequestObject; + case "SMS": + deserialized = adapterMultiChannelChannelListSMSObject.fromJsonTree(jsonObject); + newMultiChannelChannelListRequestObject.setActualInstance(deserialized); + return newMultiChannelChannelListRequestObject; + default: + log.log(Level.WARNING, String.format(Locale.ROOT, "Failed to lookup discriminator value `%s` for MultiChannelChannelListRequestObject. Possible values: MMS RBM SMS", jsonObject.get("channel").getAsString())); + } + } + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize MultiChannelChannelListRBMObject + try { + // validate the JSON object to see if any exception is thrown + MultiChannelChannelListRBMObject.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelChannelListRBMObject; + match++; + log.log(Level.FINER, "Input data matches schema 'MultiChannelChannelListRBMObject'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListRBMObject failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListRBMObject'", e); + } + // deserialize MultiChannelChannelListSMSObject + try { + // validate the JSON object to see if any exception is thrown + MultiChannelChannelListSMSObject.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelChannelListSMSObject; + match++; + log.log(Level.FINER, "Input data matches schema 'MultiChannelChannelListSMSObject'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListSMSObject failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListSMSObject'", e); + } + // deserialize MultiChannelChannelListMMSObject + try { + // validate the JSON object to see if any exception is thrown + MultiChannelChannelListMMSObject.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelChannelListMMSObject; + match++; + log.log(Level.FINER, "Input data matches schema 'MultiChannelChannelListMMSObject'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListMMSObject failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListMMSObject'", e); + } + + if (match == 1) { + MultiChannelChannelListRequestObject ret = new MultiChannelChannelListRequestObject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException(String.format(Locale.ROOT, "Failed deserialization for MultiChannelChannelListRequestObject: %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 MultiChannelChannelListRequestObject() { + super("oneOf", Boolean.FALSE); + } + + public MultiChannelChannelListRequestObject(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("MultiChannelChannelListRBMObject", MultiChannelChannelListRBMObject.class); + schemas.put("MultiChannelChannelListSMSObject", MultiChannelChannelListSMSObject.class); + schemas.put("MultiChannelChannelListMMSObject", MultiChannelChannelListMMSObject.class); + } + + @Override + public Map> getSchemas() { + return MultiChannelChannelListRequestObject.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject + * + * It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof MultiChannelChannelListRBMObject) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MultiChannelChannelListSMSObject) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MultiChannelChannelListMMSObject) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject"); + } + + /** + * Get the actual instance, which can be the following: + * MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject + * + * @return The actual instance (MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelChannelListRBMObject`. If the actual instance is not `MultiChannelChannelListRBMObject`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelChannelListRBMObject` + * @throws ClassCastException if the instance is not `MultiChannelChannelListRBMObject` + */ + public MultiChannelChannelListRBMObject getMultiChannelChannelListRBMObject() throws ClassCastException { + return (MultiChannelChannelListRBMObject)super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelChannelListSMSObject`. If the actual instance is not `MultiChannelChannelListSMSObject`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelChannelListSMSObject` + * @throws ClassCastException if the instance is not `MultiChannelChannelListSMSObject` + */ + public MultiChannelChannelListSMSObject getMultiChannelChannelListSMSObject() throws ClassCastException { + return (MultiChannelChannelListSMSObject)super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelChannelListMMSObject`. If the actual instance is not `MultiChannelChannelListMMSObject`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelChannelListMMSObject` + * @throws ClassCastException if the instance is not `MultiChannelChannelListMMSObject` + */ + public MultiChannelChannelListMMSObject getMultiChannelChannelListMMSObject() throws ClassCastException { + return (MultiChannelChannelListMMSObject)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 MultiChannelChannelListRequestObject + */ + 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 MultiChannelChannelListRBMObject + try { + MultiChannelChannelListRBMObject.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListRBMObject failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with MultiChannelChannelListSMSObject + try { + MultiChannelChannelListSMSObject.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListSMSObject failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with MultiChannelChannelListMMSObject + try { + MultiChannelChannelListMMSObject.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListMMSObject failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for MultiChannelChannelListRequestObject with oneOf schemas: MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject. %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 MultiChannelChannelListRequestObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListRequestObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListRequestObject + */ + public static MultiChannelChannelListRequestObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListRequestObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListRequestObject 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/MultiChannelChannelListResponseObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListResponseObject.java new file mode 100644 index 00000000..4d913bd2 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListResponseObject.java @@ -0,0 +1,344 @@ +/* + * 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 java.util.Locale; +import com.bandwidth.sdk.model.MmsMessageContent; +import com.bandwidth.sdk.model.MultiChannelChannelListMMSResponseObject; +import com.bandwidth.sdk.model.MultiChannelChannelListRBMResponseObject; +import com.bandwidth.sdk.model.MultiChannelChannelListSMSResponseObject; +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 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 java.util.Locale; + +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.17.0") +public class MultiChannelChannelListResponseObject extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(MultiChannelChannelListResponseObject.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListResponseObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListResponseObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterMultiChannelChannelListRBMResponseObject = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListRBMResponseObject.class)); + final TypeAdapter adapterMultiChannelChannelListSMSResponseObject = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListSMSResponseObject.class)); + final TypeAdapter adapterMultiChannelChannelListMMSResponseObject = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListMMSResponseObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListResponseObject value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `MultiChannelChannelListRBMResponseObject` + if (value.getActualInstance() instanceof MultiChannelChannelListRBMResponseObject) { + JsonElement element = adapterMultiChannelChannelListRBMResponseObject.toJsonTree((MultiChannelChannelListRBMResponseObject)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `MultiChannelChannelListSMSResponseObject` + if (value.getActualInstance() instanceof MultiChannelChannelListSMSResponseObject) { + JsonElement element = adapterMultiChannelChannelListSMSResponseObject.toJsonTree((MultiChannelChannelListSMSResponseObject)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `MultiChannelChannelListMMSResponseObject` + if (value.getActualInstance() instanceof MultiChannelChannelListMMSResponseObject) { + JsonElement element = adapterMultiChannelChannelListMMSResponseObject.toJsonTree((MultiChannelChannelListMMSResponseObject)value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: MultiChannelChannelListMMSResponseObject, MultiChannelChannelListRBMResponseObject, MultiChannelChannelListSMSResponseObject"); + } + + @Override + public MultiChannelChannelListResponseObject read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + // use discriminator value for faster oneOf lookup + MultiChannelChannelListResponseObject newMultiChannelChannelListResponseObject = new MultiChannelChannelListResponseObject(); + if (jsonObject.get("channel") == null) { + log.log(Level.WARNING, "Failed to lookup discriminator value for MultiChannelChannelListResponseObject as `channel` was not found in the payload or the payload is empty."); + } else { + // look up the discriminator value in the field `channel` + switch (jsonObject.get("channel").getAsString()) { + case "MMS": + deserialized = adapterMultiChannelChannelListMMSResponseObject.fromJsonTree(jsonObject); + newMultiChannelChannelListResponseObject.setActualInstance(deserialized); + return newMultiChannelChannelListResponseObject; + case "RBM": + deserialized = adapterMultiChannelChannelListRBMResponseObject.fromJsonTree(jsonObject); + newMultiChannelChannelListResponseObject.setActualInstance(deserialized); + return newMultiChannelChannelListResponseObject; + case "SMS": + deserialized = adapterMultiChannelChannelListSMSResponseObject.fromJsonTree(jsonObject); + newMultiChannelChannelListResponseObject.setActualInstance(deserialized); + return newMultiChannelChannelListResponseObject; + default: + log.log(Level.WARNING, String.format(Locale.ROOT, "Failed to lookup discriminator value `%s` for MultiChannelChannelListResponseObject. Possible values: MMS RBM SMS", jsonObject.get("channel").getAsString())); + } + } + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize MultiChannelChannelListRBMResponseObject + try { + // validate the JSON object to see if any exception is thrown + MultiChannelChannelListRBMResponseObject.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelChannelListRBMResponseObject; + MultiChannelChannelListResponseObject ret = new MultiChannelChannelListResponseObject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListRBMResponseObject failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListRBMResponseObject'", e); + } + // deserialize MultiChannelChannelListSMSResponseObject + try { + // validate the JSON object to see if any exception is thrown + MultiChannelChannelListSMSResponseObject.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelChannelListSMSResponseObject; + MultiChannelChannelListResponseObject ret = new MultiChannelChannelListResponseObject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListSMSResponseObject failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListSMSResponseObject'", e); + } + // deserialize MultiChannelChannelListMMSResponseObject + try { + // validate the JSON object to see if any exception is thrown + MultiChannelChannelListMMSResponseObject.validateJsonElement(jsonElement); + actualAdapter = adapterMultiChannelChannelListMMSResponseObject; + MultiChannelChannelListResponseObject ret = new MultiChannelChannelListResponseObject(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListMMSResponseObject failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListMMSResponseObject'", e); + } + + throw new IOException(String.format(Locale.ROOT, "Failed deserialization for MultiChannelChannelListResponseObject: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map> schemas = new HashMap>(); + + public MultiChannelChannelListResponseObject() { + super("anyOf", Boolean.FALSE); + } + + public MultiChannelChannelListResponseObject(Object o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("MultiChannelChannelListRBMResponseObject", MultiChannelChannelListRBMResponseObject.class); + schemas.put("MultiChannelChannelListSMSResponseObject", MultiChannelChannelListSMSResponseObject.class); + schemas.put("MultiChannelChannelListMMSResponseObject", MultiChannelChannelListMMSResponseObject.class); + } + + @Override + public Map> getSchemas() { + return MultiChannelChannelListResponseObject.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * MultiChannelChannelListMMSResponseObject, MultiChannelChannelListRBMResponseObject, MultiChannelChannelListSMSResponseObject + * + * It could be an instance of the 'anyOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof MultiChannelChannelListRBMResponseObject) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MultiChannelChannelListSMSResponseObject) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof MultiChannelChannelListMMSResponseObject) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MultiChannelChannelListMMSResponseObject, MultiChannelChannelListRBMResponseObject, MultiChannelChannelListSMSResponseObject"); + } + + /** + * Get the actual instance, which can be the following: + * MultiChannelChannelListMMSResponseObject, MultiChannelChannelListRBMResponseObject, MultiChannelChannelListSMSResponseObject + * + * @return The actual instance (MultiChannelChannelListMMSResponseObject, MultiChannelChannelListRBMResponseObject, MultiChannelChannelListSMSResponseObject) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelChannelListRBMResponseObject`. If the actual instance is not `MultiChannelChannelListRBMResponseObject`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelChannelListRBMResponseObject` + * @throws ClassCastException if the instance is not `MultiChannelChannelListRBMResponseObject` + */ + public MultiChannelChannelListRBMResponseObject getMultiChannelChannelListRBMResponseObject() throws ClassCastException { + return (MultiChannelChannelListRBMResponseObject)super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelChannelListSMSResponseObject`. If the actual instance is not `MultiChannelChannelListSMSResponseObject`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelChannelListSMSResponseObject` + * @throws ClassCastException if the instance is not `MultiChannelChannelListSMSResponseObject` + */ + public MultiChannelChannelListSMSResponseObject getMultiChannelChannelListSMSResponseObject() throws ClassCastException { + return (MultiChannelChannelListSMSResponseObject)super.getActualInstance(); + } + + /** + * Get the actual instance of `MultiChannelChannelListMMSResponseObject`. If the actual instance is not `MultiChannelChannelListMMSResponseObject`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MultiChannelChannelListMMSResponseObject` + * @throws ClassCastException if the instance is not `MultiChannelChannelListMMSResponseObject` + */ + public MultiChannelChannelListMMSResponseObject getMultiChannelChannelListMMSResponseObject() throws ClassCastException { + return (MultiChannelChannelListMMSResponseObject)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 MultiChannelChannelListResponseObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate anyOf schemas one by one + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with MultiChannelChannelListRBMResponseObject + try { + MultiChannelChannelListRBMResponseObject.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListRBMResponseObject failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with MultiChannelChannelListSMSResponseObject + try { + MultiChannelChannelListSMSResponseObject.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListSMSResponseObject failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with MultiChannelChannelListMMSResponseObject + try { + MultiChannelChannelListMMSResponseObject.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListMMSResponseObject failed with `%s`.", e.getMessage())); + // continue to the next one + } + throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for MultiChannelChannelListResponseObject with anyOf schemas: MultiChannelChannelListMMSResponseObject, MultiChannelChannelListRBMResponseObject, MultiChannelChannelListSMSResponseObject. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + } + + /** + * Create an instance of MultiChannelChannelListResponseObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListResponseObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListResponseObject + */ + public static MultiChannelChannelListResponseObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListResponseObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListResponseObject 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/MultiChannelChannelListSMSObject.java similarity index 81% rename from src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObject.java rename to src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSObject.java index d17f30f2..e844b776 100644 --- a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListObject.java +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSObject.java @@ -15,8 +15,8 @@ import java.util.Objects; import java.util.Locale; -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; +import com.bandwidth.sdk.model.SmsMessageContent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -50,10 +50,10 @@ import com.bandwidth.sdk.JSON; /** - * MultiChannelChannelListObject + * MultiChannelChannelListSMSObject */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") -public class MultiChannelChannelListObject { +public class MultiChannelChannelListSMSObject { public static final String SERIALIZED_NAME_FROM = "from"; @SerializedName(SERIALIZED_NAME_FROM) @javax.annotation.Nonnull @@ -72,12 +72,12 @@ public class MultiChannelChannelListObject { public static final String SERIALIZED_NAME_CONTENT = "content"; @SerializedName(SERIALIZED_NAME_CONTENT) @javax.annotation.Nonnull - private MultiChannelChannelListObjectContent content; + private SmsMessageContent content; - public MultiChannelChannelListObject() { + public MultiChannelChannelListSMSObject() { } - public MultiChannelChannelListObject from(@javax.annotation.Nonnull String from) { + public MultiChannelChannelListSMSObject from(@javax.annotation.Nonnull String from) { this.from = from; return this; } @@ -96,7 +96,7 @@ public void setFrom(@javax.annotation.Nonnull String from) { } - public MultiChannelChannelListObject applicationId(@javax.annotation.Nonnull String applicationId) { + public MultiChannelChannelListSMSObject applicationId(@javax.annotation.Nonnull String applicationId) { this.applicationId = applicationId; return this; } @@ -115,7 +115,7 @@ public void setApplicationId(@javax.annotation.Nonnull String applicationId) { } - public MultiChannelChannelListObject channel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum channel) { + public MultiChannelChannelListSMSObject channel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum channel) { this.channel = channel; return this; } @@ -134,7 +134,7 @@ public void setChannel(@javax.annotation.Nonnull MultiChannelMessageChannelEnum } - public MultiChannelChannelListObject content(@javax.annotation.Nonnull MultiChannelChannelListObjectContent content) { + public MultiChannelChannelListSMSObject content(@javax.annotation.Nonnull SmsMessageContent content) { this.content = content; return this; } @@ -144,11 +144,11 @@ public MultiChannelChannelListObject content(@javax.annotation.Nonnull MultiChan * @return content */ @javax.annotation.Nonnull - public MultiChannelChannelListObjectContent getContent() { + public SmsMessageContent getContent() { return content; } - public void setContent(@javax.annotation.Nonnull MultiChannelChannelListObjectContent content) { + public void setContent(@javax.annotation.Nonnull SmsMessageContent content) { this.content = content; } @@ -165,9 +165,9 @@ public void setContent(@javax.annotation.Nonnull MultiChannelChannelListObjectCo * * @param key name of the property * @param value value of the property - * @return the MultiChannelChannelListObject instance itself + * @return the MultiChannelChannelListSMSObject instance itself */ - public MultiChannelChannelListObject putAdditionalProperty(String key, Object value) { + public MultiChannelChannelListSMSObject putAdditionalProperty(String key, Object value) { if (this.additionalProperties == null) { this.additionalProperties = new HashMap(); } @@ -206,12 +206,12 @@ public boolean equals(Object o) { 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); + MultiChannelChannelListSMSObject multiChannelChannelListSMSObject = (MultiChannelChannelListSMSObject) o; + return Objects.equals(this.from, multiChannelChannelListSMSObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListSMSObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListSMSObject.channel) && + Objects.equals(this.content, multiChannelChannelListSMSObject.content)&& + Objects.equals(this.additionalProperties, multiChannelChannelListSMSObject.additionalProperties); } @Override @@ -222,7 +222,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class MultiChannelChannelListObject {\n"); + sb.append("class MultiChannelChannelListSMSObject {\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"); @@ -259,17 +259,17 @@ private String toIndentedString(Object o) { * 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 + * @throws IOException if the JSON Element is invalid with respect to MultiChannelChannelListSMSObject */ 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(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListObject is not found in the empty JSON string", MultiChannelChannelListObject.openapiRequiredFields.toString())); + if (!MultiChannelChannelListSMSObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListSMSObject is not found in the empty JSON string", MultiChannelChannelListSMSObject.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : MultiChannelChannelListObject.openapiRequiredFields) { + for (String requiredField : MultiChannelChannelListSMSObject.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -284,23 +284,23 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the required field `channel` MultiChannelMessageChannelEnum.validateJsonElement(jsonObj.get("channel")); // validate the required field `content` - MultiChannelChannelListObjectContent.validateJsonElement(jsonObj.get("content")); + SmsMessageContent.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 + if (!MultiChannelChannelListSMSObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListSMSObject' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListObject.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListSMSObject.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, MultiChannelChannelListObject value) throws IOException { + public void write(JsonWriter out, MultiChannelChannelListSMSObject value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); obj.remove("additionalProperties"); // serialize additional properties @@ -328,12 +328,12 @@ else if (entry.getValue() instanceof Character) } @Override - public MultiChannelChannelListObject read(JsonReader in) throws IOException { + public MultiChannelChannelListSMSObject 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); + MultiChannelChannelListSMSObject instance = thisAdapter.fromJsonTree(jsonObj); for (Map.Entry entry : jsonObj.entrySet()) { if (!openapiFields.contains(entry.getKey())) { if (entry.getValue().isJsonPrimitive()) { // primitive type @@ -360,18 +360,18 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean()) } /** - * Create an instance of MultiChannelChannelListObject given an JSON string + * Create an instance of MultiChannelChannelListSMSObject 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 + * @return An instance of MultiChannelChannelListSMSObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListSMSObject */ - public static MultiChannelChannelListObject fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MultiChannelChannelListObject.class); + public static MultiChannelChannelListSMSObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListSMSObject.class); } /** - * Convert an instance of MultiChannelChannelListObject to an JSON string + * Convert an instance of MultiChannelChannelListSMSObject to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSResponseObject.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSResponseObject.java new file mode 100644 index 00000000..4e481200 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListSMSResponseObject.java @@ -0,0 +1,411 @@ +/* + * 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 java.util.Locale; +import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; +import com.bandwidth.sdk.model.SmsMessageContent; +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 java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * MultiChannelChannelListSMSResponseObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class MultiChannelChannelListSMSResponseObject { + 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 SmsMessageContent content; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + @javax.annotation.Nonnull + private String owner; + + public MultiChannelChannelListSMSResponseObject() { + } + + public MultiChannelChannelListSMSResponseObject 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 MultiChannelChannelListSMSResponseObject 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 MultiChannelChannelListSMSResponseObject 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 MultiChannelChannelListSMSResponseObject content(@javax.annotation.Nonnull SmsMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * @return content + */ + @javax.annotation.Nonnull + public SmsMessageContent getContent() { + return content; + } + + public void setContent(@javax.annotation.Nonnull SmsMessageContent content) { + this.content = content; + } + + + public MultiChannelChannelListSMSResponseObject owner(@javax.annotation.Nonnull String owner) { + this.owner = owner; + return this; + } + + /** + * The Bandwidth senderId associated with the message. Identical to 'from'. + * @return owner + */ + @javax.annotation.Nonnull + public String getOwner() { + return owner; + } + + public void setOwner(@javax.annotation.Nonnull String owner) { + this.owner = owner; + } + + /** + * 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 MultiChannelChannelListSMSResponseObject instance itself + */ + public MultiChannelChannelListSMSResponseObject 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; + } + MultiChannelChannelListSMSResponseObject multiChannelChannelListSMSResponseObject = (MultiChannelChannelListSMSResponseObject) o; + return Objects.equals(this.from, multiChannelChannelListSMSResponseObject.from) && + Objects.equals(this.applicationId, multiChannelChannelListSMSResponseObject.applicationId) && + Objects.equals(this.channel, multiChannelChannelListSMSResponseObject.channel) && + Objects.equals(this.content, multiChannelChannelListSMSResponseObject.content) && + Objects.equals(this.owner, multiChannelChannelListSMSResponseObject.owner)&& + Objects.equals(this.additionalProperties, multiChannelChannelListSMSResponseObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, applicationId, channel, content, owner, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultiChannelChannelListSMSResponseObject {\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(" owner: ").append(toIndentedString(owner)).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(Arrays.asList("from", "applicationId", "channel", "content", "owner")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("from", "applicationId", "channel", "content", "owner")); + } + + /** + * 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 MultiChannelChannelListSMSResponseObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MultiChannelChannelListSMSResponseObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MultiChannelChannelListSMSResponseObject is not found in the empty JSON string", MultiChannelChannelListSMSResponseObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MultiChannelChannelListSMSResponseObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "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(Locale.ROOT, "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(Locale.ROOT, "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` + SmsMessageContent.validateJsonElement(jsonObj.get("content")); + if (!jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MultiChannelChannelListSMSResponseObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MultiChannelChannelListSMSResponseObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MultiChannelChannelListSMSResponseObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MultiChannelChannelListSMSResponseObject 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 MultiChannelChannelListSMSResponseObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MultiChannelChannelListSMSResponseObject 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(Locale.ROOT, "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 MultiChannelChannelListSMSResponseObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of MultiChannelChannelListSMSResponseObject + * @throws IOException if the JSON string is invalid with respect to MultiChannelChannelListSMSResponseObject + */ + public static MultiChannelChannelListSMSResponseObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MultiChannelChannelListSMSResponseObject.class); + } + + /** + * Convert an instance of MultiChannelChannelListSMSResponseObject 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/MultiChannelMessageRequest.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java index 05527864..4931bafc 100644 --- a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java @@ -15,7 +15,7 @@ import java.util.Objects; import java.util.Locale; -import com.bandwidth.sdk.model.MultiChannelChannelListObject; +import com.bandwidth.sdk.model.MultiChannelChannelListRequestObject; import com.bandwidth.sdk.model.PriorityEnum; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -65,7 +65,7 @@ public class MultiChannelMessageRequest { public static final String SERIALIZED_NAME_CHANNEL_LIST = "channelList"; @SerializedName(SERIALIZED_NAME_CHANNEL_LIST) @javax.annotation.Nonnull - private List channelList = new ArrayList<>(); + private List channelList = new ArrayList<>(); public static final String SERIALIZED_NAME_TAG = "tag"; @SerializedName(SERIALIZED_NAME_TAG) @@ -104,12 +104,12 @@ public void setTo(@javax.annotation.Nonnull String to) { } - public MultiChannelMessageRequest channelList(@javax.annotation.Nonnull List channelList) { + public MultiChannelMessageRequest channelList(@javax.annotation.Nonnull List channelList) { this.channelList = channelList; return this; } - public MultiChannelMessageRequest addChannelListItem(MultiChannelChannelListObject channelListItem) { + public MultiChannelMessageRequest addChannelListItem(MultiChannelChannelListRequestObject channelListItem) { if (this.channelList == null) { this.channelList = new ArrayList<>(); } @@ -122,11 +122,11 @@ public MultiChannelMessageRequest addChannelListItem(MultiChannelChannelListObje * @return channelList */ @javax.annotation.Nonnull - public List getChannelList() { + public List getChannelList() { return channelList; } - public void setChannelList(@javax.annotation.Nonnull List channelList) { + public void setChannelList(@javax.annotation.Nonnull List channelList) { this.channelList = channelList; } @@ -323,7 +323,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArraychannelList = jsonObj.getAsJsonArray("channelList"); // validate the required field `channelList` (array) for (int i = 0; i < jsonArraychannelList.size(); i++) { - MultiChannelChannelListObject.validateJsonElement(jsonArraychannelList.get(i)); + MultiChannelChannelListRequestObject.validateJsonElement(jsonArraychannelList.get(i)); }; if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); diff --git a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseData.java b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseData.java index fd7b3ac5..09fc2dcd 100644 --- a/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseData.java +++ b/src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseData.java @@ -16,7 +16,7 @@ import java.util.Objects; import java.util.Locale; import com.bandwidth.sdk.model.MessageDirectionEnum; -import com.bandwidth.sdk.model.MultiChannelMessageResponseDataChannelListInner; +import com.bandwidth.sdk.model.MultiChannelChannelListResponseObject; import com.bandwidth.sdk.model.PriorityEnum; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -83,7 +83,7 @@ public class MultiChannelMessageResponseData { public static final String SERIALIZED_NAME_CHANNEL_LIST = "channelList"; @SerializedName(SERIALIZED_NAME_CHANNEL_LIST) @javax.annotation.Nonnull - private List channelList = new ArrayList<>(); + private List channelList = new ArrayList<>(); public static final String SERIALIZED_NAME_TAG = "tag"; @SerializedName(SERIALIZED_NAME_TAG) @@ -187,12 +187,12 @@ public void setTo(@javax.annotation.Nonnull Set to) { } - public MultiChannelMessageResponseData channelList(@javax.annotation.Nonnull List channelList) { + public MultiChannelMessageResponseData channelList(@javax.annotation.Nonnull List channelList) { this.channelList = channelList; return this; } - public MultiChannelMessageResponseData addChannelListItem(MultiChannelMessageResponseDataChannelListInner channelListItem) { + public MultiChannelMessageResponseData addChannelListItem(MultiChannelChannelListResponseObject channelListItem) { if (this.channelList == null) { this.channelList = new ArrayList<>(); } @@ -205,11 +205,11 @@ public MultiChannelMessageResponseData addChannelListItem(MultiChannelMessageRes * @return channelList */ @javax.annotation.Nonnull - public List getChannelList() { + public List getChannelList() { return channelList; } - public void setChannelList(@javax.annotation.Nonnull List channelList) { + public void setChannelList(@javax.annotation.Nonnull List channelList) { this.channelList = channelList; } @@ -420,7 +420,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArraychannelList = jsonObj.getAsJsonArray("channelList"); // validate the required field `channelList` (array) for (int i = 0; i < jsonArraychannelList.size(); i++) { - MultiChannelMessageResponseDataChannelListInner.validateJsonElement(jsonArraychannelList.get(i)); + MultiChannelChannelListResponseObject.validateJsonElement(jsonArraychannelList.get(i)); }; if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); diff --git a/src/test/java/com/bandwidth/sdk/smoke/MultiChannelApiTest.java b/src/test/java/com/bandwidth/sdk/smoke/MultiChannelApiTest.java index d3ffc233..b77e06b4 100644 --- a/src/test/java/com/bandwidth/sdk/smoke/MultiChannelApiTest.java +++ b/src/test/java/com/bandwidth/sdk/smoke/MultiChannelApiTest.java @@ -7,8 +7,12 @@ import com.bandwidth.sdk.api.MultiChannelApi; import com.bandwidth.sdk.auth.HttpBasicAuth; import com.bandwidth.sdk.model.MmsMessageContent; -import com.bandwidth.sdk.model.MultiChannelChannelListObject; -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; +import com.bandwidth.sdk.model.MmsMessageContentFile; +import com.bandwidth.sdk.model.MultiChannelChannelListMMSObject; +// import com.bandwidth.sdk.model.MultiChannelChannelListObject; +// import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; +import com.bandwidth.sdk.model.MultiChannelChannelListRequestObject; +import com.bandwidth.sdk.model.MultiChannelChannelListSMSObject; import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; import com.bandwidth.sdk.model.MultiChannelMessageRequest; import com.bandwidth.sdk.model.PriorityEnum; @@ -42,14 +46,29 @@ public static void setUp() { } @Test - @Disabled + // @Disabled public void createMultiChannelMessageTest() throws ApiException { - MultiChannelChannelListObject channelListObject = new MultiChannelChannelListObject() - .from(BW_NUMBER) - .applicationId(BW_MESSAGING_APPLICATION_ID) - .channel(MultiChannelMessageChannelEnum.RBM) - .content(new MultiChannelChannelListObjectContent(new RbmMessageContentText() - .text("Hello World!"))); + MultiChannelChannelListRequestObject channelListObject = new MultiChannelChannelListRequestObject( + new MultiChannelChannelListSMSObject() + .from(BW_NUMBER) + .applicationId(BW_MESSAGING_APPLICATION_ID) + .channel(MultiChannelMessageChannelEnum.MMS) + // .content(new MmsMessageContent() + // .media(Arrays.asList(new MmsMessageContentFile() + // .fileUrl(URI.create("https://www.example.com/image.png")) + // )) + // .text("Hello World!") + // ) + .content(new SmsMessageContent().text("Hello World!")) + ); + // MultiChannelChannelListObject channelListObject = new MultiChannelChannelListObject() + // .from(BW_NUMBER) + // .applicationId(BW_MESSAGING_APPLICATION_ID) + // .channel(MultiChannelMessageChannelEnum.SMS) + // .content(new MultiChannelChannelListObjectContent( + // new SmsMessageContent().text("Hello World!") + // )); + MultiChannelMessageRequest multiChannelMessageRequest = new MultiChannelMessageRequest() .to(USER_NUMBER) .tag("tag") @@ -60,6 +79,7 @@ public void createMultiChannelMessageTest() throws ApiException { ApiResponse response = api.createMultiChannelMessageWithHttpInfo(BW_ACCOUNT_ID, multiChannelMessageRequest); + System.out.println(response.getData()); assertThat(response.getStatusCode(), is(202)); } diff --git a/src/test/java/com/bandwidth/sdk/smoke/PhoneNumberLookupApiTest.java b/src/test/java/com/bandwidth/sdk/smoke/PhoneNumberLookupApiTest.java index 296415bb..40730b7e 100644 --- a/src/test/java/com/bandwidth/sdk/smoke/PhoneNumberLookupApiTest.java +++ b/src/test/java/com/bandwidth/sdk/smoke/PhoneNumberLookupApiTest.java @@ -15,7 +15,6 @@ import com.bandwidth.sdk.model.GetAsyncBulkLookupResponse; import com.bandwidth.sdk.model.GetAsyncBulkLookupResponseData; import com.bandwidth.sdk.model.InProgressLookupStatusEnum; -import com.bandwidth.sdk.model.LatestMessageDeliveryStatusEnum; import com.bandwidth.sdk.model.LineTypeEnum; import com.bandwidth.sdk.model.LinkSchema; import com.bandwidth.sdk.model.LookupResult; @@ -23,7 +22,6 @@ import org.junit.jupiter.api.Test; -import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.UUID; diff --git a/src/test/java/com/bandwidth/sdk/unit/api/MultiChannelApiTest.java b/src/test/java/com/bandwidth/sdk/unit/api/MultiChannelApiTest.java index 64a0dbca..9832fc8e 100644 --- a/src/test/java/com/bandwidth/sdk/unit/api/MultiChannelApiTest.java +++ b/src/test/java/com/bandwidth/sdk/unit/api/MultiChannelApiTest.java @@ -6,9 +6,8 @@ import com.bandwidth.sdk.Configuration; import com.bandwidth.sdk.api.MultiChannelApi; import com.bandwidth.sdk.auth.HttpBasicAuth; -import com.bandwidth.sdk.model.CreateMultiChannelMessageResponse; -import com.bandwidth.sdk.model.MultiChannelChannelListObject; -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; +// import com.bandwidth.sdk.model.MultiChannelChannelListObject; +// import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; import com.bandwidth.sdk.model.MultiChannelMessageRequest; import com.bandwidth.sdk.model.PriorityEnum; @@ -36,26 +35,26 @@ public static void setUp() { api.setCustomBaseUrl("http://127.0.0.1:4010"); } - @Test - @Disabled // skip because prism can't handle a oneOf with differing required fields - public void createMultiChannelMessageTest() throws ApiException { - MultiChannelChannelListObject channelListObject = new MultiChannelChannelListObject() - .from(BW_NUMBER) - .applicationId(BW_MESSAGING_APPLICATION_ID) - .channel(MultiChannelMessageChannelEnum.SMS) - .content(new MultiChannelChannelListObjectContent(new SmsMessageContent() - .text("Hello World!"))); - MultiChannelMessageRequest multiChannelMessageRequest = new MultiChannelMessageRequest() - .to(USER_NUMBER) - .tag("tag") - .priority(PriorityEnum.DEFAULT) - .expiration(OffsetDateTime.now()); - - multiChannelMessageRequest.addChannelListItem(channelListObject); - - ApiResponse response = - api.createMultiChannelMessageWithHttpInfo(BW_ACCOUNT_ID, multiChannelMessageRequest); - assertThat(response.getStatusCode(), is(202)); - } + // @Test + // @Disabled // skip because prism can't handle a oneOf with differing required fields + // public void createMultiChannelMessageTest() throws ApiException { + // MultiChannelChannelListObject channelListObject = new MultiChannelChannelListObject() + // .from(BW_NUMBER) + // .applicationId(BW_MESSAGING_APPLICATION_ID) + // .channel(MultiChannelMessageChannelEnum.SMS) + // .content(new MultiChannelChannelListObjectContent(new SmsMessageContent() + // .text("Hello World!"))); + // MultiChannelMessageRequest multiChannelMessageRequest = new MultiChannelMessageRequest() + // .to(USER_NUMBER) + // .tag("tag") + // .priority(PriorityEnum.DEFAULT) + // .expiration(OffsetDateTime.now()); + + // multiChannelMessageRequest.addChannelListItem(channelListObject); + + // ApiResponse response = + // api.createMultiChannelMessageWithHttpInfo(BW_ACCOUNT_ID, multiChannelMessageRequest); + // assertThat(response.getStatusCode(), is(202)); + // } } diff --git a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelChannelListObjectContentTest.java b/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelChannelListObjectContentTest.java deleted file mode 100644 index 28060099..00000000 --- a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelChannelListObjectContentTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.unit.models; - -import org.junit.jupiter.api.Test; - -import com.bandwidth.sdk.model.MmsMessageContent; -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; -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 static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.CoreMatchers.instanceOf; -/** - * Model tests for MultiChannelChannelListObjectContent - */ -public class MultiChannelChannelListObjectContentTest { - private final MultiChannelChannelListObjectContent modelRbmMessageContentText = - new MultiChannelChannelListObjectContent(new RbmMessageContentText()); - private final MultiChannelChannelListObjectContent modelRbmMessageMedia = - new MultiChannelChannelListObjectContent(new RbmMessageMedia()); - private final MultiChannelChannelListObjectContent modelRbmMessageContentRichCard = - new MultiChannelChannelListObjectContent(new RbmMessageContentRichCard()); - private final MultiChannelChannelListObjectContent modelSmsMessageContent = - new MultiChannelChannelListObjectContent(new SmsMessageContent()); - private final MultiChannelChannelListObjectContent modelMmsMessageContent = - new MultiChannelChannelListObjectContent(new MmsMessageContent()); - - /** - * Model tests for MultiChannelChannelListObjectContent - */ - @Test - public void testMultiChannelChannelListObjectContent() { - assertThat(modelRbmMessageContentText, instanceOf(MultiChannelChannelListObjectContent.class)); - assertThat(modelRbmMessageContentText.getActualInstance(), instanceOf(RbmMessageContentText.class)); - assertThat(modelRbmMessageMedia, instanceOf(MultiChannelChannelListObjectContent.class)); - assertThat(modelRbmMessageMedia.getActualInstance(), instanceOf(RbmMessageMedia.class)); - assertThat(modelRbmMessageContentRichCard, instanceOf(MultiChannelChannelListObjectContent.class)); - assertThat(modelRbmMessageContentRichCard.getActualInstance(), instanceOf(RbmMessageContentRichCard.class)); - assertThat(modelSmsMessageContent, instanceOf(MultiChannelChannelListObjectContent.class)); - assertThat(modelSmsMessageContent.getActualInstance(), instanceOf(SmsMessageContent.class)); - assertThat(modelMmsMessageContent, instanceOf(MultiChannelChannelListObjectContent.class)); - assertThat(modelMmsMessageContent.getActualInstance(), instanceOf(MmsMessageContent.class)); - } - -} diff --git a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelChannelListObjectTest.java b/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelChannelListObjectTest.java deleted file mode 100644 index 9f432657..00000000 --- a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelChannelListObjectTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.unit.models; - -import org.junit.jupiter.api.Test; - -import com.bandwidth.sdk.model.MultiChannelChannelListObject; -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; -import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.CoreMatchers.instanceOf; - -/** - * Model tests for MultiChannelChannelListObject - */ -public class MultiChannelChannelListObjectTest { - private final MultiChannelChannelListObject model = new MultiChannelChannelListObject() - .from("from") - .applicationId("applicationId") - .channel(MultiChannelMessageChannelEnum.SMS) - .content(new MultiChannelChannelListObjectContent()); - - /** - * Model tests for MultiChannelChannelListObject - */ - @Test - public void testMultiChannelChannelListObject() { - assertThat(model, instanceOf(MultiChannelChannelListObject.class)); - } - - /** - * Test the property 'from' - */ - @Test - public void fromTest() { - assertThat(model.getFrom(), instanceOf(String.class)); - } - - /** - * Test the property 'applicationId' - */ - @Test - public void applicationIdTest() { - assertThat(model.getApplicationId(), instanceOf(String.class)); - } - - /** - * Test the property 'channel' - */ - @Test - public void channelTest() { - assertThat(model.getChannel(), instanceOf(MultiChannelMessageChannelEnum.class)); - } - - /** - * Test the property 'content' - */ - @Test - public void contentTest() { - assertThat(model.getContent(), instanceOf(MultiChannelChannelListObjectContent.class)); - } - -} diff --git a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelMessageRequestTest.java b/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelMessageRequestTest.java deleted file mode 100644 index 9edba7a5..00000000 --- a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelMessageRequestTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.unit.models; - -import org.junit.jupiter.api.Test; - -import com.bandwidth.sdk.model.MultiChannelChannelListObject; -import com.bandwidth.sdk.model.MultiChannelMessageRequest; -import com.bandwidth.sdk.model.PriorityEnum; - -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.CoreMatchers.instanceOf; - -/** - * Model tests for MultiChannelMessageRequest - */ -public class MultiChannelMessageRequestTest { - private final MultiChannelMessageRequest model = new MultiChannelMessageRequest() - .to("to") - .channelList(new ArrayList(Arrays.asList(new MultiChannelChannelListObject()))) - .tag("tag") - .priority(PriorityEnum.DEFAULT) - .expiration(OffsetDateTime.now()); - - /** - * Model tests for MultiChannelMessageRequest - */ - @Test - public void testMultiChannelMessageRequest() { - assertThat(model, instanceOf(MultiChannelMessageRequest.class)); - } - - /** - * Test the property 'to' - */ - @Test - public void toTest() { - assertThat(model.getTo(), instanceOf(String.class)); - } - - /** - * Test the property 'channelList' - */ - @Test - public void channelListTest() { - assertThat(model.getChannelList(), instanceOf(ArrayList.class)); - } - - /** - * Test the property 'tag' - */ - @Test - public void tagTest() { - assertThat(model.getTag(), instanceOf(String.class)); - } - - /** - * Test the property 'priority' - */ - @Test - public void priorityTest() { - assertThat(model.getPriority(), instanceOf(PriorityEnum.class)); - } - - /** - * Test the property 'expiration' - */ - @Test - public void expirationTest() { - assertThat(model.getExpiration(), instanceOf(OffsetDateTime.class)); - } - -} diff --git a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelMessageResponseDataChannelListInnerTest.java b/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelMessageResponseDataChannelListInnerTest.java deleted file mode 100644 index 74105478..00000000 --- a/src/test/java/com/bandwidth/sdk/unit/models/MultiChannelMessageResponseDataChannelListInnerTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.unit.models; - -import org.junit.jupiter.api.Test; - -import com.bandwidth.sdk.model.MultiChannelChannelListObjectContent; -import com.bandwidth.sdk.model.MultiChannelMessageChannelEnum; -import com.bandwidth.sdk.model.MultiChannelMessageResponseDataChannelListInner; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * Model tests for MultiChannelMessageResponseDataChannelListInner - */ -public class MultiChannelMessageResponseDataChannelListInnerTest { - private final MultiChannelMessageResponseDataChannelListInner model - = new MultiChannelMessageResponseDataChannelListInner() - .from("from") - .applicationId("applicationId") - .channel(MultiChannelMessageChannelEnum.SMS) - .content(new MultiChannelChannelListObjectContent()) - .owner("owner"); - - /** - * Model tests for MultiChannelMessageResponseDataChannelListInner - */ - @Test - public void testMultiChannelMessageResponseDataChannelListInner() { - assertThat(model, instanceOf(MultiChannelMessageResponseDataChannelListInner.class)); - } - - /** - * Test the property 'from' - */ - @Test - public void fromTest() { - assertThat(model.getFrom(), instanceOf(String.class)); - } - - /** - * Test the property 'applicationId' - */ - @Test - public void applicationIdTest() { - assertThat(model.getApplicationId(), instanceOf(String.class)); - } - - /** - * Test the property 'channel' - */ - @Test - public void channelTest() { - assertThat(model.getChannel(), instanceOf(MultiChannelMessageChannelEnum.class)); - } - - /** - * Test the property 'content' - */ - @Test - public void contentTest() { - assertThat(model.getContent(), instanceOf(MultiChannelChannelListObjectContent.class)); - } - - /** - * Test the property 'owner' - */ - @Test - public void ownerTest() { - assertThat(model.getOwner(), instanceOf(String.class)); - } - -}