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/collection.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, Collection, Configuration, ConfigurationError, Error
Constant Summary collapse
- VERSION =
"1.1.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.
15 16 17 |
# File 'lib/abacate_pay.rb', line 15 def configuration @configuration end |
Class Method Details
.checkouts ⇒ Clients::CheckoutClient
Returns Checkout API client.
101 102 103 |
# File 'lib/abacate_pay.rb', line 101 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.
65 66 67 68 69 70 |
# File 'lib/abacate_pay.rb', line 65 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.
42 43 44 45 46 47 |
# File 'lib/abacate_pay.rb', line 42 def self.configure self.configuration ||= Configuration.new yield(configuration) configuration.validate! reset_clients! end |
.coupons ⇒ Clients::CouponClient
Returns Coupon API client.
96 97 98 |
# File 'lib/abacate_pay.rb', line 96 def self.coupons clients[:coupons] ||= Clients::CouponClient.new end |
.customers ⇒ Clients::CustomerClient
Returns Customer API client.
86 87 88 |
# File 'lib/abacate_pay.rb', line 86 def self.customers clients[:customers] ||= Clients::CustomerClient.new end |
.payment_links ⇒ Clients::PaymentLinkClient
Returns Reusable payment link API client.
131 132 133 |
# File 'lib/abacate_pay.rb', line 131 def self.payment_links clients[:payment_links] ||= Clients::PaymentLinkClient.new end |
.payouts ⇒ Clients::PayoutClient
Returns Payout API client.
121 122 123 |
# File 'lib/abacate_pay.rb', line 121 def self.payouts clients[:payouts] ||= Clients::PayoutClient.new end |
.pix ⇒ Clients::PixClient
Returns PIX Transfer API client.
116 117 118 |
# File 'lib/abacate_pay.rb', line 116 def self.pix clients[:pix] ||= Clients::PixClient.new end |
.products ⇒ Clients::ProductClient
Returns Product API client.
91 92 93 |
# File 'lib/abacate_pay.rb', line 91 def self.products clients[:products] ||= Clients::ProductClient.new end |
.reset! ⇒ void
This method returns an undefined value.
Resets the configuration to defaults
52 53 54 55 |
# File 'lib/abacate_pay.rb', line 52 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
75 76 77 |
# File 'lib/abacate_pay.rb', line 75 def self.reset_clients! @clients = {} end |
.store ⇒ Clients::StoreClient
Returns Store API client.
126 127 128 |
# File 'lib/abacate_pay.rb', line 126 def self.store clients[:store] ||= Clients::StoreClient.new end |
.subscriptions ⇒ Clients::SubscriptionClient
Returns Subscription API client.
106 107 108 |
# File 'lib/abacate_pay.rb', line 106 def self.subscriptions clients[:subscriptions] ||= Clients::SubscriptionClient.new end |
.transparents ⇒ Clients::TransparentClient
Returns PIX Transparent API client.
111 112 113 |
# File 'lib/abacate_pay.rb', line 111 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.
139 140 141 |
# File 'lib/abacate_pay.rb', line 139 def self.webhook_endpoints clients[:webhook_endpoints] ||= Clients::WebhookClient.new end |