Class: AdvancedBilling::Client

Inherits:
Object
  • Object
show all
Includes:
CoreLibrary
Defined in:
lib/advanced_billing/client.rb

Overview

advanced_billing client class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection: nil, adapter: :net_http_persistent, timeout: 120, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::PRODUCTION, subdomain: 'subdomain', domain: 'chargify.com', basic_auth_credentials: nil, config: nil) ⇒ Client

Returns a new instance of Client.



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/advanced_billing/client.rb', line 204

def initialize(
  connection: nil, adapter: :net_http_persistent, timeout: 120,
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
  retry_methods: %i[get put], http_callback: nil,
  environment: Environment::PRODUCTION, subdomain: 'subdomain',
  domain: 'chargify.com', basic_auth_credentials: nil, config: nil
)
  @config = if config.nil?
              Configuration.new(
                connection: connection, adapter: adapter, timeout: timeout,
                max_retries: max_retries, retry_interval: retry_interval,
                backoff_factor: backoff_factor,
                retry_statuses: retry_statuses,
                retry_methods: retry_methods, http_callback: http_callback,
                environment: environment, subdomain: subdomain,
                domain: domain,
                basic_auth_credentials: basic_auth_credentials
              )
            else
              config
            end
  user_agent_params = BaseController.user_agent_parameters

  @global_configuration = GlobalConfiguration.new(client_configuration: @config)
                                             .base_uri_executor(@config.method(:get_base_uri))
                                             .global_errors(BaseController::GLOBAL_ERRORS)
                                             .user_agent(BaseController.user_agent,
                                                         agent_parameters: user_agent_params)

  initialize_auth_managers(@global_configuration)
  @global_configuration = @global_configuration.auth_managers(@auth_managers)
end

Instance Attribute Details

#auth_managersObject (readonly)

Returns the value of attribute auth_managers.



10
11
12
# File 'lib/advanced_billing/client.rb', line 10

def auth_managers
  @auth_managers
end

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/advanced_billing/client.rb', line 10

def config
  @config
end

Instance Method Details

#advance_invoiceAdvanceInvoiceController

Access to advance_invoice controller.

Returns:



20
21
22
# File 'lib/advanced_billing/client.rb', line 20

def advance_invoice
  @advance_invoice ||= AdvanceInvoiceController.new @global_configuration
end

#api_exportsAPIExportsController

Access to api_exports controller.

Returns:



14
15
16
# File 'lib/advanced_billing/client.rb', line 14

def api_exports
  @api_exports ||= APIExportsController.new @global_configuration
end

#billing_portalBillingPortalController

Access to billing_portal controller.

Returns:



26
27
28
# File 'lib/advanced_billing/client.rb', line 26

def billing_portal
  @billing_portal ||= BillingPortalController.new @global_configuration
end

#component_price_pointsComponentPricePointsController

Access to component_price_points controller.

Returns:



44
45
46
# File 'lib/advanced_billing/client.rb', line 44

def component_price_points
  @component_price_points ||= ComponentPricePointsController.new @global_configuration
end

#componentsComponentsController

Access to components controller.

Returns:



38
39
40
# File 'lib/advanced_billing/client.rb', line 38

def components
  @components ||= ComponentsController.new @global_configuration
end

#couponsCouponsController

Access to coupons controller.

Returns:



32
33
34
# File 'lib/advanced_billing/client.rb', line 32

def coupons
  @coupons ||= CouponsController.new @global_configuration
end

#custom_fieldsCustomFieldsController

Access to custom_fields controller.

Returns:



56
57
58
# File 'lib/advanced_billing/client.rb', line 56

def custom_fields
  @custom_fields ||= CustomFieldsController.new @global_configuration
end

#customersCustomersController

Access to customers controller.

Returns:



50
51
52
# File 'lib/advanced_billing/client.rb', line 50

def customers
  @customers ||= CustomersController.new @global_configuration
end

#eventsEventsController

Access to events controller.

Returns:



62
63
64
# File 'lib/advanced_billing/client.rb', line 62

def events
  @events ||= EventsController.new @global_configuration
end

#events_based_billing_segmentsEventsBasedBillingSegmentsController

Access to events_based_billing_segments controller.

Returns:



68
69
70
# File 'lib/advanced_billing/client.rb', line 68

def events_based_billing_segments
  @events_based_billing_segments ||= EventsBasedBillingSegmentsController.new @global_configuration
end

#initialize_auth_managers(global_config) ⇒ Object

Initializes the auth managers hash used for authenticating API calls.

Parameters:

  • global_config (GlobalConfiguration)

    The global configuration of the SDK)



240
241
242
243
244
245
# File 'lib/advanced_billing/client.rb', line 240

def initialize_auth_managers(global_config)
  @auth_managers = {}
  http_client_config = global_config.client_configuration
  %w[BasicAuth].each { |auth| @auth_managers[auth] = nil }
  @auth_managers['BasicAuth'] = BasicAuth.new(http_client_config.basic_auth_credentials)
end

#insightsInsightsController

Access to insights controller.

Returns:



74
75
76
# File 'lib/advanced_billing/client.rb', line 74

def insights
  @insights ||= InsightsController.new @global_configuration
end

#invoicesInvoicesController

Access to invoices controller.

Returns:



80
81
82
# File 'lib/advanced_billing/client.rb', line 80

def invoices
  @invoices ||= InvoicesController.new @global_configuration
end

#offersOffersController

Access to offers controller.

Returns:



86
87
88
# File 'lib/advanced_billing/client.rb', line 86

def offers
  @offers ||= OffersController.new @global_configuration
end

#payment_profilesPaymentProfilesController

Access to payment_profiles controller.

Returns:



92
93
94
# File 'lib/advanced_billing/client.rb', line 92

def payment_profiles
  @payment_profiles ||= PaymentProfilesController.new @global_configuration
end

#product_familiesProductFamiliesController

Access to product_families controller.

Returns:



98
99
100
# File 'lib/advanced_billing/client.rb', line 98

def product_families
  @product_families ||= ProductFamiliesController.new @global_configuration
end

#product_price_pointsProductPricePointsController

Access to product_price_points controller.

Returns:



110
111
112
# File 'lib/advanced_billing/client.rb', line 110

def product_price_points
  @product_price_points ||= ProductPricePointsController.new @global_configuration
end

#productsProductsController

Access to products controller.

Returns:



104
105
106
# File 'lib/advanced_billing/client.rb', line 104

def products
  @products ||= ProductsController.new @global_configuration
end

#proforma_invoicesProformaInvoicesController

Access to proforma_invoices controller.

Returns:



116
117
118
# File 'lib/advanced_billing/client.rb', line 116

def proforma_invoices
  @proforma_invoices ||= ProformaInvoicesController.new @global_configuration
end

#reason_codesReasonCodesController

Access to reason_codes controller.

Returns:



122
123
124
# File 'lib/advanced_billing/client.rb', line 122

def reason_codes
  @reason_codes ||= ReasonCodesController.new @global_configuration
end

#referral_codesReferralCodesController

Access to referral_codes controller.

Returns:



128
129
130
# File 'lib/advanced_billing/client.rb', line 128

def referral_codes
  @referral_codes ||= ReferralCodesController.new @global_configuration
end

#sales_commissionsSalesCommissionsController

Access to sales_commissions controller.

Returns:



134
135
136
# File 'lib/advanced_billing/client.rb', line 134

def sales_commissions
  @sales_commissions ||= SalesCommissionsController.new @global_configuration
end

#sitesSitesController

Access to sites controller.

Returns:



140
141
142
# File 'lib/advanced_billing/client.rb', line 140

def sites
  @sites ||= SitesController.new @global_configuration
end

#subscription_componentsSubscriptionComponentsController

Access to subscription_components controller.

Returns:



152
153
154
# File 'lib/advanced_billing/client.rb', line 152

def subscription_components
  @subscription_components ||= SubscriptionComponentsController.new @global_configuration
end

#subscription_group_invoice_accountSubscriptionGroupInvoiceAccountController

Access to subscription_group_invoice_account controller.

Returns:



164
165
166
# File 'lib/advanced_billing/client.rb', line 164

def 
  @subscription_group_invoice_account ||= SubscriptionGroupInvoiceAccountController.new @global_configuration
end

#subscription_group_statusSubscriptionGroupStatusController

Access to subscription_group_status controller.

Returns:



170
171
172
# File 'lib/advanced_billing/client.rb', line 170

def subscription_group_status
  @subscription_group_status ||= SubscriptionGroupStatusController.new @global_configuration
end

#subscription_groupsSubscriptionGroupsController

Access to subscription_groups controller.

Returns:



158
159
160
# File 'lib/advanced_billing/client.rb', line 158

def subscription_groups
  @subscription_groups ||= SubscriptionGroupsController.new @global_configuration
end

#subscription_invoice_accountSubscriptionInvoiceAccountController

Access to subscription_invoice_account controller.

Returns:



176
177
178
# File 'lib/advanced_billing/client.rb', line 176

def 
  @subscription_invoice_account ||= SubscriptionInvoiceAccountController.new @global_configuration
end

#subscription_notesSubscriptionNotesController

Access to subscription_notes controller.

Returns:



182
183
184
# File 'lib/advanced_billing/client.rb', line 182

def subscription_notes
  @subscription_notes ||= SubscriptionNotesController.new @global_configuration
end

#subscription_productsSubscriptionProductsController

Access to subscription_products controller.

Returns:



188
189
190
# File 'lib/advanced_billing/client.rb', line 188

def subscription_products
  @subscription_products ||= SubscriptionProductsController.new @global_configuration
end

#subscription_statusSubscriptionStatusController

Access to subscription_status controller.

Returns:



194
195
196
# File 'lib/advanced_billing/client.rb', line 194

def subscription_status
  @subscription_status ||= SubscriptionStatusController.new @global_configuration
end

#subscriptionsSubscriptionsController

Access to subscriptions controller.

Returns:



146
147
148
# File 'lib/advanced_billing/client.rb', line 146

def subscriptions
  @subscriptions ||= SubscriptionsController.new @global_configuration
end

#webhooksWebhooksController

Access to webhooks controller.

Returns:



200
201
202
# File 'lib/advanced_billing/client.rb', line 200

def webhooks
  @webhooks ||= WebhooksController.new @global_configuration
end