smooch-api 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/docs/AppUserApi.md +59 -0
  4. data/docs/LinkRequestResponse.md +8 -0
  5. data/docs/LinkRequestResponseLinkRequests.md +11 -0
  6. data/lib/smooch-api.rb +3 -1
  7. data/lib/smooch-api/api/app_api.rb +1 -1
  8. data/lib/smooch-api/api/app_user_api.rb +69 -1
  9. data/lib/smooch-api/api/attachments_api.rb +1 -1
  10. data/lib/smooch-api/api/conversation_api.rb +1 -1
  11. data/lib/smooch-api/api/integration_api.rb +1 -1
  12. data/lib/smooch-api/api/menu_api.rb +1 -1
  13. data/lib/smooch-api/api/webhook_api.rb +1 -1
  14. data/lib/smooch-api/api_client.rb +1 -1
  15. data/lib/smooch-api/api_error.rb +1 -1
  16. data/lib/smooch-api/configuration.rb +1 -1
  17. data/lib/smooch-api/models/action.rb +1 -1
  18. data/lib/smooch-api/models/app.rb +1 -1
  19. data/lib/smooch-api/models/app_create.rb +1 -1
  20. data/lib/smooch-api/models/app_response.rb +1 -1
  21. data/lib/smooch-api/models/app_settings.rb +1 -1
  22. data/lib/smooch-api/models/app_update.rb +1 -1
  23. data/lib/smooch-api/models/app_user.rb +1 -1
  24. data/lib/smooch-api/models/app_user_business_systems_response.rb +1 -1
  25. data/lib/smooch-api/models/app_user_channels_response.rb +1 -1
  26. data/lib/smooch-api/models/app_user_link.rb +1 -1
  27. data/lib/smooch-api/models/app_user_pre_create.rb +1 -1
  28. data/lib/smooch-api/models/app_user_response.rb +1 -1
  29. data/lib/smooch-api/models/app_user_update.rb +1 -1
  30. data/lib/smooch-api/models/attachment_response.rb +1 -1
  31. data/lib/smooch-api/models/auth_code_response.rb +1 -1
  32. data/lib/smooch-api/models/business_system_item.rb +1 -1
  33. data/lib/smooch-api/models/channel_entity_item.rb +1 -1
  34. data/lib/smooch-api/models/client.rb +1 -1
  35. data/lib/smooch-api/models/client_info.rb +1 -1
  36. data/lib/smooch-api/models/confirmation.rb +1 -1
  37. data/lib/smooch-api/models/conversation.rb +1 -1
  38. data/lib/smooch-api/models/destination.rb +1 -1
  39. data/lib/smooch-api/models/display_settings.rb +1 -1
  40. data/lib/smooch-api/models/get_messages_response.rb +1 -1
  41. data/lib/smooch-api/models/integration.rb +1 -1
  42. data/lib/smooch-api/models/integration_create.rb +1 -1
  43. data/lib/smooch-api/models/integration_response.rb +1 -1
  44. data/lib/smooch-api/models/jwt_response.rb +1 -1
  45. data/lib/smooch-api/models/link_request_response.rb +191 -0
  46. data/lib/smooch-api/models/link_request_response_link_requests.rb +239 -0
  47. data/lib/smooch-api/models/list_apps_response.rb +1 -1
  48. data/lib/smooch-api/models/list_integrations_response.rb +1 -1
  49. data/lib/smooch-api/models/list_secret_keys_response.rb +1 -1
  50. data/lib/smooch-api/models/list_webhooks_response.rb +1 -1
  51. data/lib/smooch-api/models/menu.rb +1 -1
  52. data/lib/smooch-api/models/menu_item.rb +1 -1
  53. data/lib/smooch-api/models/menu_response.rb +1 -1
  54. data/lib/smooch-api/models/message.rb +1 -1
  55. data/lib/smooch-api/models/message_item.rb +1 -1
  56. data/lib/smooch-api/models/message_post.rb +1 -1
  57. data/lib/smooch-api/models/message_response.rb +1 -1
  58. data/lib/smooch-api/models/secret_key.rb +1 -1
  59. data/lib/smooch-api/models/secret_key_create.rb +1 -1
  60. data/lib/smooch-api/models/secret_key_response.rb +1 -1
  61. data/lib/smooch-api/models/source.rb +1 -1
  62. data/lib/smooch-api/models/typing_activity_trigger.rb +1 -1
  63. data/lib/smooch-api/models/webhook.rb +1 -1
  64. data/lib/smooch-api/models/webhook_create.rb +1 -1
  65. data/lib/smooch-api/models/webhook_response.rb +1 -1
  66. data/lib/smooch-api/models/webhook_update.rb +1 -1
  67. data/lib/smooch-api/version.rb +2 -2
  68. data/smooch-api.gemspec +1 -1
  69. data/spec/api_client_spec.rb +1 -1
  70. data/spec/configuration_spec.rb +1 -1
  71. data/spec/spec_helper.rb +1 -1
  72. metadata +7 -3
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- OpenAPI spec version: 2.4
6
+ OpenAPI spec version: 2.5
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
  Swagger Codegen version: 2.2.3-SNAPSHOT
@@ -0,0 +1,191 @@
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: 2.5
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SmoochApi
16
+
17
+ class LinkRequestResponse
18
+ # The list of link requests.
19
+ attr_accessor :link_requests
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'link_requests' => :'linkRequests'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.swagger_types
31
+ {
32
+ :'link_requests' => :'Array<LinkRequestResponseLinkRequests>'
33
+ }
34
+ end
35
+
36
+ # Initializes the object
37
+ # @param [Hash] attributes Model attributes in the form of hash
38
+ def initialize(attributes = {})
39
+ return unless attributes.is_a?(Hash)
40
+
41
+ # convert string to symbol for hash key
42
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
43
+
44
+ if attributes.has_key?(:'linkRequests')
45
+ if (value = attributes[:'linkRequests']).is_a?(Array)
46
+ self.link_requests = value
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ # Show invalid properties with the reasons. Usually used together with valid?
53
+ # @return Array for valid properies with the reasons
54
+ def list_invalid_properties
55
+ invalid_properties = Array.new
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 true
63
+ end
64
+
65
+ # Checks equality by comparing each attribute.
66
+ # @param [Object] Object to be compared
67
+ def ==(o)
68
+ return true if self.equal?(o)
69
+ self.class == o.class &&
70
+ link_requests == o.link_requests
71
+ end
72
+
73
+ # @see the `==` method
74
+ # @param [Object] Object to be compared
75
+ def eql?(o)
76
+ self == o
77
+ end
78
+
79
+ # Calculates hash code according to all attributes.
80
+ # @return [Fixnum] Hash code
81
+ def hash
82
+ [link_requests].hash
83
+ end
84
+
85
+ # Builds the object from hash
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ # @return [Object] Returns the model itself
88
+ def build_from_hash(attributes)
89
+ return nil unless attributes.is_a?(Hash)
90
+ self.class.swagger_types.each_pair do |key, type|
91
+ if type =~ /\AArray<(.*)>/i
92
+ # check to ensure the input is an array given that the the attribute
93
+ # is documented as an array but the input is not
94
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
95
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
96
+ end
97
+ elsif !attributes[self.class.attribute_map[key]].nil?
98
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
99
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
100
+ end
101
+
102
+ self
103
+ end
104
+
105
+ # Deserializes the data based on type
106
+ # @param string type Data type
107
+ # @param string value Value to be deserialized
108
+ # @return [Object] Deserialized data
109
+ def _deserialize(type, value)
110
+ case type.to_sym
111
+ when :DateTime
112
+ DateTime.parse(value)
113
+ when :Date
114
+ Date.parse(value)
115
+ when :String
116
+ value.to_s
117
+ when :Integer
118
+ value.to_i
119
+ when :Float
120
+ value.to_f
121
+ when :BOOLEAN
122
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
123
+ true
124
+ else
125
+ false
126
+ end
127
+ when :Object
128
+ # generic object (usually a Hash), return directly
129
+ value
130
+ when /\AArray<(?<inner_type>.+)>\z/
131
+ inner_type = Regexp.last_match[:inner_type]
132
+ value.map { |v| _deserialize(inner_type, v) }
133
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
134
+ k_type = Regexp.last_match[:k_type]
135
+ v_type = Regexp.last_match[:v_type]
136
+ {}.tap do |hash|
137
+ value.each do |k, v|
138
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
139
+ end
140
+ end
141
+ else # model
142
+ temp_model = SmoochApi.const_get(type).new
143
+ temp_model.build_from_hash(value)
144
+ end
145
+ end
146
+
147
+ # Returns the string representation of the object
148
+ # @return [String] String presentation of the object
149
+ def to_s
150
+ to_hash.to_s
151
+ end
152
+
153
+ # to_body is an alias to to_hash (backward compatibility)
154
+ # @return [Hash] Returns the object in the form of hash
155
+ def to_body
156
+ to_hash
157
+ end
158
+
159
+ # Returns the object in the form of hash
160
+ # @return [Hash] Returns the object in the form of hash
161
+ def to_hash
162
+ hash = {}
163
+ self.class.attribute_map.each_pair do |attr, param|
164
+ value = self.send(attr)
165
+ next if value.nil?
166
+ hash[param] = _to_hash(value)
167
+ end
168
+ hash
169
+ end
170
+
171
+ # Outputs non-array value in the form of hash
172
+ # For object, use to_hash. Otherwise, just return the value
173
+ # @param [Object] value Any valid value
174
+ # @return [Hash] Returns the value in the form of hash
175
+ def _to_hash(value)
176
+ if value.is_a?(Array)
177
+ value.compact.map{ |v| _to_hash(v) }
178
+ elsif value.is_a?(Hash)
179
+ {}.tap do |hash|
180
+ value.each { |k, v| hash[k] = _to_hash(v) }
181
+ end
182
+ elsif value.respond_to? :to_hash
183
+ value.to_hash
184
+ else
185
+ value
186
+ end
187
+ end
188
+
189
+ end
190
+
191
+ end
@@ -0,0 +1,239 @@
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: 2.5
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SmoochApi
16
+
17
+ class LinkRequestResponseLinkRequests
18
+ # The integration ID.
19
+ attr_accessor :integration_id
20
+
21
+ # The integration type.
22
+ attr_accessor :type
23
+
24
+ # The link request code.
25
+ attr_accessor :code
26
+
27
+ # The link request url.
28
+ attr_accessor :url
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'integration_id' => :'integrationId',
35
+ :'type' => :'type',
36
+ :'code' => :'code',
37
+ :'url' => :'url'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.swagger_types
43
+ {
44
+ :'integration_id' => :'String',
45
+ :'type' => :'String',
46
+ :'code' => :'String',
47
+ :'url' => :'String'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
58
+
59
+ if attributes.has_key?(:'integrationId')
60
+ self.integration_id = attributes[:'integrationId']
61
+ end
62
+
63
+ if attributes.has_key?(:'type')
64
+ self.type = attributes[:'type']
65
+ end
66
+
67
+ if attributes.has_key?(:'code')
68
+ self.code = attributes[:'code']
69
+ end
70
+
71
+ if attributes.has_key?(:'url')
72
+ self.url = attributes[:'url']
73
+ end
74
+
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properies with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ if @integration_id.nil?
82
+ invalid_properties.push("invalid value for 'integration_id', integration_id cannot be nil.")
83
+ end
84
+
85
+ if @type.nil?
86
+ invalid_properties.push("invalid value for 'type', type cannot be nil.")
87
+ end
88
+
89
+ if @code.nil?
90
+ invalid_properties.push("invalid value for 'code', code cannot be nil.")
91
+ end
92
+
93
+ if @url.nil?
94
+ invalid_properties.push("invalid value for 'url', url cannot be nil.")
95
+ end
96
+
97
+ return invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ return false if @integration_id.nil?
104
+ return false if @type.nil?
105
+ return false if @code.nil?
106
+ return false if @url.nil?
107
+ return true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(o)
113
+ return true if self.equal?(o)
114
+ self.class == o.class &&
115
+ integration_id == o.integration_id &&
116
+ type == o.type &&
117
+ code == o.code &&
118
+ url == o.url
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Fixnum] Hash code
129
+ def hash
130
+ [integration_id, type, code, url].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ self.class.swagger_types.each_pair do |key, type|
139
+ if type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :DateTime
160
+ DateTime.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :BOOLEAN
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ temp_model = SmoochApi.const_get(type).new
191
+ temp_model.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ next if value.nil?
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map{ |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end