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,188 @@
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 DeviceResponse
17
+ # The device.
18
+ attr_accessor :device
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'device' => :'device'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'device' => :'Client'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'device')
44
+ self.device = attributes[:'device']
45
+ end
46
+
47
+ end
48
+
49
+ # Show invalid properties with the reasons. Usually used together with valid?
50
+ # @return Array for valid properies with the reasons
51
+ def list_invalid_properties
52
+ invalid_properties = Array.new
53
+ return invalid_properties
54
+ end
55
+
56
+ # Check to see if the all the properties in the model are valid
57
+ # @return true if the model is valid
58
+ def valid?
59
+ return true
60
+ end
61
+
62
+ # Checks equality by comparing each attribute.
63
+ # @param [Object] Object to be compared
64
+ def ==(o)
65
+ return true if self.equal?(o)
66
+ self.class == o.class &&
67
+ device == o.device
68
+ end
69
+
70
+ # @see the `==` method
71
+ # @param [Object] Object to be compared
72
+ def eql?(o)
73
+ self == o
74
+ end
75
+
76
+ # Calculates hash code according to all attributes.
77
+ # @return [Fixnum] Hash code
78
+ def hash
79
+ [device].hash
80
+ end
81
+
82
+ # Builds the object from hash
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ # @return [Object] Returns the model itself
85
+ def build_from_hash(attributes)
86
+ return nil unless attributes.is_a?(Hash)
87
+ self.class.swagger_types.each_pair do |key, type|
88
+ if type =~ /\AArray<(.*)>/i
89
+ # check to ensure the input is an array given that the the attribute
90
+ # is documented as an array but the input is not
91
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
92
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
93
+ end
94
+ elsif !attributes[self.class.attribute_map[key]].nil?
95
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
96
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
97
+ end
98
+
99
+ self
100
+ end
101
+
102
+ # Deserializes the data based on type
103
+ # @param string type Data type
104
+ # @param string value Value to be deserialized
105
+ # @return [Object] Deserialized data
106
+ def _deserialize(type, value)
107
+ case type.to_sym
108
+ when :DateTime
109
+ DateTime.parse(value)
110
+ when :Date
111
+ Date.parse(value)
112
+ when :String
113
+ value.to_s
114
+ when :Integer
115
+ value.to_i
116
+ when :Float
117
+ value.to_f
118
+ when :BOOLEAN
119
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
120
+ true
121
+ else
122
+ false
123
+ end
124
+ when :Object
125
+ # generic object (usually a Hash), return directly
126
+ value
127
+ when /\AArray<(?<inner_type>.+)>\z/
128
+ inner_type = Regexp.last_match[:inner_type]
129
+ value.map { |v| _deserialize(inner_type, v) }
130
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
131
+ k_type = Regexp.last_match[:k_type]
132
+ v_type = Regexp.last_match[:v_type]
133
+ {}.tap do |hash|
134
+ value.each do |k, v|
135
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
136
+ end
137
+ end
138
+ else # model
139
+ temp_model = SmoochApi.const_get(type).new
140
+ temp_model.build_from_hash(value)
141
+ end
142
+ end
143
+
144
+ # Returns the string representation of the object
145
+ # @return [String] String presentation of the object
146
+ def to_s
147
+ to_hash.to_s
148
+ end
149
+
150
+ # to_body is an alias to to_hash (backward compatibility)
151
+ # @return [Hash] Returns the object in the form of hash
152
+ def to_body
153
+ to_hash
154
+ end
155
+
156
+ # Returns the object in the form of hash
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_hash
159
+ hash = {}
160
+ self.class.attribute_map.each_pair do |attr, param|
161
+ value = self.send(attr)
162
+ next if value.nil?
163
+ hash[param] = _to_hash(value)
164
+ end
165
+ hash
166
+ end
167
+
168
+ # Outputs non-array value in the form of hash
169
+ # For object, use to_hash. Otherwise, just return the value
170
+ # @param [Object] value Any valid value
171
+ # @return [Hash] Returns the value in the form of hash
172
+ def _to_hash(value)
173
+ if value.is_a?(Array)
174
+ value.compact.map{ |v| _to_hash(v) }
175
+ elsif value.is_a?(Hash)
176
+ {}.tap do |hash|
177
+ value.each { |k, v| hash[k] = _to_hash(v) }
178
+ end
179
+ elsif value.respond_to? :to_hash
180
+ value.to_hash
181
+ else
182
+ value
183
+ end
184
+ end
185
+
186
+ end
187
+
188
+ end
@@ -0,0 +1,207 @@
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 DeviceUpdate
17
+ # The GCM or APN token to be used for sending push notifications to the device. Applies to only *android* and *ios* clients.
18
+ attr_accessor :push_notification_token
19
+
20
+ # A reserved string field for reporting the app version running on the device.
21
+ attr_accessor :app_version
22
+
23
+ attr_accessor :info
24
+
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'push_notification_token' => :'pushNotificationToken',
30
+ :'app_version' => :'appVersion',
31
+ :'info' => :'info'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.swagger_types
37
+ {
38
+ :'push_notification_token' => :'String',
39
+ :'app_version' => :'String',
40
+ :'info' => :'ClientInfo'
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?(:'pushNotificationToken')
53
+ self.push_notification_token = attributes[:'pushNotificationToken']
54
+ end
55
+
56
+ if attributes.has_key?(:'appVersion')
57
+ self.app_version = attributes[:'appVersion']
58
+ end
59
+
60
+ if attributes.has_key?(:'info')
61
+ self.info = attributes[:'info']
62
+ end
63
+
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properies with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
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 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
+ push_notification_token == o.push_notification_token &&
85
+ app_version == o.app_version &&
86
+ info == o.info
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Fixnum] Hash code
97
+ def hash
98
+ [push_notification_token, app_version, info].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ self.class.swagger_types.each_pair do |key, type|
107
+ if type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
111
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
112
+ end
113
+ elsif !attributes[self.class.attribute_map[key]].nil?
114
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def _deserialize(type, value)
126
+ case type.to_sym
127
+ when :DateTime
128
+ DateTime.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :BOOLEAN
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ else # model
158
+ temp_model = SmoochApi.const_get(type).new
159
+ temp_model.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
+
205
+ end
206
+
207
+ end
@@ -0,0 +1,188 @@
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 DisplaySettings
17
+ # Specifies how to display all carousel images. Valid values are *horizontal* (default) and *square*.
18
+ attr_accessor :image_aspect_ratio
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'image_aspect_ratio' => :'imageAspectRatio'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'image_aspect_ratio' => :'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
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'imageAspectRatio')
44
+ self.image_aspect_ratio = attributes[:'imageAspectRatio']
45
+ end
46
+
47
+ end
48
+
49
+ # Show invalid properties with the reasons. Usually used together with valid?
50
+ # @return Array for valid properies with the reasons
51
+ def list_invalid_properties
52
+ invalid_properties = Array.new
53
+ return invalid_properties
54
+ end
55
+
56
+ # Check to see if the all the properties in the model are valid
57
+ # @return true if the model is valid
58
+ def valid?
59
+ return true
60
+ end
61
+
62
+ # Checks equality by comparing each attribute.
63
+ # @param [Object] Object to be compared
64
+ def ==(o)
65
+ return true if self.equal?(o)
66
+ self.class == o.class &&
67
+ image_aspect_ratio == o.image_aspect_ratio
68
+ end
69
+
70
+ # @see the `==` method
71
+ # @param [Object] Object to be compared
72
+ def eql?(o)
73
+ self == o
74
+ end
75
+
76
+ # Calculates hash code according to all attributes.
77
+ # @return [Fixnum] Hash code
78
+ def hash
79
+ [image_aspect_ratio].hash
80
+ end
81
+
82
+ # Builds the object from hash
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ # @return [Object] Returns the model itself
85
+ def build_from_hash(attributes)
86
+ return nil unless attributes.is_a?(Hash)
87
+ self.class.swagger_types.each_pair do |key, type|
88
+ if type =~ /\AArray<(.*)>/i
89
+ # check to ensure the input is an array given that the the attribute
90
+ # is documented as an array but the input is not
91
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
92
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
93
+ end
94
+ elsif !attributes[self.class.attribute_map[key]].nil?
95
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
96
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
97
+ end
98
+
99
+ self
100
+ end
101
+
102
+ # Deserializes the data based on type
103
+ # @param string type Data type
104
+ # @param string value Value to be deserialized
105
+ # @return [Object] Deserialized data
106
+ def _deserialize(type, value)
107
+ case type.to_sym
108
+ when :DateTime
109
+ DateTime.parse(value)
110
+ when :Date
111
+ Date.parse(value)
112
+ when :String
113
+ value.to_s
114
+ when :Integer
115
+ value.to_i
116
+ when :Float
117
+ value.to_f
118
+ when :BOOLEAN
119
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
120
+ true
121
+ else
122
+ false
123
+ end
124
+ when :Object
125
+ # generic object (usually a Hash), return directly
126
+ value
127
+ when /\AArray<(?<inner_type>.+)>\z/
128
+ inner_type = Regexp.last_match[:inner_type]
129
+ value.map { |v| _deserialize(inner_type, v) }
130
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
131
+ k_type = Regexp.last_match[:k_type]
132
+ v_type = Regexp.last_match[:v_type]
133
+ {}.tap do |hash|
134
+ value.each do |k, v|
135
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
136
+ end
137
+ end
138
+ else # model
139
+ temp_model = SmoochApi.const_get(type).new
140
+ temp_model.build_from_hash(value)
141
+ end
142
+ end
143
+
144
+ # Returns the string representation of the object
145
+ # @return [String] String presentation of the object
146
+ def to_s
147
+ to_hash.to_s
148
+ end
149
+
150
+ # to_body is an alias to to_hash (backward compatibility)
151
+ # @return [Hash] Returns the object in the form of hash
152
+ def to_body
153
+ to_hash
154
+ end
155
+
156
+ # Returns the object in the form of hash
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_hash
159
+ hash = {}
160
+ self.class.attribute_map.each_pair do |attr, param|
161
+ value = self.send(attr)
162
+ next if value.nil?
163
+ hash[param] = _to_hash(value)
164
+ end
165
+ hash
166
+ end
167
+
168
+ # Outputs non-array value in the form of hash
169
+ # For object, use to_hash. Otherwise, just return the value
170
+ # @param [Object] value Any valid value
171
+ # @return [Hash] Returns the value in the form of hash
172
+ def _to_hash(value)
173
+ if value.is_a?(Array)
174
+ value.compact.map{ |v| _to_hash(v) }
175
+ elsif value.is_a?(Hash)
176
+ {}.tap do |hash|
177
+ value.each { |k, v| hash[k] = _to_hash(v) }
178
+ end
179
+ elsif value.respond_to? :to_hash
180
+ value.to_hash
181
+ else
182
+ value
183
+ end
184
+ end
185
+
186
+ end
187
+
188
+ end