bandwidth-sdk 17.1.1 → 17.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +17 -13
- data/bandwidth.yml +48 -5
- data/coverage/.resultset.json +9 -5
- data/coverage/index.html +242 -194
- data/custom_templates/Gemfile.mustache +1 -1
- data/custom_templates/partial_anyof_module.mustache +135 -0
- data/docs/LookupResult.md +2 -2
- data/docs/MessagesApi.md +1 -1
- data/docs/RbmActionBase.md +1 -1
- data/docs/RbmMessageMedia.md +1 -1
- data/docs/RbmSuggestionResponse.md +1 -1
- data/docs/TfvStatus.md +3 -1
- data/docs/VerificationRequest.md +3 -1
- data/docs/VerificationUpdateRequest.md +3 -1
- data/lib/bandwidth-sdk/api/messages_api.rb +2 -2
- data/lib/bandwidth-sdk/models/multi_channel_action.rb +23 -67
- data/lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb +20 -67
- data/lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb +20 -67
- data/lib/bandwidth-sdk/models/rbm_message_media.rb +4 -2
- data/lib/bandwidth-sdk/models/tfv_status.rb +39 -4
- data/lib/bandwidth-sdk/models/verification_request.rb +39 -4
- data/lib/bandwidth-sdk/models/verification_update_request.rb +39 -4
- data/lib/bandwidth-sdk/version.rb +1 -1
- data/spec/smoke/multi_channel_api_spec.rb +236 -7
- data/spec/unit/api/toll_free_verification_api_spec.rb +4 -0
- metadata +3 -2
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{{#description}}
|
|
2
|
+
# {{{.}}}
|
|
3
|
+
{{/description}}
|
|
4
|
+
module {{classname}}
|
|
5
|
+
class << self
|
|
6
|
+
{{#anyOf}}
|
|
7
|
+
{{#-first}}
|
|
8
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
9
|
+
def openapi_any_of
|
|
10
|
+
[
|
|
11
|
+
{{/-first}}
|
|
12
|
+
:'{{{.}}}'{{^-last}},{{/-last}}
|
|
13
|
+
{{#-last}}
|
|
14
|
+
]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
{{/-last}}
|
|
18
|
+
{{/anyOf}}
|
|
19
|
+
{{#discriminator}}
|
|
20
|
+
{{#propertyName}}
|
|
21
|
+
# Discriminator's property name (OpenAPI v3)
|
|
22
|
+
def openapi_discriminator_name
|
|
23
|
+
:'{{{.}}}'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
{{/propertyName}}
|
|
27
|
+
{{#mappedModels}}
|
|
28
|
+
{{#-first}}
|
|
29
|
+
# Discriminator's mapping (OpenAPI v3)
|
|
30
|
+
def openapi_discriminator_mapping
|
|
31
|
+
{
|
|
32
|
+
{{/-first}}
|
|
33
|
+
:'{{{mappingName}}}' => :'{{{modelName}}}'{{^-last}},{{/-last}}
|
|
34
|
+
{{#-last}}
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
{{/-last}}
|
|
39
|
+
{{/mappedModels}}
|
|
40
|
+
{{/discriminator}}
|
|
41
|
+
# Builds the object
|
|
42
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
43
|
+
# @return [Object] Returns the model or the data itself
|
|
44
|
+
def build(data)
|
|
45
|
+
{{#discriminator}}
|
|
46
|
+
discriminator_value = data[openapi_discriminator_name]
|
|
47
|
+
return nil if discriminator_value.nil?
|
|
48
|
+
{{#mappedModels}}
|
|
49
|
+
{{#-first}}
|
|
50
|
+
|
|
51
|
+
klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
|
|
52
|
+
return nil unless klass
|
|
53
|
+
|
|
54
|
+
{{moduleName}}.const_get(klass).build_from_hash(data)
|
|
55
|
+
{{/-first}}
|
|
56
|
+
{{/mappedModels}}
|
|
57
|
+
{{^mappedModels}}
|
|
58
|
+
{{moduleName}}.const_get(discriminator_value).build_from_hash(data)
|
|
59
|
+
{{/mappedModels}}
|
|
60
|
+
{{/discriminator}}
|
|
61
|
+
{{^discriminator}}
|
|
62
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
|
63
|
+
# Note:
|
|
64
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
65
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
66
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
67
|
+
# - TODO: logging when debugging is set.
|
|
68
|
+
openapi_any_of.each do |klass|
|
|
69
|
+
begin
|
|
70
|
+
next if klass == :AnyType # "nullable: true"
|
|
71
|
+
return find_and_cast_into_type(klass, data)
|
|
72
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
|
77
|
+
{{/discriminator}}
|
|
78
|
+
end
|
|
79
|
+
{{^discriminator}}
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
84
|
+
|
|
85
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
86
|
+
def find_and_cast_into_type(klass, data)
|
|
87
|
+
return if data.nil?
|
|
88
|
+
|
|
89
|
+
case klass.to_s
|
|
90
|
+
when 'Boolean'
|
|
91
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
92
|
+
when 'Float'
|
|
93
|
+
return data if data.instance_of?(Float)
|
|
94
|
+
when 'Integer'
|
|
95
|
+
return data if data.instance_of?(Integer)
|
|
96
|
+
when 'Time'
|
|
97
|
+
return Time.parse(data)
|
|
98
|
+
when 'Date'
|
|
99
|
+
return Date.iso8601(data)
|
|
100
|
+
when 'String'
|
|
101
|
+
return data if data.instance_of?(String)
|
|
102
|
+
when 'Object' # "type: object"
|
|
103
|
+
return data if data.instance_of?(Hash)
|
|
104
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
105
|
+
if data.instance_of?(Array)
|
|
106
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
107
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
108
|
+
end
|
|
109
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
110
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
111
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
112
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
113
|
+
end
|
|
114
|
+
else # model
|
|
115
|
+
const = {{moduleName}}.const_get(klass)
|
|
116
|
+
if const
|
|
117
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
118
|
+
model = const.build(data)
|
|
119
|
+
return model if model
|
|
120
|
+
else
|
|
121
|
+
# raise if data contains keys that are not known to the model
|
|
122
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
123
|
+
model = const.build_from_hash(data)
|
|
124
|
+
return model if model
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
raise # if no match by now, raise
|
|
130
|
+
rescue
|
|
131
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
132
|
+
end
|
|
133
|
+
{{/discriminator}}
|
|
134
|
+
end
|
|
135
|
+
end
|
data/docs/LookupResult.md
CHANGED
|
@@ -31,8 +31,8 @@ instance = Bandwidth::LookupResult.new(
|
|
|
31
31
|
deactivation_date: 2025-06-20 18:35,
|
|
32
32
|
deactivation_event: null,
|
|
33
33
|
latest_message_delivery_status: null,
|
|
34
|
-
initial_message_delivery_status_date:
|
|
35
|
-
latest_message_delivery_status_date:
|
|
34
|
+
initial_message_delivery_status_date: Fri Jun 20 00:00:00 UTC 2025,
|
|
35
|
+
latest_message_delivery_status_date: Sat Jun 21 00:00:00 UTC 2025
|
|
36
36
|
)
|
|
37
37
|
```
|
|
38
38
|
|
data/docs/MessagesApi.md
CHANGED
|
@@ -89,7 +89,7 @@ end
|
|
|
89
89
|
|
|
90
90
|
List Messages
|
|
91
91
|
|
|
92
|
-
Returns a list of messages based on query parameters.
|
|
92
|
+
Returns a list of messages based on query parameters. **Rate Limit:** This endpoint is rate limited to 3500 requests per 5 minutes per Source IP address. Exceeding the limit returns HTTP 429 with a `Retry-After` header.
|
|
93
93
|
|
|
94
94
|
### Examples
|
|
95
95
|
|
data/docs/RbmActionBase.md
CHANGED
data/docs/RbmMessageMedia.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| Name | Type | Description | Notes |
|
|
6
6
|
| ---- | ---- | ----------- | ----- |
|
|
7
|
-
| **media** | [**RbmMessageContentFile
|
|
7
|
+
| **media** | [**Array<RbmMessageContentFile>**](RbmMessageContentFile.md) | | |
|
|
8
8
|
| **suggestions** | [**Array<MultiChannelAction>**](MultiChannelAction.md) | An array of suggested actions for the recipient. | [optional] |
|
|
9
9
|
|
|
10
10
|
## Example
|
data/docs/TfvStatus.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
| **submission** | [**TfvSubmissionInfo**](TfvSubmissionInfo.md) | | [optional] |
|
|
15
15
|
| **blocked** | **Boolean** | Whether a Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked. | [optional] |
|
|
16
16
|
| **blocked_reason** | **String** | The reason why the Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked. | [optional] |
|
|
17
|
+
| **cv_token** | **String** | The token provided by Campaign Verify to validate your political use case. Only required for 527 political organizations. If you are not a 527 political organization, this field should be omitted. If you pass an empty string, it will be passed along and potentially rejected. | [optional] |
|
|
17
18
|
|
|
18
19
|
## Example
|
|
19
20
|
|
|
@@ -30,7 +31,8 @@ instance = Bandwidth::TfvStatus.new(
|
|
|
30
31
|
modified_date_time: 2021-06-08T06:45:13Z,
|
|
31
32
|
submission: null,
|
|
32
33
|
blocked: true,
|
|
33
|
-
blocked_reason: Toll-free number was used to send spam messages
|
|
34
|
+
blocked_reason: Toll-free number was used to send spam messages,
|
|
35
|
+
cv_token: cv.user123|sess456|mno|tfree|read_write|X7yZ9aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVw
|
|
34
36
|
)
|
|
35
37
|
```
|
|
36
38
|
|
data/docs/VerificationRequest.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
| **business_entity_type** | [**BusinessEntityTypeEnum**](BusinessEntityTypeEnum.md) | | [optional] |
|
|
23
23
|
| **help_message_response** | **String** | A message that gets sent to users requesting help. | [optional] |
|
|
24
24
|
| **age_gated_content** | **Boolean** | Indicates whether the content is age-gated. | [optional] |
|
|
25
|
+
| **cv_token** | **String** | The token provided by Campaign Verify to validate your political use case. Only required for 527 political organizations. If you are not a 527 political organization, this field should be omitted. If you pass an empty string, it will be passed along and potentially rejected. | [optional] |
|
|
25
26
|
|
|
26
27
|
## Example
|
|
27
28
|
|
|
@@ -46,7 +47,8 @@ instance = Bandwidth::VerificationRequest.new(
|
|
|
46
47
|
business_registration_type: null,
|
|
47
48
|
business_entity_type: null,
|
|
48
49
|
help_message_response: Please contact support for assistance.,
|
|
49
|
-
age_gated_content: false
|
|
50
|
+
age_gated_content: false,
|
|
51
|
+
cv_token: cv.user123|sess456|mno|tfree|read_write|X7yZ9aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVw
|
|
50
52
|
)
|
|
51
53
|
```
|
|
52
54
|
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
| **business_entity_type** | [**BusinessEntityTypeEnum**](BusinessEntityTypeEnum.md) | | [optional] |
|
|
22
22
|
| **help_message_response** | **String** | A message that gets sent to users requesting help. | [optional] |
|
|
23
23
|
| **age_gated_content** | **Boolean** | Indicates whether the content is age-gated. | [optional] |
|
|
24
|
+
| **cv_token** | **String** | The token provided by Campaign Verify to validate your political use case. Only required for 527 political organizations. If you are not a 527 political organization, this field should be omitted. If you pass an empty string, it will be passed along and potentially rejected. | [optional] |
|
|
24
25
|
|
|
25
26
|
## Example
|
|
26
27
|
|
|
@@ -44,7 +45,8 @@ instance = Bandwidth::VerificationUpdateRequest.new(
|
|
|
44
45
|
business_registration_type: null,
|
|
45
46
|
business_entity_type: null,
|
|
46
47
|
help_message_response: Please contact support for assistance.,
|
|
47
|
-
age_gated_content: false
|
|
48
|
+
age_gated_content: false,
|
|
49
|
+
cv_token: cv.user123|sess456|mno|tfree|read_write|X7yZ9aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789aBcDeFgHiJkLmNoPqRsTuVw
|
|
48
50
|
)
|
|
49
51
|
```
|
|
50
52
|
|
|
@@ -94,7 +94,7 @@ module Bandwidth
|
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# List Messages
|
|
97
|
-
# Returns a list of messages based on query parameters.
|
|
97
|
+
# Returns a list of messages based on query parameters. **Rate Limit:** This endpoint is rate limited to 3500 requests per 5 minutes per Source IP address. Exceeding the limit returns HTTP 429 with a `Retry-After` header.
|
|
98
98
|
# @param account_id [String] Your Bandwidth Account ID.
|
|
99
99
|
# @param [Hash] opts the optional parameters
|
|
100
100
|
# @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
|
|
@@ -131,7 +131,7 @@ module Bandwidth
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
# List Messages
|
|
134
|
-
# Returns a list of messages based on query parameters.
|
|
134
|
+
# Returns a list of messages based on query parameters. **Rate Limit:** This endpoint is rate limited to 3500 requests per 5 minutes per Source IP address. Exceeding the limit returns HTTP 429 with a `Retry-After` header.
|
|
135
135
|
# @param account_id [String] Your Bandwidth Account ID.
|
|
136
136
|
# @param [Hash] opts the optional parameters
|
|
137
137
|
# @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
|
|
@@ -27,79 +27,35 @@ module Bandwidth
|
|
|
27
27
|
]
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# Discriminator's property name (OpenAPI v3)
|
|
31
|
+
def openapi_discriminator_name
|
|
32
|
+
:'type'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Discriminator's mapping (OpenAPI v3)
|
|
36
|
+
def openapi_discriminator_mapping
|
|
37
|
+
{
|
|
38
|
+
:'CREATE_CALENDAR_EVENT' => :'MultiChannelActionCalendarEvent',
|
|
39
|
+
:'DIAL_PHONE' => :'RbmActionDial',
|
|
40
|
+
:'OPEN_URL' => :'RbmActionOpenUrl',
|
|
41
|
+
:'REPLY' => :'RbmActionBase',
|
|
42
|
+
:'REQUEST_LOCATION' => :'RbmActionBase',
|
|
43
|
+
:'SHOW_LOCATION' => :'RbmActionViewLocation'
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
30
47
|
# Builds the object
|
|
31
48
|
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
32
49
|
# @return [Object] Returns the model or the data itself
|
|
33
50
|
def build(data)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
37
|
-
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
38
|
-
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
39
|
-
# - TODO: logging when debugging is set.
|
|
40
|
-
openapi_any_of.each do |klass|
|
|
41
|
-
begin
|
|
42
|
-
next if klass == :AnyType # "nullable: true"
|
|
43
|
-
return find_and_cast_into_type(klass, data)
|
|
44
|
-
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
openapi_any_of.include?(:AnyType) ? data : nil
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
|
|
53
|
-
SchemaMismatchError = Class.new(StandardError)
|
|
51
|
+
discriminator_value = data[openapi_discriminator_name]
|
|
52
|
+
return nil if discriminator_value.nil?
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return if data.nil?
|
|
54
|
+
klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
|
|
55
|
+
return nil unless klass
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
62
|
-
when 'Float'
|
|
63
|
-
return data if data.instance_of?(Float)
|
|
64
|
-
when 'Integer'
|
|
65
|
-
return data if data.instance_of?(Integer)
|
|
66
|
-
when 'Time'
|
|
67
|
-
return Time.parse(data)
|
|
68
|
-
when 'Date'
|
|
69
|
-
return Date.iso8601(data)
|
|
70
|
-
when 'String'
|
|
71
|
-
return data if data.instance_of?(String)
|
|
72
|
-
when 'Object' # "type: object"
|
|
73
|
-
return data if data.instance_of?(Hash)
|
|
74
|
-
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
75
|
-
if data.instance_of?(Array)
|
|
76
|
-
sub_type = Regexp.last_match[:sub_type]
|
|
77
|
-
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
78
|
-
end
|
|
79
|
-
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
80
|
-
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
81
|
-
sub_type = Regexp.last_match[:sub_type]
|
|
82
|
-
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
83
|
-
end
|
|
84
|
-
else # model
|
|
85
|
-
const = Bandwidth.const_get(klass)
|
|
86
|
-
if const
|
|
87
|
-
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
88
|
-
model = const.build(data)
|
|
89
|
-
return model if model
|
|
90
|
-
else
|
|
91
|
-
# raise if data contains keys that are not known to the model
|
|
92
|
-
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
93
|
-
model = const.build_from_hash(data)
|
|
94
|
-
return model if model
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
raise # if no match by now, raise
|
|
100
|
-
rescue
|
|
101
|
-
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
102
|
-
end
|
|
57
|
+
Bandwidth.const_get(klass).build_from_hash(data)
|
|
58
|
+
end
|
|
103
59
|
end
|
|
104
60
|
end
|
|
105
61
|
end
|
|
@@ -25,79 +25,32 @@ module Bandwidth
|
|
|
25
25
|
]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Discriminator's property name (OpenAPI v3)
|
|
29
|
+
def openapi_discriminator_name
|
|
30
|
+
:'channel'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Discriminator's mapping (OpenAPI v3)
|
|
34
|
+
def openapi_discriminator_mapping
|
|
35
|
+
{
|
|
36
|
+
:'MMS' => :'MultiChannelChannelListMMSObject',
|
|
37
|
+
:'RBM' => :'MultiChannelChannelListRBMObject',
|
|
38
|
+
:'SMS' => :'MultiChannelChannelListSMSObject'
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
28
42
|
# Builds the object
|
|
29
43
|
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
30
44
|
# @return [Object] Returns the model or the data itself
|
|
31
45
|
def build(data)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
-
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
-
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
-
# - TODO: logging when debugging is set.
|
|
38
|
-
openapi_any_of.each do |klass|
|
|
39
|
-
begin
|
|
40
|
-
next if klass == :AnyType # "nullable: true"
|
|
41
|
-
return find_and_cast_into_type(klass, data)
|
|
42
|
-
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
openapi_any_of.include?(:AnyType) ? data : nil
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
SchemaMismatchError = Class.new(StandardError)
|
|
46
|
+
discriminator_value = data[openapi_discriminator_name]
|
|
47
|
+
return nil if discriminator_value.nil?
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return if data.nil?
|
|
49
|
+
klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
|
|
50
|
+
return nil unless klass
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
60
|
-
when 'Float'
|
|
61
|
-
return data if data.instance_of?(Float)
|
|
62
|
-
when 'Integer'
|
|
63
|
-
return data if data.instance_of?(Integer)
|
|
64
|
-
when 'Time'
|
|
65
|
-
return Time.parse(data)
|
|
66
|
-
when 'Date'
|
|
67
|
-
return Date.iso8601(data)
|
|
68
|
-
when 'String'
|
|
69
|
-
return data if data.instance_of?(String)
|
|
70
|
-
when 'Object' # "type: object"
|
|
71
|
-
return data if data.instance_of?(Hash)
|
|
72
|
-
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
73
|
-
if data.instance_of?(Array)
|
|
74
|
-
sub_type = Regexp.last_match[:sub_type]
|
|
75
|
-
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
76
|
-
end
|
|
77
|
-
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
78
|
-
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
79
|
-
sub_type = Regexp.last_match[:sub_type]
|
|
80
|
-
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
81
|
-
end
|
|
82
|
-
else # model
|
|
83
|
-
const = Bandwidth.const_get(klass)
|
|
84
|
-
if const
|
|
85
|
-
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
86
|
-
model = const.build(data)
|
|
87
|
-
return model if model
|
|
88
|
-
else
|
|
89
|
-
# raise if data contains keys that are not known to the model
|
|
90
|
-
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
91
|
-
model = const.build_from_hash(data)
|
|
92
|
-
return model if model
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
raise # if no match by now, raise
|
|
98
|
-
rescue
|
|
99
|
-
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
100
|
-
end
|
|
52
|
+
Bandwidth.const_get(klass).build_from_hash(data)
|
|
53
|
+
end
|
|
101
54
|
end
|
|
102
55
|
end
|
|
103
56
|
end
|
|
@@ -25,79 +25,32 @@ module Bandwidth
|
|
|
25
25
|
]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Discriminator's property name (OpenAPI v3)
|
|
29
|
+
def openapi_discriminator_name
|
|
30
|
+
:'channel'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Discriminator's mapping (OpenAPI v3)
|
|
34
|
+
def openapi_discriminator_mapping
|
|
35
|
+
{
|
|
36
|
+
:'MMS' => :'MultiChannelChannelListMMSResponseObject',
|
|
37
|
+
:'RBM' => :'MultiChannelChannelListRBMResponseObject',
|
|
38
|
+
:'SMS' => :'MultiChannelChannelListSMSResponseObject'
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
28
42
|
# Builds the object
|
|
29
43
|
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
30
44
|
# @return [Object] Returns the model or the data itself
|
|
31
45
|
def build(data)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
-
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
-
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
-
# - TODO: logging when debugging is set.
|
|
38
|
-
openapi_any_of.each do |klass|
|
|
39
|
-
begin
|
|
40
|
-
next if klass == :AnyType # "nullable: true"
|
|
41
|
-
return find_and_cast_into_type(klass, data)
|
|
42
|
-
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
openapi_any_of.include?(:AnyType) ? data : nil
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
SchemaMismatchError = Class.new(StandardError)
|
|
46
|
+
discriminator_value = data[openapi_discriminator_name]
|
|
47
|
+
return nil if discriminator_value.nil?
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return if data.nil?
|
|
49
|
+
klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
|
|
50
|
+
return nil unless klass
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
60
|
-
when 'Float'
|
|
61
|
-
return data if data.instance_of?(Float)
|
|
62
|
-
when 'Integer'
|
|
63
|
-
return data if data.instance_of?(Integer)
|
|
64
|
-
when 'Time'
|
|
65
|
-
return Time.parse(data)
|
|
66
|
-
when 'Date'
|
|
67
|
-
return Date.iso8601(data)
|
|
68
|
-
when 'String'
|
|
69
|
-
return data if data.instance_of?(String)
|
|
70
|
-
when 'Object' # "type: object"
|
|
71
|
-
return data if data.instance_of?(Hash)
|
|
72
|
-
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
73
|
-
if data.instance_of?(Array)
|
|
74
|
-
sub_type = Regexp.last_match[:sub_type]
|
|
75
|
-
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
76
|
-
end
|
|
77
|
-
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
78
|
-
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
79
|
-
sub_type = Regexp.last_match[:sub_type]
|
|
80
|
-
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
81
|
-
end
|
|
82
|
-
else # model
|
|
83
|
-
const = Bandwidth.const_get(klass)
|
|
84
|
-
if const
|
|
85
|
-
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
86
|
-
model = const.build(data)
|
|
87
|
-
return model if model
|
|
88
|
-
else
|
|
89
|
-
# raise if data contains keys that are not known to the model
|
|
90
|
-
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
91
|
-
model = const.build_from_hash(data)
|
|
92
|
-
return model if model
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
raise # if no match by now, raise
|
|
98
|
-
rescue
|
|
99
|
-
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
100
|
-
end
|
|
52
|
+
Bandwidth.const_get(klass).build_from_hash(data)
|
|
53
|
+
end
|
|
101
54
|
end
|
|
102
55
|
end
|
|
103
56
|
end
|
|
@@ -41,7 +41,7 @@ module Bandwidth
|
|
|
41
41
|
# Attribute type mapping.
|
|
42
42
|
def self.openapi_types
|
|
43
43
|
{
|
|
44
|
-
:'media' => :'RbmMessageContentFile',
|
|
44
|
+
:'media' => :'Array<RbmMessageContentFile>',
|
|
45
45
|
:'suggestions' => :'Array<MultiChannelAction>'
|
|
46
46
|
}
|
|
47
47
|
end
|
|
@@ -69,7 +69,9 @@ module Bandwidth
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if attributes.key?(:'media')
|
|
72
|
-
|
|
72
|
+
if (value = attributes[:'media']).is_a?(Array)
|
|
73
|
+
self.media = value
|
|
74
|
+
end
|
|
73
75
|
else
|
|
74
76
|
self.media = nil
|
|
75
77
|
end
|