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