maxio-advanced-billing-sdk 7.0.0 → 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 (166) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +101 -43
  3. data/bin/console +15 -0
  4. data/lib/advanced_billing/client.rb +14 -3
  5. data/lib/advanced_billing/configuration.rb +82 -5
  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 +3 -4
  10. data/lib/advanced_billing/controllers/components_controller.rb +7 -8
  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 +6 -6
  14. data/lib/advanced_billing/controllers/invoices_controller.rb +48 -11
  15. data/lib/advanced_billing/controllers/payment_profiles_controller.rb +76 -250
  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 +53 -44
  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 +87 -810
  28. data/lib/advanced_billing/controllers/webhooks_controller.rb +23 -48
  29. data/lib/advanced_billing/http/auth/basic_auth.rb +12 -0
  30. data/lib/advanced_billing/http/proxy_settings.rb +22 -0
  31. data/lib/advanced_billing/models/activate_event_based_component.rb +1 -2
  32. data/lib/advanced_billing/models/all_vaults.rb +45 -0
  33. data/lib/advanced_billing/models/allocation_preview_direction.rb +13 -0
  34. data/lib/advanced_billing/models/allocation_preview_line_item_kind.rb +15 -0
  35. data/lib/advanced_billing/models/apple_pay_vault.rb +6 -0
  36. data/lib/advanced_billing/models/auto_invite.rb +19 -0
  37. data/lib/advanced_billing/models/bank_account_holder_type.rb +13 -0
  38. data/lib/advanced_billing/models/bank_account_type.rb +13 -0
  39. data/lib/advanced_billing/models/bank_account_vault.rb +19 -0
  40. data/lib/advanced_billing/models/basic_date_field.rb +13 -0
  41. data/lib/advanced_billing/models/billing_manifest_line_item_kind.rb +17 -0
  42. data/lib/advanced_billing/models/billing_schedule.rb +2 -2
  43. data/lib/advanced_billing/models/calendar_billing.rb +3 -1
  44. data/lib/advanced_billing/models/cancellation_method.rb +17 -0
  45. data/lib/advanced_billing/models/card_type.rb +47 -0
  46. data/lib/advanced_billing/models/chargeback_status.rb +15 -0
  47. data/lib/advanced_billing/models/chargify_ebb.rb +4 -4
  48. data/lib/advanced_billing/models/cleanup_scope.rb +13 -0
  49. data/lib/advanced_billing/models/collection_method.rb +15 -0
  50. data/lib/advanced_billing/models/component.rb +31 -31
  51. data/lib/advanced_billing/models/component_custom_price.rb +61 -3
  52. data/lib/advanced_billing/models/component_kind.rb +16 -0
  53. data/lib/advanced_billing/models/compounding_strategy.rb +13 -0
  54. data/lib/advanced_billing/models/create_allocation.rb +1 -2
  55. data/lib/advanced_billing/models/create_invoice_coupon.rb +16 -7
  56. data/lib/advanced_billing/models/create_invoice_item.rb +5 -5
  57. data/lib/advanced_billing/models/create_invoice_status.rb +13 -0
  58. data/lib/advanced_billing/models/create_metafield.rb +3 -5
  59. data/lib/advanced_billing/models/create_or_update_product.rb +12 -7
  60. data/lib/advanced_billing/models/create_payment_profile.rb +6 -6
  61. data/lib/advanced_billing/models/create_prepayment_method.rb +19 -0
  62. data/lib/advanced_billing/models/create_product_price_point.rb +8 -3
  63. data/lib/advanced_billing/models/create_signup_proforma_preview_include.rb +6 -0
  64. data/lib/advanced_billing/models/create_usage.rb +17 -7
  65. data/lib/advanced_billing/models/credit_card_vault.rb +44 -0
  66. data/lib/advanced_billing/models/credit_note_status.rb +13 -0
  67. data/lib/advanced_billing/models/credit_scheme.rb +14 -0
  68. data/lib/advanced_billing/models/credit_type.rb +14 -0
  69. data/lib/advanced_billing/models/currency_price_role.rb +14 -0
  70. data/lib/advanced_billing/models/custom_field_owner.rb +13 -0
  71. data/lib/advanced_billing/models/debit_note_role.rb +13 -0
  72. data/lib/advanced_billing/models/debit_note_status.rb +15 -0
  73. data/lib/advanced_billing/models/direction.rb +13 -0
  74. data/lib/advanced_billing/models/discount_type.rb +13 -0
  75. data/lib/advanced_billing/models/ebb_component.rb +2 -2
  76. data/lib/advanced_billing/models/event_key.rb +91 -0
  77. data/lib/advanced_billing/models/expiration_interval_unit.rb +14 -0
  78. data/lib/advanced_billing/models/failed_payment_action.rb +14 -0
  79. data/lib/advanced_billing/models/first_charge_type.rb +14 -0
  80. data/lib/advanced_billing/models/group_target_type.rb +16 -0
  81. data/lib/advanced_billing/models/group_type.rb +13 -0
  82. data/lib/advanced_billing/models/include_not_null.rb +6 -0
  83. data/lib/advanced_billing/models/include_null_or_not_null.rb +13 -0
  84. data/lib/advanced_billing/models/include_option.rb +13 -0
  85. data/lib/advanced_billing/models/interval_unit.rb +13 -0
  86. data/lib/advanced_billing/models/invoice_consolidation_level.rb +14 -0
  87. data/lib/advanced_billing/models/invoice_date_field.rb +16 -0
  88. data/lib/advanced_billing/models/invoice_discount_source_type.rb +14 -0
  89. data/lib/advanced_billing/models/invoice_discount_type.rb +14 -0
  90. data/lib/advanced_billing/models/invoice_event_payment_method.rb +16 -0
  91. data/lib/advanced_billing/models/invoice_event_type.rb +26 -0
  92. data/lib/advanced_billing/models/invoice_payment_method_type.rb +17 -0
  93. data/lib/advanced_billing/models/invoice_payment_type.rb +15 -0
  94. data/lib/advanced_billing/models/invoice_role.rb +21 -0
  95. data/lib/advanced_billing/models/invoice_sort_field.rb +19 -0
  96. data/lib/advanced_billing/models/invoice_status.rb +18 -0
  97. data/lib/advanced_billing/models/item_category.rb +16 -0
  98. data/lib/advanced_billing/models/line_item_kind.rb +21 -0
  99. data/lib/advanced_billing/models/line_item_transaction_type.rb +18 -0
  100. data/lib/advanced_billing/models/list_components_price_points_include.rb +6 -0
  101. data/lib/advanced_billing/models/list_coupons_filter.rb +22 -6
  102. data/lib/advanced_billing/models/list_events_date_field.rb +6 -0
  103. data/lib/advanced_billing/models/list_prepayment_date_field.rb +13 -0
  104. data/lib/advanced_billing/models/list_products_include.rb +6 -0
  105. data/lib/advanced_billing/models/list_products_price_points_include.rb +6 -0
  106. data/lib/advanced_billing/models/list_subscription_components_include.rb +13 -0
  107. data/lib/advanced_billing/models/list_subscription_components_sort.rb +13 -0
  108. data/lib/advanced_billing/models/metafield.rb +8 -11
  109. data/lib/advanced_billing/models/metafield_input.rb +18 -5
  110. data/lib/advanced_billing/models/metafield_scope.rb +9 -4
  111. data/lib/advanced_billing/models/metered_component.rb +2 -2
  112. data/lib/advanced_billing/models/nested_subscription_group.rb +10 -0
  113. data/lib/advanced_billing/models/on_off_component.rb +2 -2
  114. data/lib/advanced_billing/models/pay_pal_vault.rb +15 -0
  115. data/lib/advanced_billing/models/payment_profile_attributes.rb +3 -3
  116. data/lib/advanced_billing/models/payment_type.rb +15 -0
  117. data/lib/advanced_billing/models/prepaid_configuration.rb +10 -0
  118. data/lib/advanced_billing/models/prepaid_usage_component.rb +2 -2
  119. data/lib/advanced_billing/models/prepayment_method.rb +18 -0
  120. data/lib/advanced_billing/models/price_point_type.rb +14 -0
  121. data/lib/advanced_billing/models/pricing_scheme.rb +15 -0
  122. data/lib/advanced_billing/models/product.rb +18 -8
  123. data/lib/advanced_billing/models/product_family.rb +10 -0
  124. data/lib/advanced_billing/models/product_price_point.rb +8 -3
  125. data/lib/advanced_billing/models/proforma_invoice_discount_source_type.rb +13 -0
  126. data/lib/advanced_billing/models/proforma_invoice_role.rb +15 -0
  127. data/lib/advanced_billing/models/proforma_invoice_status.rb +14 -0
  128. data/lib/advanced_billing/models/proforma_invoice_tax_source_type.rb +13 -0
  129. data/lib/advanced_billing/models/public_signup_page.rb +10 -0
  130. data/lib/advanced_billing/models/quantity_based_component.rb +2 -2
  131. data/lib/advanced_billing/models/reactivation_charge.rb +14 -0
  132. data/lib/advanced_billing/models/recurring_scheme.rb +14 -0
  133. data/lib/advanced_billing/models/resource_type.rb +13 -0
  134. data/lib/advanced_billing/models/restriction_type.rb +13 -0
  135. data/lib/advanced_billing/models/resume_options.rb +1 -1
  136. data/lib/advanced_billing/models/resumption_charge.rb +14 -0
  137. data/lib/advanced_billing/models/service_credit_type.rb +13 -0
  138. data/lib/advanced_billing/models/snap_day.rb +7 -2
  139. data/lib/advanced_billing/models/sorting_direction.rb +13 -0
  140. data/lib/advanced_billing/models/subscription.rb +16 -3
  141. data/lib/advanced_billing/models/subscription_custom_price.rb +23 -7
  142. data/lib/advanced_billing/models/subscription_date_field.rb +20 -0
  143. data/lib/advanced_billing/models/subscription_group_include.rb +6 -0
  144. data/lib/advanced_billing/models/subscription_group_prepayment_method.rb +17 -0
  145. data/lib/advanced_billing/models/subscription_groups_list_include.rb +6 -0
  146. data/lib/advanced_billing/models/subscription_include.rb +13 -0
  147. data/lib/advanced_billing/models/subscription_included_coupon.rb +10 -0
  148. data/lib/advanced_billing/models/subscription_list_date_field.rb +6 -0
  149. data/lib/advanced_billing/models/subscription_list_include.rb +6 -0
  150. data/lib/advanced_billing/models/subscription_purge_type.rb +13 -0
  151. data/lib/advanced_billing/models/subscription_sort.rb +17 -0
  152. data/lib/advanced_billing/models/subscription_state.rb +26 -0
  153. data/lib/advanced_billing/models/subscription_state_filter.rb +23 -0
  154. data/lib/advanced_billing/models/tax_configuration_kind.rb +15 -0
  155. data/lib/advanced_billing/models/tax_destination_address.rb +15 -0
  156. data/lib/advanced_billing/models/trial_type.rb +41 -0
  157. data/lib/advanced_billing/models/update_component.rb +2 -2
  158. data/lib/advanced_billing/models/update_metafield.rb +4 -6
  159. data/lib/advanced_billing/models/update_payment_profile.rb +3 -3
  160. data/lib/advanced_billing/models/update_subscription.rb +1 -0
  161. data/lib/advanced_billing/models/webhook_order.rb +13 -0
  162. data/lib/advanced_billing/models/webhook_status.rb +15 -0
  163. data/lib/advanced_billing/models/webhook_subscription.rb +46 -0
  164. data/lib/advanced_billing/utilities/union_type_lookup.rb +32 -5
  165. data/lib/advanced_billing.rb +2 -0
  166. metadata +11 -8
@@ -26,11 +26,15 @@ module AdvancedBilling
26
26
 
27
27
  # This attribute is particularly useful when you need to align billing
28
28
  # events for different components on distinct schedules within a
29
- # subscription. Please note this only works for site with Multifrequency
30
- # enabled
29
+ # subscription. This only works for site with Multifrequency enabled.
31
30
  # @return [BillingSchedule]
32
31
  attr_accessor :billing_schedule
33
32
 
33
+ # Create or update custom pricing unique to the subscription. Used in place
34
+ # of `price_point_id`.
35
+ # @return [ComponentCustomPrice]
36
+ attr_accessor :custom_price
37
+
34
38
  # A mapping from model property names to API property names.
35
39
  def self.names
36
40
  @_hash = {} if @_hash.nil?
@@ -38,6 +42,7 @@ module AdvancedBilling
38
42
  @_hash['price_point_id'] = 'price_point_id'
39
43
  @_hash['memo'] = 'memo'
40
44
  @_hash['billing_schedule'] = 'billing_schedule'
45
+ @_hash['custom_price'] = 'custom_price'
41
46
  @_hash
42
47
  end
43
48
 
@@ -48,6 +53,7 @@ module AdvancedBilling
48
53
  price_point_id
49
54
  memo
50
55
  billing_schedule
56
+ custom_price
51
57
  ]
52
58
  end
53
59
 
@@ -57,7 +63,8 @@ module AdvancedBilling
57
63
  end
58
64
 
59
65
  def initialize(quantity: SKIP, price_point_id: SKIP, memo: SKIP,
60
- billing_schedule: SKIP, additional_properties: {})
66
+ billing_schedule: SKIP, custom_price: SKIP,
67
+ additional_properties: {})
61
68
  # Add additional model properties to the instance.
62
69
  additional_properties.each do |_name, _value|
63
70
  instance_variable_set("@#{_name}", _value)
@@ -67,6 +74,7 @@ module AdvancedBilling
67
74
  @price_point_id = price_point_id unless price_point_id == SKIP
68
75
  @memo = memo unless memo == SKIP
69
76
  @billing_schedule = billing_schedule unless billing_schedule == SKIP
77
+ @custom_price = custom_price unless custom_price == SKIP
70
78
  end
71
79
 
72
80
  # Creates an instance of the object from a hash.
@@ -80,6 +88,7 @@ module AdvancedBilling
80
88
  memo = hash.key?('memo') ? hash['memo'] : SKIP
81
89
  billing_schedule = BillingSchedule.from_hash(hash['billing_schedule']) if
82
90
  hash['billing_schedule']
91
+ custom_price = ComponentCustomPrice.from_hash(hash['custom_price']) if hash['custom_price']
83
92
 
84
93
  # Clean out expected properties from Hash.
85
94
  additional_properties = hash.reject { |k, _| names.value?(k) }
@@ -89,6 +98,7 @@ module AdvancedBilling
89
98
  price_point_id: price_point_id,
90
99
  memo: memo,
91
100
  billing_schedule: billing_schedule,
101
+ custom_price: custom_price,
92
102
  additional_properties: additional_properties)
93
103
  end
94
104
 
@@ -96,16 +106,16 @@ module AdvancedBilling
96
106
  def to_s
97
107
  class_name = self.class.name.split('::').last
98
108
  "<#{class_name} quantity: #{@quantity}, price_point_id: #{@price_point_id}, memo: #{@memo},"\
99
- " billing_schedule: #{@billing_schedule}, additional_properties:"\
100
- " #{get_additional_properties}>"
109
+ " billing_schedule: #{@billing_schedule}, custom_price: #{@custom_price},"\
110
+ " additional_properties: #{get_additional_properties}>"
101
111
  end
102
112
 
103
113
  # Provides a debugging-friendly string with detailed object information.
104
114
  def inspect
105
115
  class_name = self.class.name.split('::').last
106
116
  "<#{class_name} quantity: #{@quantity.inspect}, price_point_id: #{@price_point_id.inspect},"\
107
- " memo: #{@memo.inspect}, billing_schedule: #{@billing_schedule.inspect},"\
108
- " additional_properties: #{get_additional_properties}>"
117
+ " memo: #{@memo.inspect}, billing_schedule: #{@billing_schedule.inspect}, custom_price:"\
118
+ " #{@custom_price.inspect}, additional_properties: #{get_additional_properties}>"
109
119
  end
110
120
  end
111
121
  end
@@ -113,5 +113,49 @@ module AdvancedBilling
113
113
 
114
114
  CREDIT_CARD_VAULT.include?(value)
115
115
  end
116
+
117
+ def self.from_value(value, default_value = ADYEN)
118
+ return default_value if value.nil?
119
+
120
+ str = value.to_s.strip
121
+
122
+ case str.downcase
123
+ when 'adyen' then ADYEN
124
+ when 'authorizenet' then AUTHORIZENET
125
+ when 'beanstream' then BEANSTREAM
126
+ when 'blue_snap' then BLUE_SNAP
127
+ when 'bogus' then BOGUS
128
+ when 'braintree1' then BRAINTREE1
129
+ when 'braintree_blue' then BRAINTREE_BLUE
130
+ when 'checkout' then CHECKOUT
131
+ when 'cybersource' then CYBERSOURCE
132
+ when 'elavon' then ELAVON
133
+ when 'eway' then EWAY
134
+ when 'eway_rapid' then EWAY_RAPID
135
+ when 'eway_rapid_std' then EWAY_RAPID_STD
136
+ when 'firstdata' then FIRSTDATA
137
+ when 'forte' then FORTE
138
+ when 'litle' then LITLE
139
+ when 'maxio_payments' then MAXIO_PAYMENTS
140
+ when 'maxp' then MAXP
141
+ when 'moduslink' then MODUSLINK
142
+ when 'moneris' then MONERIS
143
+ when 'nmi' then NMI
144
+ when 'orbital' then ORBITAL
145
+ when 'payment_express' then PAYMENT_EXPRESS
146
+ when 'paymill' then PAYMILL
147
+ when 'paypal' then PAYPAL
148
+ when 'paypal_complete' then PAYPAL_COMPLETE
149
+ when 'pin' then PIN
150
+ when 'square' then SQUARE
151
+ when 'stripe' then STRIPE
152
+ when 'stripe_connect' then STRIPE_CONNECT
153
+ when 'trust_commerce' then TRUST_COMMERCE
154
+ when 'unipaas' then UNIPAAS
155
+ when 'wirecard' then WIRECARD
156
+ else
157
+ default_value
158
+ end
159
+ end
116
160
  end
117
161
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  CREDIT_NOTE_STATUS.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = OPEN)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'open' then OPEN
30
+ when 'applied' then APPLIED
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  CREDIT_SCHEME.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = NONE)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'none' then NONE
33
+ when 'credit' then CREDIT
34
+ when 'refund' then REFUND
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -24,5 +24,19 @@ module AdvancedBilling
24
24
 
25
25
  CREDIT_TYPE.include?(value)
26
26
  end
27
+
28
+ def self.from_value(value, default_value = FULL)
29
+ return default_value if value.nil?
30
+
31
+ str = value.to_s.strip
32
+
33
+ case str.downcase
34
+ when 'full' then FULL
35
+ when 'prorated' then PRORATED
36
+ when 'none' then NONE
37
+ else
38
+ default_value
39
+ end
40
+ end
27
41
  end
28
42
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  CURRENCY_PRICE_ROLE.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = BASELINE)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'baseline' then BASELINE
33
+ when 'trial' then TRIAL
34
+ when 'initial' then INITIAL
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
  CUSTOM_FIELD_OWNER.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 'subscription' then SUBSCRIPTION
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
  DEBIT_NOTE_ROLE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = CHARGEBACK)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'chargeback' then CHARGEBACK
30
+ when 'refund' then REFUND
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -25,5 +25,20 @@ module AdvancedBilling
25
25
 
26
26
  DEBIT_NOTE_STATUS.include?(value)
27
27
  end
28
+
29
+ def self.from_value(value, default_value = OPEN)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip
33
+
34
+ case str.downcase
35
+ when 'open' then OPEN
36
+ when 'applied' then APPLIED
37
+ when 'banished' then BANISHED
38
+ when 'paid' then PAID
39
+ else
40
+ default_value
41
+ end
42
+ end
28
43
  end
29
44
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  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
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  DISCOUNT_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = AMOUNT)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'amount' then AMOUNT
30
+ when 'percent' then PERCENT
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -66,8 +66,8 @@ module AdvancedBilling
66
66
  attr_accessor :unit_price
67
67
 
68
68
  # A string representing the tax code related to the component type. This is
69
- # especially important when using the Avalara service to tax based on
70
- # locale. This attribute has a max length of 10 characters.
69
+ # especially important when using AvaTax to tax based on locale. This
70
+ # attribute has a max length of 25 characters.
71
71
  # @return [String]
72
72
  attr_accessor :tax_code
73
73
 
@@ -260,5 +260,96 @@ module AdvancedBilling
260
260
 
261
261
  EVENT_KEY.include?(value)
262
262
  end
263
+
264
+ def self.from_value(value, default_value = PAYMENT_SUCCESS)
265
+ return default_value if value.nil?
266
+
267
+ str = value.to_s.strip
268
+
269
+ case str.downcase
270
+ when 'payment_success' then PAYMENT_SUCCESS
271
+ when 'payment_failure' then PAYMENT_FAILURE
272
+ when 'signup_success' then SIGNUP_SUCCESS
273
+ when 'signup_failure' then SIGNUP_FAILURE
274
+ when 'delayed_signup_creation_success' then DELAYED_SIGNUP_CREATION_SUCCESS
275
+ when 'delayed_signup_creation_failure' then DELAYED_SIGNUP_CREATION_FAILURE
276
+ when 'billing_date_change' then BILLING_DATE_CHANGE
277
+ when 'expiration_date_change' then EXPIRATION_DATE_CHANGE
278
+ when 'renewal_success' then RENEWAL_SUCCESS
279
+ when 'renewal_failure' then RENEWAL_FAILURE
280
+ when 'subscription_state_change' then SUBSCRIPTION_STATE_CHANGE
281
+ when 'subscription_product_change' then SUBSCRIPTION_PRODUCT_CHANGE
282
+ when 'pending_cancellation_change' then PENDING_CANCELLATION_CHANGE
283
+ when 'expiring_card' then EXPIRING_CARD
284
+ when 'customer_update' then CUSTOMER_UPDATE
285
+ when 'customer_create' then CUSTOMER_CREATE
286
+ when 'customer_delete' then CUSTOMER_DELETE
287
+ when 'component_allocation_change' then COMPONENT_ALLOCATION_CHANGE
288
+ when 'metered_usage' then METERED_USAGE
289
+ when 'prepaid_usage' then PREPAID_USAGE
290
+ when 'upgrade_downgrade_success' then UPGRADE_DOWNGRADE_SUCCESS
291
+ when 'upgrade_downgrade_failure' then UPGRADE_DOWNGRADE_FAILURE
292
+ when 'statement_closed' then STATEMENT_CLOSED
293
+ when 'statement_settled' then STATEMENT_SETTLED
294
+ when 'subscription_card_update' then SUBSCRIPTION_CARD_UPDATE
295
+ when 'subscription_group_card_update' then SUBSCRIPTION_GROUP_CARD_UPDATE
296
+ when 'subscription_bank_account_update' then SUBSCRIPTION_BANK_ACCOUNT_UPDATE
297
+ when 'refund_success' then REFUND_SUCCESS
298
+ when 'refund_failure' then REFUND_FAILURE
299
+ when 'upcoming_renewal_notice' then UPCOMING_RENEWAL_NOTICE
300
+ when 'trial_end_notice' then TRIAL_END_NOTICE
301
+ when 'dunning_step_reached' then DUNNING_STEP_REACHED
302
+ when 'invoice_issued' then INVOICE_ISSUED
303
+ when 'prepaid_subscription_balance_changed' then PREPAID_SUBSCRIPTION_BALANCE_CHANGED
304
+ when 'subscription_group_signup_success' then SUBSCRIPTION_GROUP_SIGNUP_SUCCESS
305
+ when 'subscription_group_signup_failure' then SUBSCRIPTION_GROUP_SIGNUP_FAILURE
306
+ when 'direct_debit_payment_paid_out' then DIRECT_DEBIT_PAYMENT_PAID_OUT
307
+ when 'direct_debit_payment_rejected' then DIRECT_DEBIT_PAYMENT_REJECTED
308
+ when 'direct_debit_payment_pending' then DIRECT_DEBIT_PAYMENT_PENDING
309
+ when 'pending_payment_created' then PENDING_PAYMENT_CREATED
310
+ when 'pending_payment_failed' then PENDING_PAYMENT_FAILED
311
+ when 'pending_payment_completed' then PENDING_PAYMENT_COMPLETED
312
+ when 'proforma_invoice_issued' then PROFORMA_INVOICE_ISSUED
313
+ when 'subscription_prepayment_account_balance_changed' then SUBSCRIPTION_PREPAYMENT_ACCOUNT_BALANCE_CHANGED
314
+ when 'subscription_service_credit_account_balance_changed' then SUBSCRIPTION_SERVICE_CREDIT_ACCOUNT_BALANCE_CHANGED
315
+ when 'custom_field_value_change' then CUSTOM_FIELD_VALUE_CHANGE
316
+ when 'item_price_point_changed' then ITEM_PRICE_POINT_CHANGED
317
+ when 'renewal_success_recreated' then RENEWAL_SUCCESS_RECREATED
318
+ when 'renewal_failure_recreated' then RENEWAL_FAILURE_RECREATED
319
+ when 'payment_success_recreated' then PAYMENT_SUCCESS_RECREATED
320
+ when 'payment_failure_recreated' then PAYMENT_FAILURE_RECREATED
321
+ when 'subscription_deletion' then SUBSCRIPTION_DELETION
322
+ when 'subscription_group_bank_account_update' then SUBSCRIPTION_GROUP_BANK_ACCOUNT_UPDATE
323
+ when 'subscription_paypal_account_update' then SUBSCRIPTION_PAYPAL_ACCOUNT_UPDATE
324
+ when 'subscription_group_paypal_account_update' then SUBSCRIPTION_GROUP_PAYPAL_ACCOUNT_UPDATE
325
+ when 'subscription_customer_change' then SUBSCRIPTION_CUSTOMER_CHANGE
326
+ when 'account_transaction_changed' then ACCOUNT_TRANSACTION_CHANGED
327
+ when 'go_cardless_payment_paid_out' then GO_CARDLESS_PAYMENT_PAID_OUT
328
+ when 'go_cardless_payment_rejected' then GO_CARDLESS_PAYMENT_REJECTED
329
+ when 'go_cardless_payment_pending' then GO_CARDLESS_PAYMENT_PENDING
330
+ when 'stripe_direct_debit_payment_paid_out' then STRIPE_DIRECT_DEBIT_PAYMENT_PAID_OUT
331
+ when 'stripe_direct_debit_payment_rejected' then STRIPE_DIRECT_DEBIT_PAYMENT_REJECTED
332
+ when 'stripe_direct_debit_payment_pending' then STRIPE_DIRECT_DEBIT_PAYMENT_PENDING
333
+ when 'maxio_payments_direct_debit_payment_paid_out' then MAXIO_PAYMENTS_DIRECT_DEBIT_PAYMENT_PAID_OUT
334
+ when 'maxio_payments_direct_debit_payment_rejected' then MAXIO_PAYMENTS_DIRECT_DEBIT_PAYMENT_REJECTED
335
+ when 'maxio_payments_direct_debit_payment_pending' then MAXIO_PAYMENTS_DIRECT_DEBIT_PAYMENT_PENDING
336
+ when 'invoice_in_collections_canceled' then INVOICE_IN_COLLECTIONS_CANCELED
337
+ when 'subscription_added_to_group' then SUBSCRIPTION_ADDED_TO_GROUP
338
+ when 'subscription_removed_from_group' then SUBSCRIPTION_REMOVED_FROM_GROUP
339
+ when 'chargeback_opened' then CHARGEBACK_OPENED
340
+ when 'chargeback_lost' then CHARGEBACK_LOST
341
+ when 'chargeback_accepted' then CHARGEBACK_ACCEPTED
342
+ when 'chargeback_closed' then CHARGEBACK_CLOSED
343
+ when 'chargeback_won' then CHARGEBACK_WON
344
+ when 'payment_collection_method_changed' then PAYMENT_COLLECTION_METHOD_CHANGED
345
+ when 'component_billing_date_changed' then COMPONENT_BILLING_DATE_CHANGED
346
+ when 'subscription_term_renewal_scheduled' then SUBSCRIPTION_TERM_RENEWAL_SCHEDULED
347
+ when 'subscription_term_renewal_pending' then SUBSCRIPTION_TERM_RENEWAL_PENDING
348
+ when 'subscription_term_renewal_activated' then SUBSCRIPTION_TERM_RENEWAL_ACTIVATED
349
+ when 'subscription_term_renewal_removed' then SUBSCRIPTION_TERM_RENEWAL_REMOVED
350
+ else
351
+ default_value
352
+ end
353
+ end
263
354
  end
264
355
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  EXPIRATION_INTERVAL_UNIT.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = DAY)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'day' then DAY
33
+ when 'month' then MONTH
34
+ when 'never' then NEVER
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -33,5 +33,19 @@ module AdvancedBilling
33
33
 
34
34
  FAILED_PAYMENT_ACTION.include?(value)
35
35
  end
36
+
37
+ def self.from_value(value, default_value = LEAVE_OPEN_INVOICE)
38
+ return default_value if value.nil?
39
+
40
+ str = value.to_s.strip
41
+
42
+ case str.downcase
43
+ when 'leave_open_invoice' then LEAVE_OPEN_INVOICE
44
+ when 'rollback_to_pending' then ROLLBACK_TO_PENDING
45
+ when 'initiate_dunning' then INITIATE_DUNNING
46
+ else
47
+ default_value
48
+ end
49
+ end
36
50
  end
37
51
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  FIRST_CHARGE_TYPE.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = PRORATED)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'prorated' then PRORATED
33
+ when 'immediate' then IMMEDIATE
34
+ when 'delayed' then DELAYED
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -28,5 +28,21 @@ module AdvancedBilling
28
28
 
29
29
  GROUP_TARGET_TYPE.include?(value)
30
30
  end
31
+
32
+ def self.from_value(value, default_value = CUSTOMER)
33
+ return default_value if value.nil?
34
+
35
+ str = value.to_s.strip
36
+
37
+ case str.downcase
38
+ when 'customer' then CUSTOMER
39
+ when 'subscription' then SUBSCRIPTION
40
+ when 'enum_self' then ENUM_SELF
41
+ when 'parent' then PARENT
42
+ when 'eldest' then ELDEST
43
+ else
44
+ default_value
45
+ end
46
+ end
31
47
  end
32
48
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  GROUP_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = SINGLE_CUSTOMER)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'single_customer' then SINGLE_CUSTOMER
30
+ when 'multiple_customers' then MULTIPLE_CUSTOMERS
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -16,5 +16,11 @@ module AdvancedBilling
16
16
 
17
17
  INCLUDE_NOT_NULL.include?(value)
18
18
  end
19
+
20
+ def self.from_value(value, default_value = NOT_NULL)
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
  INCLUDE_NULL_OR_NOT_NULL.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = NOT_NULL)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'not_null' then NOT_NULL
30
+ when 'null' then NULL
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
  INCLUDE_OPTION.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = EXCLUDE)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'exclude' then EXCLUDE
30
+ when 'include' then INCLUDE
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
  INTERVAL_UNIT.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = DAY)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'day' then DAY
30
+ when 'month' then MONTH
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -30,5 +30,19 @@ module AdvancedBilling
30
30
 
31
31
  INVOICE_CONSOLIDATION_LEVEL.include?(value)
32
32
  end
33
+
34
+ def self.from_value(value, default_value = NONE)
35
+ return default_value if value.nil?
36
+
37
+ str = value.to_s.strip
38
+
39
+ case str.downcase
40
+ when 'none' then NONE
41
+ when 'child' then CHILD
42
+ when 'parent' then PARENT
43
+ else
44
+ default_value
45
+ end
46
+ end
33
47
  end
34
48
  end
@@ -28,5 +28,21 @@ module AdvancedBilling
28
28
 
29
29
  INVOICE_DATE_FIELD.include?(value)
30
30
  end
31
+
32
+ def self.from_value(value, default_value = CREATED_AT)
33
+ return default_value if value.nil?
34
+
35
+ str = value.to_s.strip
36
+
37
+ case str.downcase
38
+ when 'created_at' then CREATED_AT
39
+ when 'due_date' then DUE_DATE
40
+ when 'issue_date' then ISSUE_DATE
41
+ when 'updated_at' then UPDATED_AT
42
+ when 'paid_date' then PAID_DATE
43
+ else
44
+ default_value
45
+ end
46
+ end
31
47
  end
32
48
  end
@@ -22,5 +22,19 @@ module AdvancedBilling
22
22
 
23
23
  INVOICE_DISCOUNT_SOURCE_TYPE.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = COUPON)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'coupon' then COUPON
33
+ when 'referral' then REFERRAL
34
+ when 'enum_ad_hoc_coupon' then ENUM_AD_HOC_COUPON
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end