maxio-advanced-billing-sdk 7.0.1 → 8.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 (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +94 -44
  3. data/bin/console +15 -0
  4. data/lib/advanced_billing/client.rb +11 -0
  5. data/lib/advanced_billing/configuration.rb +73 -0
  6. data/lib/advanced_billing/controllers/advance_invoice_controller.rb +2 -2
  7. data/lib/advanced_billing/controllers/base_controller.rb +1 -1
  8. data/lib/advanced_billing/controllers/billing_portal_controller.rb +2 -2
  9. data/lib/advanced_billing/controllers/component_price_points_controller.rb +2 -2
  10. data/lib/advanced_billing/controllers/components_controller.rb +5 -5
  11. data/lib/advanced_billing/controllers/coupons_controller.rb +5 -11
  12. data/lib/advanced_billing/controllers/custom_fields_controller.rb +102 -128
  13. data/lib/advanced_billing/controllers/customers_controller.rb +4 -4
  14. data/lib/advanced_billing/controllers/invoices_controller.rb +48 -11
  15. data/lib/advanced_billing/controllers/payment_profiles_controller.rb +70 -243
  16. data/lib/advanced_billing/controllers/product_families_controller.rb +7 -8
  17. data/lib/advanced_billing/controllers/product_price_points_controller.rb +15 -17
  18. data/lib/advanced_billing/controllers/products_controller.rb +7 -8
  19. data/lib/advanced_billing/controllers/proforma_invoices_controller.rb +1 -1
  20. data/lib/advanced_billing/controllers/sales_commissions_controller.rb +3 -3
  21. data/lib/advanced_billing/controllers/subscription_components_controller.rb +24 -33
  22. data/lib/advanced_billing/controllers/subscription_group_status_controller.rb +9 -9
  23. data/lib/advanced_billing/controllers/subscription_groups_controller.rb +10 -5
  24. data/lib/advanced_billing/controllers/subscription_invoice_account_controller.rb +1 -1
  25. data/lib/advanced_billing/controllers/subscription_products_controller.rb +6 -7
  26. data/lib/advanced_billing/controllers/subscription_status_controller.rb +6 -7
  27. data/lib/advanced_billing/controllers/subscriptions_controller.rb +86 -808
  28. data/lib/advanced_billing/http/auth/basic_auth.rb +12 -0
  29. data/lib/advanced_billing/http/proxy_settings.rb +9 -0
  30. data/lib/advanced_billing/models/activate_event_based_component.rb +1 -2
  31. data/lib/advanced_billing/models/all_vaults.rb +45 -0
  32. data/lib/advanced_billing/models/allocation_preview_direction.rb +13 -0
  33. data/lib/advanced_billing/models/allocation_preview_line_item_kind.rb +15 -0
  34. data/lib/advanced_billing/models/apple_pay_vault.rb +6 -0
  35. data/lib/advanced_billing/models/auto_invite.rb +19 -0
  36. data/lib/advanced_billing/models/bank_account_holder_type.rb +13 -0
  37. data/lib/advanced_billing/models/bank_account_type.rb +13 -0
  38. data/lib/advanced_billing/models/bank_account_vault.rb +19 -0
  39. data/lib/advanced_billing/models/basic_date_field.rb +13 -0
  40. data/lib/advanced_billing/models/billing_manifest_line_item_kind.rb +17 -0
  41. data/lib/advanced_billing/models/billing_schedule.rb +2 -2
  42. data/lib/advanced_billing/models/calendar_billing.rb +3 -1
  43. data/lib/advanced_billing/models/cancellation_method.rb +17 -0
  44. data/lib/advanced_billing/models/card_type.rb +47 -0
  45. data/lib/advanced_billing/models/chargeback_status.rb +15 -0
  46. data/lib/advanced_billing/models/chargify_ebb.rb +4 -4
  47. data/lib/advanced_billing/models/cleanup_scope.rb +13 -0
  48. data/lib/advanced_billing/models/collection_method.rb +15 -0
  49. data/lib/advanced_billing/models/component.rb +31 -31
  50. data/lib/advanced_billing/models/component_custom_price.rb +61 -3
  51. data/lib/advanced_billing/models/component_kind.rb +16 -0
  52. data/lib/advanced_billing/models/compounding_strategy.rb +13 -0
  53. data/lib/advanced_billing/models/create_allocation.rb +1 -2
  54. data/lib/advanced_billing/models/create_invoice_coupon.rb +16 -7
  55. data/lib/advanced_billing/models/create_invoice_item.rb +5 -5
  56. data/lib/advanced_billing/models/create_invoice_status.rb +13 -0
  57. data/lib/advanced_billing/models/create_metafield.rb +3 -5
  58. data/lib/advanced_billing/models/create_or_update_product.rb +12 -7
  59. data/lib/advanced_billing/models/create_payment_profile.rb +6 -6
  60. data/lib/advanced_billing/models/create_prepayment_method.rb +19 -0
  61. data/lib/advanced_billing/models/create_product_price_point.rb +8 -3
  62. data/lib/advanced_billing/models/create_signup_proforma_preview_include.rb +6 -0
  63. data/lib/advanced_billing/models/create_usage.rb +17 -7
  64. data/lib/advanced_billing/models/credit_card_vault.rb +44 -0
  65. data/lib/advanced_billing/models/credit_note_status.rb +13 -0
  66. data/lib/advanced_billing/models/credit_scheme.rb +14 -0
  67. data/lib/advanced_billing/models/credit_type.rb +14 -0
  68. data/lib/advanced_billing/models/currency_price_role.rb +14 -0
  69. data/lib/advanced_billing/models/custom_field_owner.rb +13 -0
  70. data/lib/advanced_billing/models/debit_note_role.rb +13 -0
  71. data/lib/advanced_billing/models/debit_note_status.rb +15 -0
  72. data/lib/advanced_billing/models/direction.rb +13 -0
  73. data/lib/advanced_billing/models/discount_type.rb +13 -0
  74. data/lib/advanced_billing/models/ebb_component.rb +2 -2
  75. data/lib/advanced_billing/models/event_key.rb +91 -0
  76. data/lib/advanced_billing/models/expiration_interval_unit.rb +14 -0
  77. data/lib/advanced_billing/models/failed_payment_action.rb +14 -0
  78. data/lib/advanced_billing/models/first_charge_type.rb +14 -0
  79. data/lib/advanced_billing/models/group_target_type.rb +16 -0
  80. data/lib/advanced_billing/models/group_type.rb +13 -0
  81. data/lib/advanced_billing/models/include_not_null.rb +6 -0
  82. data/lib/advanced_billing/models/include_null_or_not_null.rb +13 -0
  83. data/lib/advanced_billing/models/include_option.rb +13 -0
  84. data/lib/advanced_billing/models/interval_unit.rb +13 -0
  85. data/lib/advanced_billing/models/invoice_consolidation_level.rb +14 -0
  86. data/lib/advanced_billing/models/invoice_date_field.rb +16 -0
  87. data/lib/advanced_billing/models/invoice_discount_source_type.rb +14 -0
  88. data/lib/advanced_billing/models/invoice_discount_type.rb +14 -0
  89. data/lib/advanced_billing/models/invoice_event_payment_method.rb +16 -0
  90. data/lib/advanced_billing/models/invoice_event_type.rb +26 -0
  91. data/lib/advanced_billing/models/invoice_payment_method_type.rb +17 -0
  92. data/lib/advanced_billing/models/invoice_payment_type.rb +15 -0
  93. data/lib/advanced_billing/models/invoice_role.rb +21 -0
  94. data/lib/advanced_billing/models/invoice_sort_field.rb +19 -0
  95. data/lib/advanced_billing/models/invoice_status.rb +18 -0
  96. data/lib/advanced_billing/models/item_category.rb +16 -0
  97. data/lib/advanced_billing/models/line_item_kind.rb +21 -0
  98. data/lib/advanced_billing/models/line_item_transaction_type.rb +18 -0
  99. data/lib/advanced_billing/models/list_components_price_points_include.rb +6 -0
  100. data/lib/advanced_billing/models/list_coupons_filter.rb +22 -6
  101. data/lib/advanced_billing/models/list_events_date_field.rb +6 -0
  102. data/lib/advanced_billing/models/list_prepayment_date_field.rb +13 -0
  103. data/lib/advanced_billing/models/list_products_include.rb +6 -0
  104. data/lib/advanced_billing/models/list_products_price_points_include.rb +6 -0
  105. data/lib/advanced_billing/models/list_subscription_components_include.rb +13 -0
  106. data/lib/advanced_billing/models/list_subscription_components_sort.rb +13 -0
  107. data/lib/advanced_billing/models/metafield.rb +8 -11
  108. data/lib/advanced_billing/models/metafield_input.rb +18 -5
  109. data/lib/advanced_billing/models/metafield_scope.rb +9 -4
  110. data/lib/advanced_billing/models/metered_component.rb +2 -2
  111. data/lib/advanced_billing/models/nested_subscription_group.rb +10 -0
  112. data/lib/advanced_billing/models/on_off_component.rb +2 -2
  113. data/lib/advanced_billing/models/pay_pal_vault.rb +15 -0
  114. data/lib/advanced_billing/models/payment_profile_attributes.rb +3 -3
  115. data/lib/advanced_billing/models/payment_type.rb +15 -0
  116. data/lib/advanced_billing/models/prepaid_configuration.rb +10 -0
  117. data/lib/advanced_billing/models/prepaid_usage_component.rb +2 -2
  118. data/lib/advanced_billing/models/prepayment_method.rb +18 -0
  119. data/lib/advanced_billing/models/price_point_type.rb +14 -0
  120. data/lib/advanced_billing/models/pricing_scheme.rb +15 -0
  121. data/lib/advanced_billing/models/product.rb +18 -8
  122. data/lib/advanced_billing/models/product_family.rb +10 -0
  123. data/lib/advanced_billing/models/product_price_point.rb +8 -3
  124. data/lib/advanced_billing/models/proforma_invoice_discount_source_type.rb +13 -0
  125. data/lib/advanced_billing/models/proforma_invoice_role.rb +15 -0
  126. data/lib/advanced_billing/models/proforma_invoice_status.rb +14 -0
  127. data/lib/advanced_billing/models/proforma_invoice_tax_source_type.rb +13 -0
  128. data/lib/advanced_billing/models/public_signup_page.rb +10 -0
  129. data/lib/advanced_billing/models/quantity_based_component.rb +2 -2
  130. data/lib/advanced_billing/models/reactivation_charge.rb +14 -0
  131. data/lib/advanced_billing/models/recurring_scheme.rb +14 -0
  132. data/lib/advanced_billing/models/resource_type.rb +13 -0
  133. data/lib/advanced_billing/models/restriction_type.rb +13 -0
  134. data/lib/advanced_billing/models/resume_options.rb +1 -1
  135. data/lib/advanced_billing/models/resumption_charge.rb +14 -0
  136. data/lib/advanced_billing/models/service_credit_type.rb +13 -0
  137. data/lib/advanced_billing/models/snap_day.rb +7 -2
  138. data/lib/advanced_billing/models/sorting_direction.rb +13 -0
  139. data/lib/advanced_billing/models/subscription.rb +16 -3
  140. data/lib/advanced_billing/models/subscription_custom_price.rb +23 -7
  141. data/lib/advanced_billing/models/subscription_date_field.rb +20 -0
  142. data/lib/advanced_billing/models/subscription_group_include.rb +6 -0
  143. data/lib/advanced_billing/models/subscription_group_prepayment_method.rb +17 -0
  144. data/lib/advanced_billing/models/subscription_groups_list_include.rb +6 -0
  145. data/lib/advanced_billing/models/subscription_include.rb +13 -0
  146. data/lib/advanced_billing/models/subscription_included_coupon.rb +10 -0
  147. data/lib/advanced_billing/models/subscription_list_date_field.rb +6 -0
  148. data/lib/advanced_billing/models/subscription_list_include.rb +6 -0
  149. data/lib/advanced_billing/models/subscription_purge_type.rb +13 -0
  150. data/lib/advanced_billing/models/subscription_sort.rb +17 -0
  151. data/lib/advanced_billing/models/subscription_state.rb +26 -0
  152. data/lib/advanced_billing/models/subscription_state_filter.rb +23 -0
  153. data/lib/advanced_billing/models/tax_configuration_kind.rb +15 -0
  154. data/lib/advanced_billing/models/tax_destination_address.rb +15 -0
  155. data/lib/advanced_billing/models/trial_type.rb +41 -0
  156. data/lib/advanced_billing/models/update_component.rb +2 -2
  157. data/lib/advanced_billing/models/update_metafield.rb +4 -6
  158. data/lib/advanced_billing/models/update_payment_profile.rb +3 -3
  159. data/lib/advanced_billing/models/update_subscription.rb +1 -0
  160. data/lib/advanced_billing/models/webhook_order.rb +13 -0
  161. data/lib/advanced_billing/models/webhook_status.rb +15 -0
  162. data/lib/advanced_billing/models/webhook_subscription.rb +46 -0
  163. data/lib/advanced_billing/utilities/union_type_lookup.rb +18 -5
  164. data/lib/advanced_billing.rb +1 -0
  165. metadata +8 -6
@@ -52,9 +52,13 @@ module AdvancedBilling
52
52
  # @return [IntervalUnit]
53
53
  attr_accessor :trial_interval_unit
54
54
 
55
- # A string representing the trial interval unit for this product price
56
- # point, either month or day
57
- # @return [String]
55
+ # Indicates how a trial is handled when the trail period ends and there is
56
+ # no credit card on file. For `no_obligation`, the subscription transitions
57
+ # to a Trial Ended state. Maxio will not send any emails or statements. For
58
+ # `payment_expected`, the subscription transitions to a Past Due state.
59
+ # Maxio will send normal dunning emails and statements according to your
60
+ # other settings.
61
+ # @return [TrialType]
58
62
  attr_accessor :trial_type
59
63
 
60
64
  # reserved for future use
@@ -188,6 +192,7 @@ module AdvancedBilling
188
192
  trial_price_in_cents
189
193
  trial_interval
190
194
  trial_interval_unit
195
+ trial_type
191
196
  introductory_offer
192
197
  initial_charge_in_cents
193
198
  initial_charge_after_trial
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  PROFORMA_INVOICE_DISCOUNT_SOURCE_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = COUPON)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'coupon' then COUPON
30
+ when 'referral' then REFERRAL
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -26,5 +26,20 @@ module AdvancedBilling
26
26
 
27
27
  PROFORMA_INVOICE_ROLE.include?(value)
28
28
  end
29
+
30
+ def self.from_value(value, default_value = UNSET)
31
+ return default_value if value.nil?
32
+
33
+ str = value.to_s.strip
34
+
35
+ case str.downcase
36
+ when 'unset' then UNSET
37
+ when 'proforma' then PROFORMA
38
+ when 'proforma_adhoc' then PROFORMA_ADHOC
39
+ when 'proforma_automatic' then PROFORMA_AUTOMATIC
40
+ else
41
+ default_value
42
+ end
43
+ end
29
44
  end
30
45
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  PROFORMA_INVOICE_STATUS.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = DRAFT)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'draft' then DRAFT
33
+ when 'voided' then VOIDED
34
+ when 'archived' then ARCHIVED
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  PROFORMA_INVOICE_TAX_SOURCE_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = TAX)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'tax' then TAX
30
+ when 'avalara' then AVALARA
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -88,6 +88,16 @@ module AdvancedBilling
88
88
  additional_properties: additional_properties)
89
89
  end
90
90
 
91
+ # Validates an instance of the object from a given value.
92
+ # @param [PublicSignupPage | Hash] The value against the validation is performed.
93
+ def self.validate(value)
94
+ return true if value.instance_of? self
95
+
96
+ return false unless value.instance_of? Hash
97
+
98
+ true
99
+ end
100
+
91
101
  # Provides a human-readable string representation of the object.
92
102
  def to_s
93
103
  class_name = self.class.name.split('::').last
@@ -78,8 +78,8 @@ module AdvancedBilling
78
78
  attr_accessor :unit_price
79
79
 
80
80
  # A string representing the tax code related to the component type. This is
81
- # especially important when using the Avalara service to tax based on
82
- # locale. This attribute has a max length of 10 characters.
81
+ # especially important when using AvaTax to tax based on locale. This
82
+ # attribute has a max length of 25 characters.
83
83
  # @return [String]
84
84
  attr_accessor :tax_code
85
85
 
@@ -26,5 +26,19 @@ module AdvancedBilling
26
26
 
27
27
  REACTIVATION_CHARGE.include?(value)
28
28
  end
29
+
30
+ def self.from_value(value, default_value = PRORATED)
31
+ return default_value if value.nil?
32
+
33
+ str = value.to_s.strip
34
+
35
+ case str.downcase
36
+ when 'prorated' then PRORATED
37
+ when 'immediate' then IMMEDIATE
38
+ when 'delayed' then DELAYED
39
+ else
40
+ default_value
41
+ end
42
+ end
29
43
  end
30
44
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  RECURRING_SCHEME.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = DO_NOT_RECUR)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'do_not_recur' then DO_NOT_RECUR
33
+ when 'recur_indefinitely' then RECUR_INDEFINITELY
34
+ when 'recur_with_duration' then RECUR_WITH_DURATION
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  RESOURCE_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = SUBSCRIPTIONS)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'subscriptions' then SUBSCRIPTIONS
30
+ when 'customers' then CUSTOMERS
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  RESTRICTION_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = COMPONENT)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'component' then COMPONENT
30
+ when 'product' then PRODUCT
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -10,7 +10,7 @@ module AdvancedBilling
10
10
  private_constant :SKIP
11
11
 
12
12
  # Chargify will only attempt to resume the subscription's billing period. If
13
- # not resumable, the subscription will be left in it's current state.
13
+ # not resumable, the subscription will be left in its current state.
14
14
  # @return [TrueClass | FalseClass]
15
15
  attr_accessor :require_resume
16
16
 
@@ -23,5 +23,19 @@ module AdvancedBilling
23
23
 
24
24
  RESUMPTION_CHARGE.include?(value)
25
25
  end
26
+
27
+ def self.from_value(value, default_value = PRORATED)
28
+ return default_value if value.nil?
29
+
30
+ str = value.to_s.strip
31
+
32
+ case str.downcase
33
+ when 'prorated' then PRORATED
34
+ when 'immediate' then IMMEDIATE
35
+ when 'delayed' then DELAYED
36
+ else
37
+ default_value
38
+ end
39
+ end
26
40
  end
27
41
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  SERVICE_CREDIT_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = CREDIT)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'credit' then CREDIT
30
+ when 'debit' then DEBIT
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -4,8 +4,7 @@
4
4
  # APIMATIC v3.0 ( https://www.apimatic.io ).
5
5
 
6
6
  module AdvancedBilling
7
- # Use for subscriptions with product eligible for calendar billing only. Value
8
- # can be 1-28 or 'end'.
7
+ # SnapDay.
9
8
  class SnapDay
10
9
  SNAP_DAY = [
11
10
  # TODO: Write general description for ENUM_END
@@ -17,5 +16,11 @@ module AdvancedBilling
17
16
 
18
17
  SNAP_DAY.include?(value)
19
18
  end
19
+
20
+ def self.from_value(value, default_value = ENUM_END)
21
+ return default_value if value.nil?
22
+
23
+ default_value
24
+ end
20
25
  end
21
26
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  SORTING_DIRECTION.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = ASC)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'asc' then ASC
30
+ when 'desc' then DESC
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -198,7 +198,7 @@ module AdvancedBilling
198
198
 
199
199
  # The day of the month that the subscription will charge according to
200
200
  # calendar billing rules, if used.
201
- # @return [String]
201
+ # @return [Object]
202
202
  attr_accessor :snap_day
203
203
 
204
204
  # The type of payment collection to be used in the subscription. For legacy
@@ -295,7 +295,8 @@ module AdvancedBilling
295
295
  attr_accessor :payer_id
296
296
 
297
297
  # The balance in cents plus the estimated renewal amount in cents. Returned
298
- # ONLY for readSubscription operation as it's compute intensive operation.
298
+ # ONLY for the readSubscription operation as it's a compute intensive
299
+ # operation.
299
300
  # @return [Integer]
300
301
  attr_accessor :current_billing_amount_in_cents
301
302
 
@@ -782,7 +783,9 @@ module AdvancedBilling
782
783
  SKIP
783
784
  end
784
785
  coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP
785
- snap_day = hash.key?('snap_day') ? hash['snap_day'] : SKIP
786
+ snap_day = hash.key?('snap_day') ? APIHelper.deserialize_union_type(
787
+ UnionTypeLookUp.get(:SubscriptionSnapDay), hash['snap_day']
788
+ ) : SKIP
786
789
  payment_collection_method =
787
790
  hash.key?('payment_collection_method') ? hash['payment_collection_method'] : SKIP
788
791
  customer = Customer.from_hash(hash['customer']) if hash['customer']
@@ -986,6 +989,16 @@ module AdvancedBilling
986
989
  DateTimeHelper.to_rfc3339(scheduled_cancellation_at)
987
990
  end
988
991
 
992
+ # Validates an instance of the object from a given value.
993
+ # @param [Subscription | Hash] The value against the validation is performed.
994
+ def self.validate(value)
995
+ return true if value.instance_of? self
996
+
997
+ return false unless value.instance_of? Hash
998
+
999
+ true
1000
+ end
1001
+
989
1002
  # Provides a human-readable string representation of the object.
990
1003
  def to_s
991
1004
  class_name = self.class.name.split('::').last
@@ -42,6 +42,15 @@ module AdvancedBilling
42
42
  # @return [IntervalUnit]
43
43
  attr_accessor :trial_interval_unit
44
44
 
45
+ # Indicates how a trial is handled when the trail period ends and there is
46
+ # no credit card on file. For `no_obligation`, the subscription transitions
47
+ # to a Trial Ended state. Maxio will not send any emails or statements. For
48
+ # `payment_expected`, the subscription transitions to a Past Due state.
49
+ # Maxio will send normal dunning emails and statements according to your
50
+ # other settings.
51
+ # @return [TrialType]
52
+ attr_accessor :trial_type
53
+
45
54
  # (Optional)
46
55
  # @return [Object]
47
56
  attr_accessor :initial_charge_in_cents
@@ -73,6 +82,7 @@ module AdvancedBilling
73
82
  @_hash['trial_price_in_cents'] = 'trial_price_in_cents'
74
83
  @_hash['trial_interval'] = 'trial_interval'
75
84
  @_hash['trial_interval_unit'] = 'trial_interval_unit'
85
+ @_hash['trial_type'] = 'trial_type'
76
86
  @_hash['initial_charge_in_cents'] = 'initial_charge_in_cents'
77
87
  @_hash['initial_charge_after_trial'] = 'initial_charge_after_trial'
78
88
  @_hash['expiration_interval'] = 'expiration_interval'
@@ -89,6 +99,7 @@ module AdvancedBilling
89
99
  trial_price_in_cents
90
100
  trial_interval
91
101
  trial_interval_unit
102
+ trial_type
92
103
  initial_charge_in_cents
93
104
  initial_charge_after_trial
94
105
  expiration_interval
@@ -101,6 +112,7 @@ module AdvancedBilling
101
112
  def self.nullables
102
113
  %w[
103
114
  interval_unit
115
+ trial_type
104
116
  expiration_interval_unit
105
117
  ]
106
118
  end
@@ -108,7 +120,7 @@ module AdvancedBilling
108
120
  def initialize(price_in_cents:, interval:, interval_unit:, name: SKIP,
109
121
  handle: SKIP, trial_price_in_cents: SKIP,
110
122
  trial_interval: SKIP, trial_interval_unit: SKIP,
111
- initial_charge_in_cents: SKIP,
123
+ trial_type: SKIP, initial_charge_in_cents: SKIP,
112
124
  initial_charge_after_trial: SKIP, expiration_interval: SKIP,
113
125
  expiration_interval_unit: SKIP, tax_included: SKIP,
114
126
  additional_properties: {})
@@ -125,6 +137,7 @@ module AdvancedBilling
125
137
  @trial_price_in_cents = trial_price_in_cents unless trial_price_in_cents == SKIP
126
138
  @trial_interval = trial_interval unless trial_interval == SKIP
127
139
  @trial_interval_unit = trial_interval_unit unless trial_interval_unit == SKIP
140
+ @trial_type = trial_type unless trial_type == SKIP
128
141
  @initial_charge_in_cents = initial_charge_in_cents unless initial_charge_in_cents == SKIP
129
142
  unless initial_charge_after_trial == SKIP
130
143
  @initial_charge_after_trial =
@@ -157,6 +170,7 @@ module AdvancedBilling
157
170
  ) : SKIP
158
171
  trial_interval_unit =
159
172
  hash.key?('trial_interval_unit') ? hash['trial_interval_unit'] : SKIP
173
+ trial_type = hash.key?('trial_type') ? hash['trial_type'] : SKIP
160
174
  initial_charge_in_cents = hash.key?('initial_charge_in_cents') ? APIHelper.deserialize_union_type(
161
175
  UnionTypeLookUp.get(:SubscriptionCustomPriceInitialChargeInCents), hash['initial_charge_in_cents']
162
176
  ) : SKIP
@@ -181,6 +195,7 @@ module AdvancedBilling
181
195
  trial_price_in_cents: trial_price_in_cents,
182
196
  trial_interval: trial_interval,
183
197
  trial_interval_unit: trial_interval_unit,
198
+ trial_type: trial_type,
184
199
  initial_charge_in_cents: initial_charge_in_cents,
185
200
  initial_charge_after_trial: initial_charge_after_trial,
186
201
  expiration_interval: expiration_interval,
@@ -221,10 +236,11 @@ module AdvancedBilling
221
236
  "<#{class_name} name: #{@name}, handle: #{@handle}, price_in_cents: #{@price_in_cents},"\
222
237
  " interval: #{@interval}, interval_unit: #{@interval_unit}, trial_price_in_cents:"\
223
238
  " #{@trial_price_in_cents}, trial_interval: #{@trial_interval}, trial_interval_unit:"\
224
- " #{@trial_interval_unit}, initial_charge_in_cents: #{@initial_charge_in_cents},"\
225
- " initial_charge_after_trial: #{@initial_charge_after_trial}, expiration_interval:"\
226
- " #{@expiration_interval}, expiration_interval_unit: #{@expiration_interval_unit},"\
227
- " tax_included: #{@tax_included}, additional_properties: #{get_additional_properties}>"
239
+ " #{@trial_interval_unit}, trial_type: #{@trial_type}, initial_charge_in_cents:"\
240
+ " #{@initial_charge_in_cents}, initial_charge_after_trial: #{@initial_charge_after_trial},"\
241
+ " expiration_interval: #{@expiration_interval}, expiration_interval_unit:"\
242
+ " #{@expiration_interval_unit}, tax_included: #{@tax_included}, additional_properties:"\
243
+ " #{get_additional_properties}>"
228
244
  end
229
245
 
230
246
  # Provides a debugging-friendly string with detailed object information.
@@ -234,8 +250,8 @@ module AdvancedBilling
234
250
  " #{@price_in_cents.inspect}, interval: #{@interval.inspect}, interval_unit:"\
235
251
  " #{@interval_unit.inspect}, trial_price_in_cents: #{@trial_price_in_cents.inspect},"\
236
252
  " trial_interval: #{@trial_interval.inspect}, trial_interval_unit:"\
237
- " #{@trial_interval_unit.inspect}, initial_charge_in_cents:"\
238
- " #{@initial_charge_in_cents.inspect}, initial_charge_after_trial:"\
253
+ " #{@trial_interval_unit.inspect}, trial_type: #{@trial_type.inspect},"\
254
+ " initial_charge_in_cents: #{@initial_charge_in_cents.inspect}, initial_charge_after_trial:"\
239
255
  " #{@initial_charge_after_trial.inspect}, expiration_interval:"\
240
256
  " #{@expiration_interval.inspect}, expiration_interval_unit:"\
241
257
  " #{@expiration_interval_unit.inspect}, tax_included: #{@tax_included.inspect},"\
@@ -40,5 +40,25 @@ module AdvancedBilling
40
40
 
41
41
  SUBSCRIPTION_DATE_FIELD.include?(value)
42
42
  end
43
+
44
+ def self.from_value(value, default_value = CURRENT_PERIOD_ENDS_AT)
45
+ return default_value if value.nil?
46
+
47
+ str = value.to_s.strip
48
+
49
+ case str.downcase
50
+ when 'current_period_ends_at' then CURRENT_PERIOD_ENDS_AT
51
+ when 'current_period_starts_at' then CURRENT_PERIOD_STARTS_AT
52
+ when 'created_at' then CREATED_AT
53
+ when 'activated_at' then ACTIVATED_AT
54
+ when 'canceled_at' then CANCELED_AT
55
+ when 'expires_at' then EXPIRES_AT
56
+ when 'trial_started_at' then TRIAL_STARTED_AT
57
+ when 'trial_ended_at' then TRIAL_ENDED_AT
58
+ when 'updated_at' then UPDATED_AT
59
+ else
60
+ default_value
61
+ end
62
+ end
43
63
  end
44
64
  end
@@ -16,5 +16,11 @@ module AdvancedBilling
16
16
 
17
17
  SUBSCRIPTION_GROUP_INCLUDE.include?(value)
18
18
  end
19
+
20
+ def self.from_value(value, default_value = CURRENT_BILLING_AMOUNT_IN_CENTS)
21
+ return default_value if value.nil?
22
+
23
+ default_value
24
+ end
19
25
  end
20
26
  end
@@ -31,5 +31,22 @@ module AdvancedBilling
31
31
 
32
32
  SUBSCRIPTION_GROUP_PREPAYMENT_METHOD.include?(value)
33
33
  end
34
+
35
+ def self.from_value(value, default_value = CHECK)
36
+ return default_value if value.nil?
37
+
38
+ str = value.to_s.strip
39
+
40
+ case str.downcase
41
+ when 'check' then CHECK
42
+ when 'cash' then CASH
43
+ when 'money_order' then MONEY_ORDER
44
+ when 'ach' then ACH
45
+ when 'paypal_account' then PAYPAL_ACCOUNT
46
+ when 'other' then OTHER
47
+ else
48
+ default_value
49
+ end
50
+ end
34
51
  end
35
52
  end
@@ -16,5 +16,11 @@ module AdvancedBilling
16
16
 
17
17
  SUBSCRIPTION_GROUPS_LIST_INCLUDE.include?(value)
18
18
  end
19
+
20
+ def self.from_value(value, default_value = ACCOUNT_BALANCES)
21
+ return default_value if value.nil?
22
+
23
+ default_value
24
+ end
19
25
  end
20
26
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  SUBSCRIPTION_INCLUDE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = COUPONS)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'coupons' then COUPONS
30
+ when 'self_service_page_token' then SELF_SERVICE_PAGE_TOKEN
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -117,6 +117,16 @@ module AdvancedBilling
117
117
  additional_properties: additional_properties)
118
118
  end
119
119
 
120
+ # Validates an instance of the object from a given value.
121
+ # @param [SubscriptionIncludedCoupon | Hash] The value against the validation is performed.
122
+ def self.validate(value)
123
+ return true if value.instance_of? self
124
+
125
+ return false unless value.instance_of? Hash
126
+
127
+ true
128
+ end
129
+
120
130
  # Provides a human-readable string representation of the object.
121
131
  def to_s
122
132
  class_name = self.class.name.split('::').last
@@ -16,5 +16,11 @@ module AdvancedBilling
16
16
 
17
17
  SUBSCRIPTION_LIST_DATE_FIELD.include?(value)
18
18
  end
19
+
20
+ def self.from_value(value, default_value = UPDATED_AT)
21
+ return default_value if value.nil?
22
+
23
+ default_value
24
+ end
19
25
  end
20
26
  end
@@ -16,5 +16,11 @@ module AdvancedBilling
16
16
 
17
17
  SUBSCRIPTION_LIST_INCLUDE.include?(value)
18
18
  end
19
+
20
+ def self.from_value(value, default_value = SELF_SERVICE_PAGE_TOKEN)
21
+ return default_value if value.nil?
22
+
23
+ default_value
24
+ end
19
25
  end
20
26
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  SUBSCRIPTION_PURGE_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = CUSTOMER)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'customer' then CUSTOMER
30
+ when 'payment_profile' then PAYMENT_PROFILE
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -31,5 +31,22 @@ module AdvancedBilling
31
31
 
32
32
  SUBSCRIPTION_SORT.include?(value)
33
33
  end
34
+
35
+ def self.from_value(value, default_value = SIGNUP_DATE)
36
+ return default_value if value.nil?
37
+
38
+ str = value.to_s.strip
39
+
40
+ case str.downcase
41
+ when 'signup_date' then SIGNUP_DATE
42
+ when 'period_start' then PERIOD_START
43
+ when 'period_end' then PERIOD_END
44
+ when 'next_assessment' then NEXT_ASSESSMENT
45
+ when 'updated_at' then UPDATED_AT
46
+ when 'created_at' then CREATED_AT
47
+ else
48
+ default_value
49
+ end
50
+ end
34
51
  end
35
52
  end
@@ -114,5 +114,31 @@ module AdvancedBilling
114
114
 
115
115
  SUBSCRIPTION_STATE.include?(value)
116
116
  end
117
+
118
+ def self.from_value(value, default_value = PENDING)
119
+ return default_value if value.nil?
120
+
121
+ str = value.to_s.strip
122
+
123
+ case str.downcase
124
+ when 'pending' then PENDING
125
+ when 'failed_to_create' then FAILED_TO_CREATE
126
+ when 'trialing' then TRIALING
127
+ when 'assessing' then ASSESSING
128
+ when 'active' then ACTIVE
129
+ when 'soft_failure' then SOFT_FAILURE
130
+ when 'past_due' then PAST_DUE
131
+ when 'suspended' then SUSPENDED
132
+ when 'canceled' then CANCELED
133
+ when 'expired' then EXPIRED
134
+ when 'paused' then PAUSED
135
+ when 'unpaid' then UNPAID
136
+ when 'trial_ended' then TRIAL_ENDED
137
+ when 'on_hold' then ON_HOLD
138
+ when 'awaiting_signup' then AWAITING_SIGNUP
139
+ else
140
+ default_value
141
+ end
142
+ end
117
143
  end
118
144
  end