messente_api 1.3.1 → 2.1.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.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -30
  3. data/docs/BlacklistApi.md +105 -37
  4. data/docs/BulkMessagingApi.md +76 -0
  5. data/docs/BulkOmniMessageCreateSuccessResponse.md +18 -0
  6. data/docs/BulkOmniMessageCreateSuccessResponseMessagesInner.md +49 -0
  7. data/docs/BulkOmnimessage.md +18 -0
  8. data/docs/Channel.md +4 -5
  9. data/docs/ContactEnvelope.md +8 -7
  10. data/docs/ContactFields.md +26 -25
  11. data/docs/ContactListEnvelope.md +8 -7
  12. data/docs/ContactResponseFields.md +28 -27
  13. data/docs/ContactUpdateFields.md +24 -23
  14. data/docs/ContactsApi.md +221 -86
  15. data/docs/DeliveryReportApi.md +29 -13
  16. data/docs/DeliveryReportResponse.md +12 -11
  17. data/docs/DeliveryResult.md +22 -17
  18. data/docs/ErrorCodeOmnichannel.md +4 -5
  19. data/docs/ErrorCodeOmnichannelMachine.md +4 -5
  20. data/docs/ErrorCodePhonebook.md +4 -5
  21. data/docs/ErrorCodeStatistics.md +4 -5
  22. data/docs/ErrorItemNumberLookup.md +8 -7
  23. data/docs/ErrorItemNumberLookupError.md +10 -9
  24. data/docs/ErrorItemOmnichannel.md +14 -13
  25. data/docs/ErrorItemPhonebook.md +12 -11
  26. data/docs/ErrorItemStatistics.md +12 -11
  27. data/docs/ErrorNumberLookup.md +8 -7
  28. data/docs/ErrorOmnichannel.md +8 -7
  29. data/docs/ErrorPhonebook.md +8 -7
  30. data/docs/ErrorStatistics.md +8 -7
  31. data/docs/ErrorTitleOmnichannel.md +4 -5
  32. data/docs/ErrorTitlePhonebook.md +4 -5
  33. data/docs/FetchBlacklistSuccess.md +8 -7
  34. data/docs/GroupEnvelope.md +8 -7
  35. data/docs/GroupListEnvelope.md +8 -7
  36. data/docs/GroupName.md +8 -7
  37. data/docs/GroupResponseFields.md +14 -13
  38. data/docs/GroupsApi.md +136 -51
  39. data/docs/MessageResult.md +12 -11
  40. data/docs/MobileNetwork.md +16 -15
  41. data/docs/NumberLookupApi.md +30 -14
  42. data/docs/NumberToBlacklist.md +8 -7
  43. data/docs/NumbersToInvestigate.md +8 -7
  44. data/docs/OmniMessageCreateSuccessResponse.md +12 -11
  45. data/docs/Omnimessage.md +18 -15
  46. data/docs/OmnimessageApi.md +56 -23
  47. data/docs/OmnimessageMessagesInner.md +53 -0
  48. data/docs/PriceInfo.md +22 -0
  49. data/docs/Priority.md +15 -0
  50. data/docs/SMS.md +20 -17
  51. data/docs/StatisticsApi.md +30 -14
  52. data/docs/StatisticsReport.md +12 -11
  53. data/docs/StatisticsReportSettings.md +12 -11
  54. data/docs/StatisticsReportSuccess.md +8 -7
  55. data/docs/Status.md +4 -5
  56. data/docs/SyncNumberLookupResult.md +24 -23
  57. data/docs/SyncNumberLookupSuccess.md +10 -9
  58. data/docs/Telegram.md +20 -19
  59. data/docs/TextStore.md +4 -5
  60. data/docs/Viber.md +22 -19
  61. data/docs/WhatsApp.md +16 -19
  62. data/docs/WhatsAppComponent.md +24 -0
  63. data/docs/WhatsAppCurrency.md +22 -0
  64. data/docs/WhatsAppDatetime.md +18 -0
  65. data/docs/WhatsAppLanguage.md +20 -0
  66. data/docs/WhatsAppMedia.md +24 -0
  67. data/docs/WhatsAppParameter.md +30 -0
  68. data/docs/WhatsAppTemplate.md +22 -0
  69. data/git_push.sh +3 -4
  70. data/lib/messente_api/api/blacklist_api.rb +22 -15
  71. data/lib/messente_api/api/bulk_messaging_api.rb +88 -0
  72. data/lib/messente_api/api/contacts_api.rb +42 -28
  73. data/lib/messente_api/api/delivery_report_api.rb +6 -5
  74. data/lib/messente_api/api/groups_api.rb +30 -19
  75. data/lib/messente_api/api/number_lookup_api.rb +10 -6
  76. data/lib/messente_api/api/omnimessage_api.rb +14 -9
  77. data/lib/messente_api/api/statistics_api.rb +10 -6
  78. data/lib/messente_api/api_client.rb +72 -66
  79. data/lib/messente_api/api_error.rb +3 -2
  80. data/lib/messente_api/configuration.rb +64 -14
  81. data/lib/messente_api/models/{whats_app_audio.rb → bulk_omni_message_create_success_response.rb} +50 -38
  82. data/lib/messente_api/models/bulk_omni_message_create_success_response_messages_inner.rb +105 -0
  83. data/lib/messente_api/models/{whats_app_text.rb → bulk_omnimessage.rb} +49 -49
  84. data/lib/messente_api/models/channel.rb +9 -5
  85. data/lib/messente_api/models/contact_envelope.rb +31 -23
  86. data/lib/messente_api/models/contact_fields.rb +33 -23
  87. data/lib/messente_api/models/contact_list_envelope.rb +41 -23
  88. data/lib/messente_api/models/contact_response_fields.rb +31 -23
  89. data/lib/messente_api/models/contact_update_fields.rb +31 -23
  90. data/lib/messente_api/models/delivery_report_response.rb +37 -23
  91. data/lib/messente_api/models/delivery_result.rb +77 -27
  92. data/lib/messente_api/models/error_code_omnichannel.rb +9 -5
  93. data/lib/messente_api/models/error_code_omnichannel_machine.rb +9 -5
  94. data/lib/messente_api/models/error_code_phonebook.rb +9 -5
  95. data/lib/messente_api/models/error_code_statistics.rb +9 -5
  96. data/lib/messente_api/models/error_item_number_lookup.rb +33 -23
  97. data/lib/messente_api/models/error_item_number_lookup_error.rb +35 -23
  98. data/lib/messente_api/models/error_item_omnichannel.rb +61 -23
  99. data/lib/messente_api/models/error_item_phonebook.rb +59 -23
  100. data/lib/messente_api/models/error_item_statistics.rb +59 -23
  101. data/lib/messente_api/models/error_number_lookup.rb +33 -23
  102. data/lib/messente_api/models/error_omnichannel.rb +33 -23
  103. data/lib/messente_api/models/error_phonebook.rb +33 -23
  104. data/lib/messente_api/models/error_statistics.rb +33 -23
  105. data/lib/messente_api/models/error_title_omnichannel.rb +9 -5
  106. data/lib/messente_api/models/error_title_phonebook.rb +9 -5
  107. data/lib/messente_api/models/fetch_blacklist_success.rb +41 -23
  108. data/lib/messente_api/models/group_envelope.rb +31 -23
  109. data/lib/messente_api/models/group_list_envelope.rb +41 -23
  110. data/lib/messente_api/models/group_name.rb +33 -23
  111. data/lib/messente_api/models/group_response_fields.rb +37 -23
  112. data/lib/messente_api/models/message_result.rb +59 -23
  113. data/lib/messente_api/models/mobile_network.rb +31 -23
  114. data/lib/messente_api/models/number_to_blacklist.rb +33 -23
  115. data/lib/messente_api/models/numbers_to_investigate.rb +62 -24
  116. data/lib/messente_api/models/omni_message_create_success_response.rb +37 -23
  117. data/lib/messente_api/models/omnimessage.rb +71 -28
  118. data/lib/messente_api/models/omnimessage_messages_inner.rb +107 -0
  119. data/lib/messente_api/models/price_info.rb +257 -0
  120. data/lib/messente_api/models/priority.rb +41 -0
  121. data/lib/messente_api/models/sms.rb +45 -25
  122. data/lib/messente_api/models/statistics_report.rb +37 -23
  123. data/lib/messente_api/models/statistics_report_settings.rb +35 -23
  124. data/lib/messente_api/models/statistics_report_success.rb +33 -23
  125. data/lib/messente_api/models/status.rb +9 -5
  126. data/lib/messente_api/models/sync_number_lookup_result.rb +35 -24
  127. data/lib/messente_api/models/sync_number_lookup_success.rb +35 -23
  128. data/lib/messente_api/models/telegram.rb +31 -23
  129. data/lib/messente_api/models/text_store.rb +9 -5
  130. data/lib/messente_api/models/viber.rb +43 -25
  131. data/lib/messente_api/models/whats_app.rb +45 -54
  132. data/lib/messente_api/models/whats_app_component.rb +255 -0
  133. data/lib/messente_api/models/whats_app_currency.rb +257 -0
  134. data/lib/messente_api/models/{whats_app_document.rb → whats_app_datetime.rb} +48 -48
  135. data/lib/messente_api/models/{whats_app_image.rb → whats_app_language.rb} +55 -45
  136. data/lib/messente_api/models/whats_app_media.rb +246 -0
  137. data/lib/messente_api/models/whats_app_parameter.rb +278 -0
  138. data/lib/messente_api/models/whats_app_template.rb +251 -0
  139. data/lib/messente_api/version.rb +3 -3
  140. data/lib/messente_api.rb +16 -6
  141. data/messente_api.gemspec +5 -5
  142. data/spec/spec_helper.rb +2 -2
  143. metadata +35 -40
  144. data/docs/WhatsAppAudio.md +0 -17
  145. data/docs/WhatsAppDocument.md +0 -19
  146. data/docs/WhatsAppImage.md +0 -19
  147. data/docs/WhatsAppText.md +0 -19
  148. data/messente_api-1.3.0.gem +0 -0
  149. data/spec/api_client_spec.rb +0 -226
  150. data/spec/configuration_spec.rb +0 -42
@@ -3,14 +3,15 @@
3
3
 
4
4
  #[Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
5
5
 
6
- The version of the OpenAPI document: 1.3.0
6
+ The version of the OpenAPI document: 2.0.0
7
7
  Contact: messente@messente.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module MessenteApi
16
17
  # A container for a response received after successfully created omnimessage
@@ -33,6 +34,11 @@ module MessenteApi
33
34
  }
34
35
  end
35
36
 
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
36
42
  # Attribute type mapping.
37
43
  def self.openapi_types
38
44
  {
@@ -67,20 +73,27 @@ module MessenteApi
67
73
  if (value = attributes[:'messages']).is_a?(Array)
68
74
  self.messages = value
69
75
  end
76
+ else
77
+ self.messages = nil
70
78
  end
71
79
 
72
80
  if attributes.key?(:'to')
73
81
  self.to = attributes[:'to']
82
+ else
83
+ self.to = nil
74
84
  end
75
85
 
76
86
  if attributes.key?(:'omnimessage_id')
77
87
  self.omnimessage_id = attributes[:'omnimessage_id']
88
+ else
89
+ self.omnimessage_id = nil
78
90
  end
79
91
  end
80
92
 
81
93
  # Show invalid properties with the reasons. Usually used together with valid?
82
94
  # @return Array for valid properties with the reasons
83
95
  def list_invalid_properties
96
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
84
97
  invalid_properties = Array.new
85
98
  if @messages.nil?
86
99
  invalid_properties.push('invalid value for "messages", messages cannot be nil.')
@@ -100,6 +113,7 @@ module MessenteApi
100
113
  # Check to see if the all the properties in the model are valid
101
114
  # @return true if the model is valid
102
115
  def valid?
116
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
117
  return false if @messages.nil?
104
118
  return false if @to.nil?
105
119
  return false if @omnimessage_id.nil?
@@ -132,37 +146,33 @@ module MessenteApi
132
146
  # @param [Hash] attributes Model attributes in the form of hash
133
147
  # @return [Object] Returns the model itself
134
148
  def self.build_from_hash(attributes)
135
- new.build_from_hash(attributes)
136
- end
137
-
138
- # Builds the object from hash
139
- # @param [Hash] attributes Model attributes in the form of hash
140
- # @return [Object] Returns the model itself
141
- def build_from_hash(attributes)
142
149
  return nil unless attributes.is_a?(Hash)
143
- self.class.openapi_types.each_pair do |key, type|
144
- if type =~ /\AArray<(.*)>/i
150
+ attributes = attributes.transform_keys(&:to_sym)
151
+ transformed_hash = {}
152
+ openapi_types.each_pair do |key, type|
153
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
154
+ transformed_hash["#{key}"] = nil
155
+ elsif type =~ /\AArray<(.*)>/i
145
156
  # check to ensure the input is an array given that the attribute
146
157
  # is documented as an array but the input is not
147
- if attributes[self.class.attribute_map[key]].is_a?(Array)
148
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ if attributes[attribute_map[key]].is_a?(Array)
159
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
149
160
  end
150
- elsif !attributes[self.class.attribute_map[key]].nil?
151
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
- end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ elsif !attributes[attribute_map[key]].nil?
162
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
163
+ end
153
164
  end
154
-
155
- self
165
+ new(transformed_hash)
156
166
  end
157
167
 
158
168
  # Deserializes the data based on type
159
169
  # @param string type Data type
160
170
  # @param string value Value to be deserialized
161
171
  # @return [Object] Deserialized data
162
- def _deserialize(type, value)
172
+ def self._deserialize(type, value)
163
173
  case type.to_sym
164
- when :DateTime
165
- DateTime.parse(value)
174
+ when :Time
175
+ Time.parse(value)
166
176
  when :Date
167
177
  Date.parse(value)
168
178
  when :String
@@ -192,7 +202,9 @@ module MessenteApi
192
202
  end
193
203
  end
194
204
  else # model
195
- MessenteApi.const_get(type).build_from_hash(value)
205
+ # models (e.g. Pet) or oneOf
206
+ klass = MessenteApi.const_get(type)
207
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
196
208
  end
197
209
  end
198
210
 
@@ -218,7 +230,7 @@ module MessenteApi
218
230
  is_nullable = self.class.openapi_nullable.include?(attr)
219
231
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
220
232
  end
221
-
233
+
222
234
  hash[param] = _to_hash(value)
223
235
  end
224
236
  hash
@@ -241,5 +253,7 @@ module MessenteApi
241
253
  value
242
254
  end
243
255
  end
256
+
244
257
  end
258
+
245
259
  end
@@ -3,14 +3,15 @@
3
3
 
4
4
  #[Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
5
5
 
6
- The version of the OpenAPI document: 1.3.0
6
+ The version of the OpenAPI document: 2.0.0
7
7
  Contact: messente@messente.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module MessenteApi
16
17
  # An omnimessage
@@ -29,6 +30,30 @@ module MessenteApi
29
30
  # Optional parameter for sending messages at some specific time in the future. Time must be specified in the ISO-8601 format. If no timezone is specified, then the timezone is assumed to be UTC Examples: * Time specified with timezone: 2018-06-22T09:05:07+00:00 Time specified in UTC: 2018-06-22T09:05:07Z * Time specified without timezone: 2018-06-22T09:05 (equivalent to 2018-06-22T09:05+00:00)
30
31
  attr_accessor :time_to_send
31
32
 
33
+ attr_accessor :priority
34
+
35
+ class EnumAttributeValidator
36
+ attr_reader :datatype
37
+ attr_reader :allowable_values
38
+
39
+ def initialize(datatype, allowable_values)
40
+ @allowable_values = allowable_values.map do |value|
41
+ case datatype.to_s
42
+ when /Integer/i
43
+ value.to_i
44
+ when /Float/i
45
+ value.to_f
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
51
+
52
+ def valid?(value)
53
+ !value || allowable_values.include?(value)
54
+ end
55
+ end
56
+
32
57
  # Attribute mapping from ruby-style variable name to JSON key.
33
58
  def self.attribute_map
34
59
  {
@@ -36,18 +61,25 @@ module MessenteApi
36
61
  :'messages' => :'messages',
37
62
  :'dlr_url' => :'dlr_url',
38
63
  :'text_store' => :'text_store',
39
- :'time_to_send' => :'time_to_send'
64
+ :'time_to_send' => :'time_to_send',
65
+ :'priority' => :'priority'
40
66
  }
41
67
  end
42
68
 
69
+ # Returns all the JSON keys this model knows about
70
+ def self.acceptable_attributes
71
+ attribute_map.values
72
+ end
73
+
43
74
  # Attribute type mapping.
44
75
  def self.openapi_types
45
76
  {
46
77
  :'to' => :'String',
47
- :'messages' => :'Array<OneOfViberSMSWhatsAppTelegram>',
78
+ :'messages' => :'Array<OmnimessageMessagesInner>',
48
79
  :'dlr_url' => :'String',
49
80
  :'text_store' => :'TextStore',
50
- :'time_to_send' => :'DateTime'
81
+ :'time_to_send' => :'Time',
82
+ :'priority' => :'Priority'
51
83
  }
52
84
  end
53
85
 
@@ -74,12 +106,16 @@ module MessenteApi
74
106
 
75
107
  if attributes.key?(:'to')
76
108
  self.to = attributes[:'to']
109
+ else
110
+ self.to = nil
77
111
  end
78
112
 
79
113
  if attributes.key?(:'messages')
80
114
  if (value = attributes[:'messages']).is_a?(Array)
81
115
  self.messages = value
82
116
  end
117
+ else
118
+ self.messages = nil
83
119
  end
84
120
 
85
121
  if attributes.key?(:'dlr_url')
@@ -93,11 +129,16 @@ module MessenteApi
93
129
  if attributes.key?(:'time_to_send')
94
130
  self.time_to_send = attributes[:'time_to_send']
95
131
  end
132
+
133
+ if attributes.key?(:'priority')
134
+ self.priority = attributes[:'priority']
135
+ end
96
136
  end
97
137
 
98
138
  # Show invalid properties with the reasons. Usually used together with valid?
99
139
  # @return Array for valid properties with the reasons
100
140
  def list_invalid_properties
141
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
101
142
  invalid_properties = Array.new
102
143
  if @to.nil?
103
144
  invalid_properties.push('invalid value for "to", to cannot be nil.')
@@ -113,6 +154,7 @@ module MessenteApi
113
154
  # Check to see if the all the properties in the model are valid
114
155
  # @return true if the model is valid
115
156
  def valid?
157
+ warn '[DEPRECATED] the `valid?` method is obsolete'
116
158
  return false if @to.nil?
117
159
  return false if @messages.nil?
118
160
  true
@@ -127,7 +169,8 @@ module MessenteApi
127
169
  messages == o.messages &&
128
170
  dlr_url == o.dlr_url &&
129
171
  text_store == o.text_store &&
130
- time_to_send == o.time_to_send
172
+ time_to_send == o.time_to_send &&
173
+ priority == o.priority
131
174
  end
132
175
 
133
176
  # @see the `==` method
@@ -139,44 +182,40 @@ module MessenteApi
139
182
  # Calculates hash code according to all attributes.
140
183
  # @return [Integer] Hash code
141
184
  def hash
142
- [to, messages, dlr_url, text_store, time_to_send].hash
185
+ [to, messages, dlr_url, text_store, time_to_send, priority].hash
143
186
  end
144
187
 
145
188
  # Builds the object from hash
146
189
  # @param [Hash] attributes Model attributes in the form of hash
147
190
  # @return [Object] Returns the model itself
148
191
  def self.build_from_hash(attributes)
149
- new.build_from_hash(attributes)
150
- end
151
-
152
- # Builds the object from hash
153
- # @param [Hash] attributes Model attributes in the form of hash
154
- # @return [Object] Returns the model itself
155
- def build_from_hash(attributes)
156
192
  return nil unless attributes.is_a?(Hash)
157
- self.class.openapi_types.each_pair do |key, type|
158
- if type =~ /\AArray<(.*)>/i
193
+ attributes = attributes.transform_keys(&:to_sym)
194
+ transformed_hash = {}
195
+ openapi_types.each_pair do |key, type|
196
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
197
+ transformed_hash["#{key}"] = nil
198
+ elsif type =~ /\AArray<(.*)>/i
159
199
  # check to ensure the input is an array given that the attribute
160
200
  # is documented as an array but the input is not
161
- if attributes[self.class.attribute_map[key]].is_a?(Array)
162
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
201
+ if attributes[attribute_map[key]].is_a?(Array)
202
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
163
203
  end
164
- elsif !attributes[self.class.attribute_map[key]].nil?
165
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
166
- end # or else data not found in attributes(hash), not an issue as the data can be optional
204
+ elsif !attributes[attribute_map[key]].nil?
205
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
206
+ end
167
207
  end
168
-
169
- self
208
+ new(transformed_hash)
170
209
  end
171
210
 
172
211
  # Deserializes the data based on type
173
212
  # @param string type Data type
174
213
  # @param string value Value to be deserialized
175
214
  # @return [Object] Deserialized data
176
- def _deserialize(type, value)
215
+ def self._deserialize(type, value)
177
216
  case type.to_sym
178
- when :DateTime
179
- DateTime.parse(value)
217
+ when :Time
218
+ Time.parse(value)
180
219
  when :Date
181
220
  Date.parse(value)
182
221
  when :String
@@ -206,7 +245,9 @@ module MessenteApi
206
245
  end
207
246
  end
208
247
  else # model
209
- MessenteApi.const_get(type).build_from_hash(value)
248
+ # models (e.g. Pet) or oneOf
249
+ klass = MessenteApi.const_get(type)
250
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
210
251
  end
211
252
  end
212
253
 
@@ -232,7 +273,7 @@ module MessenteApi
232
273
  is_nullable = self.class.openapi_nullable.include?(attr)
233
274
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
275
  end
235
-
276
+
236
277
  hash[param] = _to_hash(value)
237
278
  end
238
279
  hash
@@ -255,5 +296,7 @@ module MessenteApi
255
296
  value
256
297
  end
257
298
  end
299
+
258
300
  end
301
+
259
302
  end
@@ -0,0 +1,107 @@
1
+ =begin
2
+ #Messente API
3
+
4
+ #[Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: messente@messente.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MessenteApi
17
+ module OmnimessageMessagesInner
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'SMS',
23
+ :'Telegram',
24
+ :'Viber',
25
+ :'WhatsApp'
26
+ ]
27
+ end
28
+
29
+ # Builds the object
30
+ # @param [Mixed] Data to be matched against the list of oneOf items
31
+ # @return [Object] Returns the model or the data itself
32
+ def build(data)
33
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
34
+ # Note:
35
+ # - We do not attempt to check whether exactly one item matches.
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_one_of.each do |klass|
41
+ begin
42
+ next if klass == :AnyType # "nullable: true"
43
+ typed_data = find_and_cast_into_type(klass, data)
44
+ return typed_data if typed_data
45
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
46
+ end
47
+ end
48
+
49
+ openapi_one_of.include?(:AnyType) ? data : nil
50
+ end
51
+
52
+ private
53
+
54
+ SchemaMismatchError = Class.new(StandardError)
55
+
56
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
57
+ def find_and_cast_into_type(klass, data)
58
+ return if data.nil?
59
+
60
+ case klass.to_s
61
+ when 'Boolean'
62
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
63
+ when 'Float'
64
+ return data if data.instance_of?(Float)
65
+ when 'Integer'
66
+ return data if data.instance_of?(Integer)
67
+ when 'Time'
68
+ return Time.parse(data)
69
+ when 'Date'
70
+ return Date.parse(data)
71
+ when 'String'
72
+ return data if data.instance_of?(String)
73
+ when 'Object' # "type: object"
74
+ return data if data.instance_of?(Hash)
75
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
76
+ if data.instance_of?(Array)
77
+ sub_type = Regexp.last_match[:sub_type]
78
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
79
+ end
80
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
81
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
82
+ sub_type = Regexp.last_match[:sub_type]
83
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
84
+ end
85
+ else # model
86
+ const = MessenteApi.const_get(klass)
87
+ if const
88
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
89
+ model = const.build(data)
90
+ return model if model
91
+ else
92
+ # raise if data contains keys that are not known to the model
93
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
94
+ model = const.build_from_hash(data)
95
+ return model if model
96
+ end
97
+ end
98
+ end
99
+
100
+ raise # if no match by now, raise
101
+ rescue
102
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
103
+ end
104
+ end
105
+ end
106
+
107
+ end