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
@@ -6,30 +6,10 @@
6
6
  module AdvancedBilling
7
7
  # WebhooksController
8
8
  class WebhooksController < BaseController
9
- # ## Webhooks Intro
10
- # The Webhooks API allows you to view a list of all webhooks and to
11
- # selectively resend individual or groups of webhooks. Webhooks will be sent
12
- # on endpoints specified by you. Endpoints can be added via API or Web UI.
13
- # There is also an option to enable / disable webhooks via API request.
14
- # We recommend that you review Advanced Billing's webhook documentation
15
- # located in our help site. The following resources will help guide you on
16
- # how to use webhooks in Advanced Billing, in addition to these webhook
17
- # endpoints:
18
- # + [Adding/editing new
19
- # webhooks](https://maxio.zendesk.com/hc/en-us/articles/24286723085197-Webho
20
- # oks#configure-webhook-url)
21
- # + [Webhooks introduction and delivery
22
- # information](https://maxio.zendesk.com/hc/en-us/articles/24266143173901-We
23
- # bhooks-Overview)
24
- # + [Main webhook
25
- # reference](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webh
26
- # ooks-Reference)
27
- # + [Available webhooks and
28
- # payloads](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webho
29
- # oks-Reference#events)
30
- # ## List Webhooks for a Site
31
- # This method allows you to fetch data about webhooks. You can pass query
32
- # parameters if you want to filter webhooks.
9
+ # Allows you to view a list of webhooks. You can pass query parameters if
10
+ # you want to filter webhooks. See the
11
+ # [Webhooks](page:introduction/webhooks/webhooks) documentation for more
12
+ # information.
33
13
  # @param [WebhookStatus] status Optional parameter: Webhooks with matching
34
14
  # status would be returned.
35
15
  # @param [String] since_date Optional parameter: Format YYYY-MM-DD. Returns
@@ -75,7 +55,7 @@ module AdvancedBilling
75
55
  .execute
76
56
  end
77
57
 
78
- # This method allows you to enable webhooks via API for your site
58
+ # Allows you to enable webhooks for your site
79
59
  # @param [EnableWebhooksRequest] body Optional parameter: TODO: type
80
60
  # description here
81
61
  # @return [EnableWebhooksResponse] Response from the API call.
@@ -95,11 +75,10 @@ module AdvancedBilling
95
75
  .execute
96
76
  end
97
77
 
98
- # Posting to the replay endpoint does not immediately resend the webhooks.
99
- # They are added to a queue and will be sent as soon as possible, depending
100
- # on available system resources.
101
- # You may submit an array of up to 1000 webhook IDs to replay in the
102
- # request.
78
+ # Replays webhooks. Posting to this endpoint does not immediately resend the
79
+ # webhooks. They are added to a queue and sent as soon as possible,
80
+ # depending on available system resources. You can submit an array of up to
81
+ # 1000 webhook IDs in the replay request.
103
82
  # @param [ReplayWebhooksRequest] body Optional parameter: TODO: type
104
83
  # description here
105
84
  # @return [ReplayWebhooksResponse] Response from the API call.
@@ -119,12 +98,11 @@ module AdvancedBilling
119
98
  .execute
120
99
  end
121
100
 
122
- # The Chargify API allows you to create an endpoint and assign a list of
123
- # webhooks subscriptions (events) to it.
124
- # You can check available events here.
125
- # [Event
126
- # keys](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-
127
- # Reference#events)
101
+ # Creates an endpoint and assigns a list of webhooks subscriptions (events)
102
+ # to it.
103
+ # See the [Webhooks
104
+ # Reference](page:introduction/webhooks/webhooks-reference#events) page for
105
+ # available events.
128
106
  # @param [CreateOrUpdateEndpointRequest] body Optional parameter: TODO: type
129
107
  # description here
130
108
  # @return [EndpointResponse] Response from the API call.
@@ -148,7 +126,7 @@ module AdvancedBilling
148
126
  .execute
149
127
  end
150
128
 
151
- # This method returns created endpoints for site.
129
+ # Returns created endpoints for a site.
152
130
  # @return [Array[Endpoint]] Response from the API call.
153
131
  def list_endpoints
154
132
  @api_call
@@ -164,17 +142,14 @@ module AdvancedBilling
164
142
  .execute
165
143
  end
166
144
 
167
- # You can update an Endpoint via the API with a PUT request to the resource
168
- # endpoint.
169
- # You can change the `url` of your endpoint which consumes webhooks or list
170
- # of `webhook_subscriptions`.
171
- # Check available [Event
172
- # keys](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-
173
- # Reference#events).
174
- # Always send a complete list of events which you want subscribe/watch.
175
- # Sending an PUT request for existing endpoint with empty list of
176
- # `webhook_subscriptions` will end with unsubscribe from all events.
177
- # If you want unsubscribe from specific event, just send a list of
145
+ # Updates an Endpoint. You can change the `url` of your endpoint or the list
146
+ # of `webhook_subscriptions` to which you are subscribed. See the [Webhooks
147
+ # Reference](page:introduction/webhooks/webhooks-reference#events) page for
148
+ # available events.
149
+ # Always send a complete list of events to which you want to subscribe.
150
+ # Sending a PUT request for an existing endpoint with an empty list of
151
+ # `webhook_subscriptions` will unsubscribe all events.
152
+ # If you want unsubscribe from a specific event, send a list of
178
153
  # `webhook_subscriptions` without the specific event key.
179
154
  # @param [Integer] endpoint_id Required parameter: The Advanced Billing id
180
155
  # for the endpoint that should be updated
@@ -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
@@ -0,0 +1,22 @@
1
+ # advanced_billing
2
+ #
3
+ # This file was automatically generated for Maxio by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module AdvancedBilling
7
+ ##
8
+ # ProxySettings encapsulates HTTP proxy configuration for Faraday,
9
+ # including optional basic authentication.
10
+ #
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
21
+ end
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