smooch-api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +181 -0
  4. data/Rakefile +8 -0
  5. data/docs/Action.md +16 -0
  6. data/docs/App.md +10 -0
  7. data/docs/AppApi.md +609 -0
  8. data/docs/AppCreate.md +8 -0
  9. data/docs/AppResponse.md +8 -0
  10. data/docs/AppUser.md +18 -0
  11. data/docs/AppUserApi.md +561 -0
  12. data/docs/AppUserLink.md +9 -0
  13. data/docs/AppUserPreCreate.md +14 -0
  14. data/docs/AppUserResponse.md +8 -0
  15. data/docs/AppUserUpdate.md +12 -0
  16. data/docs/Client.md +14 -0
  17. data/docs/ClientInfo.md +15 -0
  18. data/docs/Conversation.md +9 -0
  19. data/docs/ConversationApi.md +282 -0
  20. data/docs/Destination.md +9 -0
  21. data/docs/DeviceInit.md +12 -0
  22. data/docs/DeviceResponse.md +8 -0
  23. data/docs/DeviceUpdate.md +10 -0
  24. data/docs/DisplaySettings.md +8 -0
  25. data/docs/Event.md +8 -0
  26. data/docs/GetMessagesResponse.md +10 -0
  27. data/docs/Init.md +9 -0
  28. data/docs/InitApi.md +61 -0
  29. data/docs/InitResponse.md +9 -0
  30. data/docs/Integration.md +24 -0
  31. data/docs/IntegrationApi.md +121 -0
  32. data/docs/IntegrationCreate.md +23 -0
  33. data/docs/IntegrationResponse.md +8 -0
  34. data/docs/JwtResponse.md +8 -0
  35. data/docs/ListAppsResponse.md +10 -0
  36. data/docs/ListIntegrationsResponse.md +8 -0
  37. data/docs/ListSecretKeysResponse.md +8 -0
  38. data/docs/ListWebhooksResponse.md +8 -0
  39. data/docs/Menu.md +9 -0
  40. data/docs/MenuApi.md +155 -0
  41. data/docs/MenuItem.md +11 -0
  42. data/docs/MenuResponse.md +8 -0
  43. data/docs/Message.md +23 -0
  44. data/docs/MessageItem.md +13 -0
  45. data/docs/MessagePost.md +20 -0
  46. data/docs/MessageResponse.md +9 -0
  47. data/docs/PostMessagesResponse.md +9 -0
  48. data/docs/SecretKey.md +10 -0
  49. data/docs/SecretKeyCreate.md +8 -0
  50. data/docs/SecretKeyResponse.md +8 -0
  51. data/docs/TrackEventResponse.md +8 -0
  52. data/docs/TypingActivityTrigger.md +11 -0
  53. data/docs/Webhook.md +11 -0
  54. data/docs/WebhookApi.md +287 -0
  55. data/docs/WebhookCreate.md +9 -0
  56. data/docs/WebhookResponse.md +8 -0
  57. data/docs/WebhookUpdate.md +9 -0
  58. data/git_push.sh +55 -0
  59. data/lib/smooch-api.rb +91 -0
  60. data/lib/smooch-api/api/app_api.rb +628 -0
  61. data/lib/smooch-api/api/app_user_api.rb +585 -0
  62. data/lib/smooch-api/api/conversation_api.rb +298 -0
  63. data/lib/smooch-api/api/init_api.rb +75 -0
  64. data/lib/smooch-api/api/integration_api.rb +135 -0
  65. data/lib/smooch-api/api/menu_api.rb +173 -0
  66. data/lib/smooch-api/api/webhook_api.rb +306 -0
  67. data/lib/smooch-api/api_client.rb +376 -0
  68. data/lib/smooch-api/api_error.rb +37 -0
  69. data/lib/smooch-api/configuration.rb +202 -0
  70. data/lib/smooch-api/models/action.rb +311 -0
  71. data/lib/smooch-api/models/app.rb +223 -0
  72. data/lib/smooch-api/models/app_create.rb +193 -0
  73. data/lib/smooch-api/models/app_response.rb +188 -0
  74. data/lib/smooch-api/models/app_user.rb +307 -0
  75. data/lib/smooch-api/models/app_user_link.rb +236 -0
  76. data/lib/smooch-api/models/app_user_pre_create.rb +253 -0
  77. data/lib/smooch-api/models/app_user_response.rb +193 -0
  78. data/lib/smooch-api/models/app_user_update.rb +228 -0
  79. data/lib/smooch-api/models/client.rb +290 -0
  80. data/lib/smooch-api/models/client_info.rb +258 -0
  81. data/lib/smooch-api/models/conversation.rb +208 -0
  82. data/lib/smooch-api/models/destination.rb +208 -0
  83. data/lib/smooch-api/models/device_init.rb +270 -0
  84. data/lib/smooch-api/models/device_response.rb +188 -0
  85. data/lib/smooch-api/models/device_update.rb +207 -0
  86. data/lib/smooch-api/models/display_settings.rb +188 -0
  87. data/lib/smooch-api/models/event.rb +193 -0
  88. data/lib/smooch-api/models/get_messages_response.rb +210 -0
  89. data/lib/smooch-api/models/init.rb +202 -0
  90. data/lib/smooch-api/models/init_response.rb +208 -0
  91. data/lib/smooch-api/models/integration.rb +358 -0
  92. data/lib/smooch-api/models/integration_create.rb +343 -0
  93. data/lib/smooch-api/models/integration_response.rb +188 -0
  94. data/lib/smooch-api/models/jwt_response.rb +188 -0
  95. data/lib/smooch-api/models/list_apps_response.rb +210 -0
  96. data/lib/smooch-api/models/list_integrations_response.rb +190 -0
  97. data/lib/smooch-api/models/list_secret_keys_response.rb +190 -0
  98. data/lib/smooch-api/models/list_webhooks_response.rb +195 -0
  99. data/lib/smooch-api/models/menu.rb +205 -0
  100. data/lib/smooch-api/models/menu_item.rb +228 -0
  101. data/lib/smooch-api/models/menu_response.rb +193 -0
  102. data/lib/smooch-api/models/message.rb +415 -0
  103. data/lib/smooch-api/models/message_item.rb +250 -0
  104. data/lib/smooch-api/models/message_post.rb +355 -0
  105. data/lib/smooch-api/models/message_response.rb +208 -0
  106. data/lib/smooch-api/models/post_messages_response.rb +200 -0
  107. data/lib/smooch-api/models/secret_key.rb +223 -0
  108. data/lib/smooch-api/models/secret_key_create.rb +193 -0
  109. data/lib/smooch-api/models/secret_key_response.rb +188 -0
  110. data/lib/smooch-api/models/track_event_response.rb +188 -0
  111. data/lib/smooch-api/models/typing_activity_trigger.rb +228 -0
  112. data/lib/smooch-api/models/webhook.rb +261 -0
  113. data/lib/smooch-api/models/webhook_create.rb +226 -0
  114. data/lib/smooch-api/models/webhook_response.rb +193 -0
  115. data/lib/smooch-api/models/webhook_update.rb +221 -0
  116. data/lib/smooch-api/version.rb +14 -0
  117. data/smooch-api.gemspec +44 -0
  118. data/spec/api_client_spec.rb +225 -0
  119. data/spec/configuration_spec.rb +41 -0
  120. data/spec/spec_helper.rb +110 -0
  121. metadata +349 -0
@@ -0,0 +1,208 @@
1
+ =begin
2
+ #Smooch
3
+
4
+ #The Smooch API is a unified interface for powering messaging in your customer experiences across every channel. Our API speeds access to new markets, reduces time to ship, eliminates complexity, and helps you build the best experiences for your customers. For more information, visit our [official documentation](https://docs.smooch.io).
5
+
6
+ OpenAPI spec version: 1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SmoochApi
15
+
16
+ class InitResponse
17
+ # The app user.
18
+ attr_accessor :app_user
19
+
20
+ # The app.
21
+ attr_accessor :app
22
+
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'app_user' => :'appUser',
28
+ :'app' => :'app'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'app_user' => :'AppUser',
36
+ :'app' => :'App'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
47
+
48
+ if attributes.has_key?(:'appUser')
49
+ self.app_user = attributes[:'appUser']
50
+ end
51
+
52
+ if attributes.has_key?(:'app')
53
+ self.app = attributes[:'app']
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 @app_user.nil?
63
+ invalid_properties.push("invalid value for 'app_user', app_user cannot be nil.")
64
+ end
65
+
66
+ if @app.nil?
67
+ invalid_properties.push("invalid value for 'app', app cannot be nil.")
68
+ end
69
+
70
+ return invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ return false if @app_user.nil?
77
+ return false if @app.nil?
78
+ return true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ app_user == o.app_user &&
87
+ app == o.app
88
+ end
89
+
90
+ # @see the `==` method
91
+ # @param [Object] Object to be compared
92
+ def eql?(o)
93
+ self == o
94
+ end
95
+
96
+ # Calculates hash code according to all attributes.
97
+ # @return [Fixnum] Hash code
98
+ def hash
99
+ [app_user, app].hash
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.swagger_types.each_pair do |key, type|
108
+ if type =~ /\AArray<(.*)>/i
109
+ # check to ensure the input is an array given that the 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
+ temp_model = SmoochApi.const_get(type).new
160
+ temp_model.build_from_hash(value)
161
+ end
162
+ end
163
+
164
+ # Returns the string representation of the object
165
+ # @return [String] String presentation of the object
166
+ def to_s
167
+ to_hash.to_s
168
+ end
169
+
170
+ # to_body is an alias to to_hash (backward compatibility)
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_body
173
+ to_hash
174
+ end
175
+
176
+ # Returns the object in the form of hash
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_hash
179
+ hash = {}
180
+ self.class.attribute_map.each_pair do |attr, param|
181
+ value = self.send(attr)
182
+ next if value.nil?
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ # Outputs non-array value in the form of hash
189
+ # For object, use to_hash. Otherwise, just return the value
190
+ # @param [Object] value Any valid value
191
+ # @return [Hash] Returns the value in the form of hash
192
+ def _to_hash(value)
193
+ if value.is_a?(Array)
194
+ value.compact.map{ |v| _to_hash(v) }
195
+ elsif value.is_a?(Hash)
196
+ {}.tap do |hash|
197
+ value.each { |k, v| hash[k] = _to_hash(v) }
198
+ end
199
+ elsif value.respond_to? :to_hash
200
+ value.to_hash
201
+ else
202
+ value
203
+ end
204
+ end
205
+
206
+ end
207
+
208
+ end
@@ -0,0 +1,358 @@
1
+ =begin
2
+ #Smooch
3
+
4
+ #The Smooch API is a unified interface for powering messaging in your customer experiences across every channel. Our API speeds access to new markets, reduces time to ship, eliminates complexity, and helps you build the best experiences for your customers. For more information, visit our [official documentation](https://docs.smooch.io).
5
+
6
+ OpenAPI spec version: 1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SmoochApi
15
+
16
+ class Integration
17
+ # The integration ID, generated automatically.
18
+ attr_accessor :_id
19
+
20
+ # The integration type.
21
+ attr_accessor :type
22
+
23
+ # Facebook Page Access Token. Required for *messenger* integrations.
24
+ attr_accessor :page_access_token
25
+
26
+ # Facebook App ID OR WeChat App ID. Required for *messenger* and *wechat* integrations.
27
+ attr_accessor :app_id
28
+
29
+ # Facebook Page App Secret OR WeChat App Secret. Required for *messenger* and *wechat* integrations.
30
+ attr_accessor :app_secret
31
+
32
+ # Twilio Account SID. Required for *twilio* integrations.
33
+ attr_accessor :account_sid
34
+
35
+ # Twilio Auth Token. Required for *twilio* integrations.
36
+ attr_accessor :auth_token
37
+
38
+ # SID for specific phone number. Required for *twilio* integrations.
39
+ attr_accessor :phone_number_sid
40
+
41
+ # Telegram Bot Token OR Viber Public Account token. Required for *twilio* and *viber* integrations.
42
+ attr_accessor :token
43
+
44
+ # LINE Channel Access Token. Required for *line* integrations.
45
+ attr_accessor :channel_access_token
46
+
47
+ # AES Encoding Key. (Optional) Used for *wechat* integrations.
48
+ attr_accessor :encoding_aes_key
49
+
50
+ # Email will display as coming from this address. (Optional) Used for *frontendEmail* integrations.
51
+ attr_accessor :from_address
52
+
53
+ # The binary of your APN certificate base64 encoded. Required for *apn* integrations.
54
+ attr_accessor :certificate
55
+
56
+ # The password for your APN certificate. (Optional) Used for *apn* integrations.
57
+ attr_accessor :password
58
+
59
+ # Use the unread count of the conversation as the application badge. (Optional) Used for *apn* integrations.
60
+ attr_accessor :auto_update_badge
61
+
62
+ # Your server key from the fcm console. Required for *fcm* integrations.
63
+ attr_accessor :server_key
64
+
65
+ # Your sender id from the fcm console. Required for *fcm* integrations.
66
+ attr_accessor :sender_id
67
+
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'_id' => :'_id',
73
+ :'type' => :'type',
74
+ :'page_access_token' => :'pageAccessToken',
75
+ :'app_id' => :'appId',
76
+ :'app_secret' => :'appSecret',
77
+ :'account_sid' => :'accountSid',
78
+ :'auth_token' => :'authToken',
79
+ :'phone_number_sid' => :'phoneNumberSid',
80
+ :'token' => :'token',
81
+ :'channel_access_token' => :'channelAccessToken',
82
+ :'encoding_aes_key' => :'encodingAesKey',
83
+ :'from_address' => :'fromAddress',
84
+ :'certificate' => :'certificate',
85
+ :'password' => :'password',
86
+ :'auto_update_badge' => :'autoUpdateBadge',
87
+ :'server_key' => :'serverKey',
88
+ :'sender_id' => :'senderId'
89
+ }
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.swagger_types
94
+ {
95
+ :'_id' => :'String',
96
+ :'type' => :'String',
97
+ :'page_access_token' => :'String',
98
+ :'app_id' => :'String',
99
+ :'app_secret' => :'String',
100
+ :'account_sid' => :'String',
101
+ :'auth_token' => :'String',
102
+ :'phone_number_sid' => :'String',
103
+ :'token' => :'String',
104
+ :'channel_access_token' => :'String',
105
+ :'encoding_aes_key' => :'String',
106
+ :'from_address' => :'String',
107
+ :'certificate' => :'String',
108
+ :'password' => :'String',
109
+ :'auto_update_badge' => :'BOOLEAN',
110
+ :'server_key' => :'String',
111
+ :'sender_id' => :'String'
112
+ }
113
+ end
114
+
115
+ # Initializes the object
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ def initialize(attributes = {})
118
+ return unless attributes.is_a?(Hash)
119
+
120
+ # convert string to symbol for hash key
121
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
122
+
123
+ if attributes.has_key?(:'_id')
124
+ self._id = attributes[:'_id']
125
+ end
126
+
127
+ if attributes.has_key?(:'type')
128
+ self.type = attributes[:'type']
129
+ end
130
+
131
+ if attributes.has_key?(:'pageAccessToken')
132
+ self.page_access_token = attributes[:'pageAccessToken']
133
+ end
134
+
135
+ if attributes.has_key?(:'appId')
136
+ self.app_id = attributes[:'appId']
137
+ end
138
+
139
+ if attributes.has_key?(:'appSecret')
140
+ self.app_secret = attributes[:'appSecret']
141
+ end
142
+
143
+ if attributes.has_key?(:'accountSid')
144
+ self.account_sid = attributes[:'accountSid']
145
+ end
146
+
147
+ if attributes.has_key?(:'authToken')
148
+ self.auth_token = attributes[:'authToken']
149
+ end
150
+
151
+ if attributes.has_key?(:'phoneNumberSid')
152
+ self.phone_number_sid = attributes[:'phoneNumberSid']
153
+ end
154
+
155
+ if attributes.has_key?(:'token')
156
+ self.token = attributes[:'token']
157
+ end
158
+
159
+ if attributes.has_key?(:'channelAccessToken')
160
+ self.channel_access_token = attributes[:'channelAccessToken']
161
+ end
162
+
163
+ if attributes.has_key?(:'encodingAesKey')
164
+ self.encoding_aes_key = attributes[:'encodingAesKey']
165
+ end
166
+
167
+ if attributes.has_key?(:'fromAddress')
168
+ self.from_address = attributes[:'fromAddress']
169
+ end
170
+
171
+ if attributes.has_key?(:'certificate')
172
+ self.certificate = attributes[:'certificate']
173
+ end
174
+
175
+ if attributes.has_key?(:'password')
176
+ self.password = attributes[:'password']
177
+ end
178
+
179
+ if attributes.has_key?(:'autoUpdateBadge')
180
+ self.auto_update_badge = attributes[:'autoUpdateBadge']
181
+ end
182
+
183
+ if attributes.has_key?(:'serverKey')
184
+ self.server_key = attributes[:'serverKey']
185
+ end
186
+
187
+ if attributes.has_key?(:'senderId')
188
+ self.sender_id = attributes[:'senderId']
189
+ end
190
+
191
+ end
192
+
193
+ # Show invalid properties with the reasons. Usually used together with valid?
194
+ # @return Array for valid properies with the reasons
195
+ def list_invalid_properties
196
+ invalid_properties = Array.new
197
+ if @_id.nil?
198
+ invalid_properties.push("invalid value for '_id', _id cannot be nil.")
199
+ end
200
+
201
+ if @type.nil?
202
+ invalid_properties.push("invalid value for 'type', type cannot be nil.")
203
+ end
204
+
205
+ return invalid_properties
206
+ end
207
+
208
+ # Check to see if the all the properties in the model are valid
209
+ # @return true if the model is valid
210
+ def valid?
211
+ return false if @_id.nil?
212
+ return false if @type.nil?
213
+ return true
214
+ end
215
+
216
+ # Checks equality by comparing each attribute.
217
+ # @param [Object] Object to be compared
218
+ def ==(o)
219
+ return true if self.equal?(o)
220
+ self.class == o.class &&
221
+ _id == o._id &&
222
+ type == o.type &&
223
+ page_access_token == o.page_access_token &&
224
+ app_id == o.app_id &&
225
+ app_secret == o.app_secret &&
226
+ account_sid == o.account_sid &&
227
+ auth_token == o.auth_token &&
228
+ phone_number_sid == o.phone_number_sid &&
229
+ token == o.token &&
230
+ channel_access_token == o.channel_access_token &&
231
+ encoding_aes_key == o.encoding_aes_key &&
232
+ from_address == o.from_address &&
233
+ certificate == o.certificate &&
234
+ password == o.password &&
235
+ auto_update_badge == o.auto_update_badge &&
236
+ server_key == o.server_key &&
237
+ sender_id == o.sender_id
238
+ end
239
+
240
+ # @see the `==` method
241
+ # @param [Object] Object to be compared
242
+ def eql?(o)
243
+ self == o
244
+ end
245
+
246
+ # Calculates hash code according to all attributes.
247
+ # @return [Fixnum] Hash code
248
+ def hash
249
+ [_id, type, page_access_token, app_id, app_secret, account_sid, auth_token, phone_number_sid, token, channel_access_token, encoding_aes_key, from_address, certificate, password, auto_update_badge, server_key, sender_id].hash
250
+ end
251
+
252
+ # Builds the object from hash
253
+ # @param [Hash] attributes Model attributes in the form of hash
254
+ # @return [Object] Returns the model itself
255
+ def build_from_hash(attributes)
256
+ return nil unless attributes.is_a?(Hash)
257
+ self.class.swagger_types.each_pair do |key, type|
258
+ if type =~ /\AArray<(.*)>/i
259
+ # check to ensure the input is an array given that the the attribute
260
+ # is documented as an array but the input is not
261
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
262
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
263
+ end
264
+ elsif !attributes[self.class.attribute_map[key]].nil?
265
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
266
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
267
+ end
268
+
269
+ self
270
+ end
271
+
272
+ # Deserializes the data based on type
273
+ # @param string type Data type
274
+ # @param string value Value to be deserialized
275
+ # @return [Object] Deserialized data
276
+ def _deserialize(type, value)
277
+ case type.to_sym
278
+ when :DateTime
279
+ DateTime.parse(value)
280
+ when :Date
281
+ Date.parse(value)
282
+ when :String
283
+ value.to_s
284
+ when :Integer
285
+ value.to_i
286
+ when :Float
287
+ value.to_f
288
+ when :BOOLEAN
289
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
290
+ true
291
+ else
292
+ false
293
+ end
294
+ when :Object
295
+ # generic object (usually a Hash), return directly
296
+ value
297
+ when /\AArray<(?<inner_type>.+)>\z/
298
+ inner_type = Regexp.last_match[:inner_type]
299
+ value.map { |v| _deserialize(inner_type, v) }
300
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
301
+ k_type = Regexp.last_match[:k_type]
302
+ v_type = Regexp.last_match[:v_type]
303
+ {}.tap do |hash|
304
+ value.each do |k, v|
305
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
306
+ end
307
+ end
308
+ else # model
309
+ temp_model = SmoochApi.const_get(type).new
310
+ temp_model.build_from_hash(value)
311
+ end
312
+ end
313
+
314
+ # Returns the string representation of the object
315
+ # @return [String] String presentation of the object
316
+ def to_s
317
+ to_hash.to_s
318
+ end
319
+
320
+ # to_body is an alias to to_hash (backward compatibility)
321
+ # @return [Hash] Returns the object in the form of hash
322
+ def to_body
323
+ to_hash
324
+ end
325
+
326
+ # Returns the object in the form of hash
327
+ # @return [Hash] Returns the object in the form of hash
328
+ def to_hash
329
+ hash = {}
330
+ self.class.attribute_map.each_pair do |attr, param|
331
+ value = self.send(attr)
332
+ next if value.nil?
333
+ hash[param] = _to_hash(value)
334
+ end
335
+ hash
336
+ end
337
+
338
+ # Outputs non-array value in the form of hash
339
+ # For object, use to_hash. Otherwise, just return the value
340
+ # @param [Object] value Any valid value
341
+ # @return [Hash] Returns the value in the form of hash
342
+ def _to_hash(value)
343
+ if value.is_a?(Array)
344
+ value.compact.map{ |v| _to_hash(v) }
345
+ elsif value.is_a?(Hash)
346
+ {}.tap do |hash|
347
+ value.each { |k, v| hash[k] = _to_hash(v) }
348
+ end
349
+ elsif value.respond_to? :to_hash
350
+ value.to_hash
351
+ else
352
+ value
353
+ end
354
+ end
355
+
356
+ end
357
+
358
+ end