rainbow-submarine-test-3356 1.2.2

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