rainbow-submarine-test-3356 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/README.md +150 -0
- data/Rakefile +8 -0
- data/docs/AppUser.md +14 -0
- data/docs/AppUserApi.md +616 -0
- data/docs/AppUserLink.md +9 -0
- data/docs/AppUserPreCreate.md +14 -0
- data/docs/AppUserResponse.md +8 -0
- data/docs/AppUserUpdate.md +12 -0
- data/docs/Client.md +12 -0
- data/docs/ClientInfo.md +15 -0
- data/docs/ClientResponse.md +8 -0
- data/docs/Conversation.md +9 -0
- data/docs/ConversationApi.md +192 -0
- data/docs/DeviceUpdate.md +10 -0
- data/docs/Event.md +8 -0
- data/docs/GetMessagesResponse.md +10 -0
- data/docs/Menu.md +9 -0
- data/docs/MenuApi.md +163 -0
- data/docs/MenuItem.md +13 -0
- data/docs/MenuResponse.md +8 -0
- data/docs/Message.md +17 -0
- data/docs/MessageResponse.md +9 -0
- data/docs/Postback.md +11 -0
- data/docs/TrackEventResponse.md +8 -0
- data/docs/TypingActivityTrigger.md +11 -0
- data/git_push.sh +55 -0
- data/lib/rainbow-submarine-test-3356.rb +61 -0
- data/lib/rainbow-submarine-test-3356/api/app_user_api.rb +585 -0
- data/lib/rainbow-submarine-test-3356/api/conversation_api.rb +189 -0
- data/lib/rainbow-submarine-test-3356/api/menu_api.rb +173 -0
- data/lib/rainbow-submarine-test-3356/api_client.rb +376 -0
- data/lib/rainbow-submarine-test-3356/api_error.rb +37 -0
- data/lib/rainbow-submarine-test-3356/configuration.rb +209 -0
- data/lib/rainbow-submarine-test-3356/models/app_user.rb +258 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_link.rb +201 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_pre_create.rb +246 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_response.rb +192 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_update.rb +223 -0
- data/lib/rainbow-submarine-test-3356/models/client.rb +248 -0
- data/lib/rainbow-submarine-test-3356/models/client_info.rb +250 -0
- data/lib/rainbow-submarine-test-3356/models/client_response.rb +187 -0
- data/lib/rainbow-submarine-test-3356/models/conversation.rb +206 -0
- data/lib/rainbow-submarine-test-3356/models/device_update.rb +205 -0
- data/lib/rainbow-submarine-test-3356/models/event.rb +192 -0
- data/lib/rainbow-submarine-test-3356/models/get_messages_response.rb +207 -0
- data/lib/rainbow-submarine-test-3356/models/menu.rb +203 -0
- data/lib/rainbow-submarine-test-3356/models/menu_item.rb +242 -0
- data/lib/rainbow-submarine-test-3356/models/menu_response.rb +192 -0
- data/lib/rainbow-submarine-test-3356/models/message.rb +303 -0
- data/lib/rainbow-submarine-test-3356/models/message_response.rb +206 -0
- data/lib/rainbow-submarine-test-3356/models/postback.rb +229 -0
- data/lib/rainbow-submarine-test-3356/models/track_event_response.rb +187 -0
- data/lib/rainbow-submarine-test-3356/models/typing_activity_trigger.rb +224 -0
- data/lib/rainbow-submarine-test-3356/version.rb +14 -0
- data/lib/swagger_client.rb +61 -0
- data/lib/swagger_client/api/app_user_api.rb +585 -0
- data/lib/swagger_client/api/conversation_api.rb +189 -0
- data/lib/swagger_client/api/menu_api.rb +173 -0
- data/lib/swagger_client/api_client.rb +376 -0
- data/lib/swagger_client/api_error.rb +37 -0
- data/lib/swagger_client/configuration.rb +209 -0
- data/lib/swagger_client/models/app_user.rb +258 -0
- data/lib/swagger_client/models/app_user_link.rb +201 -0
- data/lib/swagger_client/models/app_user_pre_create.rb +246 -0
- data/lib/swagger_client/models/app_user_response.rb +192 -0
- data/lib/swagger_client/models/app_user_update.rb +223 -0
- data/lib/swagger_client/models/client.rb +248 -0
- data/lib/swagger_client/models/client_info.rb +250 -0
- data/lib/swagger_client/models/client_response.rb +187 -0
- data/lib/swagger_client/models/conversation.rb +206 -0
- data/lib/swagger_client/models/device_update.rb +205 -0
- data/lib/swagger_client/models/event.rb +192 -0
- data/lib/swagger_client/models/get_messages_response.rb +207 -0
- data/lib/swagger_client/models/menu.rb +203 -0
- data/lib/swagger_client/models/menu_item.rb +242 -0
- data/lib/swagger_client/models/menu_response.rb +192 -0
- data/lib/swagger_client/models/message.rb +303 -0
- data/lib/swagger_client/models/message_response.rb +206 -0
- data/lib/swagger_client/models/postback.rb +229 -0
- data/lib/swagger_client/models/track_event_response.rb +187 -0
- data/lib/swagger_client/models/typing_activity_trigger.rb +224 -0
- data/lib/swagger_client/version.rb +14 -0
- data/rainbow-submarine-test-3356.gemspec +44 -0
- data/spec/api/app_user_api_spec.rb +162 -0
- data/spec/api/conversation_api_spec.rb +73 -0
- data/spec/api/menu_api_spec.rb +68 -0
- data/spec/api_client_spec.rb +225 -0
- data/spec/configuration_spec.rb +41 -0
- data/spec/models/app_user_link_spec.rb +47 -0
- data/spec/models/app_user_pre_create_spec.rb +77 -0
- data/spec/models/app_user_response_spec.rb +41 -0
- data/spec/models/app_user_spec.rb +77 -0
- data/spec/models/app_user_update_spec.rb +65 -0
- data/spec/models/client_info_spec.rb +83 -0
- data/spec/models/client_response_spec.rb +41 -0
- data/spec/models/client_spec.rb +65 -0
- data/spec/models/conversation_spec.rb +47 -0
- data/spec/models/device_update_spec.rb +53 -0
- data/spec/models/event_spec.rb +41 -0
- data/spec/models/get_messages_response_spec.rb +53 -0
- data/spec/models/menu_item_spec.rb +71 -0
- data/spec/models/menu_response_spec.rb +41 -0
- data/spec/models/menu_spec.rb +47 -0
- data/spec/models/message_response_spec.rb +47 -0
- data/spec/models/message_spec.rb +95 -0
- data/spec/models/postback_spec.rb +59 -0
- data/spec/models/track_event_response_spec.rb +41 -0
- data/spec/models/typing_activity_trigger_spec.rb +59 -0
- data/spec/spec_helper.rb +110 -0
- data/swagger_client.gemspec +45 -0
- metadata +361 -0
@@ -0,0 +1,303 @@
|
|
1
|
+
=begin
|
2
|
+
#Smooch
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module RainbowSubmarineTest3356
|
15
|
+
|
16
|
+
class Message
|
17
|
+
attr_accessor :_id
|
18
|
+
|
19
|
+
attr_accessor :author_id
|
20
|
+
|
21
|
+
attr_accessor :role
|
22
|
+
|
23
|
+
attr_accessor :name
|
24
|
+
|
25
|
+
attr_accessor :text
|
26
|
+
|
27
|
+
attr_accessor :received
|
28
|
+
|
29
|
+
attr_accessor :avatar_url
|
30
|
+
|
31
|
+
attr_accessor :media_url
|
32
|
+
|
33
|
+
attr_accessor :media_type
|
34
|
+
|
35
|
+
attr_accessor :metadata
|
36
|
+
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:'_id' => :'_id',
|
42
|
+
:'author_id' => :'authorId',
|
43
|
+
:'role' => :'role',
|
44
|
+
:'name' => :'name',
|
45
|
+
:'text' => :'text',
|
46
|
+
:'received' => :'received',
|
47
|
+
:'avatar_url' => :'avatarUrl',
|
48
|
+
:'media_url' => :'mediaUrl',
|
49
|
+
:'media_type' => :'mediaType',
|
50
|
+
:'metadata' => :'metadata'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute type mapping.
|
55
|
+
def self.swagger_types
|
56
|
+
{
|
57
|
+
:'_id' => :'String',
|
58
|
+
:'author_id' => :'String',
|
59
|
+
:'role' => :'String',
|
60
|
+
:'name' => :'String',
|
61
|
+
:'text' => :'String',
|
62
|
+
:'received' => :'Float',
|
63
|
+
:'avatar_url' => :'String',
|
64
|
+
:'media_url' => :'String',
|
65
|
+
:'media_type' => :'String',
|
66
|
+
:'metadata' => :'Object'
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
# Initializes the object
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
72
|
+
def initialize(attributes = {})
|
73
|
+
return unless attributes.is_a?(Hash)
|
74
|
+
|
75
|
+
# convert string to symbol for hash key
|
76
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
77
|
+
|
78
|
+
if attributes.has_key?(:'_id')
|
79
|
+
self._id = attributes[:'_id']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.has_key?(:'authorId')
|
83
|
+
self.author_id = attributes[:'authorId']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.has_key?(:'role')
|
87
|
+
self.role = attributes[:'role']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.has_key?(:'name')
|
91
|
+
self.name = attributes[:'name']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.has_key?(:'text')
|
95
|
+
self.text = attributes[:'text']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.has_key?(:'received')
|
99
|
+
self.received = attributes[:'received']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.has_key?(:'avatarUrl')
|
103
|
+
self.avatar_url = attributes[:'avatarUrl']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.has_key?(:'mediaUrl')
|
107
|
+
self.media_url = attributes[:'mediaUrl']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.has_key?(:'mediaType')
|
111
|
+
self.media_type = attributes[:'mediaType']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.has_key?(:'metadata')
|
115
|
+
self.metadata = attributes[:'metadata']
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
121
|
+
# @return Array for valid properies with the reasons
|
122
|
+
def list_invalid_properties
|
123
|
+
invalid_properties = Array.new
|
124
|
+
if @_id.nil?
|
125
|
+
invalid_properties.push("invalid value for '_id', _id cannot be nil.")
|
126
|
+
end
|
127
|
+
|
128
|
+
if @author_id.nil?
|
129
|
+
invalid_properties.push("invalid value for 'author_id', author_id cannot be nil.")
|
130
|
+
end
|
131
|
+
|
132
|
+
if @role.nil?
|
133
|
+
invalid_properties.push("invalid value for 'role', role cannot be nil.")
|
134
|
+
end
|
135
|
+
|
136
|
+
if @name.nil?
|
137
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
138
|
+
end
|
139
|
+
|
140
|
+
if @text.nil?
|
141
|
+
invalid_properties.push("invalid value for 'text', text cannot be nil.")
|
142
|
+
end
|
143
|
+
|
144
|
+
if @received.nil?
|
145
|
+
invalid_properties.push("invalid value for 'received', received cannot be nil.")
|
146
|
+
end
|
147
|
+
|
148
|
+
if @avatar_url.nil?
|
149
|
+
invalid_properties.push("invalid value for 'avatar_url', avatar_url cannot be nil.")
|
150
|
+
end
|
151
|
+
|
152
|
+
return invalid_properties
|
153
|
+
end
|
154
|
+
|
155
|
+
# Check to see if the all the properties in the model are valid
|
156
|
+
# @return true if the model is valid
|
157
|
+
def valid?
|
158
|
+
return false if @_id.nil?
|
159
|
+
return false if @author_id.nil?
|
160
|
+
return false if @role.nil?
|
161
|
+
return false if @name.nil?
|
162
|
+
return false if @text.nil?
|
163
|
+
return false if @received.nil?
|
164
|
+
return false if @avatar_url.nil?
|
165
|
+
return true
|
166
|
+
end
|
167
|
+
|
168
|
+
# Checks equality by comparing each attribute.
|
169
|
+
# @param [Object] Object to be compared
|
170
|
+
def ==(o)
|
171
|
+
return true if self.equal?(o)
|
172
|
+
self.class == o.class &&
|
173
|
+
_id == o._id &&
|
174
|
+
author_id == o.author_id &&
|
175
|
+
role == o.role &&
|
176
|
+
name == o.name &&
|
177
|
+
text == o.text &&
|
178
|
+
received == o.received &&
|
179
|
+
avatar_url == o.avatar_url &&
|
180
|
+
media_url == o.media_url &&
|
181
|
+
media_type == o.media_type &&
|
182
|
+
metadata == o.metadata
|
183
|
+
end
|
184
|
+
|
185
|
+
# @see the `==` method
|
186
|
+
# @param [Object] Object to be compared
|
187
|
+
def eql?(o)
|
188
|
+
self == o
|
189
|
+
end
|
190
|
+
|
191
|
+
# Calculates hash code according to all attributes.
|
192
|
+
# @return [Fixnum] Hash code
|
193
|
+
def hash
|
194
|
+
[_id, author_id, role, name, text, received, avatar_url, media_url, media_type, metadata].hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Builds the object from hash
|
198
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
199
|
+
# @return [Object] Returns the model itself
|
200
|
+
def build_from_hash(attributes)
|
201
|
+
return nil unless attributes.is_a?(Hash)
|
202
|
+
self.class.swagger_types.each_pair do |key, type|
|
203
|
+
if type =~ /\AArray<(.*)>/i
|
204
|
+
# check to ensure the input is an array given that the the attribute
|
205
|
+
# is documented as an array but the input is not
|
206
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
207
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
208
|
+
end
|
209
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
210
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
211
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
212
|
+
end
|
213
|
+
|
214
|
+
self
|
215
|
+
end
|
216
|
+
|
217
|
+
# Deserializes the data based on type
|
218
|
+
# @param string type Data type
|
219
|
+
# @param string value Value to be deserialized
|
220
|
+
# @return [Object] Deserialized data
|
221
|
+
def _deserialize(type, value)
|
222
|
+
case type.to_sym
|
223
|
+
when :DateTime
|
224
|
+
DateTime.parse(value)
|
225
|
+
when :Date
|
226
|
+
Date.parse(value)
|
227
|
+
when :String
|
228
|
+
value.to_s
|
229
|
+
when :Integer
|
230
|
+
value.to_i
|
231
|
+
when :Float
|
232
|
+
value.to_f
|
233
|
+
when :BOOLEAN
|
234
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
235
|
+
true
|
236
|
+
else
|
237
|
+
false
|
238
|
+
end
|
239
|
+
when :Object
|
240
|
+
# generic object (usually a Hash), return directly
|
241
|
+
value
|
242
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
243
|
+
inner_type = Regexp.last_match[:inner_type]
|
244
|
+
value.map { |v| _deserialize(inner_type, v) }
|
245
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
246
|
+
k_type = Regexp.last_match[:k_type]
|
247
|
+
v_type = Regexp.last_match[:v_type]
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each do |k, v|
|
250
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
else # model
|
254
|
+
temp_model = RainbowSubmarineTest3356.const_get(type).new
|
255
|
+
temp_model.build_from_hash(value)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns the string representation of the object
|
260
|
+
# @return [String] String presentation of the object
|
261
|
+
def to_s
|
262
|
+
to_hash.to_s
|
263
|
+
end
|
264
|
+
|
265
|
+
# to_body is an alias to to_hash (backward compatibility)
|
266
|
+
# @return [Hash] Returns the object in the form of hash
|
267
|
+
def to_body
|
268
|
+
to_hash
|
269
|
+
end
|
270
|
+
|
271
|
+
# Returns the object in the form of hash
|
272
|
+
# @return [Hash] Returns the object in the form of hash
|
273
|
+
def to_hash
|
274
|
+
hash = {}
|
275
|
+
self.class.attribute_map.each_pair do |attr, param|
|
276
|
+
value = self.send(attr)
|
277
|
+
next if value.nil?
|
278
|
+
hash[param] = _to_hash(value)
|
279
|
+
end
|
280
|
+
hash
|
281
|
+
end
|
282
|
+
|
283
|
+
# Outputs non-array value in the form of hash
|
284
|
+
# For object, use to_hash. Otherwise, just return the value
|
285
|
+
# @param [Object] value Any valid value
|
286
|
+
# @return [Hash] Returns the value in the form of hash
|
287
|
+
def _to_hash(value)
|
288
|
+
if value.is_a?(Array)
|
289
|
+
value.compact.map{ |v| _to_hash(v) }
|
290
|
+
elsif value.is_a?(Hash)
|
291
|
+
{}.tap do |hash|
|
292
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
293
|
+
end
|
294
|
+
elsif value.respond_to? :to_hash
|
295
|
+
value.to_hash
|
296
|
+
else
|
297
|
+
value
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|
302
|
+
|
303
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
=begin
|
2
|
+
#Smooch
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module RainbowSubmarineTest3356
|
15
|
+
|
16
|
+
class MessageResponse
|
17
|
+
attr_accessor :message
|
18
|
+
|
19
|
+
attr_accessor :conversation
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'message' => :'message',
|
26
|
+
:'conversation' => :'conversation'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.swagger_types
|
32
|
+
{
|
33
|
+
:'message' => :'Object',
|
34
|
+
:'conversation' => :'Conversation'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Initializes the object
|
39
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
40
|
+
def initialize(attributes = {})
|
41
|
+
return unless attributes.is_a?(Hash)
|
42
|
+
|
43
|
+
# convert string to symbol for hash key
|
44
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
45
|
+
|
46
|
+
if attributes.has_key?(:'message')
|
47
|
+
self.message = attributes[:'message']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes.has_key?(:'conversation')
|
51
|
+
self.conversation = attributes[:'conversation']
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
57
|
+
# @return Array for valid properies with the reasons
|
58
|
+
def list_invalid_properties
|
59
|
+
invalid_properties = Array.new
|
60
|
+
if @message.nil?
|
61
|
+
invalid_properties.push("invalid value for 'message', message cannot be nil.")
|
62
|
+
end
|
63
|
+
|
64
|
+
if @conversation.nil?
|
65
|
+
invalid_properties.push("invalid value for 'conversation', conversation cannot be nil.")
|
66
|
+
end
|
67
|
+
|
68
|
+
return invalid_properties
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check to see if the all the properties in the model are valid
|
72
|
+
# @return true if the model is valid
|
73
|
+
def valid?
|
74
|
+
return false if @message.nil?
|
75
|
+
return false if @conversation.nil?
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks equality by comparing each attribute.
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def ==(o)
|
82
|
+
return true if self.equal?(o)
|
83
|
+
self.class == o.class &&
|
84
|
+
message == o.message &&
|
85
|
+
conversation == o.conversation
|
86
|
+
end
|
87
|
+
|
88
|
+
# @see the `==` method
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def eql?(o)
|
91
|
+
self == o
|
92
|
+
end
|
93
|
+
|
94
|
+
# Calculates hash code according to all attributes.
|
95
|
+
# @return [Fixnum] Hash code
|
96
|
+
def hash
|
97
|
+
[message, conversation].hash
|
98
|
+
end
|
99
|
+
|
100
|
+
# Builds the object from hash
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
# @return [Object] Returns the model itself
|
103
|
+
def build_from_hash(attributes)
|
104
|
+
return nil unless attributes.is_a?(Hash)
|
105
|
+
self.class.swagger_types.each_pair do |key, type|
|
106
|
+
if type =~ /\AArray<(.*)>/i
|
107
|
+
# check to ensure the input is an array given that the the attribute
|
108
|
+
# is documented as an array but the input is not
|
109
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
110
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
111
|
+
end
|
112
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
113
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
114
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
115
|
+
end
|
116
|
+
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
# Deserializes the data based on type
|
121
|
+
# @param string type Data type
|
122
|
+
# @param string value Value to be deserialized
|
123
|
+
# @return [Object] Deserialized data
|
124
|
+
def _deserialize(type, value)
|
125
|
+
case type.to_sym
|
126
|
+
when :DateTime
|
127
|
+
DateTime.parse(value)
|
128
|
+
when :Date
|
129
|
+
Date.parse(value)
|
130
|
+
when :String
|
131
|
+
value.to_s
|
132
|
+
when :Integer
|
133
|
+
value.to_i
|
134
|
+
when :Float
|
135
|
+
value.to_f
|
136
|
+
when :BOOLEAN
|
137
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
138
|
+
true
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
142
|
+
when :Object
|
143
|
+
# generic object (usually a Hash), return directly
|
144
|
+
value
|
145
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
146
|
+
inner_type = Regexp.last_match[:inner_type]
|
147
|
+
value.map { |v| _deserialize(inner_type, v) }
|
148
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
149
|
+
k_type = Regexp.last_match[:k_type]
|
150
|
+
v_type = Regexp.last_match[:v_type]
|
151
|
+
{}.tap do |hash|
|
152
|
+
value.each do |k, v|
|
153
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
else # model
|
157
|
+
temp_model = RainbowSubmarineTest3356.const_get(type).new
|
158
|
+
temp_model.build_from_hash(value)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the string representation of the object
|
163
|
+
# @return [String] String presentation of the object
|
164
|
+
def to_s
|
165
|
+
to_hash.to_s
|
166
|
+
end
|
167
|
+
|
168
|
+
# to_body is an alias to to_hash (backward compatibility)
|
169
|
+
# @return [Hash] Returns the object in the form of hash
|
170
|
+
def to_body
|
171
|
+
to_hash
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the object in the form of hash
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_hash
|
177
|
+
hash = {}
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
179
|
+
value = self.send(attr)
|
180
|
+
next if value.nil?
|
181
|
+
hash[param] = _to_hash(value)
|
182
|
+
end
|
183
|
+
hash
|
184
|
+
end
|
185
|
+
|
186
|
+
# Outputs non-array value in the form of hash
|
187
|
+
# For object, use to_hash. Otherwise, just return the value
|
188
|
+
# @param [Object] value Any valid value
|
189
|
+
# @return [Hash] Returns the value in the form of hash
|
190
|
+
def _to_hash(value)
|
191
|
+
if value.is_a?(Array)
|
192
|
+
value.compact.map{ |v| _to_hash(v) }
|
193
|
+
elsif value.is_a?(Hash)
|
194
|
+
{}.tap do |hash|
|
195
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
196
|
+
end
|
197
|
+
elsif value.respond_to? :to_hash
|
198
|
+
value.to_hash
|
199
|
+
else
|
200
|
+
value
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|