Module: AbacatePay
- Defined in:
- lib/abacate_pay.rb,
lib/abacate_pay/enums.rb,
lib/abacate_pay/clients.rb,
lib/abacate_pay/version.rb,
lib/abacate_pay/webhooks.rb,
lib/abacate_pay/resources.rb,
lib/abacate_pay/configuration.rb,
lib/abacate_pay/clients/client.rb,
lib/abacate_pay/webhooks/event.rb,
lib/abacate_pay/resources/store.rb,
lib/abacate_pay/resources/coupons.rb,
lib/abacate_pay/resources/payouts.rb,
lib/abacate_pay/clients/pix_client.rb,
lib/abacate_pay/resources/billings.rb,
lib/abacate_pay/resources/products.rb,
lib/abacate_pay/resources/resource.rb,
lib/abacate_pay/enums/pix/key_types.rb,
lib/abacate_pay/resources/checkouts.rb,
lib/abacate_pay/resources/customers.rb,
lib/abacate_pay/clients/store_client.rb,
lib/abacate_pay/clients/coupon_client.rb,
lib/abacate_pay/clients/payout_client.rb,
lib/abacate_pay/enums/products/cycles.rb,
lib/abacate_pay/clients/billing_client.rb,
lib/abacate_pay/clients/product_client.rb,
lib/abacate_pay/clients/webhook_client.rb,
lib/abacate_pay/enums/billings/methods.rb,
lib/abacate_pay/enums/coupons/statuses.rb,
lib/abacate_pay/enums/payouts/statuses.rb,
lib/abacate_pay/resources/transparents.rb,
lib/abacate_pay/clients/checkout_client.rb,
lib/abacate_pay/clients/customer_client.rb,
lib/abacate_pay/enums/billings/statuses.rb,
lib/abacate_pay/resources/pix_transfers.rb,
lib/abacate_pay/resources/store/balance.rb,
lib/abacate_pay/resources/subscriptions.rb,
lib/abacate_pay/enums/checkouts/statuses.rb,
lib/abacate_pay/enums/transfers/statuses.rb,
lib/abacate_pay/clients/transparent_client.rb,
lib/abacate_pay/enums/billings/frequencies.rb,
lib/abacate_pay/enums/webhooks/event_types.rb,
lib/abacate_pay/resources/billings/product.rb,
lib/abacate_pay/clients/payment_link_client.rb,
lib/abacate_pay/clients/subscription_client.rb,
lib/abacate_pay/resources/billings/metadata.rb,
lib/abacate_pay/resources/webhook_endpoints.rb,
lib/abacate_pay/enums/coupons/discount_kinds.rb,
lib/abacate_pay/resources/customers/metadata.rb
Overview
Main module for AbacatePay SDK integration
Defined Under Namespace
Modules: Clients, Enums, Resources, Webhooks Classes: ApiError, Configuration, ConfigurationError, Error
Constant Summary collapse
- VERSION =
"1.0.0"
Class Attribute Summary collapse
-
.configuration ⇒ Configuration?
The global configuration.
Class Method Summary collapse
-
.checkouts ⇒ Clients::CheckoutClient
Checkout API client.
-
.configuration! ⇒ Configuration
Returns the configuration, refusing to proceed if the SDK was never set up.
-
.configure {|config| ... } ⇒ void
Configures the SDK.
-
.coupons ⇒ Clients::CouponClient
Coupon API client.
-
.customers ⇒ Clients::CustomerClient
Customer API client.
-
.payment_links ⇒ Clients::PaymentLinkClient
Reusable payment link API client.
-
.payouts ⇒ Clients::PayoutClient
Payout API client.
-
.pix ⇒ Clients::PixClient
PIX Transfer API client.
-
.products ⇒ Clients::ProductClient
Product API client.
-
.reset! ⇒ void
Resets the configuration to defaults.
-
.reset_clients! ⇒ void
Discards every memoized client so the next call rebuilds from current config.
-
.store ⇒ Clients::StoreClient
Store API client.
-
.subscriptions ⇒ Clients::SubscriptionClient
Subscription API client.
-
.transparents ⇒ Clients::TransparentClient
PIX Transparent API client.
-
.webhook_endpoints ⇒ Clients::WebhookClient
Webhook endpoint registration.
Class Attribute Details
.configuration ⇒ Configuration?
Returns The global configuration.
14 15 16 |
# File 'lib/abacate_pay.rb', line 14 def configuration @configuration end |
Class Method Details
.checkouts ⇒ Clients::CheckoutClient
Returns Checkout API client.
100 101 102 |
# File 'lib/abacate_pay.rb', line 100 def self.checkouts clients[:checkouts] ||= Clients::CheckoutClient.new end |
.configuration! ⇒ Configuration
Returns the configuration, refusing to proceed if the SDK was never set up.
Forgetting to call configure is the most common first-run mistake; without
this the failure surfaces as NoMethodError: undefined method 'api_url' for nil from deep inside the client.
64 65 66 67 68 69 |
# File 'lib/abacate_pay.rb', line 64 def self.configuration! configuration || raise( ConfigurationError, "AbacatePay is not configured. Call AbacatePay.configure { |c| c.api_token = ENV['ABACATEPAY_API_KEY'] } first." ) end |
.configure {|config| ... } ⇒ void
This method returns an undefined value.
Configures the SDK
Memoized clients are discarded so a token changed at runtime takes effect immediately. Without this, a client built before the change keeps sending the old bearer token.
41 42 43 44 45 46 |
# File 'lib/abacate_pay.rb', line 41 def self.configure self.configuration ||= Configuration.new yield(configuration) configuration.validate! reset_clients! end |
.coupons ⇒ Clients::CouponClient
Returns Coupon API client.
95 96 97 |
# File 'lib/abacate_pay.rb', line 95 def self.coupons clients[:coupons] ||= Clients::CouponClient.new end |
.customers ⇒ Clients::CustomerClient
Returns Customer API client.
85 86 87 |
# File 'lib/abacate_pay.rb', line 85 def self.customers clients[:customers] ||= Clients::CustomerClient.new end |
.payment_links ⇒ Clients::PaymentLinkClient
Returns Reusable payment link API client.
130 131 132 |
# File 'lib/abacate_pay.rb', line 130 def self.payment_links clients[:payment_links] ||= Clients::PaymentLinkClient.new end |
.payouts ⇒ Clients::PayoutClient
Returns Payout API client.
120 121 122 |
# File 'lib/abacate_pay.rb', line 120 def self.payouts clients[:payouts] ||= Clients::PayoutClient.new end |
.pix ⇒ Clients::PixClient
Returns PIX Transfer API client.
115 116 117 |
# File 'lib/abacate_pay.rb', line 115 def self.pix clients[:pix] ||= Clients::PixClient.new end |
.products ⇒ Clients::ProductClient
Returns Product API client.
90 91 92 |
# File 'lib/abacate_pay.rb', line 90 def self.products clients[:products] ||= Clients::ProductClient.new end |
.reset! ⇒ void
This method returns an undefined value.
Resets the configuration to defaults
51 52 53 54 |
# File 'lib/abacate_pay.rb', line 51 def self.reset! self.configuration = Configuration.new reset_clients! end |
.reset_clients! ⇒ void
This method returns an undefined value.
Discards every memoized client so the next call rebuilds from current config
74 75 76 |
# File 'lib/abacate_pay.rb', line 74 def self.reset_clients! @clients = {} end |
.store ⇒ Clients::StoreClient
Returns Store API client.
125 126 127 |
# File 'lib/abacate_pay.rb', line 125 def self.store clients[:store] ||= Clients::StoreClient.new end |
.subscriptions ⇒ Clients::SubscriptionClient
Returns Subscription API client.
105 106 107 |
# File 'lib/abacate_pay.rb', line 105 def self.subscriptions clients[:subscriptions] ||= Clients::SubscriptionClient.new end |
.transparents ⇒ Clients::TransparentClient
Returns PIX Transparent API client.
110 111 112 |
# File 'lib/abacate_pay.rb', line 110 def self.transparents clients[:transparents] ||= Clients::TransparentClient.new end |
.webhook_endpoints ⇒ Clients::WebhookClient
Webhook endpoint registration. To verify an inbound delivery, use AbacatePay::Webhooks.construct_event.
138 139 140 |
# File 'lib/abacate_pay.rb', line 138 def self.webhook_endpoints clients[:webhook_endpoints] ||= Clients::WebhookClient.new end |