talon_one 8.0.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -8
  3. data/docs/AchievementBase.md +35 -0
  4. data/docs/AchievementProgressWithDefinition.md +45 -0
  5. data/docs/AchievementStatusEntry.md +45 -0
  6. data/docs/AnalyticsSKU.md +23 -0
  7. data/docs/ApplicationCIFReferences.md +19 -0
  8. data/docs/CampaignDetail.md +19 -0
  9. data/docs/CampaignStoreBudgetLimitConfig.md +25 -0
  10. data/docs/CampaignTemplate.md +3 -1
  11. data/docs/HiddenConditionsEffects.md +23 -0
  12. data/docs/InlineResponse20048.md +19 -0
  13. data/docs/InlineResponse20049.md +19 -0
  14. data/docs/IntegrationApi.md +3 -1
  15. data/docs/LedgerTransactionLogEntryIntegrationAPI.md +3 -1
  16. data/docs/LoyaltyLedgerEntryFlags.md +17 -0
  17. data/docs/LoyaltyProgramTransaction.md +3 -1
  18. data/docs/ManagementApi.md +164 -323
  19. data/docs/MessageTest.md +27 -0
  20. data/docs/NewMessageTest.md +29 -0
  21. data/docs/ProductUnitAnalyticsDataPoint.md +25 -0
  22. data/docs/ProductUnitAnalyticsTotals.md +17 -0
  23. data/docs/SkuUnitAnalytics.md +19 -0
  24. data/docs/SkuUnitAnalyticsDataPoint.md +23 -0
  25. data/docs/StrikethroughLabelingNotification.md +2 -0
  26. data/lib/talon_one/api/integration_api.rb +3 -0
  27. data/lib/talon_one/api/management_api.rb +191 -354
  28. data/lib/talon_one/models/achievement_base.rb +377 -0
  29. data/lib/talon_one/models/achievement_progress_with_definition.rb +490 -0
  30. data/lib/talon_one/models/achievement_status_entry.rb +472 -0
  31. data/lib/talon_one/models/analytics_sku.rb +246 -0
  32. data/lib/talon_one/models/application_cif_references.rb +219 -0
  33. data/lib/talon_one/models/campaign_detail.rb +232 -0
  34. data/lib/talon_one/models/campaign_store_budget_limit_config.rb +322 -0
  35. data/lib/talon_one/models/campaign_template.rb +16 -4
  36. data/lib/talon_one/models/delete_user_request.rb +0 -1
  37. data/lib/talon_one/models/hidden_conditions_effects.rb +246 -0
  38. data/lib/talon_one/models/inline_response20048.rb +222 -0
  39. data/lib/talon_one/models/inline_response20049.rb +227 -0
  40. data/lib/talon_one/models/ledger_transaction_log_entry_integration_api.rb +13 -4
  41. data/lib/talon_one/models/loyalty_ledger_entry_flags.rb +208 -0
  42. data/lib/talon_one/models/loyalty_program_transaction.rb +13 -4
  43. data/lib/talon_one/models/message_test.rb +227 -0
  44. data/lib/talon_one/models/new_message_test.rb +322 -0
  45. data/lib/talon_one/models/product_unit_analytics_data_point.rb +271 -0
  46. data/lib/talon_one/models/product_unit_analytics_totals.rb +206 -0
  47. data/lib/talon_one/models/sku_unit_analytics.rb +227 -0
  48. data/lib/talon_one/models/sku_unit_analytics_data_point.rb +256 -0
  49. data/lib/talon_one/models/strikethrough_labeling_notification.rb +11 -1
  50. data/lib/talon_one/version.rb +1 -1
  51. data/lib/talon_one.rb +2 -1
  52. data/spec/api/integration_api_spec.rb +1 -0
  53. data/spec/api/management_api_spec.rb +60 -87
  54. data/spec/models/campaign_template_spec.rb +6 -0
  55. data/spec/models/ledger_transaction_log_entry_integration_api_spec.rb +6 -0
  56. data/spec/models/loyalty_program_transaction_spec.rb +6 -0
  57. data/spec/models/revision_activation_request_spec.rb +47 -0
  58. data/spec/models/strikethrough_labeling_notification_spec.rb +6 -0
  59. metadata +563 -527
@@ -0,0 +1,322 @@
1
+ =begin
2
+ #Talon.One API
3
+
4
+ #Use the Talon.One API to integrate with your application and to manage applications and campaigns: - Use the operations in the [Integration API section](#integration-api) are used to integrate with our platform - Use the operation in the [Management API section](#management-api) to manage applications and campaigns. ## Determining the base URL of the endpoints The API is available at the same hostname as your Campaign Manager deployment. For example, if you access the Campaign Manager at `https://yourbaseurl.talon.one/`, the URL for the [updateCustomerSessionV2](https://docs.talon.one/integration-api#operation/updateCustomerSessionV2) endpoint is `https://yourbaseurl.talon.one/v2/customer_sessions/{Id}`
5
+
6
+ The version of the OpenAPI document:
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module TalonOne
16
+ class CampaignStoreBudgetLimitConfig
17
+ # The limitable action to which this limit applies. For example: - `setDiscount` - `setDiscountEffect` - `redeemCoupon` - `createCoupon`
18
+ attr_accessor :action
19
+
20
+ # The value to set for the limit.
21
+ attr_accessor :limit
22
+
23
+ # The period on which the budget limit recurs.
24
+ attr_accessor :period
25
+
26
+ # The entity that this limit applies to.
27
+ attr_accessor :entities
28
+
29
+ # Indicates whether this limit configuration is managed via a CSV file.
30
+ attr_accessor :imported
31
+
32
+ class EnumAttributeValidator
33
+ attr_reader :datatype
34
+ attr_reader :allowable_values
35
+
36
+ def initialize(datatype, allowable_values)
37
+ @allowable_values = allowable_values.map do |value|
38
+ case datatype.to_s
39
+ when /Integer/i
40
+ value.to_i
41
+ when /Float/i
42
+ value.to_f
43
+ else
44
+ value
45
+ end
46
+ end
47
+ end
48
+
49
+ def valid?(value)
50
+ !value || allowable_values.include?(value)
51
+ end
52
+ end
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'action' => :'action',
58
+ :'limit' => :'limit',
59
+ :'period' => :'period',
60
+ :'entities' => :'entities',
61
+ :'imported' => :'imported'
62
+ }
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'action' => :'String',
69
+ :'limit' => :'Float',
70
+ :'period' => :'String',
71
+ :'entities' => :'Array<String>',
72
+ :'imported' => :'Boolean'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::CampaignStoreBudgetLimitConfig` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::CampaignStoreBudgetLimitConfig`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'action')
98
+ self.action = attributes[:'action']
99
+ end
100
+
101
+ if attributes.key?(:'limit')
102
+ self.limit = attributes[:'limit']
103
+ end
104
+
105
+ if attributes.key?(:'period')
106
+ self.period = attributes[:'period']
107
+ end
108
+
109
+ if attributes.key?(:'entities')
110
+ if (value = attributes[:'entities']).is_a?(Array)
111
+ self.entities = value
112
+ end
113
+ end
114
+
115
+ if attributes.key?(:'imported')
116
+ self.imported = attributes[:'imported']
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ if @action.nil?
125
+ invalid_properties.push('invalid value for "action", action cannot be nil.')
126
+ end
127
+
128
+ if @limit.nil?
129
+ invalid_properties.push('invalid value for "limit", limit cannot be nil.')
130
+ end
131
+
132
+ if @limit < 0
133
+ invalid_properties.push('invalid value for "limit", must be greater than or equal to 0.')
134
+ end
135
+
136
+ if @entities.nil?
137
+ invalid_properties.push('invalid value for "entities", entities cannot be nil.')
138
+ end
139
+
140
+ if @imported.nil?
141
+ invalid_properties.push('invalid value for "imported", imported cannot be nil.')
142
+ end
143
+
144
+ invalid_properties
145
+ end
146
+
147
+ # Check to see if the all the properties in the model are valid
148
+ # @return true if the model is valid
149
+ def valid?
150
+ return false if @action.nil?
151
+ return false if @limit.nil?
152
+ return false if @limit < 0
153
+ period_validator = EnumAttributeValidator.new('String', ["daily", "weekly", "monthly", "yearly"])
154
+ return false unless period_validator.valid?(@period)
155
+ return false if @entities.nil?
156
+ return false if @imported.nil?
157
+ true
158
+ end
159
+
160
+ # Custom attribute writer method with validation
161
+ # @param [Object] limit Value to be assigned
162
+ def limit=(limit)
163
+ if limit.nil?
164
+ fail ArgumentError, 'limit cannot be nil'
165
+ end
166
+
167
+ if limit < 0
168
+ fail ArgumentError, 'invalid value for "limit", must be greater than or equal to 0.'
169
+ end
170
+
171
+ @limit = limit
172
+ end
173
+
174
+ # Custom attribute writer method checking allowed values (enum).
175
+ # @param [Object] period Object to be assigned
176
+ def period=(period)
177
+ validator = EnumAttributeValidator.new('String', ["daily", "weekly", "monthly", "yearly"])
178
+ unless validator.valid?(period)
179
+ fail ArgumentError, "invalid value for \"period\", must be one of #{validator.allowable_values}."
180
+ end
181
+ @period = period
182
+ end
183
+
184
+ # Checks equality by comparing each attribute.
185
+ # @param [Object] Object to be compared
186
+ def ==(o)
187
+ return true if self.equal?(o)
188
+ self.class == o.class &&
189
+ action == o.action &&
190
+ limit == o.limit &&
191
+ period == o.period &&
192
+ entities == o.entities &&
193
+ imported == o.imported
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Integer] Hash code
204
+ def hash
205
+ [action, limit, period, entities, imported].hash
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def self.build_from_hash(attributes)
212
+ new.build_from_hash(attributes)
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ self.class.openapi_types.each_pair do |key, type|
221
+ if type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
225
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
226
+ end
227
+ elsif !attributes[self.class.attribute_map[key]].nil?
228
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
229
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
230
+ end
231
+
232
+ self
233
+ end
234
+
235
+ # Deserializes the data based on type
236
+ # @param string type Data type
237
+ # @param string value Value to be deserialized
238
+ # @return [Object] Deserialized data
239
+ def _deserialize(type, value)
240
+ case type.to_sym
241
+ when :DateTime
242
+ DateTime.parse(value)
243
+ when :Date
244
+ Date.parse(value)
245
+ when :String
246
+ value.to_s
247
+ when :Integer
248
+ value.to_i
249
+ when :Float
250
+ value.to_f
251
+ when :Boolean
252
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
253
+ true
254
+ else
255
+ false
256
+ end
257
+ when :Object
258
+ # generic object (usually a Hash), return directly
259
+ value
260
+ when /\AArray<(?<inner_type>.+)>\z/
261
+ inner_type = Regexp.last_match[:inner_type]
262
+ value.map { |v| _deserialize(inner_type, v) }
263
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
264
+ k_type = Regexp.last_match[:k_type]
265
+ v_type = Regexp.last_match[:v_type]
266
+ {}.tap do |hash|
267
+ value.each do |k, v|
268
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
269
+ end
270
+ end
271
+ else # model
272
+ TalonOne.const_get(type).build_from_hash(value)
273
+ end
274
+ end
275
+
276
+ # Returns the string representation of the object
277
+ # @return [String] String presentation of the object
278
+ def to_s
279
+ to_hash.to_s
280
+ end
281
+
282
+ # to_body is an alias to to_hash (backward compatibility)
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_body
285
+ to_hash
286
+ end
287
+
288
+ # Returns the object in the form of hash
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_hash
291
+ hash = {}
292
+ self.class.attribute_map.each_pair do |attr, param|
293
+ value = self.send(attr)
294
+ if value.nil?
295
+ is_nullable = self.class.openapi_nullable.include?(attr)
296
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
297
+ end
298
+
299
+ hash[param] = _to_hash(value)
300
+ end
301
+ hash
302
+ end
303
+
304
+ # Outputs non-array value in the form of hash
305
+ # For object, use to_hash. Otherwise, just return the value
306
+ # @param [Object] value Any valid value
307
+ # @return [Hash] Returns the value in the form of hash
308
+ def _to_hash(value)
309
+ if value.is_a?(Array)
310
+ value.compact.map { |v| _to_hash(v) }
311
+ elsif value.is_a?(Hash)
312
+ {}.tap do |hash|
313
+ value.each { |k, v| hash[k] = _to_hash(v) }
314
+ end
315
+ elsif value.respond_to? :to_hash
316
+ value.to_hash
317
+ else
318
+ value
319
+ end
320
+ end
321
+ end
322
+ end
@@ -86,6 +86,9 @@ module TalonOne
86
86
  # The IDs of the Applications that are related to this entity.
87
87
  attr_accessor :valid_application_ids
88
88
 
89
+ # A flag indicating whether the user marked the template as a favorite.
90
+ attr_accessor :is_user_favorite
91
+
89
92
  class EnumAttributeValidator
90
93
  attr_reader :datatype
91
94
  attr_reader :allowable_values
@@ -135,7 +138,8 @@ module TalonOne
135
138
  :'campaign_type' => :'campaignType',
136
139
  :'updated' => :'updated',
137
140
  :'updated_by' => :'updatedBy',
138
- :'valid_application_ids' => :'validApplicationIds'
141
+ :'valid_application_ids' => :'validApplicationIds',
142
+ :'is_user_favorite' => :'isUserFavorite'
139
143
  }
140
144
  end
141
145
 
@@ -166,7 +170,8 @@ module TalonOne
166
170
  :'campaign_type' => :'String',
167
171
  :'updated' => :'DateTime',
168
172
  :'updated_by' => :'String',
169
- :'valid_application_ids' => :'Array<Integer>'
173
+ :'valid_application_ids' => :'Array<Integer>',
174
+ :'is_user_favorite' => :'Boolean'
170
175
  }
171
176
  end
172
177
 
@@ -306,6 +311,12 @@ module TalonOne
306
311
  self.valid_application_ids = value
307
312
  end
308
313
  end
314
+
315
+ if attributes.key?(:'is_user_favorite')
316
+ self.is_user_favorite = attributes[:'is_user_favorite']
317
+ else
318
+ self.is_user_favorite = false
319
+ end
309
320
  end
310
321
 
311
322
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -448,7 +459,8 @@ module TalonOne
448
459
  campaign_type == o.campaign_type &&
449
460
  updated == o.updated &&
450
461
  updated_by == o.updated_by &&
451
- valid_application_ids == o.valid_application_ids
462
+ valid_application_ids == o.valid_application_ids &&
463
+ is_user_favorite == o.is_user_favorite
452
464
  end
453
465
 
454
466
  # @see the `==` method
@@ -460,7 +472,7 @@ module TalonOne
460
472
  # Calculates hash code according to all attributes.
461
473
  # @return [Integer] Hash code
462
474
  def hash
463
- [id, created, account_id, user_id, name, description, instructions, campaign_attributes, coupon_attributes, state, active_ruleset_id, tags, features, coupon_settings, coupon_reservation_settings, referral_settings, limits, template_params, applications_ids, campaign_collections, default_campaign_group_id, campaign_type, updated, updated_by, valid_application_ids].hash
475
+ [id, created, account_id, user_id, name, description, instructions, campaign_attributes, coupon_attributes, state, active_ruleset_id, tags, features, coupon_settings, coupon_reservation_settings, referral_settings, limits, template_params, applications_ids, campaign_collections, default_campaign_group_id, campaign_type, updated, updated_by, valid_application_ids, is_user_favorite].hash
464
476
  end
465
477
 
466
478
  # Builds the object from hash
@@ -13,7 +13,6 @@ OpenAPI Generator version: 4.3.1
13
13
  require 'date'
14
14
 
15
15
  module TalonOne
16
- #
17
16
  class DeleteUserRequest
18
17
  # The email address associated with the user profile.
19
18
  attr_accessor :email
@@ -0,0 +1,246 @@
1
+ =begin
2
+ #Talon.One API
3
+
4
+ #Use the Talon.One API to integrate with your application and to manage applications and campaigns: - Use the operations in the [Integration API section](#integration-api) are used to integrate with our platform - Use the operation in the [Management API section](#management-api) to manage applications and campaigns. ## Determining the base URL of the endpoints The API is available at the same hostname as your Campaign Manager deployment. For example, if you access the Campaign Manager at `https://yourbaseurl.talon.one/`, the URL for the [updateCustomerSessionV2](https://docs.talon.one/integration-api#operation/updateCustomerSessionV2) endpoint is `https://yourbaseurl.talon.one/v2/customer_sessions/{Id}`
5
+
6
+ The version of the OpenAPI document:
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module TalonOne
16
+ # Contains information about hidden conditions and effects in the Application.
17
+ class HiddenConditionsEffects
18
+ # List of hidden built-in effects.
19
+ attr_accessor :built_in_effects
20
+
21
+ # List of hidden conditions.
22
+ attr_accessor :conditions
23
+
24
+ # List of the IDs of hidden custom effects.
25
+ attr_accessor :custom_effects
26
+
27
+ # List of the IDs of hidden webhooks.
28
+ attr_accessor :webhooks
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'built_in_effects' => :'builtInEffects',
34
+ :'conditions' => :'conditions',
35
+ :'custom_effects' => :'customEffects',
36
+ :'webhooks' => :'webhooks'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'built_in_effects' => :'Array<String>',
44
+ :'conditions' => :'Array<String>',
45
+ :'custom_effects' => :'Array<Integer>',
46
+ :'webhooks' => :'Array<Integer>'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::HiddenConditionsEffects` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::HiddenConditionsEffects`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'built_in_effects')
72
+ if (value = attributes[:'built_in_effects']).is_a?(Array)
73
+ self.built_in_effects = value
74
+ end
75
+ end
76
+
77
+ if attributes.key?(:'conditions')
78
+ if (value = attributes[:'conditions']).is_a?(Array)
79
+ self.conditions = value
80
+ end
81
+ end
82
+
83
+ if attributes.key?(:'custom_effects')
84
+ if (value = attributes[:'custom_effects']).is_a?(Array)
85
+ self.custom_effects = value
86
+ end
87
+ end
88
+
89
+ if attributes.key?(:'webhooks')
90
+ if (value = attributes[:'webhooks']).is_a?(Array)
91
+ self.webhooks = value
92
+ end
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ true
107
+ end
108
+
109
+ # Checks equality by comparing each attribute.
110
+ # @param [Object] Object to be compared
111
+ def ==(o)
112
+ return true if self.equal?(o)
113
+ self.class == o.class &&
114
+ built_in_effects == o.built_in_effects &&
115
+ conditions == o.conditions &&
116
+ custom_effects == o.custom_effects &&
117
+ webhooks == o.webhooks
118
+ end
119
+
120
+ # @see the `==` method
121
+ # @param [Object] Object to be compared
122
+ def eql?(o)
123
+ self == o
124
+ end
125
+
126
+ # Calculates hash code according to all attributes.
127
+ # @return [Integer] Hash code
128
+ def hash
129
+ [built_in_effects, conditions, custom_effects, webhooks].hash
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def self.build_from_hash(attributes)
136
+ new.build_from_hash(attributes)
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def build_from_hash(attributes)
143
+ return nil unless attributes.is_a?(Hash)
144
+ self.class.openapi_types.each_pair do |key, type|
145
+ if type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
149
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
150
+ end
151
+ elsif !attributes[self.class.attribute_map[key]].nil?
152
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
153
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
154
+ end
155
+
156
+ self
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def _deserialize(type, value)
164
+ case type.to_sym
165
+ when :DateTime
166
+ DateTime.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+ when :Object
182
+ # generic object (usually a Hash), return directly
183
+ value
184
+ when /\AArray<(?<inner_type>.+)>\z/
185
+ inner_type = Regexp.last_match[:inner_type]
186
+ value.map { |v| _deserialize(inner_type, v) }
187
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
+ k_type = Regexp.last_match[:k_type]
189
+ v_type = Regexp.last_match[:v_type]
190
+ {}.tap do |hash|
191
+ value.each do |k, v|
192
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
+ end
194
+ end
195
+ else # model
196
+ TalonOne.const_get(type).build_from_hash(value)
197
+ end
198
+ end
199
+
200
+ # Returns the string representation of the object
201
+ # @return [String] String presentation of the object
202
+ def to_s
203
+ to_hash.to_s
204
+ end
205
+
206
+ # to_body is an alias to to_hash (backward compatibility)
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_body
209
+ to_hash
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = self.send(attr)
218
+ if value.nil?
219
+ is_nullable = self.class.openapi_nullable.include?(attr)
220
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
221
+ end
222
+
223
+ hash[param] = _to_hash(value)
224
+ end
225
+ hash
226
+ end
227
+
228
+ # Outputs non-array value in the form of hash
229
+ # For object, use to_hash. Otherwise, just return the value
230
+ # @param [Object] value Any valid value
231
+ # @return [Hash] Returns the value in the form of hash
232
+ def _to_hash(value)
233
+ if value.is_a?(Array)
234
+ value.compact.map { |v| _to_hash(v) }
235
+ elsif value.is_a?(Hash)
236
+ {}.tap do |hash|
237
+ value.each { |k, v| hash[k] = _to_hash(v) }
238
+ end
239
+ elsif value.respond_to? :to_hash
240
+ value.to_hash
241
+ else
242
+ value
243
+ end
244
+ end
245
+ end
246
+ end