messente_api 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -3
- data/docs/ErrorCodeStatistics.md +16 -0
- data/docs/ErrorItemNumberLookup.md +17 -0
- data/docs/ErrorItemNumberLookupError.md +19 -0
- data/docs/ErrorItemStatistics.md +21 -0
- data/docs/ErrorNumberLookup.md +17 -0
- data/docs/ErrorStatistics.md +17 -0
- data/docs/MobileNetwork.md +25 -0
- data/docs/NumberLookupApi.md +60 -0
- data/docs/NumbersToInvestigate.md +17 -0
- data/docs/StatisticsApi.md +60 -0
- data/docs/StatisticsReport.md +21 -0
- data/docs/StatisticsReportSettings.md +21 -0
- data/docs/StatisticsReportSuccess.md +17 -0
- data/docs/SyncNumberLookupResult.md +33 -0
- data/docs/SyncNumberLookupSuccess.md +19 -0
- data/lib/messente_api.rb +17 -2
- data/lib/messente_api/api/blacklist_api.rb +2 -2
- data/lib/messente_api/api/contacts_api.rb +2 -2
- data/lib/messente_api/api/delivery_report_api.rb +2 -2
- data/lib/messente_api/api/groups_api.rb +2 -2
- data/lib/messente_api/api/number_lookup_api.rb +84 -0
- data/lib/messente_api/api/omnimessage_api.rb +2 -2
- data/lib/messente_api/api/statistics_api.rb +84 -0
- data/lib/messente_api/api_client.rb +2 -2
- data/lib/messente_api/api_error.rb +2 -2
- data/lib/messente_api/configuration.rb +2 -2
- data/lib/messente_api/models/channel.rb +2 -2
- data/lib/messente_api/models/contact_envelope.rb +2 -2
- data/lib/messente_api/models/contact_fields.rb +2 -2
- data/lib/messente_api/models/contact_list_envelope.rb +2 -2
- data/lib/messente_api/models/contact_update_fields.rb +2 -2
- data/lib/messente_api/models/delivery_report_response.rb +2 -2
- data/lib/messente_api/models/delivery_result.rb +2 -2
- data/lib/messente_api/models/error_code_omnichannel.rb +2 -2
- data/lib/messente_api/models/error_code_omnichannel_machine.rb +2 -2
- data/lib/messente_api/models/error_code_phonebook.rb +2 -2
- data/lib/messente_api/models/error_code_statistics.rb +38 -0
- data/lib/messente_api/models/error_item_number_lookup.rb +202 -0
- data/lib/messente_api/models/error_item_number_lookup_error.rb +246 -0
- data/lib/messente_api/models/error_item_omnichannel.rb +2 -2
- data/lib/messente_api/models/error_item_phonebook.rb +2 -2
- data/lib/messente_api/models/error_item_statistics.rb +232 -0
- data/lib/messente_api/models/error_number_lookup.rb +205 -0
- data/lib/messente_api/models/error_omnichannel.rb +2 -2
- data/lib/messente_api/models/error_phonebook.rb +2 -2
- data/lib/messente_api/models/error_statistics.rb +205 -0
- data/lib/messente_api/models/error_title_omnichannel.rb +2 -2
- data/lib/messente_api/models/error_title_phonebook.rb +2 -2
- data/lib/messente_api/models/fetch_blacklist_success.rb +2 -2
- data/lib/messente_api/models/group_envelope.rb +2 -2
- data/lib/messente_api/models/group_list_envelope.rb +2 -2
- data/lib/messente_api/models/group_name.rb +2 -2
- data/lib/messente_api/models/group_response_fields.rb +2 -2
- data/lib/messente_api/models/message_result.rb +2 -2
- data/lib/messente_api/models/mobile_network.rb +238 -0
- data/lib/messente_api/models/number_to_blacklist.rb +2 -2
- data/lib/messente_api/models/numbers_to_investigate.rb +205 -0
- data/lib/messente_api/models/omni_message_create_success_response.rb +2 -2
- data/lib/messente_api/models/omnimessage.rb +2 -2
- data/lib/messente_api/models/sms.rb +2 -2
- data/lib/messente_api/models/statistics_report.rb +233 -0
- data/lib/messente_api/models/statistics_report_settings.rb +230 -0
- data/lib/messente_api/models/statistics_report_success.rb +205 -0
- data/lib/messente_api/models/status.rb +2 -2
- data/lib/messente_api/models/sync_number_lookup_result.rb +313 -0
- data/lib/messente_api/models/sync_number_lookup_success.rb +220 -0
- data/lib/messente_api/models/telegram.rb +2 -2
- data/lib/messente_api/models/text_store.rb +2 -2
- data/lib/messente_api/models/viber.rb +2 -2
- data/lib/messente_api/models/whats_app.rb +2 -2
- data/lib/messente_api/models/whats_app_audio.rb +2 -2
- data/lib/messente_api/models/whats_app_document.rb +2 -2
- data/lib/messente_api/models/whats_app_image.rb +2 -2
- data/lib/messente_api/models/whats_app_text.rb +2 -2
- data/lib/messente_api/version.rb +3 -3
- data/messente_api.gemspec +3 -3
- data/spec/api_client_spec.rb +2 -2
- data/spec/configuration_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +38 -7
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
2
|
#Messente API
|
3
3
|
|
4
|
-
#[Messente](https://messente.com) is a global provider of messaging and user verification services.
|
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.
|
6
|
+
The version of the OpenAPI document: 1.2.0
|
7
7
|
Contact: messente@messente.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
9
|
OpenAPI Generator version: 4.0.3
|
@@ -0,0 +1,205 @@
|
|
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: 1.2.0
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module MessenteApi
|
16
|
+
# A container for phone numbers
|
17
|
+
class NumbersToInvestigate
|
18
|
+
# Array of phone numbers
|
19
|
+
attr_accessor :numbers
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'numbers' => :'numbers'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.openapi_types
|
30
|
+
{
|
31
|
+
:'numbers' => :'Array<String>'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
if (!attributes.is_a?(Hash))
|
39
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MessenteApi::NumbersToInvestigate` initialize method"
|
40
|
+
end
|
41
|
+
|
42
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
44
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
45
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MessenteApi::NumbersToInvestigate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
46
|
+
end
|
47
|
+
h[k.to_sym] = v
|
48
|
+
}
|
49
|
+
|
50
|
+
if attributes.key?(:'numbers')
|
51
|
+
if (value = attributes[:'numbers']).is_a?(Array)
|
52
|
+
self.numbers = value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
58
|
+
# @return Array for valid properties with the reasons
|
59
|
+
def list_invalid_properties
|
60
|
+
invalid_properties = Array.new
|
61
|
+
if @numbers.nil?
|
62
|
+
invalid_properties.push('invalid value for "numbers", numbers cannot be nil.')
|
63
|
+
end
|
64
|
+
|
65
|
+
invalid_properties
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check to see if the all the properties in the model are valid
|
69
|
+
# @return true if the model is valid
|
70
|
+
def valid?
|
71
|
+
return false if @numbers.nil?
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
# Checks equality by comparing each attribute.
|
76
|
+
# @param [Object] Object to be compared
|
77
|
+
def ==(o)
|
78
|
+
return true if self.equal?(o)
|
79
|
+
self.class == o.class &&
|
80
|
+
numbers == o.numbers
|
81
|
+
end
|
82
|
+
|
83
|
+
# @see the `==` method
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def eql?(o)
|
86
|
+
self == o
|
87
|
+
end
|
88
|
+
|
89
|
+
# Calculates hash code according to all attributes.
|
90
|
+
# @return [Integer] Hash code
|
91
|
+
def hash
|
92
|
+
[numbers].hash
|
93
|
+
end
|
94
|
+
|
95
|
+
# Builds the object from hash
|
96
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
97
|
+
# @return [Object] Returns the model itself
|
98
|
+
def self.build_from_hash(attributes)
|
99
|
+
new.build_from_hash(attributes)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Builds the object from hash
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
# @return [Object] Returns the model itself
|
105
|
+
def build_from_hash(attributes)
|
106
|
+
return nil unless attributes.is_a?(Hash)
|
107
|
+
self.class.openapi_types.each_pair do |key, type|
|
108
|
+
if type =~ /\AArray<(.*)>/i
|
109
|
+
# check to ensure the input is an array given that the attribute
|
110
|
+
# is documented as an array but the input is not
|
111
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
112
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
113
|
+
end
|
114
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
115
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
116
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
117
|
+
end
|
118
|
+
|
119
|
+
self
|
120
|
+
end
|
121
|
+
|
122
|
+
# Deserializes the data based on type
|
123
|
+
# @param string type Data type
|
124
|
+
# @param string value Value to be deserialized
|
125
|
+
# @return [Object] Deserialized data
|
126
|
+
def _deserialize(type, value)
|
127
|
+
case type.to_sym
|
128
|
+
when :DateTime
|
129
|
+
DateTime.parse(value)
|
130
|
+
when :Date
|
131
|
+
Date.parse(value)
|
132
|
+
when :String
|
133
|
+
value.to_s
|
134
|
+
when :Integer
|
135
|
+
value.to_i
|
136
|
+
when :Float
|
137
|
+
value.to_f
|
138
|
+
when :Boolean
|
139
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
140
|
+
true
|
141
|
+
else
|
142
|
+
false
|
143
|
+
end
|
144
|
+
when :Object
|
145
|
+
# generic object (usually a Hash), return directly
|
146
|
+
value
|
147
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
148
|
+
inner_type = Regexp.last_match[:inner_type]
|
149
|
+
value.map { |v| _deserialize(inner_type, v) }
|
150
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
151
|
+
k_type = Regexp.last_match[:k_type]
|
152
|
+
v_type = Regexp.last_match[:v_type]
|
153
|
+
{}.tap do |hash|
|
154
|
+
value.each do |k, v|
|
155
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
else # model
|
159
|
+
MessenteApi.const_get(type).build_from_hash(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the string representation of the object
|
164
|
+
# @return [String] String presentation of the object
|
165
|
+
def to_s
|
166
|
+
to_hash.to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
# to_body is an alias to to_hash (backward compatibility)
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_body
|
172
|
+
to_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the object in the form of hash
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
177
|
+
def to_hash
|
178
|
+
hash = {}
|
179
|
+
self.class.attribute_map.each_pair do |attr, param|
|
180
|
+
value = self.send(attr)
|
181
|
+
next if value.nil?
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Outputs non-array value in the form of hash
|
188
|
+
# For object, use to_hash. Otherwise, just return the value
|
189
|
+
# @param [Object] value Any valid value
|
190
|
+
# @return [Hash] Returns the value in the form of hash
|
191
|
+
def _to_hash(value)
|
192
|
+
if value.is_a?(Array)
|
193
|
+
value.compact.map { |v| _to_hash(v) }
|
194
|
+
elsif value.is_a?(Hash)
|
195
|
+
{}.tap do |hash|
|
196
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
197
|
+
end
|
198
|
+
elsif value.respond_to? :to_hash
|
199
|
+
value.to_hash
|
200
|
+
else
|
201
|
+
value
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
2
|
#Messente API
|
3
3
|
|
4
|
-
#[Messente](https://messente.com) is a global provider of messaging and user verification services.
|
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.
|
6
|
+
The version of the OpenAPI document: 1.2.0
|
7
7
|
Contact: messente@messente.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
9
|
OpenAPI Generator version: 4.0.3
|
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
2
|
#Messente API
|
3
3
|
|
4
|
-
#[Messente](https://messente.com) is a global provider of messaging and user verification services.
|
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.
|
6
|
+
The version of the OpenAPI document: 1.2.0
|
7
7
|
Contact: messente@messente.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
9
|
OpenAPI Generator version: 4.0.3
|
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
2
|
#Messente API
|
3
3
|
|
4
|
-
#[Messente](https://messente.com) is a global provider of messaging and user verification services.
|
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.
|
6
|
+
The version of the OpenAPI document: 1.2.0
|
7
7
|
Contact: messente@messente.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
9
|
OpenAPI Generator version: 4.0.3
|
@@ -0,0 +1,233 @@
|
|
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: 1.2.0
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module MessenteApi
|
16
|
+
# Report for one country
|
17
|
+
class StatisticsReport
|
18
|
+
# Sum of all messages
|
19
|
+
attr_accessor :total_messages
|
20
|
+
|
21
|
+
# Price for all messages
|
22
|
+
attr_accessor :total_price
|
23
|
+
|
24
|
+
# Target country of all messages
|
25
|
+
attr_accessor :country
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'total_messages' => :'total_messages',
|
31
|
+
:'total_price' => :'total_price',
|
32
|
+
:'country' => :'country'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute type mapping.
|
37
|
+
def self.openapi_types
|
38
|
+
{
|
39
|
+
:'total_messages' => :'Integer',
|
40
|
+
:'total_price' => :'String',
|
41
|
+
:'country' => :'String'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
if (!attributes.is_a?(Hash))
|
49
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MessenteApi::StatisticsReport` initialize method"
|
50
|
+
end
|
51
|
+
|
52
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
54
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
55
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MessenteApi::StatisticsReport`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
56
|
+
end
|
57
|
+
h[k.to_sym] = v
|
58
|
+
}
|
59
|
+
|
60
|
+
if attributes.key?(:'total_messages')
|
61
|
+
self.total_messages = attributes[:'total_messages']
|
62
|
+
end
|
63
|
+
|
64
|
+
if attributes.key?(:'total_price')
|
65
|
+
self.total_price = attributes[:'total_price']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'country')
|
69
|
+
self.country = attributes[:'country']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
if @total_messages.nil?
|
78
|
+
invalid_properties.push('invalid value for "total_messages", total_messages cannot be nil.')
|
79
|
+
end
|
80
|
+
|
81
|
+
if @total_price.nil?
|
82
|
+
invalid_properties.push('invalid value for "total_price", total_price cannot be nil.')
|
83
|
+
end
|
84
|
+
|
85
|
+
if @country.nil?
|
86
|
+
invalid_properties.push('invalid value for "country", country cannot be nil.')
|
87
|
+
end
|
88
|
+
|
89
|
+
invalid_properties
|
90
|
+
end
|
91
|
+
|
92
|
+
# Check to see if the all the properties in the model are valid
|
93
|
+
# @return true if the model is valid
|
94
|
+
def valid?
|
95
|
+
return false if @total_messages.nil?
|
96
|
+
return false if @total_price.nil?
|
97
|
+
return false if @country.nil?
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
# Checks equality by comparing each attribute.
|
102
|
+
# @param [Object] Object to be compared
|
103
|
+
def ==(o)
|
104
|
+
return true if self.equal?(o)
|
105
|
+
self.class == o.class &&
|
106
|
+
total_messages == o.total_messages &&
|
107
|
+
total_price == o.total_price &&
|
108
|
+
country == o.country
|
109
|
+
end
|
110
|
+
|
111
|
+
# @see the `==` method
|
112
|
+
# @param [Object] Object to be compared
|
113
|
+
def eql?(o)
|
114
|
+
self == o
|
115
|
+
end
|
116
|
+
|
117
|
+
# Calculates hash code according to all attributes.
|
118
|
+
# @return [Integer] Hash code
|
119
|
+
def hash
|
120
|
+
[total_messages, total_price, country].hash
|
121
|
+
end
|
122
|
+
|
123
|
+
# Builds the object from hash
|
124
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
125
|
+
# @return [Object] Returns the model itself
|
126
|
+
def self.build_from_hash(attributes)
|
127
|
+
new.build_from_hash(attributes)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Builds the object from hash
|
131
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
132
|
+
# @return [Object] Returns the model itself
|
133
|
+
def build_from_hash(attributes)
|
134
|
+
return nil unless attributes.is_a?(Hash)
|
135
|
+
self.class.openapi_types.each_pair do |key, type|
|
136
|
+
if type =~ /\AArray<(.*)>/i
|
137
|
+
# check to ensure the input is an array given that the attribute
|
138
|
+
# is documented as an array but the input is not
|
139
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
140
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
141
|
+
end
|
142
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
143
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
144
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
145
|
+
end
|
146
|
+
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
# Deserializes the data based on type
|
151
|
+
# @param string type Data type
|
152
|
+
# @param string value Value to be deserialized
|
153
|
+
# @return [Object] Deserialized data
|
154
|
+
def _deserialize(type, value)
|
155
|
+
case type.to_sym
|
156
|
+
when :DateTime
|
157
|
+
DateTime.parse(value)
|
158
|
+
when :Date
|
159
|
+
Date.parse(value)
|
160
|
+
when :String
|
161
|
+
value.to_s
|
162
|
+
when :Integer
|
163
|
+
value.to_i
|
164
|
+
when :Float
|
165
|
+
value.to_f
|
166
|
+
when :Boolean
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
MessenteApi.const_get(type).build_from_hash(value)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the string representation of the object
|
192
|
+
# @return [String] String presentation of the object
|
193
|
+
def to_s
|
194
|
+
to_hash.to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the object in the form of hash
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_hash
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
next if value.nil?
|
210
|
+
hash[param] = _to_hash(value)
|
211
|
+
end
|
212
|
+
hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Outputs non-array value in the form of hash
|
216
|
+
# For object, use to_hash. Otherwise, just return the value
|
217
|
+
# @param [Object] value Any valid value
|
218
|
+
# @return [Hash] Returns the value in the form of hash
|
219
|
+
def _to_hash(value)
|
220
|
+
if value.is_a?(Array)
|
221
|
+
value.compact.map { |v| _to_hash(v) }
|
222
|
+
elsif value.is_a?(Hash)
|
223
|
+
{}.tap do |hash|
|
224
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
225
|
+
end
|
226
|
+
elsif value.respond_to? :to_hash
|
227
|
+
value.to_hash
|
228
|
+
else
|
229
|
+
value
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|