boxx_client 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +109 -0
  4. data/Rakefile +8 -0
  5. data/boxx_client.gemspec +46 -0
  6. data/dist/boxx_client-1.4.0.gem +0 -0
  7. data/dist/examples/upload_customer.rb +76 -0
  8. data/dist/examples/upload_product.rb +54 -0
  9. data/dist/examples/upload_transaction.rb +56 -0
  10. data/docs/DeleteAll.md +10 -0
  11. data/docs/DeleteAllApi.md +56 -0
  12. data/docs/DeleteSpecific.md +11 -0
  13. data/docs/DeleteSpecificApi.md +56 -0
  14. data/docs/InlineResponse200.md +9 -0
  15. data/docs/InlineResponse2001.md +9 -0
  16. data/docs/InlineResponse2001Response.md +9 -0
  17. data/docs/InlineResponse200Response.md +11 -0
  18. data/docs/InlineResponse400.md +9 -0
  19. data/docs/InlineResponse4001.md +9 -0
  20. data/docs/UploadCustomer.md +14 -0
  21. data/docs/UploadCustomerDeviceTokens.md +11 -0
  22. data/docs/UploadCustomerMobileTokens.md +10 -0
  23. data/docs/UploadCustomerRequest.md +11 -0
  24. data/docs/UploadDataApi.md +149 -0
  25. data/docs/UploadOkResponse.md +9 -0
  26. data/docs/UploadOkResponseResult.md +11 -0
  27. data/docs/UploadProduct.md +13 -0
  28. data/docs/UploadProductRequest.md +11 -0
  29. data/docs/UploadTransaction.md +16 -0
  30. data/docs/UploadTransactionRequest.md +11 -0
  31. data/git_push.sh +55 -0
  32. data/lib/boxx_client.rb +60 -0
  33. data/lib/boxx_client/api/delete_all_api.rb +78 -0
  34. data/lib/boxx_client/api/delete_specific_api.rb +78 -0
  35. data/lib/boxx_client/api/upload_data_api.rb +188 -0
  36. data/lib/boxx_client/api_client.rb +388 -0
  37. data/lib/boxx_client/api_error.rb +38 -0
  38. data/lib/boxx_client/configuration.rb +202 -0
  39. data/lib/boxx_client/models/delete_all.rb +224 -0
  40. data/lib/boxx_client/models/delete_specific.rb +241 -0
  41. data/lib/boxx_client/models/inline_response_200.rb +197 -0
  42. data/lib/boxx_client/models/inline_response_200_1.rb +197 -0
  43. data/lib/boxx_client/models/inline_response_200_1_response.rb +199 -0
  44. data/lib/boxx_client/models/inline_response_200_response.rb +217 -0
  45. data/lib/boxx_client/models/inline_response_400.rb +197 -0
  46. data/lib/boxx_client/models/inline_response_400_1.rb +197 -0
  47. data/lib/boxx_client/models/upload_customer.rb +255 -0
  48. data/lib/boxx_client/models/upload_customer_device_tokens.rb +215 -0
  49. data/lib/boxx_client/models/upload_customer_mobile_tokens.rb +206 -0
  50. data/lib/boxx_client/models/upload_customer_request.rb +236 -0
  51. data/lib/boxx_client/models/upload_ok_response.rb +197 -0
  52. data/lib/boxx_client/models/upload_ok_response_result.rb +217 -0
  53. data/lib/boxx_client/models/upload_product.rb +244 -0
  54. data/lib/boxx_client/models/upload_product_request.rb +236 -0
  55. data/lib/boxx_client/models/upload_transaction.rb +279 -0
  56. data/lib/boxx_client/models/upload_transaction_request.rb +236 -0
  57. data/lib/boxx_client/version.rb +15 -0
  58. data/spec/api/delete_all_api_spec.rb +47 -0
  59. data/spec/api/delete_specific_api_spec.rb +47 -0
  60. data/spec/api/upload_data_api_spec.rb +71 -0
  61. data/spec/api_client_spec.rb +226 -0
  62. data/spec/configuration_spec.rb +42 -0
  63. data/spec/models/delete_all_spec.rb +54 -0
  64. data/spec/models/delete_specific_spec.rb +60 -0
  65. data/spec/models/inline_response_200_1_response_spec.rb +48 -0
  66. data/spec/models/inline_response_200_1_spec.rb +48 -0
  67. data/spec/models/inline_response_200_response_spec.rb +60 -0
  68. data/spec/models/inline_response_200_spec.rb +48 -0
  69. data/spec/models/inline_response_400_1_spec.rb +48 -0
  70. data/spec/models/inline_response_400_spec.rb +48 -0
  71. data/spec/models/upload_customer_device_tokens_spec.rb +60 -0
  72. data/spec/models/upload_customer_mobile_tokens_spec.rb +54 -0
  73. data/spec/models/upload_customer_request_spec.rb +60 -0
  74. data/spec/models/upload_customer_spec.rb +78 -0
  75. data/spec/models/upload_ok_response_result_spec.rb +60 -0
  76. data/spec/models/upload_ok_response_spec.rb +48 -0
  77. data/spec/models/upload_product_request_spec.rb +60 -0
  78. data/spec/models/upload_product_spec.rb +72 -0
  79. data/spec/models/upload_transaction_request_spec.rb +60 -0
  80. data/spec/models/upload_transaction_spec.rb +90 -0
  81. data/spec/spec_helper.rb +111 -0
  82. metadata +327 -0
@@ -0,0 +1,215 @@
1
+ =begin
2
+ #Upload and Delete Data API
3
+
4
+ #Boxx.ai's customer, product and interaction data ingestion sdk
5
+
6
+ OpenAPI spec version: 1.4.1
7
+ Contact: aida@boxx.ai
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BoxxClient
16
+
17
+ class UploadCustomerDeviceTokens
18
+ attr_accessor :endpoint
19
+
20
+ attr_accessor :p256dh
21
+
22
+ attr_accessor :auth
23
+
24
+ attr_accessor :browser
25
+
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'endpoint' => :'endpoint',
31
+ :'p256dh' => :'p256dh',
32
+ :'auth' => :'auth',
33
+ :'browser' => :'browser'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'endpoint' => :'String',
41
+ :'p256dh' => :'String',
42
+ :'auth' => :'String',
43
+ :'browser' => :'String'
44
+ }
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ return unless attributes.is_a?(Hash)
51
+
52
+ # convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
54
+
55
+ if attributes.has_key?(:'endpoint')
56
+ self.endpoint = attributes[:'endpoint']
57
+ end
58
+
59
+ if attributes.has_key?(:'p256dh')
60
+ self.p256dh = attributes[:'p256dh']
61
+ end
62
+
63
+ if attributes.has_key?(:'auth')
64
+ self.auth = attributes[:'auth']
65
+ end
66
+
67
+ if attributes.has_key?(:'browser')
68
+ self.browser = attributes[:'browser']
69
+ end
70
+
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ return invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ return true
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ endpoint == o.endpoint &&
92
+ p256dh == o.p256dh &&
93
+ auth == o.auth &&
94
+ browser == o.browser
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Fixnum] Hash code
105
+ def hash
106
+ [endpoint, p256dh, auth, browser].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def build_from_hash(attributes)
113
+ return nil unless attributes.is_a?(Hash)
114
+ self.class.swagger_types.each_pair do |key, type|
115
+ if type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :DateTime
136
+ DateTime.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :BOOLEAN
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ temp_model = BoxxClient.const_get(type).new
167
+ temp_model.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ next if value.nil?
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map{ |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+
213
+ end
214
+
215
+ end
@@ -0,0 +1,206 @@
1
+ =begin
2
+ #Upload and Delete Data API
3
+
4
+ #Boxx.ai's customer, product and interaction data ingestion sdk
5
+
6
+ OpenAPI spec version: 1.4.1
7
+ Contact: aida@boxx.ai
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BoxxClient
16
+
17
+ class UploadCustomerMobileTokens
18
+ attr_accessor :device_registration
19
+
20
+ attr_accessor :device_platform
21
+
22
+ attr_accessor :source
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'device_registration' => :'device_registration',
29
+ :'device_platform' => :'device_platform',
30
+ :'source' => :'source'
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'device_registration' => :'String',
38
+ :'device_platform' => :'String',
39
+ :'source' => :'String'
40
+ }
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ return unless attributes.is_a?(Hash)
47
+
48
+ # convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
50
+
51
+ if attributes.has_key?(:'device_registration')
52
+ self.device_registration = attributes[:'device_registration']
53
+ end
54
+
55
+ if attributes.has_key?(:'device_platform')
56
+ self.device_platform = attributes[:'device_platform']
57
+ end
58
+
59
+ if attributes.has_key?(:'source')
60
+ self.source = attributes[:'source']
61
+ end
62
+
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ return invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ return true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ device_registration == o.device_registration &&
84
+ device_platform == o.device_platform &&
85
+ source == o.source
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Fixnum] Hash code
96
+ def hash
97
+ [device_registration, device_platform, source].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def build_from_hash(attributes)
104
+ return nil unless attributes.is_a?(Hash)
105
+ self.class.swagger_types.each_pair do |key, type|
106
+ if type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
110
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
111
+ end
112
+ elsif !attributes[self.class.attribute_map[key]].nil?
113
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
114
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def _deserialize(type, value)
125
+ case type.to_sym
126
+ when :DateTime
127
+ DateTime.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :BOOLEAN
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ temp_model = BoxxClient.const_get(type).new
158
+ temp_model.build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map{ |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+
206
+ end
@@ -0,0 +1,236 @@
1
+ =begin
2
+ #Upload and Delete Data API
3
+
4
+ #Boxx.ai's customer, product and interaction data ingestion sdk
5
+
6
+ OpenAPI spec version: 1.4.1
7
+ Contact: aida@boxx.ai
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BoxxClient
16
+ # upload customer request
17
+ class UploadCustomerRequest
18
+ # client id of the user
19
+ attr_accessor :client_id
20
+
21
+ # access token of the user
22
+ attr_accessor :access_token
23
+
24
+ attr_accessor :data
25
+
26
+ attr_accessor :data_format
27
+
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'client_id' => :'client_id',
33
+ :'access_token' => :'access_token',
34
+ :'data' => :'data',
35
+ :'data_format' => :'data_format'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'client_id' => :'String',
43
+ :'access_token' => :'String',
44
+ :'data' => :'Array<UploadCustomer>',
45
+ :'data_format' => :'Hash<String, String>'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
56
+
57
+ if attributes.has_key?(:'client_id')
58
+ self.client_id = attributes[:'client_id']
59
+ end
60
+
61
+ if attributes.has_key?(:'access_token')
62
+ self.access_token = attributes[:'access_token']
63
+ end
64
+
65
+ if attributes.has_key?(:'data')
66
+ if (value = attributes[:'data']).is_a?(Array)
67
+ self.data = value
68
+ end
69
+ end
70
+
71
+ if attributes.has_key?(:'data_format')
72
+ if (value = attributes[:'data_format']).is_a?(Hash)
73
+ self.data_format = value
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ if @client_id.nil?
84
+ invalid_properties.push("invalid value for 'client_id', client_id cannot be nil.")
85
+ end
86
+
87
+ if @access_token.nil?
88
+ invalid_properties.push("invalid value for 'access_token', access_token cannot be nil.")
89
+ end
90
+
91
+ if @data.nil?
92
+ invalid_properties.push("invalid value for 'data', data cannot be nil.")
93
+ end
94
+
95
+ return invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ return false if @client_id.nil?
102
+ return false if @access_token.nil?
103
+ return false if @data.nil?
104
+ return true
105
+ end
106
+
107
+ # Checks equality by comparing each attribute.
108
+ # @param [Object] Object to be compared
109
+ def ==(o)
110
+ return true if self.equal?(o)
111
+ self.class == o.class &&
112
+ client_id == o.client_id &&
113
+ access_token == o.access_token &&
114
+ data == o.data &&
115
+ data_format == o.data_format
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Fixnum] Hash code
126
+ def hash
127
+ [client_id, access_token, data, data_format].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.swagger_types.each_pair do |key, type|
136
+ if type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :DateTime
157
+ DateTime.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :BOOLEAN
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ temp_model = BoxxClient.const_get(type).new
188
+ temp_model.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ next if value.nil?
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map{ |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ end