abacatepay-ruby 0.1.0 → 1.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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +125 -0
  3. data/CHANGELOG.md +121 -1
  4. data/README.md +408 -87
  5. data/Rakefile +1 -1
  6. data/abacatepay-ruby.gemspec +16 -10
  7. data/lib/abacate_pay/clients/billing_client.rb +80 -0
  8. data/lib/abacate_pay/clients/checkout_client.rb +70 -0
  9. data/lib/{abacatepay → abacate_pay}/clients/client.rb +20 -7
  10. data/lib/abacate_pay/clients/coupon_client.rb +57 -0
  11. data/lib/abacate_pay/clients/customer_client.rb +58 -0
  12. data/lib/abacate_pay/clients/payment_link_client.rb +71 -0
  13. data/lib/abacate_pay/clients/payout_client.rb +41 -0
  14. data/lib/abacate_pay/clients/pix_client.rb +47 -0
  15. data/lib/abacate_pay/clients/product_client.rb +54 -0
  16. data/lib/abacate_pay/clients/store_client.rb +40 -0
  17. data/lib/abacate_pay/clients/subscription_client.rb +55 -0
  18. data/lib/abacate_pay/clients/transparent_client.rb +73 -0
  19. data/lib/abacate_pay/clients/webhook_client.rb +82 -0
  20. data/lib/abacate_pay/clients.rb +24 -0
  21. data/lib/abacate_pay/configuration.rb +67 -0
  22. data/lib/{abacatepay/enums/billing → abacate_pay/enums/billings}/frequencies.rb +9 -3
  23. data/lib/{abacatepay/enums/billing → abacate_pay/enums/billings}/methods.rb +5 -3
  24. data/lib/{abacatepay/enums/billing → abacate_pay/enums/billings}/statuses.rb +3 -2
  25. data/lib/abacate_pay/enums/checkouts/statuses.rb +29 -0
  26. data/lib/abacate_pay/enums/coupons/discount_kinds.rb +26 -0
  27. data/lib/abacate_pay/enums/coupons/statuses.rb +27 -0
  28. data/lib/abacate_pay/enums/payouts/statuses.rb +29 -0
  29. data/lib/abacate_pay/enums/pix/key_types.rb +30 -0
  30. data/lib/abacate_pay/enums/products/cycles.rb +28 -0
  31. data/lib/abacate_pay/enums/transfers/statuses.rb +30 -0
  32. data/lib/abacate_pay/enums/webhooks/event_types.rb +43 -0
  33. data/lib/abacate_pay/enums.rb +20 -0
  34. data/lib/{abacatepay/resources/billing → abacate_pay/resources/billings}/metadata.rb +2 -8
  35. data/lib/{abacatepay/resources/billing → abacate_pay/resources/billings}/product.rb +2 -8
  36. data/lib/{abacatepay/resources/billing.rb → abacate_pay/resources/billings.rb} +16 -16
  37. data/lib/abacate_pay/resources/checkouts.rb +76 -0
  38. data/lib/abacate_pay/resources/coupons.rb +41 -0
  39. data/lib/{abacatepay/resources/customer → abacate_pay/resources/customers}/metadata.rb +2 -8
  40. data/lib/{abacatepay/resources/customer.rb → abacate_pay/resources/customers.rb} +5 -5
  41. data/lib/abacate_pay/resources/payouts.rb +40 -0
  42. data/lib/abacate_pay/resources/pix_transfers.rb +41 -0
  43. data/lib/abacate_pay/resources/products.rb +40 -0
  44. data/lib/{abacatepay → abacate_pay}/resources/resource.rb +33 -21
  45. data/lib/abacate_pay/resources/store/balance.rb +20 -0
  46. data/lib/abacate_pay/resources/store.rb +36 -0
  47. data/lib/abacate_pay/resources/subscriptions.rb +72 -0
  48. data/lib/abacate_pay/resources/transparents.rb +46 -0
  49. data/lib/abacate_pay/resources/webhook_endpoints.rb +49 -0
  50. data/lib/abacate_pay/resources.rb +27 -0
  51. data/lib/{abacatepay → abacate_pay}/version.rb +2 -2
  52. data/lib/abacate_pay/webhooks/event.rb +20 -0
  53. data/lib/abacate_pay/webhooks.rb +100 -0
  54. data/lib/abacate_pay.rb +111 -4
  55. metadata +69 -56
  56. data/lib/abacatepay/clients/billing_client.rb +0 -60
  57. data/lib/abacatepay/clients/customer_client.rb +0 -39
  58. data/lib/abacatepay/clients.rb +0 -12
  59. data/lib/abacatepay/configuration.rb +0 -56
  60. data/lib/abacatepay/enums.rb +0 -12
  61. data/lib/abacatepay/resources.rb +0 -15
  62. data/sig/abacatepay/rails.rbs +0 -6
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Clients
5
+ # Client for transparent PIX checkout in the AbacatePay API.
6
+ #
7
+ # Transparent checkout returns the QR code and copy-and-paste
8
+ # payload directly, so the payment stays inside your own UI.
9
+ class TransparentClient < Client
10
+ URI = "transparents"
11
+
12
+ def initialize(client = nil)
13
+ super(URI, client)
14
+ end
15
+
16
+ # @param params [Hash] Optional pagination params (after, before, limit)
17
+ # @return [Array<Resources::Transparents>]
18
+ def list(**params)
19
+ response = request("GET", "list", params: params.empty? ? nil : params)
20
+ Array(response).map { |data| Resources::Transparents.new(data) }
21
+ end
22
+
23
+ # @param data [Resources::Transparents]
24
+ # @return [Resources::Transparents]
25
+ def create(data)
26
+ request_data = {
27
+ method: "PIX",
28
+ data: {
29
+ amount: data.amount
30
+ },
31
+ expiresIn: data.expires_in,
32
+ description: data.description
33
+ }
34
+
35
+ if data.customer
36
+ request_data[:customer] = {
37
+ name: data.customer.metadata&.name,
38
+ email: data.customer.metadata&.email,
39
+ cellphone: data.customer.metadata&.cellphone,
40
+ taxId: data.customer.metadata&.tax_id
41
+ }
42
+ end
43
+
44
+ response = request("POST", "create", json: request_data)
45
+ Resources::Transparents.new(response)
46
+ end
47
+
48
+ # @param id [String] QR code ID
49
+ # @return [Resources::Transparents]
50
+ def check(id)
51
+ response = request("GET", "check", params: { id: id })
52
+ Resources::Transparents.new(response)
53
+ end
54
+
55
+ # @param id [String] QR code ID (dev mode only)
56
+ # @return [Resources::Transparents]
57
+ def simulate_payment(id)
58
+ response = request("POST", "simulate-payment", json: { id: id })
59
+ Resources::Transparents.new(response)
60
+ end
61
+
62
+ # Refunds a transparent payment in full. AbacatePay does not support
63
+ # partial refunds — the original amount is always returned.
64
+ #
65
+ # @param id [String] Public charge ID (`pix_char_...`, `card_...`, `char_...`)
66
+ # @return [Resources::Transparents] The refunded charge
67
+ def refund(id)
68
+ response = request("POST", "refund", json: { id: id })
69
+ Resources::Transparents.new(response)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+
5
+ module AbacatePay
6
+ module Clients
7
+ # Client for managing webhook endpoint registrations in the AbacatePay API.
8
+ #
9
+ # This manages *where* AbacatePay delivers events. To verify and parse an
10
+ # inbound delivery, use {AbacatePay::Webhooks.construct_event}.
11
+ class WebhookClient < Client
12
+ URI = "webhooks"
13
+
14
+ # @param client [Faraday::Connection, nil] Optional Faraday client
15
+ def initialize(client = nil)
16
+ super(URI, client)
17
+ end
18
+
19
+ # @param params [Hash] Optional params (limit, after, before, startDate, endDate)
20
+ # @return [Array<Resources::WebhookEndpoints>]
21
+ def list(**params)
22
+ response = request("GET", "list", params: params.empty? ? nil : params)
23
+ Array(response).map { |data| Resources::WebhookEndpoints.new(data) }
24
+ end
25
+
26
+ # @param id [String] The webhook ID
27
+ # @return [Resources::WebhookEndpoints]
28
+ def get(id)
29
+ response = request("GET", "get", params: { id: id })
30
+ Resources::WebhookEndpoints.new(response)
31
+ end
32
+
33
+ # Registers a new webhook endpoint.
34
+ #
35
+ # The secret is what AbacatePay signs deliveries with — pass the same
36
+ # value to {AbacatePay::Webhooks.construct_event} when handling them.
37
+ #
38
+ # @param name [String] Identifying name
39
+ # @param endpoint [String] HTTPS URL that will receive the events
40
+ # @param secret [String] Signing secret
41
+ # @param events [Array<String>] Event types to subscribe to
42
+ # @return [Resources::WebhookEndpoints] The created webhook
43
+ # @raise [ArgumentError] if the endpoint is not an HTTPS URL
44
+ def create(name:, endpoint:, secret:, events:)
45
+ raise ArgumentError, "endpoint must be an HTTPS URL, got #{endpoint.inspect}" unless https_url?(endpoint)
46
+ raise ArgumentError, "events must not be empty" if Array(events).empty?
47
+
48
+ response = request("POST", "create", json: {
49
+ name: name,
50
+ endpoint: endpoint,
51
+ secret: secret,
52
+ events: Array(events)
53
+ })
54
+ Resources::WebhookEndpoints.new(response)
55
+ end
56
+
57
+ # @param id [String] The webhook ID
58
+ # @return [Resources::WebhookEndpoints] The deleted webhook
59
+ def delete(id)
60
+ response = request("POST", "delete", json: { id: id })
61
+ Resources::WebhookEndpoints.new(response)
62
+ end
63
+
64
+ private
65
+
66
+ # AbacatePay only delivers to HTTPS endpoints; failing here beats a
67
+ # confusing rejection after the round trip.
68
+ #
69
+ # The class-level URI constant shadows Ruby's URI module inside this
70
+ # class, so the global scope operator is required.
71
+ #
72
+ # @param value [String] The candidate URL
73
+ # @return [Boolean]
74
+ def https_url?(value)
75
+ uri = ::URI::DEFAULT_PARSER.parse(value.to_s)
76
+ uri.is_a?(::URI::HTTPS) && !uri.host.nil?
77
+ rescue ::URI::InvalidURIError
78
+ false
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Client must load first — every other client inherits from it.
4
+ require "abacate_pay/clients/client"
5
+
6
+ require "abacate_pay/clients/billing_client"
7
+ require "abacate_pay/clients/checkout_client"
8
+ require "abacate_pay/clients/coupon_client"
9
+ require "abacate_pay/clients/customer_client"
10
+ require "abacate_pay/clients/payment_link_client"
11
+ require "abacate_pay/clients/payout_client"
12
+ require "abacate_pay/clients/pix_client"
13
+ require "abacate_pay/clients/product_client"
14
+ require "abacate_pay/clients/store_client"
15
+ require "abacate_pay/clients/subscription_client"
16
+ require "abacate_pay/clients/transparent_client"
17
+ require "abacate_pay/clients/webhook_client"
18
+
19
+ module AbacatePay
20
+ # The Clients module contains all API client implementations
21
+ # for interacting with the AbacatePay API endpoints.
22
+ module Clients
23
+ end
24
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ # Configuration class for the AbacatePay SDK
5
+ #
6
+ # This class handles all configuration options for the SDK, including
7
+ # API credentials and request behaviour.
8
+ #
9
+ # @api public
10
+ class Configuration
11
+ # The only base URL AbacatePay serves. The v1 prefix was retired and now
12
+ # answers `{"error":"Not found"}` for every path, so there is nothing to
13
+ # negotiate between.
14
+ API_BASE_URL = "https://api.abacatepay.com/v2"
15
+
16
+ # @return [String] API token for authentication
17
+ attr_accessor :api_token
18
+
19
+ # @return [Integer] Request timeout in seconds
20
+ attr_accessor :timeout
21
+
22
+ # Initialize a new configuration with default values
23
+ #
24
+ # @api public
25
+ def initialize
26
+ @timeout = 30
27
+ @api_token = nil
28
+ end
29
+
30
+ # @deprecated The environment is determined by the API key itself — keys
31
+ # created in Dev mode produce simulated transactions, production keys
32
+ # produce real ones. This setting has never had any effect and is kept
33
+ # only so existing initializers keep loading.
34
+ # @return [nil]
35
+ attr_reader :environment
36
+
37
+ # @deprecated See {#environment}.
38
+ # @param value [Symbol] Ignored
39
+ # @return [void]
40
+ def environment=(value)
41
+ @environment = value
42
+ warn "[DEPRECATION] AbacatePay config.environment has no effect and will be removed. " \
43
+ "The environment is determined by the API key: Dev mode keys simulate transactions, " \
44
+ "production keys do not."
45
+ end
46
+
47
+ # Validates the configuration
48
+ #
49
+ # @raise [ConfigurationError] if any required settings are missing or invalid
50
+ # @return [void]
51
+ #
52
+ # @api public
53
+ def validate!
54
+ raise ConfigurationError, "API token is required" if api_token.nil?
55
+ raise ConfigurationError, "API token must not be empty" if api_token.to_s.strip.empty?
56
+ end
57
+
58
+ # Gets the base API URL
59
+ #
60
+ # @return [String] The base API URL
61
+ #
62
+ # @api public
63
+ def api_url
64
+ API_BASE_URL
65
+ end
66
+ end
67
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module AbacatePay
4
4
  module Enums
5
- module Billing
5
+ module Billings
6
6
  # Enumeration defining billing frequencies.
7
7
  #
8
8
  # This enumeration is used to categorize different payment or billing frequencies.
@@ -10,11 +10,16 @@ module AbacatePay
10
10
  # One-time billing.
11
11
  # @return [String] Represents a billing that occurs only once
12
12
  ONE_TIME = "ONE_TIME"
13
+ WEEKLY = "WEEKLY"
14
+ MONTHLY = "MONTHLY"
15
+ SEMIANNUALLY = "SEMIANNUALLY"
16
+ ANNUALLY = "ANNUALLY"
17
+ MULTIPLE_PAYMENTS = "MULTIPLE_PAYMENTS"
13
18
 
14
19
  # Gets all valid frequency values
15
20
  # @return [Array<String>] List of all valid frequencies
16
21
  def self.values
17
- [ONE_TIME]
22
+ [ONE_TIME, WEEKLY, MONTHLY, SEMIANNUALLY, ANNUALLY, MULTIPLE_PAYMENTS]
18
23
  end
19
24
 
20
25
  # Validates if a given value is a valid frequency
@@ -30,9 +35,10 @@ module AbacatePay
30
35
  # @raise [ArgumentError] if value is invalid
31
36
  def self.validate!(value)
32
37
  raise ArgumentError, "Invalid frequency: #{value}" unless valid?(value)
38
+
33
39
  value
34
40
  end
35
41
  end
36
42
  end
37
43
  end
38
- end
44
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module AbacatePay
4
4
  module Enums
5
- module Billing
5
+ module Billings
6
6
  # Enumeration defining billing methods.
7
7
  #
8
8
  # This enumeration is used to represent different payment methods available for billing.
@@ -10,11 +10,12 @@ module AbacatePay
10
10
  # PIX payment method.
11
11
  # @return [String] Represents the PIX payment method, a popular instant payment system in Brazil
12
12
  PIX = "PIX"
13
+ CARD = "CARD"
13
14
 
14
15
  # Gets all valid method values
15
16
  # @return [Array<String>] List of all valid payment methods
16
17
  def self.values
17
- [PIX]
18
+ [PIX, CARD]
18
19
  end
19
20
 
20
21
  # Validates if a given value is a valid method
@@ -30,9 +31,10 @@ module AbacatePay
30
31
  # @raise [ArgumentError] if value is invalid
31
32
  def self.validate!(value)
32
33
  raise ArgumentError, "Invalid payment method: #{value}" unless valid?(value)
34
+
33
35
  value
34
36
  end
35
37
  end
36
38
  end
37
39
  end
38
- end
40
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module AbacatePay
4
4
  module Enums
5
- module Billing
5
+ module Billings
6
6
  # Enumeration defining billing statuses.
7
7
  #
8
8
  # This enumeration is used to represent the various statuses that a billing process can have.
@@ -46,9 +46,10 @@ module AbacatePay
46
46
  # @raise [ArgumentError] if value is invalid
47
47
  def self.validate!(value)
48
48
  raise ArgumentError, "Invalid status: #{value}" unless valid?(value)
49
+
49
50
  value
50
51
  end
51
52
  end
52
53
  end
53
54
  end
54
- end
55
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Checkouts
6
+ class Statuses
7
+ PENDING = "PENDING"
8
+ EXPIRED = "EXPIRED"
9
+ CANCELLED = "CANCELLED"
10
+ PAID = "PAID"
11
+ REFUNDED = "REFUNDED"
12
+
13
+ def self.values
14
+ [PENDING, EXPIRED, CANCELLED, PAID, REFUNDED]
15
+ end
16
+
17
+ def self.valid?(value)
18
+ values.include?(value)
19
+ end
20
+
21
+ def self.validate!(value)
22
+ raise ArgumentError, "Invalid checkout status: #{value}" unless valid?(value)
23
+
24
+ value
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Coupons
6
+ class DiscountKinds
7
+ PERCENTAGE = "PERCENTAGE"
8
+ FIXED = "FIXED"
9
+
10
+ def self.values
11
+ [PERCENTAGE, FIXED]
12
+ end
13
+
14
+ def self.valid?(value)
15
+ values.include?(value)
16
+ end
17
+
18
+ def self.validate!(value)
19
+ raise ArgumentError, "Invalid discount kind: #{value}" unless valid?(value)
20
+
21
+ value
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Coupons
6
+ class Statuses
7
+ ACTIVE = "ACTIVE"
8
+ INACTIVE = "INACTIVE"
9
+ EXPIRED = "EXPIRED"
10
+
11
+ def self.values
12
+ [ACTIVE, INACTIVE, EXPIRED]
13
+ end
14
+
15
+ def self.valid?(value)
16
+ values.include?(value)
17
+ end
18
+
19
+ def self.validate!(value)
20
+ raise ArgumentError, "Invalid coupon status: #{value}" unless valid?(value)
21
+
22
+ value
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Payouts
6
+ class Statuses
7
+ PENDING = "PENDING"
8
+ COMPLETE = "COMPLETE"
9
+ CANCELLED = "CANCELLED"
10
+ EXPIRED = "EXPIRED"
11
+ REFUNDED = "REFUNDED"
12
+
13
+ def self.values
14
+ [PENDING, COMPLETE, CANCELLED, EXPIRED, REFUNDED]
15
+ end
16
+
17
+ def self.valid?(value)
18
+ values.include?(value)
19
+ end
20
+
21
+ def self.validate!(value)
22
+ raise ArgumentError, "Invalid payout status: #{value}" unless valid?(value)
23
+
24
+ value
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Pix
6
+ class KeyTypes
7
+ CPF = "CPF"
8
+ CNPJ = "CNPJ"
9
+ PHONE = "PHONE"
10
+ EMAIL = "EMAIL"
11
+ RANDOM = "RANDOM"
12
+ BR_CODE = "BR_CODE"
13
+
14
+ def self.values
15
+ [CPF, CNPJ, PHONE, EMAIL, RANDOM, BR_CODE]
16
+ end
17
+
18
+ def self.valid?(value)
19
+ values.include?(value)
20
+ end
21
+
22
+ def self.validate!(value)
23
+ raise ArgumentError, "Invalid PIX key type: #{value}" unless valid?(value)
24
+
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Products
6
+ class Cycles
7
+ WEEKLY = "WEEKLY"
8
+ MONTHLY = "MONTHLY"
9
+ SEMIANNUALLY = "SEMIANNUALLY"
10
+ ANNUALLY = "ANNUALLY"
11
+
12
+ def self.values
13
+ [WEEKLY, MONTHLY, SEMIANNUALLY, ANNUALLY]
14
+ end
15
+
16
+ def self.valid?(value)
17
+ values.include?(value)
18
+ end
19
+
20
+ def self.validate!(value)
21
+ raise ArgumentError, "Invalid product cycle: #{value}" unless valid?(value)
22
+
23
+ value
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Transfers
6
+ class Statuses
7
+ PENDING = "PENDING"
8
+ COMPLETE = "COMPLETE"
9
+ CANCELLED = "CANCELLED"
10
+ EXPIRED = "EXPIRED"
11
+ REFUNDED = "REFUNDED"
12
+ FAILED = "FAILED"
13
+
14
+ def self.values
15
+ [PENDING, COMPLETE, CANCELLED, EXPIRED, REFUNDED, FAILED]
16
+ end
17
+
18
+ def self.valid?(value)
19
+ values.include?(value)
20
+ end
21
+
22
+ def self.validate!(value)
23
+ raise ArgumentError, "Invalid transfer status: #{value}" unless valid?(value)
24
+
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbacatePay
4
+ module Enums
5
+ module Webhooks
6
+ class EventTypes
7
+ CHECKOUT_COMPLETED = "checkout.completed"
8
+ CHECKOUT_REFUNDED = "checkout.refunded"
9
+ CHECKOUT_DISPUTED = "checkout.disputed"
10
+ TRANSPARENT_COMPLETED = "transparent.completed"
11
+ TRANSPARENT_REFUNDED = "transparent.refunded"
12
+ TRANSPARENT_DISPUTED = "transparent.disputed"
13
+ SUBSCRIPTION_COMPLETED = "subscription.completed"
14
+ SUBSCRIPTION_RENEWED = "subscription.renewed"
15
+ SUBSCRIPTION_CANCELLED = "subscription.cancelled"
16
+ TRANSFER_COMPLETED = "transfer.completed"
17
+ TRANSFER_FAILED = "transfer.failed"
18
+ PAYOUT_COMPLETED = "payout.completed"
19
+ PAYOUT_FAILED = "payout.failed"
20
+
21
+ def self.values
22
+ [
23
+ CHECKOUT_COMPLETED, CHECKOUT_REFUNDED, CHECKOUT_DISPUTED,
24
+ TRANSPARENT_COMPLETED, TRANSPARENT_REFUNDED, TRANSPARENT_DISPUTED,
25
+ SUBSCRIPTION_COMPLETED, SUBSCRIPTION_RENEWED, SUBSCRIPTION_CANCELLED,
26
+ TRANSFER_COMPLETED, TRANSFER_FAILED,
27
+ PAYOUT_COMPLETED, PAYOUT_FAILED
28
+ ]
29
+ end
30
+
31
+ def self.valid?(value)
32
+ values.include?(value)
33
+ end
34
+
35
+ def self.validate!(value)
36
+ raise ArgumentError, "Invalid webhook event type: #{value}" unless valid?(value)
37
+
38
+ value
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "abacate_pay/enums/billings/frequencies"
4
+ require "abacate_pay/enums/billings/methods"
5
+ require "abacate_pay/enums/billings/statuses"
6
+ require "abacate_pay/enums/checkouts/statuses"
7
+ require "abacate_pay/enums/coupons/discount_kinds"
8
+ require "abacate_pay/enums/coupons/statuses"
9
+ require "abacate_pay/enums/payouts/statuses"
10
+ require "abacate_pay/enums/pix/key_types"
11
+ require "abacate_pay/enums/products/cycles"
12
+ require "abacate_pay/enums/transfers/statuses"
13
+ require "abacate_pay/enums/webhooks/event_types"
14
+
15
+ module AbacatePay
16
+ # The Enums module contains all enumeration classes used
17
+ # throughout the AbacatePay SDK.
18
+ module Enums
19
+ end
20
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module AbacatePay
4
4
  module Resources
5
- module Billing
5
+ class Billings
6
6
  # Represents metadata for a billing resource in the AbacatePay system.
7
7
  #
8
8
  # This class contains additional information related to a billing resource,
@@ -23,13 +23,7 @@ module AbacatePay
23
23
  def initialize(data)
24
24
  fill(data)
25
25
  end
26
-
27
- protected
28
-
29
- def to_hash
30
- super
31
- end
32
26
  end
33
27
  end
34
28
  end
35
- end
29
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module AbacatePay
4
4
  module Resources
5
- module Billing
5
+ class Billings
6
6
  # Represents a product in a billing resource in the AbacatePay system.
7
7
  #
8
8
  # This class contains information about a product, such as its identifier,
@@ -32,13 +32,7 @@ module AbacatePay
32
32
  def initialize(data)
33
33
  fill(data)
34
34
  end
35
-
36
- protected
37
-
38
- def to_hash
39
- super
40
- end
41
35
  end
42
36
  end
43
37
  end
44
- end
38
+ end