talon_one 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -6
  3. data/docs/AccountAnalytics.md +1 -0
  4. data/docs/AccountLimits.md +1 -0
  5. data/docs/Application.md +1 -0
  6. data/docs/AttributesMandatory.md +9 -0
  7. data/docs/AttributesSettings.md +8 -0
  8. data/docs/BaseSamlConnection.md +15 -0
  9. data/docs/CampaignAnalytics.md +9 -3
  10. data/docs/CampaignCopy.md +4 -0
  11. data/docs/Change.md +2 -2
  12. data/docs/CustomerInventory.md +9 -0
  13. data/docs/InlineResponse20020.md +1 -1
  14. data/docs/InlineResponse20021.md +1 -1
  15. data/docs/InlineResponse20022.md +1 -1
  16. data/docs/InlineResponse20023.md +1 -1
  17. data/docs/InlineResponse20024.md +1 -1
  18. data/docs/InlineResponse20025.md +2 -3
  19. data/docs/InlineResponse20026.md +3 -2
  20. data/docs/InlineResponse20027.md +1 -1
  21. data/docs/InlineResponse20028.md +1 -1
  22. data/docs/InlineResponse20029.md +9 -0
  23. data/docs/IntegrationApi.md +66 -0
  24. data/docs/ManagementApi.md +162 -101
  25. data/docs/NewApplication.md +1 -0
  26. data/docs/NewSamlConnection.md +3 -2
  27. data/docs/SamlConnection.md +4 -5
  28. data/docs/SamlConnectionMetadata.md +11 -0
  29. data/docs/UpdateApplication.md +1 -0
  30. data/lib/talon_one.rb +6 -0
  31. data/lib/talon_one/api/integration_api.rb +60 -0
  32. data/lib/talon_one/api/management_api.rb +177 -119
  33. data/lib/talon_one/models/account_analytics.rb +19 -4
  34. data/lib/talon_one/models/account_limits.rb +11 -1
  35. data/lib/talon_one/models/application.rb +10 -1
  36. data/lib/talon_one/models/attributes_mandatory.rb +199 -0
  37. data/lib/talon_one/models/attributes_settings.rb +184 -0
  38. data/lib/talon_one/models/base_saml_connection.rb +336 -0
  39. data/lib/talon_one/models/campaign_analytics.rb +94 -4
  40. data/lib/talon_one/models/campaign_copy.rb +46 -4
  41. data/lib/talon_one/models/change.rb +2 -2
  42. data/lib/talon_one/models/customer_inventory.rb +194 -0
  43. data/lib/talon_one/models/inline_response_200_20.rb +1 -1
  44. data/lib/talon_one/models/inline_response_200_21.rb +1 -1
  45. data/lib/talon_one/models/inline_response_200_22.rb +1 -1
  46. data/lib/talon_one/models/inline_response_200_23.rb +1 -1
  47. data/lib/talon_one/models/inline_response_200_24.rb +1 -1
  48. data/lib/talon_one/models/inline_response_200_25.rb +7 -11
  49. data/lib/talon_one/models/inline_response_200_26.rb +11 -7
  50. data/lib/talon_one/models/inline_response_200_27.rb +1 -1
  51. data/lib/talon_one/models/inline_response_200_28.rb +1 -1
  52. data/lib/talon_one/models/inline_response_200_29.rb +204 -0
  53. data/lib/talon_one/models/new_application.rb +10 -1
  54. data/lib/talon_one/models/new_saml_connection.rb +58 -43
  55. data/lib/talon_one/models/saml_connection.rb +45 -78
  56. data/lib/talon_one/models/saml_connection_metadata.rb +271 -0
  57. data/lib/talon_one/models/update_application.rb +13 -4
  58. data/lib/talon_one/version.rb +1 -1
  59. data/spec/api/integration_api_spec.rb +14 -0
  60. data/spec/api/management_api_spec.rb +50 -36
  61. data/spec/models/account_analytics_spec.rb +6 -0
  62. data/spec/models/account_limits_spec.rb +6 -0
  63. data/spec/models/application_spec.rb +6 -0
  64. data/spec/models/attributes_mandatory_spec.rb +47 -0
  65. data/spec/models/attributes_settings_spec.rb +41 -0
  66. data/spec/models/base_saml_connection_spec.rb +83 -0
  67. data/spec/models/campaign_analytics_spec.rb +36 -0
  68. data/spec/models/campaign_copy_spec.rb +24 -0
  69. data/spec/models/customer_inventory_spec.rb +47 -0
  70. data/spec/models/inline_response_200_25_spec.rb +0 -6
  71. data/spec/models/inline_response_200_26_spec.rb +6 -0
  72. data/spec/models/inline_response_200_29_spec.rb +47 -0
  73. data/spec/models/new_application_spec.rb +6 -0
  74. data/spec/models/new_saml_connection_spec.rb +13 -7
  75. data/spec/models/saml_connection_metadata_spec.rb +59 -0
  76. data/spec/models/saml_connection_spec.rb +9 -15
  77. data/spec/models/update_application_spec.rb +6 -0
  78. data/talon_one-1.3.0.gem +0 -0
  79. metadata +27 -2
@@ -56,6 +56,9 @@ module TalonOne
56
56
  # Total Number of loyalty programs inside the account
57
57
  attr_accessor :loyalty_programs
58
58
 
59
+ # Total Number of active rules in the account
60
+ attr_accessor :active_rules
61
+
59
62
  # Attribute mapping from ruby-style variable name to JSON key.
60
63
  def self.attribute_map
61
64
  {
@@ -72,7 +75,8 @@ module TalonOne
72
75
  :'users' => :'users',
73
76
  :'roles' => :'roles',
74
77
  :'webhooks' => :'webhooks',
75
- :'loyalty_programs' => :'loyaltyPrograms'
78
+ :'loyalty_programs' => :'loyaltyPrograms',
79
+ :'active_rules' => :'activeRules'
76
80
  }
77
81
  end
78
82
 
@@ -92,7 +96,8 @@ module TalonOne
92
96
  :'users' => :'Integer',
93
97
  :'roles' => :'Integer',
94
98
  :'webhooks' => :'Integer',
95
- :'loyalty_programs' => :'Integer'
99
+ :'loyalty_programs' => :'Integer',
100
+ :'active_rules' => :'Integer'
96
101
  }
97
102
  end
98
103
 
@@ -159,6 +164,10 @@ module TalonOne
159
164
  if attributes.has_key?(:'loyaltyPrograms')
160
165
  self.loyalty_programs = attributes[:'loyaltyPrograms']
161
166
  end
167
+
168
+ if attributes.has_key?(:'activeRules')
169
+ self.active_rules = attributes[:'activeRules']
170
+ end
162
171
  end
163
172
 
164
173
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -221,6 +230,10 @@ module TalonOne
221
230
  invalid_properties.push('invalid value for "loyalty_programs", loyalty_programs cannot be nil.')
222
231
  end
223
232
 
233
+ if @active_rules.nil?
234
+ invalid_properties.push('invalid value for "active_rules", active_rules cannot be nil.')
235
+ end
236
+
224
237
  invalid_properties
225
238
  end
226
239
 
@@ -241,6 +254,7 @@ module TalonOne
241
254
  return false if @roles.nil?
242
255
  return false if @webhooks.nil?
243
256
  return false if @loyalty_programs.nil?
257
+ return false if @active_rules.nil?
244
258
  true
245
259
  end
246
260
 
@@ -262,7 +276,8 @@ module TalonOne
262
276
  users == o.users &&
263
277
  roles == o.roles &&
264
278
  webhooks == o.webhooks &&
265
- loyalty_programs == o.loyalty_programs
279
+ loyalty_programs == o.loyalty_programs &&
280
+ active_rules == o.active_rules
266
281
  end
267
282
 
268
283
  # @see the `==` method
@@ -274,7 +289,7 @@ module TalonOne
274
289
  # Calculates hash code according to all attributes.
275
290
  # @return [Fixnum] Hash code
276
291
  def hash
277
- [applications, active_campaigns, campaigns, coupons, active_coupons, expired_coupons, custom_attributes, referral_codes, active_referral_codes, expired_referral_codes, users, roles, webhooks, loyalty_programs].hash
292
+ [applications, active_campaigns, campaigns, coupons, active_coupons, expired_coupons, custom_attributes, referral_codes, active_referral_codes, expired_referral_codes, users, roles, webhooks, loyalty_programs, active_rules].hash
278
293
  end
279
294
 
280
295
  # Builds the object from hash
@@ -44,6 +44,9 @@ module TalonOne
44
44
  # Total allowed api volume
45
45
  attr_accessor :api_volume
46
46
 
47
+ # Total allowed active rulesets
48
+ attr_accessor :active_rules
49
+
47
50
  # array of rulesets where webhook is used
48
51
  attr_accessor :promotion_types
49
52
 
@@ -60,6 +63,7 @@ module TalonOne
60
63
  :'webhooks' => :'webhooks',
61
64
  :'users' => :'users',
62
65
  :'api_volume' => :'apiVolume',
66
+ :'active_rules' => :'activeRules',
63
67
  :'promotion_types' => :'promotionTypes'
64
68
  }
65
69
  end
@@ -77,6 +81,7 @@ module TalonOne
77
81
  :'webhooks' => :'Integer',
78
82
  :'users' => :'Integer',
79
83
  :'api_volume' => :'Integer',
84
+ :'active_rules' => :'Integer',
80
85
  :'promotion_types' => :'Array<String>'
81
86
  }
82
87
  end
@@ -129,6 +134,10 @@ module TalonOne
129
134
  self.api_volume = attributes[:'apiVolume']
130
135
  end
131
136
 
137
+ if attributes.has_key?(:'activeRules')
138
+ self.active_rules = attributes[:'activeRules']
139
+ end
140
+
132
141
  if attributes.has_key?(:'promotionTypes')
133
142
  if (value = attributes[:'promotionTypes']).is_a?(Array)
134
143
  self.promotion_types = value
@@ -219,6 +228,7 @@ module TalonOne
219
228
  webhooks == o.webhooks &&
220
229
  users == o.users &&
221
230
  api_volume == o.api_volume &&
231
+ active_rules == o.active_rules &&
222
232
  promotion_types == o.promotion_types
223
233
  end
224
234
 
@@ -231,7 +241,7 @@ module TalonOne
231
241
  # Calculates hash code according to all attributes.
232
242
  # @return [Fixnum] Hash code
233
243
  def hash
234
- [live_applications, sandbox_applications, active_campaigns, coupons, referral_codes, live_loyalty_programs, sandbox_loyalty_programs, webhooks, users, api_volume, promotion_types].hash
244
+ [live_applications, sandbox_applications, active_campaigns, coupons, referral_codes, live_loyalty_programs, sandbox_loyalty_programs, webhooks, users, api_volume, active_rules, promotion_types].hash
235
245
  end
236
246
 
237
247
  # Builds the object from hash
@@ -48,6 +48,8 @@ module TalonOne
48
48
  # Default limits for campaigns created in this application
49
49
  attr_accessor :limits
50
50
 
51
+ attr_accessor :attributes_settings
52
+
51
53
  # Hex key for HMAC-signing API calls as coming from this application (16 hex digits)
52
54
  attr_accessor :key
53
55
 
@@ -90,6 +92,7 @@ module TalonOne
90
92
  :'case_sensitivity' => :'caseSensitivity',
91
93
  :'attributes' => :'attributes',
92
94
  :'limits' => :'limits',
95
+ :'attributes_settings' => :'attributesSettings',
93
96
  :'key' => :'key',
94
97
  :'loyalty_programs' => :'loyaltyPrograms'
95
98
  }
@@ -109,6 +112,7 @@ module TalonOne
109
112
  :'case_sensitivity' => :'String',
110
113
  :'attributes' => :'Object',
111
114
  :'limits' => :'Array<LimitConfig>',
115
+ :'attributes_settings' => :'AttributesSettings',
112
116
  :'key' => :'String',
113
117
  :'loyalty_programs' => :'Array<LoyaltyProgram>'
114
118
  }
@@ -168,6 +172,10 @@ module TalonOne
168
172
  end
169
173
  end
170
174
 
175
+ if attributes.has_key?(:'attributesSettings')
176
+ self.attributes_settings = attributes[:'attributesSettings']
177
+ end
178
+
171
179
  if attributes.has_key?(:'key')
172
180
  self.key = attributes[:'key']
173
181
  end
@@ -359,6 +367,7 @@ module TalonOne
359
367
  case_sensitivity == o.case_sensitivity &&
360
368
  attributes == o.attributes &&
361
369
  limits == o.limits &&
370
+ attributes_settings == o.attributes_settings &&
362
371
  key == o.key &&
363
372
  loyalty_programs == o.loyalty_programs
364
373
  end
@@ -372,7 +381,7 @@ module TalonOne
372
381
  # Calculates hash code according to all attributes.
373
382
  # @return [Fixnum] Hash code
374
383
  def hash
375
- [id, created, modified, account_id, name, description, timezone, currency, case_sensitivity, attributes, limits, key, loyalty_programs].hash
384
+ [id, created, modified, account_id, name, description, timezone, currency, case_sensitivity, attributes, limits, attributes_settings, key, loyalty_programs].hash
376
385
  end
377
386
 
378
387
  # Builds the object from hash
@@ -0,0 +1,199 @@
1
+ =begin
2
+ #Talon.One API
3
+
4
+ #The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.7
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module TalonOne
16
+ # Arbitrary settings associated with attributes.
17
+ class AttributesMandatory
18
+ # List of mandatory attributes for campaigns.
19
+ attr_accessor :campaigns
20
+
21
+ # List of mandatory attributes for campaigns.
22
+ attr_accessor :coupons
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'campaigns' => :'campaigns',
28
+ :'coupons' => :'coupons'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'campaigns' => :'Array<String>',
36
+ :'coupons' => :'Array<String>'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
47
+
48
+ if attributes.has_key?(:'campaigns')
49
+ if (value = attributes[:'campaigns']).is_a?(Array)
50
+ self.campaigns = value
51
+ end
52
+ end
53
+
54
+ if attributes.has_key?(:'coupons')
55
+ if (value = attributes[:'coupons']).is_a?(Array)
56
+ self.coupons = value
57
+ end
58
+ end
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properties with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ campaigns == o.campaigns &&
80
+ coupons == o.coupons
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(o)
86
+ self == o
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Fixnum] Hash code
91
+ def hash
92
+ [campaigns, coupons].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ self.class.swagger_types.each_pair do |key, type|
101
+ if type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
105
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
106
+ end
107
+ elsif !attributes[self.class.attribute_map[key]].nil?
108
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
109
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
110
+ end
111
+
112
+ self
113
+ end
114
+
115
+ # Deserializes the data based on type
116
+ # @param string type Data type
117
+ # @param string value Value to be deserialized
118
+ # @return [Object] Deserialized data
119
+ def _deserialize(type, value)
120
+ case type.to_sym
121
+ when :DateTime
122
+ DateTime.parse(value)
123
+ when :Date
124
+ Date.parse(value)
125
+ when :String
126
+ value.to_s
127
+ when :Integer
128
+ value.to_i
129
+ when :Float
130
+ value.to_f
131
+ when :BOOLEAN
132
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
133
+ true
134
+ else
135
+ false
136
+ end
137
+ when :Object
138
+ # generic object (usually a Hash), return directly
139
+ value
140
+ when /\AArray<(?<inner_type>.+)>\z/
141
+ inner_type = Regexp.last_match[:inner_type]
142
+ value.map { |v| _deserialize(inner_type, v) }
143
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144
+ k_type = Regexp.last_match[:k_type]
145
+ v_type = Regexp.last_match[:v_type]
146
+ {}.tap do |hash|
147
+ value.each do |k, v|
148
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149
+ end
150
+ end
151
+ else # model
152
+ temp_model = TalonOne.const_get(type).new
153
+ temp_model.build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ # Returns the object in the form of hash
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_hash
172
+ hash = {}
173
+ self.class.attribute_map.each_pair do |attr, param|
174
+ value = self.send(attr)
175
+ next if value.nil?
176
+ hash[param] = _to_hash(value)
177
+ end
178
+ hash
179
+ end
180
+
181
+ # Outputs non-array value in the form of hash
182
+ # For object, use to_hash. Otherwise, just return the value
183
+ # @param [Object] value Any valid value
184
+ # @return [Hash] Returns the value in the form of hash
185
+ def _to_hash(value)
186
+ if value.is_a?(Array)
187
+ value.compact.map { |v| _to_hash(v) }
188
+ elsif value.is_a?(Hash)
189
+ {}.tap do |hash|
190
+ value.each { |k, v| hash[k] = _to_hash(v) }
191
+ end
192
+ elsif value.respond_to? :to_hash
193
+ value.to_hash
194
+ else
195
+ value
196
+ end
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,184 @@
1
+ =begin
2
+ #Talon.One API
3
+
4
+ #The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.7
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module TalonOne
16
+ # Arbitrary settings associated with attributes.
17
+ class AttributesSettings
18
+ attr_accessor :mandatory
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'mandatory' => :'mandatory'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.swagger_types
29
+ {
30
+ :'mandatory' => :'AttributesMandatory'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
41
+
42
+ if attributes.has_key?(:'mandatory')
43
+ self.mandatory = attributes[:'mandatory']
44
+ end
45
+ end
46
+
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properties with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ invalid_properties
52
+ end
53
+
54
+ # Check to see if the all the properties in the model are valid
55
+ # @return true if the model is valid
56
+ def valid?
57
+ true
58
+ end
59
+
60
+ # Checks equality by comparing each attribute.
61
+ # @param [Object] Object to be compared
62
+ def ==(o)
63
+ return true if self.equal?(o)
64
+ self.class == o.class &&
65
+ mandatory == o.mandatory
66
+ end
67
+
68
+ # @see the `==` method
69
+ # @param [Object] Object to be compared
70
+ def eql?(o)
71
+ self == o
72
+ end
73
+
74
+ # Calculates hash code according to all attributes.
75
+ # @return [Fixnum] Hash code
76
+ def hash
77
+ [mandatory].hash
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def build_from_hash(attributes)
84
+ return nil unless attributes.is_a?(Hash)
85
+ self.class.swagger_types.each_pair do |key, type|
86
+ if type =~ /\AArray<(.*)>/i
87
+ # check to ensure the input is an array given that the the attribute
88
+ # is documented as an array but the input is not
89
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
90
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
91
+ end
92
+ elsif !attributes[self.class.attribute_map[key]].nil?
93
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
94
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
95
+ end
96
+
97
+ self
98
+ end
99
+
100
+ # Deserializes the data based on type
101
+ # @param string type Data type
102
+ # @param string value Value to be deserialized
103
+ # @return [Object] Deserialized data
104
+ def _deserialize(type, value)
105
+ case type.to_sym
106
+ when :DateTime
107
+ DateTime.parse(value)
108
+ when :Date
109
+ Date.parse(value)
110
+ when :String
111
+ value.to_s
112
+ when :Integer
113
+ value.to_i
114
+ when :Float
115
+ value.to_f
116
+ when :BOOLEAN
117
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
118
+ true
119
+ else
120
+ false
121
+ end
122
+ when :Object
123
+ # generic object (usually a Hash), return directly
124
+ value
125
+ when /\AArray<(?<inner_type>.+)>\z/
126
+ inner_type = Regexp.last_match[:inner_type]
127
+ value.map { |v| _deserialize(inner_type, v) }
128
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
129
+ k_type = Regexp.last_match[:k_type]
130
+ v_type = Regexp.last_match[:v_type]
131
+ {}.tap do |hash|
132
+ value.each do |k, v|
133
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
134
+ end
135
+ end
136
+ else # model
137
+ temp_model = TalonOne.const_get(type).new
138
+ temp_model.build_from_hash(value)
139
+ end
140
+ end
141
+
142
+ # Returns the string representation of the object
143
+ # @return [String] String presentation of the object
144
+ def to_s
145
+ to_hash.to_s
146
+ end
147
+
148
+ # to_body is an alias to to_hash (backward compatibility)
149
+ # @return [Hash] Returns the object in the form of hash
150
+ def to_body
151
+ to_hash
152
+ end
153
+
154
+ # Returns the object in the form of hash
155
+ # @return [Hash] Returns the object in the form of hash
156
+ def to_hash
157
+ hash = {}
158
+ self.class.attribute_map.each_pair do |attr, param|
159
+ value = self.send(attr)
160
+ next if value.nil?
161
+ hash[param] = _to_hash(value)
162
+ end
163
+ hash
164
+ end
165
+
166
+ # Outputs non-array value in the form of hash
167
+ # For object, use to_hash. Otherwise, just return the value
168
+ # @param [Object] value Any valid value
169
+ # @return [Hash] Returns the value in the form of hash
170
+ def _to_hash(value)
171
+ if value.is_a?(Array)
172
+ value.compact.map { |v| _to_hash(v) }
173
+ elsif value.is_a?(Hash)
174
+ {}.tap do |hash|
175
+ value.each { |k, v| hash[k] = _to_hash(v) }
176
+ end
177
+ elsif value.respond_to? :to_hash
178
+ value.to_hash
179
+ else
180
+ value
181
+ end
182
+ end
183
+ end
184
+ end