messente_api 1.4.0 → 2.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.
Files changed (151) 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 -17
  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 +4 -5
  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 +24 -19
  61. data/docs/ViberVideo.md +24 -0
  62. data/docs/WhatsApp.md +16 -19
  63. data/docs/WhatsAppComponent.md +24 -0
  64. data/docs/WhatsAppCurrency.md +22 -0
  65. data/docs/WhatsAppDatetime.md +18 -0
  66. data/docs/WhatsAppLanguage.md +20 -0
  67. data/docs/WhatsAppMedia.md +24 -0
  68. data/docs/WhatsAppParameter.md +30 -0
  69. data/docs/WhatsAppTemplate.md +22 -0
  70. data/git_push.sh +3 -4
  71. data/lib/messente_api/api/blacklist_api.rb +22 -15
  72. data/lib/messente_api/api/bulk_messaging_api.rb +88 -0
  73. data/lib/messente_api/api/contacts_api.rb +42 -28
  74. data/lib/messente_api/api/delivery_report_api.rb +6 -5
  75. data/lib/messente_api/api/groups_api.rb +30 -19
  76. data/lib/messente_api/api/number_lookup_api.rb +10 -6
  77. data/lib/messente_api/api/omnimessage_api.rb +14 -9
  78. data/lib/messente_api/api/statistics_api.rb +10 -6
  79. data/lib/messente_api/api_client.rb +72 -66
  80. data/lib/messente_api/api_error.rb +3 -2
  81. data/lib/messente_api/configuration.rb +64 -14
  82. data/lib/messente_api/models/{whats_app_audio.rb → bulk_omni_message_create_success_response.rb} +50 -38
  83. data/lib/messente_api/models/bulk_omni_message_create_success_response_messages_inner.rb +105 -0
  84. data/lib/messente_api/models/{whats_app_text.rb → bulk_omnimessage.rb} +49 -49
  85. data/lib/messente_api/models/channel.rb +9 -5
  86. data/lib/messente_api/models/contact_envelope.rb +31 -23
  87. data/lib/messente_api/models/contact_fields.rb +33 -23
  88. data/lib/messente_api/models/contact_list_envelope.rb +41 -23
  89. data/lib/messente_api/models/contact_response_fields.rb +31 -23
  90. data/lib/messente_api/models/contact_update_fields.rb +31 -23
  91. data/lib/messente_api/models/delivery_report_response.rb +37 -23
  92. data/lib/messente_api/models/delivery_result.rb +77 -27
  93. data/lib/messente_api/models/error_code_omnichannel.rb +9 -5
  94. data/lib/messente_api/models/error_code_omnichannel_machine.rb +9 -5
  95. data/lib/messente_api/models/error_code_phonebook.rb +9 -5
  96. data/lib/messente_api/models/error_code_statistics.rb +9 -5
  97. data/lib/messente_api/models/error_item_number_lookup.rb +33 -23
  98. data/lib/messente_api/models/error_item_number_lookup_error.rb +35 -23
  99. data/lib/messente_api/models/error_item_omnichannel.rb +61 -23
  100. data/lib/messente_api/models/error_item_phonebook.rb +59 -23
  101. data/lib/messente_api/models/error_item_statistics.rb +59 -23
  102. data/lib/messente_api/models/error_number_lookup.rb +33 -23
  103. data/lib/messente_api/models/error_omnichannel.rb +33 -23
  104. data/lib/messente_api/models/error_phonebook.rb +33 -23
  105. data/lib/messente_api/models/error_statistics.rb +33 -23
  106. data/lib/messente_api/models/error_title_omnichannel.rb +9 -5
  107. data/lib/messente_api/models/error_title_phonebook.rb +9 -5
  108. data/lib/messente_api/models/fetch_blacklist_success.rb +41 -23
  109. data/lib/messente_api/models/group_envelope.rb +31 -23
  110. data/lib/messente_api/models/group_list_envelope.rb +41 -23
  111. data/lib/messente_api/models/group_name.rb +33 -23
  112. data/lib/messente_api/models/group_response_fields.rb +37 -23
  113. data/lib/messente_api/models/message_result.rb +59 -23
  114. data/lib/messente_api/models/mobile_network.rb +31 -23
  115. data/lib/messente_api/models/number_to_blacklist.rb +33 -23
  116. data/lib/messente_api/models/numbers_to_investigate.rb +62 -24
  117. data/lib/messente_api/models/omni_message_create_success_response.rb +37 -23
  118. data/lib/messente_api/models/omnimessage.rb +59 -25
  119. data/lib/messente_api/models/omnimessage_messages_inner.rb +107 -0
  120. data/lib/messente_api/models/price_info.rb +257 -0
  121. data/lib/messente_api/models/priority.rb +9 -5
  122. data/lib/messente_api/models/sms.rb +45 -25
  123. data/lib/messente_api/models/statistics_report.rb +37 -23
  124. data/lib/messente_api/models/statistics_report_settings.rb +35 -23
  125. data/lib/messente_api/models/statistics_report_success.rb +33 -23
  126. data/lib/messente_api/models/status.rb +9 -5
  127. data/lib/messente_api/models/sync_number_lookup_result.rb +35 -24
  128. data/lib/messente_api/models/sync_number_lookup_success.rb +35 -23
  129. data/lib/messente_api/models/telegram.rb +31 -23
  130. data/lib/messente_api/models/text_store.rb +9 -5
  131. data/lib/messente_api/models/viber.rb +55 -28
  132. data/lib/messente_api/models/viber_video.rb +274 -0
  133. data/lib/messente_api/models/whats_app.rb +45 -54
  134. data/lib/messente_api/models/whats_app_component.rb +255 -0
  135. data/lib/messente_api/models/whats_app_currency.rb +257 -0
  136. data/lib/messente_api/models/{whats_app_document.rb → whats_app_datetime.rb} +48 -48
  137. data/lib/messente_api/models/{whats_app_image.rb → whats_app_language.rb} +55 -45
  138. data/lib/messente_api/models/whats_app_media.rb +246 -0
  139. data/lib/messente_api/models/whats_app_parameter.rb +278 -0
  140. data/lib/messente_api/models/whats_app_template.rb +251 -0
  141. data/lib/messente_api/version.rb +3 -3
  142. data/lib/messente_api.rb +16 -6
  143. data/messente_api.gemspec +5 -5
  144. data/spec/spec_helper.rb +2 -2
  145. metadata +35 -39
  146. data/docs/WhatsAppAudio.md +0 -17
  147. data/docs/WhatsAppDocument.md +0 -19
  148. data/docs/WhatsAppImage.md +0 -19
  149. data/docs/WhatsAppText.md +0 -19
  150. data/spec/api_client_spec.rb +0 -226
  151. data/spec/configuration_spec.rb +0 -42
@@ -0,0 +1,255 @@
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
+ # Whatsapp template component
18
+ class WhatsAppComponent
19
+ # Type of the component
20
+ attr_accessor :type
21
+
22
+ # Sub-type of the component
23
+ attr_accessor :sub_type
24
+
25
+ # index used to position buttons
26
+ attr_accessor :index
27
+
28
+ # List of parameters for the component
29
+ attr_accessor :parameters
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'type' => :'type',
35
+ :'sub_type' => :'sub_type',
36
+ :'index' => :'index',
37
+ :'parameters' => :'parameters'
38
+ }
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'type' => :'String',
50
+ :'sub_type' => :'String',
51
+ :'index' => :'Integer',
52
+ :'parameters' => :'Array<WhatsAppParameter>'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MessenteApi::WhatsAppComponent` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MessenteApi::WhatsAppComponent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'type')
78
+ self.type = attributes[:'type']
79
+ else
80
+ self.type = nil
81
+ end
82
+
83
+ if attributes.key?(:'sub_type')
84
+ self.sub_type = attributes[:'sub_type']
85
+ end
86
+
87
+ if attributes.key?(:'index')
88
+ self.index = attributes[:'index']
89
+ end
90
+
91
+ if attributes.key?(:'parameters')
92
+ if (value = attributes[:'parameters']).is_a?(Array)
93
+ self.parameters = value
94
+ end
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
102
+ invalid_properties = Array.new
103
+ if @type.nil?
104
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
105
+ end
106
+
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ warn '[DEPRECATED] the `valid?` method is obsolete'
114
+ return false if @type.nil?
115
+ true
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ type == o.type &&
124
+ sub_type == o.sub_type &&
125
+ index == o.index &&
126
+ parameters == o.parameters
127
+ end
128
+
129
+ # @see the `==` method
130
+ # @param [Object] Object to be compared
131
+ def eql?(o)
132
+ self == o
133
+ end
134
+
135
+ # Calculates hash code according to all attributes.
136
+ # @return [Integer] Hash code
137
+ def hash
138
+ [type, sub_type, index, parameters].hash
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def self.build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ attributes = attributes.transform_keys(&:to_sym)
147
+ transformed_hash = {}
148
+ openapi_types.each_pair do |key, type|
149
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
150
+ transformed_hash["#{key}"] = nil
151
+ elsif type =~ /\AArray<(.*)>/i
152
+ # check to ensure the input is an array given that the attribute
153
+ # is documented as an array but the input is not
154
+ if attributes[attribute_map[key]].is_a?(Array)
155
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
156
+ end
157
+ elsif !attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
159
+ end
160
+ end
161
+ new(transformed_hash)
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def self._deserialize(type, value)
169
+ case type.to_sym
170
+ when :Time
171
+ Time.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ # models (e.g. Pet) or oneOf
202
+ klass = MessenteApi.const_get(type)
203
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end
@@ -0,0 +1,257 @@
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
+ # Whatsapp currency object.
18
+ class WhatsAppCurrency
19
+ # Default text if localization fails.
20
+ attr_accessor :fallback_value
21
+
22
+ # Currency code as defined in ISO 4217.
23
+ attr_accessor :code
24
+
25
+ # Amount multiplied by 1000.
26
+ attr_accessor :amount_1000
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'fallback_value' => :'fallback_value',
32
+ :'code' => :'code',
33
+ :'amount_1000' => :'amount_1000'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'fallback_value' => :'String',
46
+ :'code' => :'String',
47
+ :'amount_1000' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MessenteApi::WhatsAppCurrency` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MessenteApi::WhatsAppCurrency`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'fallback_value')
73
+ self.fallback_value = attributes[:'fallback_value']
74
+ else
75
+ self.fallback_value = nil
76
+ end
77
+
78
+ if attributes.key?(:'code')
79
+ self.code = attributes[:'code']
80
+ else
81
+ self.code = nil
82
+ end
83
+
84
+ if attributes.key?(:'amount_1000')
85
+ self.amount_1000 = attributes[:'amount_1000']
86
+ else
87
+ self.amount_1000 = nil
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @fallback_value.nil?
97
+ invalid_properties.push('invalid value for "fallback_value", fallback_value cannot be nil.')
98
+ end
99
+
100
+ if @code.nil?
101
+ invalid_properties.push('invalid value for "code", code cannot be nil.')
102
+ end
103
+
104
+ if @amount_1000.nil?
105
+ invalid_properties.push('invalid value for "amount_1000", amount_1000 cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @fallback_value.nil?
116
+ return false if @code.nil?
117
+ return false if @amount_1000.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ fallback_value == o.fallback_value &&
127
+ code == o.code &&
128
+ amount_1000 == o.amount_1000
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [fallback_value, code, amount_1000].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = MessenteApi.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end