talon_one 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -12
  3. data/docs/AddLoyaltyPointsEffectProps.md +3 -1
  4. data/docs/Application.md +2 -0
  5. data/docs/ApplicationEvent.md +3 -1
  6. data/docs/Binding.md +2 -0
  7. data/docs/Campaign.md +11 -1
  8. data/docs/CartItem.md +1 -3
  9. data/docs/Change.md +2 -0
  10. data/docs/CustomerProfileIntegrationRequestV2.md +3 -1
  11. data/docs/DeductLoyaltyPointsEffectProps.md +3 -1
  12. data/docs/Effect.md +2 -0
  13. data/docs/EffectEntity.md +3 -1
  14. data/docs/Import.md +1 -1
  15. data/docs/InlineResponse20020.md +2 -2
  16. data/docs/InlineResponse20021.md +1 -1
  17. data/docs/InlineResponse20022.md +1 -1
  18. data/docs/InlineResponse20023.md +1 -1
  19. data/docs/InlineResponse20024.md +1 -1
  20. data/docs/InlineResponse20025.md +1 -1
  21. data/docs/InlineResponse20026.md +1 -1
  22. data/docs/InlineResponse20027.md +2 -4
  23. data/docs/InlineResponse20028.md +4 -2
  24. data/docs/InlineResponse20029.md +1 -1
  25. data/docs/IntegrationApi.md +27 -27
  26. data/docs/IntegrationRequest.md +1 -1
  27. data/docs/IntegrationStateV2.md +2 -0
  28. data/docs/LoyaltyProgramBalance.md +10 -2
  29. data/docs/LoyaltyProgramLedgers.md +3 -1
  30. data/docs/LoyaltySubLedger.md +1 -1
  31. data/docs/ManagementApi.md +623 -169
  32. data/docs/NewApplication.md +2 -0
  33. data/docs/NewCoupons.md +5 -5
  34. data/docs/NewCouponsForMultipleRecipients.md +31 -0
  35. data/docs/ProfileAudiencesChanges.md +19 -0
  36. data/docs/RejectCouponEffectProps.md +7 -1
  37. data/docs/RejectReferralEffectProps.md +7 -1
  38. data/docs/RollbackAddedLoyaltyPointsEffectProps.md +25 -0
  39. data/docs/RollbackDeductedLoyaltyPointsEffectProps.md +29 -0
  40. data/docs/RollbackReferralEffectProps.md +17 -0
  41. data/docs/RuleFailureReason.md +39 -0
  42. data/docs/UpdateApplication.md +2 -0
  43. data/lib/talon_one.rb +6 -3
  44. data/lib/talon_one/api/integration_api.rb +30 -30
  45. data/lib/talon_one/api/management_api.rb +816 -242
  46. data/lib/talon_one/models/add_loyalty_points_effect_props.rb +19 -4
  47. data/lib/talon_one/models/application.rb +23 -1
  48. data/lib/talon_one/models/application_api_key.rb +2 -2
  49. data/lib/talon_one/models/application_event.rb +16 -4
  50. data/lib/talon_one/models/binding.rb +11 -1
  51. data/lib/talon_one/models/campaign.rb +52 -2
  52. data/lib/talon_one/models/cart_item.rb +4 -13
  53. data/lib/talon_one/models/change.rb +11 -1
  54. data/lib/talon_one/models/code_generator_settings.rb +9 -0
  55. data/lib/talon_one/models/create_application_api_key.rb +2 -2
  56. data/lib/talon_one/models/customer_profile_integration_request_v2.rb +11 -2
  57. data/lib/talon_one/models/customer_session.rb +38 -0
  58. data/lib/talon_one/models/customer_session_v2.rb +15 -0
  59. data/lib/talon_one/models/deduct_loyalty_points_effect_props.rb +19 -4
  60. data/lib/talon_one/models/effect.rb +11 -1
  61. data/lib/talon_one/models/effect_entity.rb +14 -4
  62. data/lib/talon_one/models/import.rb +1 -35
  63. data/lib/talon_one/models/inline_response20020.rb +1 -6
  64. data/lib/talon_one/models/inline_response20021.rb +1 -1
  65. data/lib/talon_one/models/inline_response20022.rb +1 -1
  66. data/lib/talon_one/models/inline_response20023.rb +1 -1
  67. data/lib/talon_one/models/inline_response20024.rb +1 -1
  68. data/lib/talon_one/models/inline_response20025.rb +1 -1
  69. data/lib/talon_one/models/inline_response20026.rb +1 -1
  70. data/lib/talon_one/models/inline_response20027.rb +7 -11
  71. data/lib/talon_one/models/inline_response20028.rb +11 -7
  72. data/lib/talon_one/models/inline_response20029.rb +1 -1
  73. data/lib/talon_one/models/integration_request.rb +1 -1
  74. data/lib/talon_one/models/integration_state_v2.rb +12 -1
  75. data/lib/talon_one/models/limit_config.rb +0 -12
  76. data/lib/talon_one/models/loyalty_points.rb +28 -0
  77. data/lib/talon_one/models/loyalty_program_balance.rb +65 -4
  78. data/lib/talon_one/models/loyalty_program_ledgers.rb +16 -1
  79. data/lib/talon_one/models/loyalty_sub_ledger.rb +1 -1
  80. data/lib/talon_one/models/new_application.rb +23 -1
  81. data/lib/talon_one/models/new_application_api_key.rb +2 -2
  82. data/lib/talon_one/models/new_coupons.rb +36 -41
  83. data/lib/talon_one/models/new_coupons_for_multiple_recipients.rb +368 -0
  84. data/lib/talon_one/models/new_customer_session.rb +30 -0
  85. data/lib/talon_one/models/new_customer_session_v2.rb +15 -0
  86. data/lib/talon_one/models/{new_import.rb → profile_audiences_changes.rb} +32 -48
  87. data/lib/talon_one/models/reject_coupon_effect_props.rb +34 -4
  88. data/lib/talon_one/models/reject_referral_effect_props.rb +34 -4
  89. data/lib/talon_one/models/{cart_item_adjustment.rb → rollback_added_loyalty_points_effect_props.rb} +63 -61
  90. data/lib/talon_one/models/rollback_deducted_loyalty_points_effect_props.rb +293 -0
  91. data/lib/talon_one/models/{import_coupons.rb → rollback_referral_effect_props.rb} +15 -13
  92. data/lib/talon_one/models/rule_failure_reason.rb +343 -0
  93. data/lib/talon_one/models/update_application.rb +23 -1
  94. data/lib/talon_one/version.rb +1 -1
  95. data/spec/api/integration_api_spec.rb +15 -15
  96. data/spec/api/management_api_spec.rb +183 -68
  97. data/spec/models/add_loyalty_points_effect_props_spec.rb +6 -0
  98. data/spec/models/application_api_key_spec.rb +1 -1
  99. data/spec/models/application_event_spec.rb +6 -0
  100. data/spec/models/application_spec.rb +10 -0
  101. data/spec/models/binding_spec.rb +6 -0
  102. data/spec/models/campaign_spec.rb +30 -0
  103. data/spec/models/cart_item_spec.rb +0 -6
  104. data/spec/models/change_spec.rb +6 -0
  105. data/spec/models/create_application_api_key_spec.rb +1 -1
  106. data/spec/models/customer_profile_integration_request_v2_spec.rb +7 -1
  107. data/spec/models/deduct_loyalty_points_effect_props_spec.rb +6 -0
  108. data/spec/models/effect_entity_spec.rb +6 -0
  109. data/spec/models/effect_spec.rb +6 -0
  110. data/spec/models/import_spec.rb +0 -4
  111. data/spec/models/inline_response20027_spec.rb +0 -6
  112. data/spec/models/inline_response20028_spec.rb +6 -0
  113. data/spec/models/integration_request_spec.rb +1 -1
  114. data/spec/models/integration_state_v2_spec.rb +6 -0
  115. data/spec/models/limit_config_spec.rb +0 -4
  116. data/spec/models/loyalty_program_balance_spec.rb +24 -0
  117. data/spec/models/loyalty_program_ledgers_spec.rb +6 -0
  118. data/spec/models/new_application_api_key_spec.rb +1 -1
  119. data/spec/models/new_application_spec.rb +10 -0
  120. data/spec/models/new_coupons_for_multiple_recipients_spec.rb +83 -0
  121. data/spec/models/new_coupons_spec.rb +6 -6
  122. data/spec/models/{cart_item_adjustment_spec.rb → profile_audiences_changes_spec.rb} +8 -14
  123. data/spec/models/reject_coupon_effect_props_spec.rb +18 -0
  124. data/spec/models/reject_referral_effect_props_spec.rb +18 -0
  125. data/spec/models/rollback_added_loyalty_points_effect_props_spec.rb +65 -0
  126. data/spec/models/rollback_deducted_loyalty_points_effect_props_spec.rb +77 -0
  127. data/spec/models/{import_coupons_spec.rb → rollback_referral_effect_props_spec.rb} +7 -7
  128. data/spec/models/rule_failure_reason_spec.rb +107 -0
  129. data/spec/models/update_application_spec.rb +10 -0
  130. metadata +26 -14
  131. data/docs/CartItemAdjustment.md +0 -21
  132. data/docs/ImportCoupons.md +0 -17
  133. data/docs/NewImport.md +0 -17
  134. data/spec/models/new_import_spec.rb +0 -45
@@ -15,6 +15,9 @@ require 'date'
15
15
  module TalonOne
16
16
  # Customer specific information about loyalty points.
17
17
  class LoyaltyProgramLedgers
18
+ # The internal ID of loyalty program
19
+ attr_accessor :id
20
+
18
21
  # Visible name of loyalty program
19
22
  attr_accessor :title
20
23
 
@@ -29,6 +32,7 @@ module TalonOne
29
32
  # Attribute mapping from ruby-style variable name to JSON key.
30
33
  def self.attribute_map
31
34
  {
35
+ :'id' => :'id',
32
36
  :'title' => :'title',
33
37
  :'name' => :'name',
34
38
  :'ledger' => :'ledger',
@@ -39,6 +43,7 @@ module TalonOne
39
43
  # Attribute type mapping.
40
44
  def self.openapi_types
41
45
  {
46
+ :'id' => :'Integer',
42
47
  :'title' => :'String',
43
48
  :'name' => :'String',
44
49
  :'ledger' => :'LoyaltyProgramBalance',
@@ -67,6 +72,10 @@ module TalonOne
67
72
  h[k.to_sym] = v
68
73
  }
69
74
 
75
+ if attributes.key?(:'id')
76
+ self.id = attributes[:'id']
77
+ end
78
+
70
79
  if attributes.key?(:'title')
71
80
  self.title = attributes[:'title']
72
81
  end
@@ -90,6 +99,10 @@ module TalonOne
90
99
  # @return Array for valid properties with the reasons
91
100
  def list_invalid_properties
92
101
  invalid_properties = Array.new
102
+ if @id.nil?
103
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
104
+ end
105
+
93
106
  if @title.nil?
94
107
  invalid_properties.push('invalid value for "title", title cannot be nil.')
95
108
  end
@@ -108,6 +121,7 @@ module TalonOne
108
121
  # Check to see if the all the properties in the model are valid
109
122
  # @return true if the model is valid
110
123
  def valid?
124
+ return false if @id.nil?
111
125
  return false if @title.nil?
112
126
  return false if @name.nil?
113
127
  return false if @ledger.nil?
@@ -119,6 +133,7 @@ module TalonOne
119
133
  def ==(o)
120
134
  return true if self.equal?(o)
121
135
  self.class == o.class &&
136
+ id == o.id &&
122
137
  title == o.title &&
123
138
  name == o.name &&
124
139
  ledger == o.ledger &&
@@ -134,7 +149,7 @@ module TalonOne
134
149
  # Calculates hash code according to all attributes.
135
150
  # @return [Integer] Hash code
136
151
  def hash
137
- [title, name, ledger, sub_ledgers].hash
152
+ [id, title, name, ledger, sub_ledgers].hash
138
153
  end
139
154
 
140
155
  # Builds the object from hash
@@ -15,7 +15,7 @@ require 'date'
15
15
  module TalonOne
16
16
  # Ledger of Balance in Loyalty Program for a Customer
17
17
  class LoyaltySubLedger
18
- # ⚠️ Deprecated: Please use 'totalActivePoints' property instead. Total amount of currently active and available points in the customer's balance
18
+ # ⚠️ Deprecated: Use 'totalActivePoints' property instead. Total amount of currently active and available points in the customer's balance
19
19
  attr_accessor :total
20
20
 
21
21
  # Total amount of currently active and available points in the customer's balance
@@ -42,6 +42,9 @@ module TalonOne
42
42
  # The strategy used when choosing exclusive campaigns for evaluation, can be one of (listOrder, lowestDiscount, highestDiscount). If no value is provided, this is set to \"listOrder\"
43
43
  attr_accessor :exclusive_campaigns_strategy
44
44
 
45
+ # The default scope to apply \"setDiscount\" effects on if no scope was provided with the effect.
46
+ attr_accessor :default_discount_scope
47
+
45
48
  # Flag indicating if discounts should cascade for this application
46
49
  attr_accessor :enable_cascading_discounts
47
50
 
@@ -90,6 +93,7 @@ module TalonOne
90
93
  :'limits' => :'limits',
91
94
  :'campaign_priority' => :'campaignPriority',
92
95
  :'exclusive_campaigns_strategy' => :'exclusiveCampaignsStrategy',
96
+ :'default_discount_scope' => :'defaultDiscountScope',
93
97
  :'enable_cascading_discounts' => :'enableCascadingDiscounts',
94
98
  :'enable_flattened_cart_items' => :'enableFlattenedCartItems',
95
99
  :'attributes_settings' => :'attributesSettings',
@@ -110,6 +114,7 @@ module TalonOne
110
114
  :'limits' => :'Array<LimitConfig>',
111
115
  :'campaign_priority' => :'String',
112
116
  :'exclusive_campaigns_strategy' => :'String',
117
+ :'default_discount_scope' => :'String',
113
118
  :'enable_cascading_discounts' => :'Boolean',
114
119
  :'enable_flattened_cart_items' => :'Boolean',
115
120
  :'attributes_settings' => :'AttributesSettings',
@@ -177,6 +182,10 @@ module TalonOne
177
182
  self.exclusive_campaigns_strategy = attributes[:'exclusive_campaigns_strategy']
178
183
  end
179
184
 
185
+ if attributes.key?(:'default_discount_scope')
186
+ self.default_discount_scope = attributes[:'default_discount_scope']
187
+ end
188
+
180
189
  if attributes.key?(:'enable_cascading_discounts')
181
190
  self.enable_cascading_discounts = attributes[:'enable_cascading_discounts']
182
191
  end
@@ -249,6 +258,8 @@ module TalonOne
249
258
  return false unless campaign_priority_validator.valid?(@campaign_priority)
250
259
  exclusive_campaigns_strategy_validator = EnumAttributeValidator.new('String', ["listOrder", "lowestDiscount", "highestDiscount"])
251
260
  return false unless exclusive_campaigns_strategy_validator.valid?(@exclusive_campaigns_strategy)
261
+ default_discount_scope_validator = EnumAttributeValidator.new('String', ["sessionTotal", "cartItems", "additionalCosts"])
262
+ return false unless default_discount_scope_validator.valid?(@default_discount_scope)
252
263
  return false if !@key.nil? && @key !~ Regexp.new(/^[a-fA-F0-9]{16}$/)
253
264
  true
254
265
  end
@@ -325,6 +336,16 @@ module TalonOne
325
336
  @exclusive_campaigns_strategy = exclusive_campaigns_strategy
326
337
  end
327
338
 
339
+ # Custom attribute writer method checking allowed values (enum).
340
+ # @param [Object] default_discount_scope Object to be assigned
341
+ def default_discount_scope=(default_discount_scope)
342
+ validator = EnumAttributeValidator.new('String', ["sessionTotal", "cartItems", "additionalCosts"])
343
+ unless validator.valid?(default_discount_scope)
344
+ fail ArgumentError, "invalid value for \"default_discount_scope\", must be one of #{validator.allowable_values}."
345
+ end
346
+ @default_discount_scope = default_discount_scope
347
+ end
348
+
328
349
  # Custom attribute writer method with validation
329
350
  # @param [Object] key Value to be assigned
330
351
  def key=(key)
@@ -350,6 +371,7 @@ module TalonOne
350
371
  limits == o.limits &&
351
372
  campaign_priority == o.campaign_priority &&
352
373
  exclusive_campaigns_strategy == o.exclusive_campaigns_strategy &&
374
+ default_discount_scope == o.default_discount_scope &&
353
375
  enable_cascading_discounts == o.enable_cascading_discounts &&
354
376
  enable_flattened_cart_items == o.enable_flattened_cart_items &&
355
377
  attributes_settings == o.attributes_settings &&
@@ -366,7 +388,7 @@ module TalonOne
366
388
  # Calculates hash code according to all attributes.
367
389
  # @return [Integer] Hash code
368
390
  def hash
369
- [name, description, timezone, currency, case_sensitivity, attributes, limits, campaign_priority, exclusive_campaigns_strategy, enable_cascading_discounts, enable_flattened_cart_items, attributes_settings, sandbox, key].hash
391
+ [name, description, timezone, currency, case_sensitivity, attributes, limits, campaign_priority, exclusive_campaigns_strategy, default_discount_scope, enable_cascading_discounts, enable_flattened_cart_items, attributes_settings, sandbox, key].hash
370
392
  end
371
393
 
372
394
  # Builds the object from hash
@@ -196,7 +196,7 @@ module TalonOne
196
196
  def valid?
197
197
  return false if @title.nil?
198
198
  return false if @expires.nil?
199
- platform_validator = EnumAttributeValidator.new('String', ["none", "segment", "braze", "mparticle"])
199
+ platform_validator = EnumAttributeValidator.new('String', ["none", "segment", "braze", "mparticle", "selligent"])
200
200
  return false unless platform_validator.valid?(@platform)
201
201
  return false if @id.nil?
202
202
  return false if @created_by.nil?
@@ -210,7 +210,7 @@ module TalonOne
210
210
  # Custom attribute writer method checking allowed values (enum).
211
211
  # @param [Object] platform Object to be assigned
212
212
  def platform=(platform)
213
- validator = EnumAttributeValidator.new('String', ["none", "segment", "braze", "mparticle"])
213
+ validator = EnumAttributeValidator.new('String', ["none", "segment", "braze", "mparticle", "selligent"])
214
214
  unless validator.valid?(platform)
215
215
  fail ArgumentError, "invalid value for \"platform\", must be one of #{validator.allowable_values}."
216
216
  end
@@ -27,12 +27,6 @@ module TalonOne
27
27
  # Expiry date of the coupon. Coupon never expires if this is omitted, zero, or negative.
28
28
  attr_accessor :expiry_date
29
29
 
30
- # Set of characters to be used when generating random part of code. Defaults to [A-Z, 0-9] (in terms of RegExp).
31
- attr_accessor :valid_characters
32
-
33
- # The pattern that will be used to generate coupon codes. The character `#` acts as a placeholder and will be replaced by a random character from the `validCharacters` set.
34
- attr_accessor :coupon_pattern
35
-
36
30
  # The number of new coupon codes to generate for the campaign. Must be at least 1.
37
31
  attr_accessor :number_of_coupons
38
32
 
@@ -45,6 +39,12 @@ module TalonOne
45
39
  # The integration ID for this coupon's beneficiary's profile
46
40
  attr_accessor :recipient_integration_id
47
41
 
42
+ # Set of characters to be used when generating random part of code. Defaults to [A-Z, 0-9] (in terms of RegExp).
43
+ attr_accessor :valid_characters
44
+
45
+ # The pattern that will be used to generate coupon codes. The character `#` acts as a placeholder and will be replaced by a random character from the `validCharacters` set.
46
+ attr_accessor :coupon_pattern
47
+
48
48
  # Attribute mapping from ruby-style variable name to JSON key.
49
49
  def self.attribute_map
50
50
  {
@@ -52,12 +52,12 @@ module TalonOne
52
52
  :'discount_limit' => :'discountLimit',
53
53
  :'start_date' => :'startDate',
54
54
  :'expiry_date' => :'expiryDate',
55
- :'valid_characters' => :'validCharacters',
56
- :'coupon_pattern' => :'couponPattern',
57
55
  :'number_of_coupons' => :'numberOfCoupons',
58
56
  :'unique_prefix' => :'uniquePrefix',
59
57
  :'attributes' => :'attributes',
60
- :'recipient_integration_id' => :'recipientIntegrationId'
58
+ :'recipient_integration_id' => :'recipientIntegrationId',
59
+ :'valid_characters' => :'validCharacters',
60
+ :'coupon_pattern' => :'couponPattern'
61
61
  }
62
62
  end
63
63
 
@@ -68,12 +68,12 @@ module TalonOne
68
68
  :'discount_limit' => :'Float',
69
69
  :'start_date' => :'DateTime',
70
70
  :'expiry_date' => :'DateTime',
71
- :'valid_characters' => :'Array<String>',
72
- :'coupon_pattern' => :'String',
73
71
  :'number_of_coupons' => :'Integer',
74
72
  :'unique_prefix' => :'String',
75
73
  :'attributes' => :'Object',
76
- :'recipient_integration_id' => :'String'
74
+ :'recipient_integration_id' => :'String',
75
+ :'valid_characters' => :'Array<String>',
76
+ :'coupon_pattern' => :'String'
77
77
  }
78
78
  end
79
79
 
@@ -114,16 +114,6 @@ module TalonOne
114
114
  self.expiry_date = attributes[:'expiry_date']
115
115
  end
116
116
 
117
- if attributes.key?(:'valid_characters')
118
- if (value = attributes[:'valid_characters']).is_a?(Array)
119
- self.valid_characters = value
120
- end
121
- end
122
-
123
- if attributes.key?(:'coupon_pattern')
124
- self.coupon_pattern = attributes[:'coupon_pattern']
125
- end
126
-
127
117
  if attributes.key?(:'number_of_coupons')
128
118
  self.number_of_coupons = attributes[:'number_of_coupons']
129
119
  end
@@ -139,6 +129,16 @@ module TalonOne
139
129
  if attributes.key?(:'recipient_integration_id')
140
130
  self.recipient_integration_id = attributes[:'recipient_integration_id']
141
131
  end
132
+
133
+ if attributes.key?(:'valid_characters')
134
+ if (value = attributes[:'valid_characters']).is_a?(Array)
135
+ self.valid_characters = value
136
+ end
137
+ end
138
+
139
+ if attributes.key?(:'coupon_pattern')
140
+ self.coupon_pattern = attributes[:'coupon_pattern']
141
+ end
142
142
  end
143
143
 
144
144
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -165,22 +165,18 @@ module TalonOne
165
165
  invalid_properties.push('invalid value for "discount_limit", must be greater than or equal to 0.')
166
166
  end
167
167
 
168
- if @valid_characters.nil?
169
- invalid_properties.push('invalid value for "valid_characters", valid_characters cannot be nil.')
168
+ if @number_of_coupons.nil?
169
+ invalid_properties.push('invalid value for "number_of_coupons", number_of_coupons cannot be nil.')
170
170
  end
171
171
 
172
- if @coupon_pattern.nil?
173
- invalid_properties.push('invalid value for "coupon_pattern", coupon_pattern cannot be nil.')
172
+ if !@coupon_pattern.nil? && @coupon_pattern.to_s.length > 100
173
+ invalid_properties.push('invalid value for "coupon_pattern", the character length must be smaller than or equal to 100.')
174
174
  end
175
175
 
176
- if @coupon_pattern.to_s.length < 3
176
+ if !@coupon_pattern.nil? && @coupon_pattern.to_s.length < 3
177
177
  invalid_properties.push('invalid value for "coupon_pattern", the character length must be great than or equal to 3.')
178
178
  end
179
179
 
180
- if @number_of_coupons.nil?
181
- invalid_properties.push('invalid value for "number_of_coupons", number_of_coupons cannot be nil.')
182
- end
183
-
184
180
  invalid_properties
185
181
  end
186
182
 
@@ -192,10 +188,9 @@ module TalonOne
192
188
  return false if @usage_limit < 0
193
189
  return false if !@discount_limit.nil? && @discount_limit > 999999
194
190
  return false if !@discount_limit.nil? && @discount_limit < 0
195
- return false if @valid_characters.nil?
196
- return false if @coupon_pattern.nil?
197
- return false if @coupon_pattern.to_s.length < 3
198
191
  return false if @number_of_coupons.nil?
192
+ return false if !@coupon_pattern.nil? && @coupon_pattern.to_s.length > 100
193
+ return false if !@coupon_pattern.nil? && @coupon_pattern.to_s.length < 3
199
194
  true
200
195
  end
201
196
 
@@ -234,11 +229,11 @@ module TalonOne
234
229
  # Custom attribute writer method with validation
235
230
  # @param [Object] coupon_pattern Value to be assigned
236
231
  def coupon_pattern=(coupon_pattern)
237
- if coupon_pattern.nil?
238
- fail ArgumentError, 'coupon_pattern cannot be nil'
232
+ if !coupon_pattern.nil? && coupon_pattern.to_s.length > 100
233
+ fail ArgumentError, 'invalid value for "coupon_pattern", the character length must be smaller than or equal to 100.'
239
234
  end
240
235
 
241
- if coupon_pattern.to_s.length < 3
236
+ if !coupon_pattern.nil? && coupon_pattern.to_s.length < 3
242
237
  fail ArgumentError, 'invalid value for "coupon_pattern", the character length must be great than or equal to 3.'
243
238
  end
244
239
 
@@ -254,12 +249,12 @@ module TalonOne
254
249
  discount_limit == o.discount_limit &&
255
250
  start_date == o.start_date &&
256
251
  expiry_date == o.expiry_date &&
257
- valid_characters == o.valid_characters &&
258
- coupon_pattern == o.coupon_pattern &&
259
252
  number_of_coupons == o.number_of_coupons &&
260
253
  unique_prefix == o.unique_prefix &&
261
254
  attributes == o.attributes &&
262
- recipient_integration_id == o.recipient_integration_id
255
+ recipient_integration_id == o.recipient_integration_id &&
256
+ valid_characters == o.valid_characters &&
257
+ coupon_pattern == o.coupon_pattern
263
258
  end
264
259
 
265
260
  # @see the `==` method
@@ -271,7 +266,7 @@ module TalonOne
271
266
  # Calculates hash code according to all attributes.
272
267
  # @return [Integer] Hash code
273
268
  def hash
274
- [usage_limit, discount_limit, start_date, expiry_date, valid_characters, coupon_pattern, number_of_coupons, unique_prefix, attributes, recipient_integration_id].hash
269
+ [usage_limit, discount_limit, start_date, expiry_date, number_of_coupons, unique_prefix, attributes, recipient_integration_id, valid_characters, coupon_pattern].hash
275
270
  end
276
271
 
277
272
  # Builds the object from hash
@@ -0,0 +1,368 @@
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
+ The version of the OpenAPI document: 1.0.0
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
+ #
17
+ class NewCouponsForMultipleRecipients
18
+ # The number of times a coupon code can be redeemed. This can be set to 0 for no limit, but any campaign usage limits will still apply.
19
+ attr_accessor :usage_limit
20
+
21
+ # The amount of discounts that can be given with this coupon code.
22
+ attr_accessor :discount_limit
23
+
24
+ # Timestamp at which point the coupon becomes valid.
25
+ attr_accessor :start_date
26
+
27
+ # Expiry date of the coupon. Coupon never expires if this is omitted, zero, or negative.
28
+ attr_accessor :expiry_date
29
+
30
+ # Arbitrary properties associated with this item
31
+ attr_accessor :attributes
32
+
33
+ # The integration IDs for recipients
34
+ attr_accessor :recipients_integration_ids
35
+
36
+ # Set of characters to be used when generating random part of code. Defaults to [A-Z, 0-9] (in terms of RegExp).
37
+ attr_accessor :valid_characters
38
+
39
+ # The pattern that will be used to generate coupon codes. The character `#` acts as a placeholder and will be replaced by a random character from the `validCharacters` set.
40
+ attr_accessor :coupon_pattern
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'usage_limit' => :'usageLimit',
46
+ :'discount_limit' => :'discountLimit',
47
+ :'start_date' => :'startDate',
48
+ :'expiry_date' => :'expiryDate',
49
+ :'attributes' => :'attributes',
50
+ :'recipients_integration_ids' => :'recipientsIntegrationIds',
51
+ :'valid_characters' => :'validCharacters',
52
+ :'coupon_pattern' => :'couponPattern'
53
+ }
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.openapi_types
58
+ {
59
+ :'usage_limit' => :'Integer',
60
+ :'discount_limit' => :'Float',
61
+ :'start_date' => :'DateTime',
62
+ :'expiry_date' => :'DateTime',
63
+ :'attributes' => :'Object',
64
+ :'recipients_integration_ids' => :'Array<String>',
65
+ :'valid_characters' => :'Array<String>',
66
+ :'coupon_pattern' => :'String'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::NewCouponsForMultipleRecipients` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::NewCouponsForMultipleRecipients`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'usage_limit')
92
+ self.usage_limit = attributes[:'usage_limit']
93
+ end
94
+
95
+ if attributes.key?(:'discount_limit')
96
+ self.discount_limit = attributes[:'discount_limit']
97
+ end
98
+
99
+ if attributes.key?(:'start_date')
100
+ self.start_date = attributes[:'start_date']
101
+ end
102
+
103
+ if attributes.key?(:'expiry_date')
104
+ self.expiry_date = attributes[:'expiry_date']
105
+ end
106
+
107
+ if attributes.key?(:'attributes')
108
+ self.attributes = attributes[:'attributes']
109
+ end
110
+
111
+ if attributes.key?(:'recipients_integration_ids')
112
+ if (value = attributes[:'recipients_integration_ids']).is_a?(Array)
113
+ self.recipients_integration_ids = value
114
+ end
115
+ end
116
+
117
+ if attributes.key?(:'valid_characters')
118
+ if (value = attributes[:'valid_characters']).is_a?(Array)
119
+ self.valid_characters = value
120
+ end
121
+ end
122
+
123
+ if attributes.key?(:'coupon_pattern')
124
+ self.coupon_pattern = attributes[:'coupon_pattern']
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ invalid_properties = Array.new
132
+ if @usage_limit.nil?
133
+ invalid_properties.push('invalid value for "usage_limit", usage_limit cannot be nil.')
134
+ end
135
+
136
+ if @usage_limit > 999999
137
+ invalid_properties.push('invalid value for "usage_limit", must be smaller than or equal to 999999.')
138
+ end
139
+
140
+ if @usage_limit < 0
141
+ invalid_properties.push('invalid value for "usage_limit", must be greater than or equal to 0.')
142
+ end
143
+
144
+ if !@discount_limit.nil? && @discount_limit > 999999
145
+ invalid_properties.push('invalid value for "discount_limit", must be smaller than or equal to 999999.')
146
+ end
147
+
148
+ if !@discount_limit.nil? && @discount_limit < 0
149
+ invalid_properties.push('invalid value for "discount_limit", must be greater than or equal to 0.')
150
+ end
151
+
152
+ if @recipients_integration_ids.nil?
153
+ invalid_properties.push('invalid value for "recipients_integration_ids", recipients_integration_ids cannot be nil.')
154
+ end
155
+
156
+ if !@coupon_pattern.nil? && @coupon_pattern.to_s.length > 100
157
+ invalid_properties.push('invalid value for "coupon_pattern", the character length must be smaller than or equal to 100.')
158
+ end
159
+
160
+ if !@coupon_pattern.nil? && @coupon_pattern.to_s.length < 3
161
+ invalid_properties.push('invalid value for "coupon_pattern", the character length must be great than or equal to 3.')
162
+ end
163
+
164
+ invalid_properties
165
+ end
166
+
167
+ # Check to see if the all the properties in the model are valid
168
+ # @return true if the model is valid
169
+ def valid?
170
+ return false if @usage_limit.nil?
171
+ return false if @usage_limit > 999999
172
+ return false if @usage_limit < 0
173
+ return false if !@discount_limit.nil? && @discount_limit > 999999
174
+ return false if !@discount_limit.nil? && @discount_limit < 0
175
+ return false if @recipients_integration_ids.nil?
176
+ return false if !@coupon_pattern.nil? && @coupon_pattern.to_s.length > 100
177
+ return false if !@coupon_pattern.nil? && @coupon_pattern.to_s.length < 3
178
+ true
179
+ end
180
+
181
+ # Custom attribute writer method with validation
182
+ # @param [Object] usage_limit Value to be assigned
183
+ def usage_limit=(usage_limit)
184
+ if usage_limit.nil?
185
+ fail ArgumentError, 'usage_limit cannot be nil'
186
+ end
187
+
188
+ if usage_limit > 999999
189
+ fail ArgumentError, 'invalid value for "usage_limit", must be smaller than or equal to 999999.'
190
+ end
191
+
192
+ if usage_limit < 0
193
+ fail ArgumentError, 'invalid value for "usage_limit", must be greater than or equal to 0.'
194
+ end
195
+
196
+ @usage_limit = usage_limit
197
+ end
198
+
199
+ # Custom attribute writer method with validation
200
+ # @param [Object] discount_limit Value to be assigned
201
+ def discount_limit=(discount_limit)
202
+ if !discount_limit.nil? && discount_limit > 999999
203
+ fail ArgumentError, 'invalid value for "discount_limit", must be smaller than or equal to 999999.'
204
+ end
205
+
206
+ if !discount_limit.nil? && discount_limit < 0
207
+ fail ArgumentError, 'invalid value for "discount_limit", must be greater than or equal to 0.'
208
+ end
209
+
210
+ @discount_limit = discount_limit
211
+ end
212
+
213
+ # Custom attribute writer method with validation
214
+ # @param [Object] coupon_pattern Value to be assigned
215
+ def coupon_pattern=(coupon_pattern)
216
+ if !coupon_pattern.nil? && coupon_pattern.to_s.length > 100
217
+ fail ArgumentError, 'invalid value for "coupon_pattern", the character length must be smaller than or equal to 100.'
218
+ end
219
+
220
+ if !coupon_pattern.nil? && coupon_pattern.to_s.length < 3
221
+ fail ArgumentError, 'invalid value for "coupon_pattern", the character length must be great than or equal to 3.'
222
+ end
223
+
224
+ @coupon_pattern = coupon_pattern
225
+ end
226
+
227
+ # Checks equality by comparing each attribute.
228
+ # @param [Object] Object to be compared
229
+ def ==(o)
230
+ return true if self.equal?(o)
231
+ self.class == o.class &&
232
+ usage_limit == o.usage_limit &&
233
+ discount_limit == o.discount_limit &&
234
+ start_date == o.start_date &&
235
+ expiry_date == o.expiry_date &&
236
+ attributes == o.attributes &&
237
+ recipients_integration_ids == o.recipients_integration_ids &&
238
+ valid_characters == o.valid_characters &&
239
+ coupon_pattern == o.coupon_pattern
240
+ end
241
+
242
+ # @see the `==` method
243
+ # @param [Object] Object to be compared
244
+ def eql?(o)
245
+ self == o
246
+ end
247
+
248
+ # Calculates hash code according to all attributes.
249
+ # @return [Integer] Hash code
250
+ def hash
251
+ [usage_limit, discount_limit, start_date, expiry_date, attributes, recipients_integration_ids, valid_characters, coupon_pattern].hash
252
+ end
253
+
254
+ # Builds the object from hash
255
+ # @param [Hash] attributes Model attributes in the form of hash
256
+ # @return [Object] Returns the model itself
257
+ def self.build_from_hash(attributes)
258
+ new.build_from_hash(attributes)
259
+ end
260
+
261
+ # Builds the object from hash
262
+ # @param [Hash] attributes Model attributes in the form of hash
263
+ # @return [Object] Returns the model itself
264
+ def build_from_hash(attributes)
265
+ return nil unless attributes.is_a?(Hash)
266
+ self.class.openapi_types.each_pair do |key, type|
267
+ if type =~ /\AArray<(.*)>/i
268
+ # check to ensure the input is an array given that the attribute
269
+ # is documented as an array but the input is not
270
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
271
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
272
+ end
273
+ elsif !attributes[self.class.attribute_map[key]].nil?
274
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
275
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
276
+ end
277
+
278
+ self
279
+ end
280
+
281
+ # Deserializes the data based on type
282
+ # @param string type Data type
283
+ # @param string value Value to be deserialized
284
+ # @return [Object] Deserialized data
285
+ def _deserialize(type, value)
286
+ case type.to_sym
287
+ when :DateTime
288
+ DateTime.parse(value)
289
+ when :Date
290
+ Date.parse(value)
291
+ when :String
292
+ value.to_s
293
+ when :Integer
294
+ value.to_i
295
+ when :Float
296
+ value.to_f
297
+ when :Boolean
298
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
299
+ true
300
+ else
301
+ false
302
+ end
303
+ when :Object
304
+ # generic object (usually a Hash), return directly
305
+ value
306
+ when /\AArray<(?<inner_type>.+)>\z/
307
+ inner_type = Regexp.last_match[:inner_type]
308
+ value.map { |v| _deserialize(inner_type, v) }
309
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
310
+ k_type = Regexp.last_match[:k_type]
311
+ v_type = Regexp.last_match[:v_type]
312
+ {}.tap do |hash|
313
+ value.each do |k, v|
314
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
315
+ end
316
+ end
317
+ else # model
318
+ TalonOne.const_get(type).build_from_hash(value)
319
+ end
320
+ end
321
+
322
+ # Returns the string representation of the object
323
+ # @return [String] String presentation of the object
324
+ def to_s
325
+ to_hash.to_s
326
+ end
327
+
328
+ # to_body is an alias to to_hash (backward compatibility)
329
+ # @return [Hash] Returns the object in the form of hash
330
+ def to_body
331
+ to_hash
332
+ end
333
+
334
+ # Returns the object in the form of hash
335
+ # @return [Hash] Returns the object in the form of hash
336
+ def to_hash
337
+ hash = {}
338
+ self.class.attribute_map.each_pair do |attr, param|
339
+ value = self.send(attr)
340
+ if value.nil?
341
+ is_nullable = self.class.openapi_nullable.include?(attr)
342
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
343
+ end
344
+
345
+ hash[param] = _to_hash(value)
346
+ end
347
+ hash
348
+ end
349
+
350
+ # Outputs non-array value in the form of hash
351
+ # For object, use to_hash. Otherwise, just return the value
352
+ # @param [Object] value Any valid value
353
+ # @return [Hash] Returns the value in the form of hash
354
+ def _to_hash(value)
355
+ if value.is_a?(Array)
356
+ value.compact.map { |v| _to_hash(v) }
357
+ elsif value.is_a?(Hash)
358
+ {}.tap do |hash|
359
+ value.each { |k, v| hash[k] = _to_hash(v) }
360
+ end
361
+ elsif value.respond_to? :to_hash
362
+ value.to_hash
363
+ else
364
+ value
365
+ end
366
+ end
367
+ end
368
+ end