omnichannel 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +79 -0
- data/README.md +120 -0
- data/Rakefile +10 -0
- data/config.json +12 -0
- data/docs/Channel.md +7 -0
- data/docs/DeliveryReportApi.md +58 -0
- data/docs/DeliveryReportResponse.md +10 -0
- data/docs/DeliveryResult.md +13 -0
- data/docs/Err.md +7 -0
- data/docs/ErrorItem.md +11 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/Message.md +9 -0
- data/docs/MessageResult.md +10 -0
- data/docs/OmniMessageCreateSuccessResponse.md +10 -0
- data/docs/Omnimessage.md +11 -0
- data/docs/OmnimessageApi.md +107 -0
- data/docs/ResponseErrorCode.md +7 -0
- data/docs/ResponseErrorTitle.md +7 -0
- data/docs/SMS.md +13 -0
- data/docs/Status.md +7 -0
- data/docs/Viber.md +14 -0
- data/docs/WhatsApp.md +14 -0
- data/docs/WhatsAppAudio.md +8 -0
- data/docs/WhatsAppDocument.md +9 -0
- data/docs/WhatsAppImage.md +9 -0
- data/docs/WhatsAppText.md +9 -0
- data/git_push.sh +55 -0
- data/lib/omnichannel.rb +60 -0
- data/lib/omnichannel/api/delivery_report_api.rb +74 -0
- data/lib/omnichannel/api/omnimessage_api.rb +126 -0
- data/lib/omnichannel/api_client.rb +387 -0
- data/lib/omnichannel/api_error.rb +38 -0
- data/lib/omnichannel/configuration.rb +251 -0
- data/lib/omnichannel/models/channel.rb +39 -0
- data/lib/omnichannel/models/delivery_report_response.rb +229 -0
- data/lib/omnichannel/models/delivery_result.rb +239 -0
- data/lib/omnichannel/models/err.rb +48 -0
- data/lib/omnichannel/models/error_item.rb +240 -0
- data/lib/omnichannel/models/error_response.rb +198 -0
- data/lib/omnichannel/models/message.rb +207 -0
- data/lib/omnichannel/models/message_result.rb +226 -0
- data/lib/omnichannel/models/omni_message_create_success_response.rb +229 -0
- data/lib/omnichannel/models/omnimessage.rb +233 -0
- data/lib/omnichannel/models/response_error_code.rb +43 -0
- data/lib/omnichannel/models/response_error_title.rb +42 -0
- data/lib/omnichannel/models/sms.rb +249 -0
- data/lib/omnichannel/models/status.rb +47 -0
- data/lib/omnichannel/models/viber.rb +254 -0
- data/lib/omnichannel/models/whats_app.rb +250 -0
- data/lib/omnichannel/models/whats_app_audio.rb +197 -0
- data/lib/omnichannel/models/whats_app_document.rb +207 -0
- data/lib/omnichannel/models/whats_app_image.rb +207 -0
- data/lib/omnichannel/models/whats_app_text.rb +209 -0
- data/lib/omnichannel/version.rb +15 -0
- data/lib/openapi_client.rb +61 -0
- data/lib/openapi_client/api/delivery_report_api.rb +74 -0
- data/lib/openapi_client/api/omnimessage_api.rb +126 -0
- data/lib/openapi_client/api_client.rb +387 -0
- data/lib/openapi_client/api_error.rb +38 -0
- data/lib/openapi_client/configuration.rb +251 -0
- data/lib/openapi_client/models/channel.rb +39 -0
- data/lib/openapi_client/models/delivery_report_response.rb +229 -0
- data/lib/openapi_client/models/delivery_result.rb +239 -0
- data/lib/openapi_client/models/err.rb +48 -0
- data/lib/openapi_client/models/error_item.rb +240 -0
- data/lib/openapi_client/models/error_response.rb +198 -0
- data/lib/openapi_client/models/message.rb +221 -0
- data/lib/openapi_client/models/message_result.rb +226 -0
- data/lib/openapi_client/models/omni_message_create_success_response.rb +229 -0
- data/lib/openapi_client/models/omnimessage.rb +233 -0
- data/lib/openapi_client/models/response_error_code.rb +43 -0
- data/lib/openapi_client/models/response_error_title.rb +42 -0
- data/lib/openapi_client/models/sms.rb +228 -0
- data/lib/openapi_client/models/status.rb +47 -0
- data/lib/openapi_client/models/viber.rb +233 -0
- data/lib/openapi_client/models/whats_app.rb +229 -0
- data/lib/openapi_client/models/whats_app_audio.rb +197 -0
- data/lib/openapi_client/models/whats_app_document.rb +207 -0
- data/lib/openapi_client/models/whats_app_image.rb +207 -0
- data/lib/openapi_client/models/whats_app_text.rb +209 -0
- data/lib/openapi_client/version.rb +15 -0
- data/omnichannel.gemspec +45 -0
- data/spec/api/delivery_report_api_spec.rb +46 -0
- data/spec/api/omnimessage_api_spec.rb +57 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/channel_spec.rb +35 -0
- data/spec/models/delivery_report_response_spec.rb +53 -0
- data/spec/models/delivery_result_spec.rb +71 -0
- data/spec/models/err_spec.rb +35 -0
- data/spec/models/error_item_spec.rb +59 -0
- data/spec/models/error_response_spec.rb +41 -0
- data/spec/models/message_result_spec.rb +53 -0
- data/spec/models/message_spec.rb +53 -0
- data/spec/models/omni_message_create_success_response_spec.rb +53 -0
- data/spec/models/omnimessage_spec.rb +59 -0
- data/spec/models/response_error_code_spec.rb +35 -0
- data/spec/models/response_error_title_spec.rb +35 -0
- data/spec/models/sms_spec.rb +71 -0
- data/spec/models/status_spec.rb +35 -0
- data/spec/models/viber_spec.rb +77 -0
- data/spec/models/whats_app_audio_spec.rb +41 -0
- data/spec/models/whats_app_document_spec.rb +47 -0
- data/spec/models/whats_app_image_spec.rb +47 -0
- data/spec/models/whats_app_spec.rb +77 -0
- data/spec/models/whats_app_text_spec.rb +47 -0
- data/spec/spec_helper.rb +111 -0
- data/templates/README.mustache +114 -0
- metadata +358 -0
@@ -0,0 +1,229 @@
|
|
1
|
+
=begin
|
2
|
+
#Omnichannel API
|
3
|
+
|
4
|
+
#Messente's API which allows sending messages via various channels with fallback options.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.2
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module OpenapiClient
|
16
|
+
class OmniMessageCreateSuccessResponse
|
17
|
+
# List of messages that compose the Omnimessage
|
18
|
+
attr_accessor :messages
|
19
|
+
|
20
|
+
# Recipient phone number in e.164 format
|
21
|
+
attr_accessor :to
|
22
|
+
|
23
|
+
# Unique identifier for the Omnimessage
|
24
|
+
attr_accessor :omnimessage_id
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'messages' => :'messages',
|
30
|
+
:'to' => :'to',
|
31
|
+
:'omnimessage_id' => :'omnimessage_id'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'messages' => :'Array<MessageResult>',
|
39
|
+
:'to' => :'String',
|
40
|
+
:'omnimessage_id' => :'String'
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
return unless attributes.is_a?(Hash)
|
48
|
+
|
49
|
+
# convert string to symbol for hash key
|
50
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
51
|
+
|
52
|
+
if attributes.has_key?(:'messages')
|
53
|
+
if (value = attributes[:'messages']).is_a?(Array)
|
54
|
+
self.messages = value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes.has_key?(:'to')
|
59
|
+
self.to = attributes[:'to']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:'omnimessage_id')
|
63
|
+
self.omnimessage_id = attributes[:'omnimessage_id']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
68
|
+
# @return Array for valid properties with the reasons
|
69
|
+
def list_invalid_properties
|
70
|
+
invalid_properties = Array.new
|
71
|
+
if @messages.nil?
|
72
|
+
invalid_properties.push('invalid value for "messages", messages cannot be nil.')
|
73
|
+
end
|
74
|
+
|
75
|
+
if @to.nil?
|
76
|
+
invalid_properties.push('invalid value for "to", to cannot be nil.')
|
77
|
+
end
|
78
|
+
|
79
|
+
if @omnimessage_id.nil?
|
80
|
+
invalid_properties.push('invalid value for "omnimessage_id", omnimessage_id cannot be nil.')
|
81
|
+
end
|
82
|
+
|
83
|
+
invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
return false if @messages.nil?
|
90
|
+
return false if @to.nil?
|
91
|
+
return false if @omnimessage_id.nil?
|
92
|
+
true
|
93
|
+
end
|
94
|
+
|
95
|
+
# Checks equality by comparing each attribute.
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def ==(o)
|
98
|
+
return true if self.equal?(o)
|
99
|
+
self.class == o.class &&
|
100
|
+
messages == o.messages &&
|
101
|
+
to == o.to &&
|
102
|
+
omnimessage_id == o.omnimessage_id
|
103
|
+
end
|
104
|
+
|
105
|
+
# @see the `==` method
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def eql?(o)
|
108
|
+
self == o
|
109
|
+
end
|
110
|
+
|
111
|
+
# Calculates hash code according to all attributes.
|
112
|
+
# @return [Fixnum] Hash code
|
113
|
+
def hash
|
114
|
+
[messages, to, omnimessage_id].hash
|
115
|
+
end
|
116
|
+
|
117
|
+
# Builds the object from hash
|
118
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
119
|
+
# @return [Object] Returns the model itself
|
120
|
+
def self.build_from_hash(attributes)
|
121
|
+
new.build_from_hash(attributes)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def build_from_hash(attributes)
|
128
|
+
return nil unless attributes.is_a?(Hash)
|
129
|
+
self.class.openapi_types.each_pair do |key, type|
|
130
|
+
if type =~ /\AArray<(.*)>/i
|
131
|
+
# check to ensure the input is an array given that the attribute
|
132
|
+
# is documented as an array but the input is not
|
133
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
134
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
135
|
+
end
|
136
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
137
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
138
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
139
|
+
end
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
# Deserializes the data based on type
|
145
|
+
# @param string type Data type
|
146
|
+
# @param string value Value to be deserialized
|
147
|
+
# @return [Object] Deserialized data
|
148
|
+
def _deserialize(type, value)
|
149
|
+
case type.to_sym
|
150
|
+
when :DateTime
|
151
|
+
DateTime.parse(value)
|
152
|
+
when :Date
|
153
|
+
Date.parse(value)
|
154
|
+
when :String
|
155
|
+
value.to_s
|
156
|
+
when :Integer
|
157
|
+
value.to_i
|
158
|
+
when :Float
|
159
|
+
value.to_f
|
160
|
+
when :BOOLEAN
|
161
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
162
|
+
true
|
163
|
+
else
|
164
|
+
false
|
165
|
+
end
|
166
|
+
when :Object
|
167
|
+
# generic object (usually a Hash), return directly
|
168
|
+
value
|
169
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
170
|
+
inner_type = Regexp.last_match[:inner_type]
|
171
|
+
value.map { |v| _deserialize(inner_type, v) }
|
172
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
173
|
+
k_type = Regexp.last_match[:k_type]
|
174
|
+
v_type = Regexp.last_match[:v_type]
|
175
|
+
{}.tap do |hash|
|
176
|
+
value.each do |k, v|
|
177
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
else # model
|
181
|
+
OpenapiClient.const_get(type).build_from_hash(value)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the string representation of the object
|
186
|
+
# @return [String] String presentation of the object
|
187
|
+
def to_s
|
188
|
+
to_hash.to_s
|
189
|
+
end
|
190
|
+
|
191
|
+
# to_body is an alias to to_hash (backward compatibility)
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_body
|
194
|
+
to_hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the object in the form of hash
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_hash
|
200
|
+
hash = {}
|
201
|
+
self.class.attribute_map.each_pair do |attr, param|
|
202
|
+
value = self.send(attr)
|
203
|
+
next if value.nil?
|
204
|
+
hash[param] = _to_hash(value)
|
205
|
+
end
|
206
|
+
hash
|
207
|
+
end
|
208
|
+
|
209
|
+
# Outputs non-array value in the form of hash
|
210
|
+
# For object, use to_hash. Otherwise, just return the value
|
211
|
+
# @param [Object] value Any valid value
|
212
|
+
# @return [Hash] Returns the value in the form of hash
|
213
|
+
def _to_hash(value)
|
214
|
+
if value.is_a?(Array)
|
215
|
+
value.compact.map { |v| _to_hash(v) }
|
216
|
+
elsif value.is_a?(Hash)
|
217
|
+
{}.tap do |hash|
|
218
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
219
|
+
end
|
220
|
+
elsif value.respond_to? :to_hash
|
221
|
+
value.to_hash
|
222
|
+
else
|
223
|
+
value
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
=begin
|
2
|
+
#Omnichannel API
|
3
|
+
|
4
|
+
#Messente's API which allows sending messages via various channels with fallback options.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.2
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module OpenapiClient
|
16
|
+
class Omnimessage
|
17
|
+
attr_accessor :messages
|
18
|
+
|
19
|
+
# Phone number of the recipient in e.164 format
|
20
|
+
attr_accessor :to
|
21
|
+
|
22
|
+
# URL where the delivery report will be sent
|
23
|
+
attr_accessor :dlr_url
|
24
|
+
|
25
|
+
# Optional parameter for sending messages at some specific time in the future. Time must be specified in the 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)
|
26
|
+
attr_accessor :time_to_send
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'messages' => :'messages',
|
32
|
+
:'to' => :'to',
|
33
|
+
:'dlr_url' => :'dlr_url',
|
34
|
+
:'time_to_send' => :'time_to_send'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'messages' => :'Array<OneOfViberSMSWhatsApp>',
|
42
|
+
:'to' => :'String',
|
43
|
+
:'dlr_url' => :'String',
|
44
|
+
:'time_to_send' => :'DateTime'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Initializes the object
|
49
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
50
|
+
def initialize(attributes = {})
|
51
|
+
return unless attributes.is_a?(Hash)
|
52
|
+
|
53
|
+
# convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
55
|
+
|
56
|
+
if attributes.has_key?(:'messages')
|
57
|
+
if (value = attributes[:'messages']).is_a?(Array)
|
58
|
+
self.messages = value
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:'to')
|
63
|
+
self.to = attributes[:'to']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:'dlr_url')
|
67
|
+
self.dlr_url = attributes[:'dlr_url']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:'time_to_send')
|
71
|
+
self.time_to_send = attributes[:'time_to_send']
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
76
|
+
# @return Array for valid properties with the reasons
|
77
|
+
def list_invalid_properties
|
78
|
+
invalid_properties = Array.new
|
79
|
+
if @messages.nil?
|
80
|
+
invalid_properties.push('invalid value for "messages", messages cannot be nil.')
|
81
|
+
end
|
82
|
+
|
83
|
+
if @to.nil?
|
84
|
+
invalid_properties.push('invalid value for "to", to cannot be nil.')
|
85
|
+
end
|
86
|
+
|
87
|
+
invalid_properties
|
88
|
+
end
|
89
|
+
|
90
|
+
# Check to see if the all the properties in the model are valid
|
91
|
+
# @return true if the model is valid
|
92
|
+
def valid?
|
93
|
+
return false if @messages.nil?
|
94
|
+
return false if @to.nil?
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
# Checks equality by comparing each attribute.
|
99
|
+
# @param [Object] Object to be compared
|
100
|
+
def ==(o)
|
101
|
+
return true if self.equal?(o)
|
102
|
+
self.class == o.class &&
|
103
|
+
messages == o.messages &&
|
104
|
+
to == o.to &&
|
105
|
+
dlr_url == o.dlr_url &&
|
106
|
+
time_to_send == o.time_to_send
|
107
|
+
end
|
108
|
+
|
109
|
+
# @see the `==` method
|
110
|
+
# @param [Object] Object to be compared
|
111
|
+
def eql?(o)
|
112
|
+
self == o
|
113
|
+
end
|
114
|
+
|
115
|
+
# Calculates hash code according to all attributes.
|
116
|
+
# @return [Fixnum] Hash code
|
117
|
+
def hash
|
118
|
+
[messages, to, dlr_url, time_to_send].hash
|
119
|
+
end
|
120
|
+
|
121
|
+
# Builds the object from hash
|
122
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
123
|
+
# @return [Object] Returns the model itself
|
124
|
+
def self.build_from_hash(attributes)
|
125
|
+
new.build_from_hash(attributes)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Builds the object from hash
|
129
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
130
|
+
# @return [Object] Returns the model itself
|
131
|
+
def build_from_hash(attributes)
|
132
|
+
return nil unless attributes.is_a?(Hash)
|
133
|
+
self.class.openapi_types.each_pair do |key, type|
|
134
|
+
if type =~ /\AArray<(.*)>/i
|
135
|
+
# check to ensure the input is an array given that the attribute
|
136
|
+
# is documented as an array but the input is not
|
137
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
138
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
139
|
+
end
|
140
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
141
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
142
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
143
|
+
end
|
144
|
+
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
# Deserializes the data based on type
|
149
|
+
# @param string type Data type
|
150
|
+
# @param string value Value to be deserialized
|
151
|
+
# @return [Object] Deserialized data
|
152
|
+
def _deserialize(type, value)
|
153
|
+
case type.to_sym
|
154
|
+
when :DateTime
|
155
|
+
DateTime.parse(value)
|
156
|
+
when :Date
|
157
|
+
Date.parse(value)
|
158
|
+
when :String
|
159
|
+
value.to_s
|
160
|
+
when :Integer
|
161
|
+
value.to_i
|
162
|
+
when :Float
|
163
|
+
value.to_f
|
164
|
+
when :BOOLEAN
|
165
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
166
|
+
true
|
167
|
+
else
|
168
|
+
false
|
169
|
+
end
|
170
|
+
when :Object
|
171
|
+
# generic object (usually a Hash), return directly
|
172
|
+
value
|
173
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
174
|
+
inner_type = Regexp.last_match[:inner_type]
|
175
|
+
value.map { |v| _deserialize(inner_type, v) }
|
176
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
177
|
+
k_type = Regexp.last_match[:k_type]
|
178
|
+
v_type = Regexp.last_match[:v_type]
|
179
|
+
{}.tap do |hash|
|
180
|
+
value.each do |k, v|
|
181
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
else # model
|
185
|
+
OpenapiClient.const_get(type).build_from_hash(value)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns the string representation of the object
|
190
|
+
# @return [String] String presentation of the object
|
191
|
+
def to_s
|
192
|
+
to_hash.to_s
|
193
|
+
end
|
194
|
+
|
195
|
+
# to_body is an alias to to_hash (backward compatibility)
|
196
|
+
# @return [Hash] Returns the object in the form of hash
|
197
|
+
def to_body
|
198
|
+
to_hash
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the object in the form of hash
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
203
|
+
def to_hash
|
204
|
+
hash = {}
|
205
|
+
self.class.attribute_map.each_pair do |attr, param|
|
206
|
+
value = self.send(attr)
|
207
|
+
next if value.nil?
|
208
|
+
hash[param] = _to_hash(value)
|
209
|
+
end
|
210
|
+
hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Outputs non-array value in the form of hash
|
214
|
+
# For object, use to_hash. Otherwise, just return the value
|
215
|
+
# @param [Object] value Any valid value
|
216
|
+
# @return [Hash] Returns the value in the form of hash
|
217
|
+
def _to_hash(value)
|
218
|
+
if value.is_a?(Array)
|
219
|
+
value.compact.map { |v| _to_hash(v) }
|
220
|
+
elsif value.is_a?(Hash)
|
221
|
+
{}.tap do |hash|
|
222
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
223
|
+
end
|
224
|
+
elsif value.respond_to? :to_hash
|
225
|
+
value.to_hash
|
226
|
+
else
|
227
|
+
value
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|