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
@@ -40,6 +40,18 @@ module AdvancedBilling
40
40
  @password = password
41
41
  end
42
42
 
43
+ def self.from_env
44
+ username = ENV['USERNAME']
45
+ password = ENV['PASSWORD']
46
+ all_nil = [
47
+ username,
48
+ password
49
+ ].all?(&:nil?)
50
+ return nil if all_nil
51
+
52
+ new(username: username, password: password)
53
+ end
54
+
43
55
  def clone_with(username: nil, password: nil)
44
56
  username ||= self.username
45
57
  password ||= self.password
@@ -9,5 +9,14 @@ module AdvancedBilling
9
9
  # including optional basic authentication.
10
10
  #
11
11
  class ProxySettings < CoreLibrary::ProxySettings
12
+ def self.from_env
13
+ address = ENV['PROXY_ADDRESS']
14
+ port = ENV['PROXY_PORT']
15
+ username = ENV['PROXY_USERNAME']
16
+ password = ENV['PROXY_PASSWORD']
17
+ return nil if address.nil? || address.strip.empty?
18
+
19
+ new(address: address, port: port, username: username, password: password)
20
+ end
12
21
  end
13
22
  end
@@ -15,8 +15,7 @@ module AdvancedBilling
15
15
 
16
16
  # This attribute is particularly useful when you need to align billing
17
17
  # events for different components on distinct schedules within a
18
- # subscription. Please note this only works for site with Multifrequency
19
- # enabled
18
+ # subscription. This only works for site with Multifrequency enabled.
20
19
  # @return [BillingSchedule]
21
20
  attr_accessor :billing_schedule
22
21
 
@@ -116,5 +116,50 @@ module AdvancedBilling
116
116
 
117
117
  ALL_VAULTS.include?(value)
118
118
  end
119
+
120
+ def self.from_value(value, default_value = ADYEN)
121
+ return default_value if value.nil?
122
+
123
+ str = value.to_s.strip
124
+
125
+ case str.downcase
126
+ when 'adyen' then ADYEN
127
+ when 'authorizenet' then AUTHORIZENET
128
+ when 'beanstream' then BEANSTREAM
129
+ when 'blue_snap' then BLUE_SNAP
130
+ when 'bogus' then BOGUS
131
+ when 'braintree1' then BRAINTREE1
132
+ when 'braintree_blue' then BRAINTREE_BLUE
133
+ when 'checkout' then CHECKOUT
134
+ when 'cybersource' then CYBERSOURCE
135
+ when 'elavon' then ELAVON
136
+ when 'eway' then EWAY
137
+ when 'eway_rapid' then EWAY_RAPID
138
+ when 'eway_rapid_std' then EWAY_RAPID_STD
139
+ when 'firstdata' then FIRSTDATA
140
+ when 'forte' then FORTE
141
+ when 'gocardless' then GOCARDLESS
142
+ when 'litle' then LITLE
143
+ when 'maxio_payments' then MAXIO_PAYMENTS
144
+ when 'maxp' then MAXP
145
+ when 'moduslink' then MODUSLINK
146
+ when 'moneris' then MONERIS
147
+ when 'nmi' then NMI
148
+ when 'orbital' then ORBITAL
149
+ when 'payment_express' then PAYMENT_EXPRESS
150
+ when 'paymill' then PAYMILL
151
+ when 'paypal' then PAYPAL
152
+ when 'paypal_complete' then PAYPAL_COMPLETE
153
+ when 'pin' then PIN
154
+ when 'square' then SQUARE
155
+ when 'stripe' then STRIPE
156
+ when 'stripe_connect' then STRIPE_CONNECT
157
+ when 'trust_commerce' then TRUST_COMMERCE
158
+ when 'unipaas' then UNIPAAS
159
+ when 'wirecard' then WIRECARD
160
+ else
161
+ default_value
162
+ end
163
+ end
119
164
  end
120
165
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  ALLOCATION_PREVIEW_DIRECTION.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = UPGRADE)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'upgrade' then UPGRADE
30
+ when 'downgrade' then DOWNGRADE
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
  ALLOCATION_PREVIEW_LINE_ITEM_KIND.include?(value)
27
27
  end
28
+
29
+ def self.from_value(value, default_value = QUANTITY_BASED_COMPONENT)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip
33
+
34
+ case str.downcase
35
+ when 'quantity_based_component' then QUANTITY_BASED_COMPONENT
36
+ when 'on_off_component' then ON_OFF_COMPONENT
37
+ when 'coupon' then COUPON
38
+ when 'tax' then TAX
39
+ else
40
+ default_value
41
+ end
42
+ end
28
43
  end
29
44
  end
@@ -16,5 +16,11 @@ module AdvancedBilling
16
16
 
17
17
  APPLE_PAY_VAULT.include?(value)
18
18
  end
19
+
20
+ def self.from_value(value, default_value = BRAINTREE_BLUE)
21
+ return default_value if value.nil?
22
+
23
+ default_value
24
+ end
19
25
  end
20
26
  end
@@ -19,5 +19,24 @@ module AdvancedBilling
19
19
 
20
20
  AUTO_INVITE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = NO)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+ if str.match?(/\A\d+\z/)
28
+ num = str.to_i
29
+ return num if AUTO_INVITE.include?(num)
30
+
31
+ return default_value
32
+ end
33
+
34
+ case str.downcase
35
+ when 'no' then NO
36
+ when 'yes' then YES
37
+ else
38
+ default_value
39
+ end
40
+ end
22
41
  end
23
42
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  BANK_ACCOUNT_HOLDER_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = PERSONAL)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'personal' then PERSONAL
30
+ when 'business' then BUSINESS
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
  BANK_ACCOUNT_TYPE.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = CHECKING)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'checking' then CHECKING
30
+ when 'savings' then SAVINGS
31
+ else
32
+ default_value
33
+ end
34
+ end
22
35
  end
23
36
  end
@@ -38,5 +38,24 @@ module AdvancedBilling
38
38
 
39
39
  BANK_ACCOUNT_VAULT.include?(value)
40
40
  end
41
+
42
+ def self.from_value(value, default_value = AUTHORIZENET)
43
+ return default_value if value.nil?
44
+
45
+ str = value.to_s.strip
46
+
47
+ case str.downcase
48
+ when 'authorizenet' then AUTHORIZENET
49
+ when 'blue_snap' then BLUE_SNAP
50
+ when 'bogus' then BOGUS
51
+ when 'forte' then FORTE
52
+ when 'gocardless' then GOCARDLESS
53
+ when 'maxio_payments' then MAXIO_PAYMENTS
54
+ when 'maxp' then MAXP
55
+ when 'stripe_connect' then STRIPE_CONNECT
56
+ else
57
+ default_value
58
+ end
59
+ end
41
60
  end
42
61
  end
@@ -19,5 +19,18 @@ module AdvancedBilling
19
19
 
20
20
  BASIC_DATE_FIELD.include?(value)
21
21
  end
22
+
23
+ def self.from_value(value, default_value = UPDATED_AT)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'updated_at' then UPDATED_AT
30
+ when 'created_at' then CREATED_AT
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
  BILLING_MANIFEST_LINE_ITEM_KIND.include?(value)
33
33
  end
34
+
35
+ def self.from_value(value, default_value = BASELINE)
36
+ return default_value if value.nil?
37
+
38
+ str = value.to_s.strip
39
+
40
+ case str.downcase
41
+ when 'baseline' then BASELINE
42
+ when 'initial' then INITIAL
43
+ when 'trial' then TRIAL
44
+ when 'coupon' then COUPON
45
+ when 'component' then COMPONENT
46
+ when 'tax' then TAX
47
+ else
48
+ default_value
49
+ end
50
+ end
34
51
  end
35
52
  end
@@ -5,8 +5,8 @@
5
5
 
6
6
  module AdvancedBilling
7
7
  # This attribute is particularly useful when you need to align billing events
8
- # for different components on distinct schedules within a subscription. Please
9
- # note this only works for site with Multifrequency enabled
8
+ # for different components on distinct schedules within a subscription. This
9
+ # only works for site with Multifrequency enabled.
10
10
  class BillingSchedule < BaseModel
11
11
  SKIP = Object.new
12
12
  private_constant :SKIP
@@ -38,7 +38,9 @@ module AdvancedBilling
38
38
 
39
39
  # An array for nullable fields
40
40
  def self.nullables
41
- []
41
+ %w[
42
+ snap_day
43
+ ]
42
44
  end
43
45
 
44
46
  def initialize(snap_day: SKIP, calendar_billing_first_charge: SKIP,
@@ -32,5 +32,22 @@ module AdvancedBilling
32
32
 
33
33
  CANCELLATION_METHOD.include?(value)
34
34
  end
35
+
36
+ def self.from_value(value, default_value = MERCHANT_UI)
37
+ return default_value if value.nil?
38
+
39
+ str = value.to_s.strip
40
+
41
+ case str.downcase
42
+ when 'merchant_ui' then MERCHANT_UI
43
+ when 'merchant_api' then MERCHANT_API
44
+ when 'dunning' then DUNNING
45
+ when 'billing_portal' then BILLING_PORTAL
46
+ when 'unknown' then UNKNOWN
47
+ when 'imported' then IMPORTED
48
+ else
49
+ default_value
50
+ end
51
+ end
35
52
  end
36
53
  end
@@ -121,5 +121,52 @@ module AdvancedBilling
121
121
 
122
122
  CARD_TYPE.include?(value)
123
123
  end
124
+
125
+ def self.from_value(value, default_value = VISA)
126
+ return default_value if value.nil?
127
+
128
+ str = value.to_s.strip
129
+
130
+ case str.downcase
131
+ when 'visa' then VISA
132
+ when 'master' then MASTER
133
+ when 'elo' then ELO
134
+ when 'cabal' then CABAL
135
+ when 'alelo' then ALELO
136
+ when 'discover' then DISCOVER
137
+ when 'american_express' then AMERICAN_EXPRESS
138
+ when 'naranja' then NARANJA
139
+ when 'diners_club' then DINERS_CLUB
140
+ when 'jcb' then JCB
141
+ when 'dankort' then DANKORT
142
+ when 'maestro' then MAESTRO
143
+ when 'maestro_no_luhn' then MAESTRO_NO_LUHN
144
+ when 'forbrugsforeningen' then FORBRUGSFORENINGEN
145
+ when 'sodexo' then SODEXO
146
+ when 'alia' then ALIA
147
+ when 'vr' then VR
148
+ when 'unionpay' then UNIONPAY
149
+ when 'carnet' then CARNET
150
+ when 'cartes_bancaires' then CARTES_BANCAIRES
151
+ when 'olimpica' then OLIMPICA
152
+ when 'creditel' then CREDITEL
153
+ when 'confiable' then CONFIABLE
154
+ when 'synchrony' then SYNCHRONY
155
+ when 'routex' then ROUTEX
156
+ when 'mada' then MADA
157
+ when 'bp_plus' then BP_PLUS
158
+ when 'passcard' then PASSCARD
159
+ when 'edenred' then EDENRED
160
+ when 'anda' then ANDA
161
+ when 'tarjetad' then TARJETAD
162
+ when 'hipercard' then HIPERCARD
163
+ when 'bogus' then BOGUS
164
+ when 'switch' then SWITCH
165
+ when 'solo' then SOLO
166
+ when 'laser' then LASER
167
+ else
168
+ default_value
169
+ end
170
+ end
124
171
  end
125
172
  end
@@ -25,5 +25,20 @@ module AdvancedBilling
25
25
 
26
26
  CHARGEBACK_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 'lost' then LOST
37
+ when 'won' then WON
38
+ when 'closed' then CLOSED
39
+ else
40
+ default_value
41
+ end
42
+ end
28
43
  end
29
44
  end
@@ -16,14 +16,14 @@ module AdvancedBilling
16
16
  # @return [DateTime]
17
17
  attr_accessor :timestamp
18
18
 
19
- # A unique ID set by Chargify. Please note that this field is reserved. If
20
- # `chargify.id` is present in the request payload, it will be overwritten.
19
+ # A unique ID set by Chargify. This field is reserved. If `chargify.id` is
20
+ # present in the request payload, it will be overwritten.
21
21
  # @return [String]
22
22
  attr_accessor :id
23
23
 
24
24
  # An ISO-8601 timestamp, set by Chargify at the time each event is recorded.
25
- # Please note that this field is reserved. If `chargify.created_at` is
26
- # present in the request payload, it will be overwritten.
25
+ # This field is reserved. If `chargify.created_at` is present in the request
26
+ # payload, it will be overwritten.
27
27
  # @return [DateTime]
28
28
  attr_accessor :created_at
29
29
 
@@ -22,5 +22,18 @@ module AdvancedBilling
22
22
 
23
23
  CLEANUP_SCOPE.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = ALL)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'all' then ALL
33
+ when 'customers' then CUSTOMERS
34
+ else
35
+ default_value
36
+ end
37
+ end
25
38
  end
26
39
  end
@@ -28,5 +28,20 @@ module AdvancedBilling
28
28
 
29
29
  COLLECTION_METHOD.include?(value)
30
30
  end
31
+
32
+ def self.from_value(value, default_value = AUTOMATIC)
33
+ return default_value if value.nil?
34
+
35
+ str = value.to_s.strip
36
+
37
+ case str.downcase
38
+ when 'automatic' then AUTOMATIC
39
+ when 'remittance' then REMITTANCE
40
+ when 'prepaid' then PREPAID
41
+ when 'invoice' then INVOICE
42
+ else
43
+ default_value
44
+ end
45
+ end
31
46
  end
32
47
  end
@@ -62,10 +62,6 @@ module AdvancedBilling
62
62
  # @return [TrueClass | FalseClass]
63
63
  attr_accessor :archived
64
64
 
65
- # Boolean flag describing whether a component is taxable or not.
66
- # @return [TrueClass | FalseClass]
67
- attr_accessor :taxable
68
-
69
65
  # The description of the component.
70
66
  # @return [String]
71
67
  attr_accessor :description
@@ -98,15 +94,19 @@ module AdvancedBilling
98
94
  # @return [String]
99
95
  attr_accessor :default_price_point_name
100
96
 
97
+ # Boolean flag describing whether a component is taxable or not.
98
+ # @return [TrueClass | FalseClass]
99
+ attr_accessor :taxable
100
+
101
101
  # A string representing the tax code related to the component type. This is
102
- # especially important when using the Avalara service to tax based on
103
- # locale. This attribute has a max length of 10 characters.
102
+ # especially important when using AvaTax to tax based on locale. This
103
+ # attribute has a max length of 25 characters.
104
104
  # @return [String]
105
105
  attr_accessor :tax_code
106
106
 
107
107
  # A string representing the tax code related to the component type. This is
108
- # especially important when using the Avalara service to tax based on
109
- # locale. This attribute has a max length of 10 characters.
108
+ # especially important when using AvaTax to tax based on locale. This
109
+ # attribute has a max length of 25 characters.
110
110
  # @return [TrueClass | FalseClass]
111
111
  attr_accessor :recurring
112
112
 
@@ -193,7 +193,6 @@ module AdvancedBilling
193
193
  @_hash['price_per_unit_in_cents'] = 'price_per_unit_in_cents'
194
194
  @_hash['kind'] = 'kind'
195
195
  @_hash['archived'] = 'archived'
196
- @_hash['taxable'] = 'taxable'
197
196
  @_hash['description'] = 'description'
198
197
  @_hash['default_price_point_id'] = 'default_price_point_id'
199
198
  @_hash['overage_prices'] = 'overage_prices'
@@ -201,6 +200,7 @@ module AdvancedBilling
201
200
  @_hash['price_point_count'] = 'price_point_count'
202
201
  @_hash['price_points_url'] = 'price_points_url'
203
202
  @_hash['default_price_point_name'] = 'default_price_point_name'
203
+ @_hash['taxable'] = 'taxable'
204
204
  @_hash['tax_code'] = 'tax_code'
205
205
  @_hash['recurring'] = 'recurring'
206
206
  @_hash['upgrade_charge'] = 'upgrade_charge'
@@ -235,7 +235,6 @@ module AdvancedBilling
235
235
  price_per_unit_in_cents
236
236
  kind
237
237
  archived
238
- taxable
239
238
  description
240
239
  default_price_point_id
241
240
  overage_prices
@@ -243,6 +242,7 @@ module AdvancedBilling
243
242
  price_point_count
244
243
  price_points_url
245
244
  default_price_point_name
245
+ taxable
246
246
  tax_code
247
247
  recurring
248
248
  upgrade_charge
@@ -288,13 +288,13 @@ module AdvancedBilling
288
288
  unit_name: SKIP, unit_price: SKIP, product_family_id: SKIP,
289
289
  product_family_name: SKIP, product_family_handle: SKIP,
290
290
  price_per_unit_in_cents: SKIP, kind: SKIP, archived: SKIP,
291
- taxable: SKIP, description: SKIP,
292
- default_price_point_id: SKIP, overage_prices: SKIP,
293
- prices: SKIP, price_point_count: SKIP,
291
+ description: SKIP, default_price_point_id: SKIP,
292
+ overage_prices: SKIP, prices: SKIP, price_point_count: SKIP,
294
293
  price_points_url: SKIP, default_price_point_name: SKIP,
295
- tax_code: SKIP, recurring: SKIP, upgrade_charge: SKIP,
296
- downgrade_credit: SKIP, created_at: SKIP, updated_at: SKIP,
297
- archived_at: SKIP, hide_date_range_on_invoice: SKIP,
294
+ taxable: SKIP, tax_code: SKIP, recurring: SKIP,
295
+ upgrade_charge: SKIP, downgrade_credit: SKIP,
296
+ created_at: SKIP, updated_at: SKIP, archived_at: SKIP,
297
+ hide_date_range_on_invoice: SKIP,
298
298
  allow_fractional_quantities: SKIP, item_category: SKIP,
299
299
  use_site_exchange_rate: SKIP, accounting_code: SKIP,
300
300
  event_based_billing_metric_id: SKIP, interval: SKIP,
@@ -316,7 +316,6 @@ module AdvancedBilling
316
316
  @price_per_unit_in_cents = price_per_unit_in_cents unless price_per_unit_in_cents == SKIP
317
317
  @kind = kind unless kind == SKIP
318
318
  @archived = archived unless archived == SKIP
319
- @taxable = taxable unless taxable == SKIP
320
319
  @description = description unless description == SKIP
321
320
  @default_price_point_id = default_price_point_id unless default_price_point_id == SKIP
322
321
  @overage_prices = overage_prices unless overage_prices == SKIP
@@ -324,6 +323,7 @@ module AdvancedBilling
324
323
  @price_point_count = price_point_count unless price_point_count == SKIP
325
324
  @price_points_url = price_points_url unless price_points_url == SKIP
326
325
  @default_price_point_name = default_price_point_name unless default_price_point_name == SKIP
326
+ @taxable = taxable unless taxable == SKIP
327
327
  @tax_code = tax_code unless tax_code == SKIP
328
328
  @recurring = recurring unless recurring == SKIP
329
329
  @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP
@@ -372,7 +372,6 @@ module AdvancedBilling
372
372
  hash.key?('price_per_unit_in_cents') ? hash['price_per_unit_in_cents'] : SKIP
373
373
  kind = hash.key?('kind') ? hash['kind'] : SKIP
374
374
  archived = hash.key?('archived') ? hash['archived'] : SKIP
375
- taxable = hash.key?('taxable') ? hash['taxable'] : SKIP
376
375
  description = hash.key?('description') ? hash['description'] : SKIP
377
376
  default_price_point_id =
378
377
  hash.key?('default_price_point_id') ? hash['default_price_point_id'] : SKIP
@@ -402,6 +401,7 @@ module AdvancedBilling
402
401
  hash.key?('price_points_url') ? hash['price_points_url'] : SKIP
403
402
  default_price_point_name =
404
403
  hash.key?('default_price_point_name') ? hash['default_price_point_name'] : SKIP
404
+ taxable = hash.key?('taxable') ? hash['taxable'] : SKIP
405
405
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP
406
406
  recurring = hash.key?('recurring') ? hash['recurring'] : SKIP
407
407
  upgrade_charge =
@@ -453,7 +453,6 @@ module AdvancedBilling
453
453
  price_per_unit_in_cents: price_per_unit_in_cents,
454
454
  kind: kind,
455
455
  archived: archived,
456
- taxable: taxable,
457
456
  description: description,
458
457
  default_price_point_id: default_price_point_id,
459
458
  overage_prices: overage_prices,
@@ -461,6 +460,7 @@ module AdvancedBilling
461
460
  price_point_count: price_point_count,
462
461
  price_points_url: price_points_url,
463
462
  default_price_point_name: default_price_point_name,
463
+ taxable: taxable,
464
464
  tax_code: tax_code,
465
465
  recurring: recurring,
466
466
  upgrade_charge: upgrade_charge,
@@ -498,13 +498,13 @@ module AdvancedBilling
498
498
  " #{@pricing_scheme}, unit_name: #{@unit_name}, unit_price: #{@unit_price},"\
499
499
  " product_family_id: #{@product_family_id}, product_family_name: #{@product_family_name},"\
500
500
  " product_family_handle: #{@product_family_handle}, price_per_unit_in_cents:"\
501
- " #{@price_per_unit_in_cents}, kind: #{@kind}, archived: #{@archived}, taxable: #{@taxable},"\
502
- " description: #{@description}, default_price_point_id: #{@default_price_point_id},"\
503
- " overage_prices: #{@overage_prices}, prices: #{@prices}, price_point_count:"\
504
- " #{@price_point_count}, price_points_url: #{@price_points_url}, default_price_point_name:"\
505
- " #{@default_price_point_name}, tax_code: #{@tax_code}, recurring: #{@recurring},"\
506
- " upgrade_charge: #{@upgrade_charge}, downgrade_credit: #{@downgrade_credit}, created_at:"\
507
- " #{@created_at}, updated_at: #{@updated_at}, archived_at: #{@archived_at},"\
501
+ " #{@price_per_unit_in_cents}, kind: #{@kind}, archived: #{@archived}, description:"\
502
+ " #{@description}, default_price_point_id: #{@default_price_point_id}, overage_prices:"\
503
+ " #{@overage_prices}, prices: #{@prices}, price_point_count: #{@price_point_count},"\
504
+ " price_points_url: #{@price_points_url}, default_price_point_name:"\
505
+ " #{@default_price_point_name}, taxable: #{@taxable}, tax_code: #{@tax_code}, recurring:"\
506
+ " #{@recurring}, upgrade_charge: #{@upgrade_charge}, downgrade_credit: #{@downgrade_credit},"\
507
+ " created_at: #{@created_at}, updated_at: #{@updated_at}, archived_at: #{@archived_at},"\
508
508
  " hide_date_range_on_invoice: #{@hide_date_range_on_invoice}, allow_fractional_quantities:"\
509
509
  " #{@allow_fractional_quantities}, item_category: #{@item_category}, use_site_exchange_rate:"\
510
510
  " #{@use_site_exchange_rate}, accounting_code: #{@accounting_code},"\
@@ -521,11 +521,11 @@ module AdvancedBilling
521
521
  " product_family_name: #{@product_family_name.inspect}, product_family_handle:"\
522
522
  " #{@product_family_handle.inspect}, price_per_unit_in_cents:"\
523
523
  " #{@price_per_unit_in_cents.inspect}, kind: #{@kind.inspect}, archived:"\
524
- " #{@archived.inspect}, taxable: #{@taxable.inspect}, description: #{@description.inspect},"\
525
- " default_price_point_id: #{@default_price_point_id.inspect}, overage_prices:"\
526
- " #{@overage_prices.inspect}, prices: #{@prices.inspect}, price_point_count:"\
527
- " #{@price_point_count.inspect}, price_points_url: #{@price_points_url.inspect},"\
528
- " default_price_point_name: #{@default_price_point_name.inspect}, tax_code:"\
524
+ " #{@archived.inspect}, description: #{@description.inspect}, default_price_point_id:"\
525
+ " #{@default_price_point_id.inspect}, overage_prices: #{@overage_prices.inspect}, prices:"\
526
+ " #{@prices.inspect}, price_point_count: #{@price_point_count.inspect}, price_points_url:"\
527
+ " #{@price_points_url.inspect}, default_price_point_name:"\
528
+ " #{@default_price_point_name.inspect}, taxable: #{@taxable.inspect}, tax_code:"\
529
529
  " #{@tax_code.inspect}, recurring: #{@recurring.inspect}, upgrade_charge:"\
530
530
  " #{@upgrade_charge.inspect}, downgrade_credit: #{@downgrade_credit.inspect}, created_at:"\
531
531
  " #{@created_at.inspect}, updated_at: #{@updated_at.inspect}, archived_at:"\