billingrails 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 578d04e03ffeda8152c01935292f52b588d735dd51410fd1cd1b738f207f8ea4
4
- data.tar.gz: 0e717f9b4d706c23c22e1cd73858f43af220c1a44515c0b4f5a6e4f1bd3aec61
3
+ metadata.gz: 0afc8782d1a0cb29269523d547085dc3be039a06a01799f02fb45da80f7955ad
4
+ data.tar.gz: 0c6137d1ef84e8b8c2bd6af4f620070412e9779a11a08483477e240a8df8c6bd
5
5
  SHA512:
6
- metadata.gz: 6ca2172ccfe271014ff2dfb8a6cdd16486334345b6dabf53e992112560e170dfe02e8fa7884d0a2411f0231567eb2485612024b545172e2cdbdce5e5d276e279
7
- data.tar.gz: 284159ff6cf0727e3315ee82b06ecdc7536f4e98a3ef70b64a2e0d7f5962420e0b4a1dd27eceffb3e7d8e87096822c80f95ff6d305cc29bb4d80d9d2ab27e4d1
6
+ metadata.gz: e3b8d82e571b1518e748ac67f96dd383769eb0a623049bb1af01c49a3c47fb1e17bac4a682c60fbce317ac1b920cccf0acd015c9e130349b050f965a64a62ef8
7
+ data.tar.gz: c8024c193dd04c62c2916ebdba05aae826e38515d6b14e0b9080baf2435bed065921867868fcbb483e1a56df1d8724f01c2ba11491df87ab177d121c08d926fd
data/CHANGELOG.md CHANGED
@@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
  - Initial release of Billingrails Ruby SDK
12
12
  - Complete API client with authentication
13
13
  - Resource-based API structure
14
- - Nested namespaces for biller and seller resources
15
14
  - Comprehensive error handling
16
15
  - Retry logic with exponential backoff
17
16
  - Full test coverage
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/billingrails.svg)](https://rubygems.org/gems/billingrails)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- Official Ruby SDK for the Billingrails API - Flexible, composable, and intuitive API-first commerce platform.
6
+ Official Ruby SDK for the [Billingrails](https://billingrails.com) API - Flexible, composable, and intuitive API-first commerce platform.
7
7
 
8
8
  ## Installation
9
9
 
@@ -5,36 +5,15 @@ require 'json'
5
5
  require 'uri'
6
6
 
7
7
  module Billingrails
8
- # Nested namespace for biller resources
9
- class BillerNamespace
10
- attr_reader :events, :meters, :plans, :subscriptions
11
-
12
- def initialize(client)
13
- @events = Resources::Events.new(client)
14
- @meters = Resources::Meters.new(client)
15
- @plans = Resources::Plans.new(client)
16
- @subscriptions = Resources::Subscriptions.new(client)
17
- end
18
- end
19
-
20
- # Nested namespace for seller resources
21
- class SellerNamespace
22
- attr_reader :products, :orders
23
-
24
- def initialize(client)
25
- @products = Resources::Products.new(client)
26
- @orders = Resources::Orders.new(client)
27
- end
28
- end
29
-
30
8
  # Main client for interacting with the Billingrails API
31
9
  class Client
32
10
  DEFAULT_BASE_URL = 'https://api.billingrails.com/v1'
33
11
  DEFAULT_TIMEOUT = 30
34
12
 
35
13
  attr_reader :api_key, :base_url, :timeout
36
- attr_reader :accounts, :credit_grants, :discounts, :fees, :invoices, :payments, :payment_pages
37
- attr_reader :biller, :seller
14
+ attr_reader :accounts, :invoices, :payments, :payment_links
15
+ attr_reader :events, :meters, :plans, :fees, :prices, :subscriptions
16
+ attr_reader :discounts, :credit_grants
38
17
 
39
18
  # Initialize a new client
40
19
  #
@@ -49,16 +28,21 @@ module Billingrails
49
28
 
50
29
  # Initialize top-level resources
51
30
  @accounts = Resources::Accounts.new(self)
52
- @credit_grants = Resources::CreditGrants.new(self)
53
- @discounts = Resources::Discounts.new(self)
54
- @fees = Resources::Fees.new(self)
55
31
  @invoices = Resources::Invoices.new(self)
56
32
  @payments = Resources::Payments.new(self)
57
- @payment_pages = Resources::PaymentPages.new(self)
33
+ @payment_pages = Resources::PaymentLinks.new(self)
34
+ @checkout_sessions = Resources::CheckoutSessions.new(client)
58
35
 
59
- # Initialize nested namespaces
60
- @biller = BillerNamespace.new(self)
61
- @seller = SellerNamespace.new(self)
36
+ @subscriptions = Resources::Subscriptions.new(client)
37
+ @plans = Resources::Plans.new(client)
38
+ @fees = Resources::Fees.new(self)
39
+ @prices = Resources::Prices.new(client)
40
+ @events = Resources::Events.new(client)
41
+ @meters = Resources::Meters.new(client)
42
+
43
+ @credit_grants = Resources::CreditGrants.new(self)
44
+ @discounts = Resources::Discounts.new(self)
45
+ @tax_rates = Resources::TaxRates.new(self)
62
46
  end
63
47
 
64
48
  # Make an HTTP request
@@ -11,6 +11,28 @@ module Billingrails
11
11
  @client = client
12
12
  end
13
13
 
14
+ # List accounts
15
+ #
16
+ # Retrieve a list of accounts.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/accounts"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create an account
26
+ #
27
+ # Creates an account.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/accounts"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
14
36
  # Retrieve an account
15
37
  #
16
38
  # Retrieves an account by ID.
@@ -35,18 +57,6 @@ module Billingrails
35
57
  @client.request(:put, path, body: data)
36
58
  end
37
59
 
38
- # Debit balance
39
- #
40
- # Debits an account's balance.
41
- #
42
- # @param id [String] Resource ID
43
- # @param data [Hash] Request body
44
- # @return [Hash] Response data
45
- def debit(id, data)
46
- path = "/accounts/#{id}/debit"
47
- @client.request(:post, path, body: data)
48
- end
49
-
50
60
  # Get balances
51
61
  #
52
62
  # Retrieve credit balances for an account.
@@ -59,25 +69,15 @@ module Billingrails
59
69
  @client.request(:get, path, params: params)
60
70
  end
61
71
 
62
- # List accounts
63
- #
64
- # Retrieve a list of accounts.
65
- #
66
- # @param params [Hash, nil] Query parameters
67
- # @return [Hash] Response data
68
- def list(params: nil)
69
- path = "/accounts"
70
- @client.request(:get, path, params: params)
71
- end
72
-
73
- # Create an account
72
+ # Debit balance
74
73
  #
75
- # Creates an account.
74
+ # Debits an account's balance.
76
75
  #
76
+ # @param id [String] Resource ID
77
77
  # @param data [Hash] Request body
78
78
  # @return [Hash] Response data
79
- def create(data)
80
- path = "/accounts"
79
+ def debit(id, data)
80
+ path = "/accounts/#{id}/debit"
81
81
  @client.request(:post, path, body: data)
82
82
  end
83
83
 
@@ -4,56 +4,45 @@
4
4
 
5
5
  module Billingrails
6
6
  module Resources
7
- # Payment pages resource
8
- class PaymentPages
7
+ # Checkout sessions resource
8
+ class CheckoutSessions
9
9
  # @param client [Client] The API client
10
10
  def initialize(client)
11
11
  @client = client
12
12
  end
13
13
 
14
- # List payment pages
14
+ # Create a checkout session
15
15
  #
16
- # Retrieves a list of payment pages.
17
- #
18
- # @param params [Hash, nil] Query parameters
19
- # @return [Hash] Response data
20
- def list_payment_pages(params: nil)
21
- path = "/payment_pages"
22
- @client.request(:get, path, params: params)
23
- end
24
-
25
- # Create payment page
26
- #
27
- # Creates a new payment page.
16
+ # Creates a checkout session for processing payments.
28
17
  #
29
18
  # @param data [Hash] Request body
30
19
  # @return [Hash] Response data
31
- def create_payment_page(data)
32
- path = "/payment_pages"
20
+ def create(data)
21
+ path = "/checkout_sessions"
33
22
  @client.request(:post, path, body: data)
34
23
  end
35
24
 
36
- # Retrieve payment page
25
+ # Retrieve a checkout session
37
26
  #
38
- # Retrieves a payment page by ID.
27
+ # Retrieves a checkout session by ID.
39
28
  #
40
29
  # @param id [String] Resource ID
41
30
  # @param params [Hash, nil] Query parameters
42
31
  # @return [Hash] Response data
43
- def retrieve_payment_page(id, params: nil)
44
- path = "/payment_pages/#{id}"
32
+ def retrieve(id, params: nil)
33
+ path = "/checkout_sessions/#{id}"
45
34
  @client.request(:get, path, params: params)
46
35
  end
47
36
 
48
- # Update payment page
37
+ # Update a checkout session
49
38
  #
50
- # Updates a payment page.
39
+ # Updates a checkout session.
51
40
  #
52
41
  # @param id [String] Resource ID
53
42
  # @param data [Hash] Request body
54
43
  # @return [Hash] Response data
55
- def update_payment_page(id, data)
56
- path = "/payment_pages/#{id}"
44
+ def update(id, data)
45
+ path = "/checkout_sessions/#{id}"
57
46
  @client.request(:put, path, body: data)
58
47
  end
59
48
 
@@ -11,27 +11,25 @@ module Billingrails
11
11
  @client = client
12
12
  end
13
13
 
14
- # Apply credit grant
14
+ # List credit grants
15
15
  #
16
- # Applies a credit grant to an invoice or logs an external usage.
16
+ # Retrieves a list of credit grants.
17
17
  #
18
- # @param id [String] Resource ID
19
- # @param data [Hash] Request body
20
18
  # @return [Hash] Response data
21
- def apply_credit_grant(id, data)
22
- path = "/credit_grants/#{id}/apply"
23
- @client.request(:post, path, body: data)
19
+ def list()
20
+ path = "/credit_grants"
21
+ @client.request(:get, path)
24
22
  end
25
23
 
26
- # Expire credit grant
24
+ # Create a credit grant
27
25
  #
28
- # Expires a credit grant.
26
+ # Creates a credit grant.
29
27
  #
30
- # @param id [String] Resource ID
28
+ # @param data [Hash] Request body
31
29
  # @return [Hash] Response data
32
- def expire_credit_grant(id)
33
- path = "/credit_grants/#{id}/expire"
34
- @client.request(:post, path)
30
+ def create(data)
31
+ path = "/credit_grants"
32
+ @client.request(:post, path, body: data)
35
33
  end
36
34
 
37
35
  # Retrieve a credit grant
@@ -41,30 +39,32 @@ module Billingrails
41
39
  # @param id [String] Resource ID
42
40
  # @param params [Hash, nil] Query parameters
43
41
  # @return [Hash] Response data
44
- def retrieve_credit_grant(id, params: nil)
42
+ def retrieve(id, params: nil)
45
43
  path = "/credit_grants/#{id}"
46
44
  @client.request(:get, path, params: params)
47
45
  end
48
46
 
49
- # List credit grants
47
+ # Apply credit grant
50
48
  #
51
- # Retrieves a list of credit grants.
49
+ # Applies a credit grant to an invoice or logs an external usage.
52
50
  #
51
+ # @param id [String] Resource ID
52
+ # @param data [Hash] Request body
53
53
  # @return [Hash] Response data
54
- def list_credit_grants()
55
- path = "/credit_grants"
56
- @client.request(:get, path)
54
+ def apply(id, data)
55
+ path = "/credit_grants/#{id}/apply"
56
+ @client.request(:post, path, body: data)
57
57
  end
58
58
 
59
- # Create a credit grant
59
+ # Expire credit grant
60
60
  #
61
- # Creates a credit grant.
61
+ # Expires a credit grant.
62
62
  #
63
- # @param data [Hash] Request body
63
+ # @param id [String] Resource ID
64
64
  # @return [Hash] Response data
65
- def create_credit_grant(data)
66
- path = "/credit_grants"
67
- @client.request(:post, path, body: data)
65
+ def expire(id)
66
+ path = "/credit_grants/#{id}/expire"
67
+ @client.request(:post, path)
68
68
  end
69
69
 
70
70
  # Reverse credit grant transaction
@@ -74,7 +74,7 @@ module Billingrails
74
74
  # @param id [String] Resource ID
75
75
  # @param data [Hash] Request body
76
76
  # @return [Hash] Response data
77
- def reverse_credit_grant_transaction(id, data)
77
+ def reverse_transaction(id, data)
78
78
  path = "/credit_grants/#{id}/reverse_transaction"
79
79
  @client.request(:post, path, body: data)
80
80
  end
@@ -18,7 +18,7 @@ module Billingrails
18
18
  # @param data [Hash] Request body
19
19
  # @return [Hash] Response data
20
20
  def ingest(data)
21
- path = "/biller/events/ingest"
21
+ path = "/events/ingest"
22
22
  @client.request(:post, path, body: data)
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ module Billingrails
29
29
  # @param data [Hash] Request body
30
30
  # @return [Hash] Response data
31
31
  def ingest_batch(data)
32
- path = "/biller/events/batch"
32
+ path = "/events/batch"
33
33
  @client.request(:post, path, body: data)
34
34
  end
35
35
 
@@ -11,6 +11,27 @@ module Billingrails
11
11
  @client = client
12
12
  end
13
13
 
14
+ # List fees
15
+ #
16
+ # Retrieve a list of fees.
17
+ #
18
+ # @return [Hash] Response data
19
+ def list()
20
+ path = "/fees"
21
+ @client.request(:get, path)
22
+ end
23
+
24
+ # Create a fee
25
+ #
26
+ # Creates a fee.
27
+ #
28
+ # @param data [Hash] Request body
29
+ # @return [Hash] Response data
30
+ def create(data)
31
+ path = "/fees"
32
+ @client.request(:post, path, body: data)
33
+ end
34
+
14
35
  # Retrieve fee
15
36
  #
16
37
  # Retrieves a fee by ID.
@@ -19,7 +40,7 @@ module Billingrails
19
40
  # @param params [Hash, nil] Query parameters
20
41
  # @return [Hash] Response data
21
42
  def retrieve(id, params: nil)
22
- path = "/biller/fees/#{id}"
43
+ path = "/fees/#{id}"
23
44
  @client.request(:get, path, params: params)
24
45
  end
25
46
 
@@ -31,7 +52,7 @@ module Billingrails
31
52
  # @param data [Hash] Request body
32
53
  # @return [Hash] Response data
33
54
  def update(id, data)
34
- path = "/biller/fees/#{id}"
55
+ path = "/fees/#{id}"
35
56
  @client.request(:put, path, body: data)
36
57
  end
37
58
 
@@ -42,29 +63,30 @@ module Billingrails
42
63
  # @param id [String] Resource ID
43
64
  # @return [Hash] Response data
44
65
  def delete(id)
45
- path = "/biller/fees/#{id}"
66
+ path = "/fees/#{id}"
46
67
  @client.request(:delete, path)
47
68
  end
48
69
 
49
- # List fees
70
+ # Archive a fee
50
71
  #
51
- # Retrieve a list of fees.
72
+ # Archives a fee, making it inactive for new subscriptions.
52
73
  #
74
+ # @param id [String] Resource ID
53
75
  # @return [Hash] Response data
54
- def list()
55
- path = "/biller/fees"
56
- @client.request(:get, path)
76
+ def archive(id)
77
+ path = "/fees/#{id}/archive"
78
+ @client.request(:post, path)
57
79
  end
58
80
 
59
- # Create a fee
81
+ # Unarchive a fee
60
82
  #
61
- # Creates a fee.
83
+ # Restores an archived fee to active status.
62
84
  #
63
- # @param data [Hash] Request body
85
+ # @param id [String] Resource ID
64
86
  # @return [Hash] Response data
65
- def create(data)
66
- path = "/biller/fees"
67
- @client.request(:post, path, body: data)
87
+ def undo_archive(id)
88
+ path = "/fees/#{id}/unarchive"
89
+ @client.request(:post, path)
68
90
  end
69
91
 
70
92
  end
@@ -33,18 +33,6 @@ module Billingrails
33
33
  @client.request(:post, path, body: data)
34
34
  end
35
35
 
36
- # Issue an invoice
37
- #
38
- # Issues an invoice.
39
- #
40
- # @param id [String] Resource ID
41
- # @param data [Hash] Request body
42
- # @return [Hash] Response data
43
- def issue(id, data)
44
- path = "/invoices/#{id}/issue"
45
- @client.request(:post, path, body: data)
46
- end
47
-
48
36
  # Retrieve invoice
49
37
  #
50
38
  # Retrieves an invoice by ID.
@@ -69,6 +57,18 @@ module Billingrails
69
57
  @client.request(:put, path, body: data)
70
58
  end
71
59
 
60
+ # Issue an invoice
61
+ #
62
+ # Issues an invoice.
63
+ #
64
+ # @param id [String] Resource ID
65
+ # @param data [Hash] Request body
66
+ # @return [Hash] Response data
67
+ def issue(id, data)
68
+ path = "/invoices/#{id}/issue"
69
+ @client.request(:post, path, body: data)
70
+ end
71
+
72
72
  end
73
73
  end
74
74
  end
@@ -18,7 +18,7 @@ module Billingrails
18
18
  # @param params [Hash, nil] Query parameters
19
19
  # @return [Hash] Response data
20
20
  def list(params: nil)
21
- path = "/biller/meters"
21
+ path = "/meters"
22
22
  @client.request(:get, path, params: params)
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ module Billingrails
29
29
  # @param data [Hash] Request body
30
30
  # @return [Hash] Response data
31
31
  def create(data)
32
- path = "/biller/meters"
32
+ path = "/meters"
33
33
  @client.request(:post, path, body: data)
34
34
  end
35
35
 
@@ -41,7 +41,7 @@ module Billingrails
41
41
  # @param params [Hash, nil] Query parameters
42
42
  # @return [Hash] Response data
43
43
  def retrieve(id, params: nil)
44
- path = "/biller/meters/#{id}"
44
+ path = "/meters/#{id}"
45
45
  @client.request(:get, path, params: params)
46
46
  end
47
47
 
@@ -53,7 +53,7 @@ module Billingrails
53
53
  # @param data [Hash] Request body
54
54
  # @return [Hash] Response data
55
55
  def update(id, data)
56
- path = "/biller/meters/#{id}"
56
+ path = "/meters/#{id}"
57
57
  @client.request(:put, path, body: data)
58
58
  end
59
59
 
@@ -4,56 +4,56 @@
4
4
 
5
5
  module Billingrails
6
6
  module Resources
7
- # Products resource
8
- class Products
7
+ # Payment links resource
8
+ class PaymentLinks
9
9
  # @param client [Client] The API client
10
10
  def initialize(client)
11
11
  @client = client
12
12
  end
13
13
 
14
- # List products
14
+ # List payment links
15
15
  #
16
- # Retrieves a list of products.
16
+ # Retrieves a list of payment links.
17
17
  #
18
18
  # @param params [Hash, nil] Query parameters
19
19
  # @return [Hash] Response data
20
20
  def list(params: nil)
21
- path = "/seller/products"
21
+ path = "/payment_links"
22
22
  @client.request(:get, path, params: params)
23
23
  end
24
24
 
25
- # Create a product
25
+ # Create payment link
26
26
  #
27
- # Creates a product.
27
+ # Creates a new payment link.
28
28
  #
29
29
  # @param data [Hash] Request body
30
30
  # @return [Hash] Response data
31
31
  def create(data)
32
- path = "/seller/products"
32
+ path = "/payment_links"
33
33
  @client.request(:post, path, body: data)
34
34
  end
35
35
 
36
- # Retrieve a product
36
+ # Retrieve payment link
37
37
  #
38
- # Retrieves a product by ID.
38
+ # Retrieves a payment link by ID.
39
39
  #
40
40
  # @param id [String] Resource ID
41
41
  # @param params [Hash, nil] Query parameters
42
42
  # @return [Hash] Response data
43
43
  def retrieve(id, params: nil)
44
- path = "/seller/products/#{id}"
44
+ path = "/payment_links/#{id}"
45
45
  @client.request(:get, path, params: params)
46
46
  end
47
47
 
48
- # Update a product
48
+ # Update payment link
49
49
  #
50
- # Updates a product.
50
+ # Updates a payment link.
51
51
  #
52
52
  # @param id [String] Resource ID
53
53
  # @param data [Hash] Request body
54
54
  # @return [Hash] Response data
55
55
  def update(id, data)
56
- path = "/seller/products/#{id}"
56
+ path = "/payment_links/#{id}"
57
57
  @client.request(:put, path, body: data)
58
58
  end
59
59
 
@@ -11,9 +11,20 @@ module Billingrails
11
11
  @client = client
12
12
  end
13
13
 
14
+ # List payments
15
+ #
16
+ # Retrieves a list of payments.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/payments"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
14
25
  # Create a payment
15
26
  #
16
- # Create an online or offline payment for an invoice, order, payment request, or credit grant.
27
+ # Create an online or offline payment for an invoice, payment request, or credit grant.
17
28
  #
18
29
  # @param data [Hash] Request body
19
30
  # @return [Hash] Response data
@@ -22,6 +33,18 @@ module Billingrails
22
33
  @client.request(:post, path, body: data)
23
34
  end
24
35
 
36
+ # Retrieve payment
37
+ #
38
+ # Retrieves a payment by ID.
39
+ #
40
+ # @param id [String] Resource ID
41
+ # @param params [Hash, nil] Query parameters
42
+ # @return [Hash] Response data
43
+ def retrieve(id, params: nil)
44
+ path = "/payments/#{id}"
45
+ @client.request(:get, path, params: params)
46
+ end
47
+
25
48
  end
26
49
  end
27
50
  end
@@ -18,7 +18,7 @@ module Billingrails
18
18
  # @param params [Hash, nil] Query parameters
19
19
  # @return [Hash] Response data
20
20
  def list(params: nil)
21
- path = "/biller/plans"
21
+ path = "/plans"
22
22
  @client.request(:get, path, params: params)
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ module Billingrails
29
29
  # @param data [Hash] Request body
30
30
  # @return [Hash] Response data
31
31
  def create(data)
32
- path = "/biller/plans"
32
+ path = "/plans"
33
33
  @client.request(:post, path, body: data)
34
34
  end
35
35
 
@@ -41,7 +41,7 @@ module Billingrails
41
41
  # @param params [Hash, nil] Query parameters
42
42
  # @return [Hash] Response data
43
43
  def retrieve(id, params: nil)
44
- path = "/biller/plans/#{id}"
44
+ path = "/plans/#{id}"
45
45
  @client.request(:get, path, params: params)
46
46
  end
47
47
 
@@ -53,7 +53,7 @@ module Billingrails
53
53
  # @param data [Hash] Request body
54
54
  # @return [Hash] Response data
55
55
  def update(id, data)
56
- path = "/biller/plans/#{id}"
56
+ path = "/plans/#{id}"
57
57
  @client.request(:put, path, body: data)
58
58
  end
59
59
 
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ module Billingrails
6
+ module Resources
7
+ # Prices resource
8
+ class Prices
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Create a price
15
+ #
16
+ # Creates a price.
17
+ #
18
+ # @param data [Hash] Request body
19
+ # @return [Hash] Response data
20
+ def create(data)
21
+ path = "/prices"
22
+ @client.request(:post, path, body: data)
23
+ end
24
+
25
+ # Retrieve a price
26
+ #
27
+ # Retrieves a price by ID.
28
+ #
29
+ # @param id [String] Resource ID
30
+ # @param params [Hash, nil] Query parameters
31
+ # @return [Hash] Response data
32
+ def retrieve(id, params: nil)
33
+ path = "/prices/#{id}"
34
+ @client.request(:get, path, params: params)
35
+ end
36
+
37
+ # Update a price
38
+ #
39
+ # Updates a price by ID.
40
+ #
41
+ # @param id [String] Resource ID
42
+ # @param data [Hash] Request body
43
+ # @return [Hash] Response data
44
+ def update(id, data)
45
+ path = "/prices/#{id}"
46
+ @client.request(:put, path, body: data)
47
+ end
48
+
49
+ # Delete a price
50
+ #
51
+ # Deletes a price by ID.
52
+ #
53
+ # @param id [String] Resource ID
54
+ # @return [Hash] Response data
55
+ def delete(id)
56
+ path = "/prices/#{id}"
57
+ @client.request(:delete, path)
58
+ end
59
+
60
+ # Archive a price
61
+ #
62
+ # Archives a price, making it inactive for new subscriptions.
63
+ #
64
+ # @param id [String] Resource ID
65
+ # @return [Hash] Response data
66
+ def archive(id)
67
+ path = "/prices/#{id}/archive"
68
+ @client.request(:post, path)
69
+ end
70
+
71
+ # Unarchive a price
72
+ #
73
+ # Restores an archived price to active status.
74
+ #
75
+ # @param id [String] Resource ID
76
+ # @return [Hash] Response data
77
+ def undo_archive(id)
78
+ path = "/prices/#{id}/unarchive"
79
+ @client.request(:post, path)
80
+ end
81
+
82
+ end
83
+ end
84
+ end
@@ -11,6 +11,28 @@ module Billingrails
11
11
  @client = client
12
12
  end
13
13
 
14
+ # List subscriptions
15
+ #
16
+ # Retrieves a list of subscriptions.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/subscriptions"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create a subscription
26
+ #
27
+ # Creates a subscription.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/subscriptions"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
14
36
  # Retrieve subscription
15
37
  #
16
38
  # Retrieves a subscription by ID.
@@ -19,7 +41,7 @@ module Billingrails
19
41
  # @param params [Hash, nil] Query parameters
20
42
  # @return [Hash] Response data
21
43
  def retrieve(id, params: nil)
22
- path = "/biller/subscriptions/#{id}"
44
+ path = "/subscriptions/#{id}"
23
45
  @client.request(:get, path, params: params)
24
46
  end
25
47
 
@@ -31,29 +53,19 @@ module Billingrails
31
53
  # @param data [Hash] Request body
32
54
  # @return [Hash] Response data
33
55
  def update(id, data)
34
- path = "/biller/subscriptions/#{id}"
56
+ path = "/subscriptions/#{id}"
35
57
  @client.request(:put, path, body: data)
36
58
  end
37
59
 
38
- # List subscriptions
60
+ # Resume a paused subscription
39
61
  #
40
- # Retrieves a list of subscriptions.
41
- #
42
- # @param params [Hash, nil] Query parameters
43
- # @return [Hash] Response data
44
- def list(params: nil)
45
- path = "/biller/subscriptions"
46
- @client.request(:get, path, params: params)
47
- end
48
-
49
- # Create a subscription
50
- #
51
- # Creates a subscription.
62
+ # Creates a subscription resumption checkout session, triggers payment, and returns the payment link. The subscription must be paused. Requires an active payment integration (site payment routes or an active integration). The customer is redirected to the payment link to pay the resumption invoice; after payment the subscription becomes active again.
52
63
  #
64
+ # @param id [String] Resource ID
53
65
  # @param data [Hash] Request body
54
66
  # @return [Hash] Response data
55
- def create(data)
56
- path = "/biller/subscriptions"
67
+ def resume(id, data)
68
+ path = "/subscriptions/#{id}/resume"
57
69
  @client.request(:post, path, body: data)
58
70
  end
59
71
 
@@ -4,68 +4,79 @@
4
4
 
5
5
  module Billingrails
6
6
  module Resources
7
- # Orders resource
8
- class Orders
7
+ # Tax rates resource
8
+ class TaxRates
9
9
  # @param client [Client] The API client
10
10
  def initialize(client)
11
11
  @client = client
12
12
  end
13
13
 
14
- # Cancel an order
14
+ # List tax rates
15
15
  #
16
- # Cancels an order.
16
+ # Retrieve a list of tax rates.
17
17
  #
18
- # @param id [String] Resource ID
18
+ # @param params [Hash, nil] Query parameters
19
19
  # @return [Hash] Response data
20
- def cancel(id)
21
- path = "/seller/orders/#{id}/cancel"
22
- @client.request(:post, path)
20
+ def list(params: nil)
21
+ path = "/tax_rates"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create a tax rate
26
+ #
27
+ # Creates a tax rate.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/tax_rates"
33
+ @client.request(:post, path, body: data)
23
34
  end
24
35
 
25
- # Retrieve an order
36
+ # Retrieve tax rate
26
37
  #
27
- # Retrieves an order by ID.
38
+ # Retrieves a tax rate by ID.
28
39
  #
29
40
  # @param id [String] Resource ID
30
41
  # @param params [Hash, nil] Query parameters
31
42
  # @return [Hash] Response data
32
43
  def retrieve(id, params: nil)
33
- path = "/seller/orders/#{id}"
44
+ path = "/tax_rates/#{id}"
34
45
  @client.request(:get, path, params: params)
35
46
  end
36
47
 
37
- # Update an order
48
+ # Update a tax rate
38
49
  #
39
- # Updates an order.
50
+ # Updates a tax rate.
40
51
  #
41
52
  # @param id [String] Resource ID
42
53
  # @param data [Hash] Request body
43
54
  # @return [Hash] Response data
44
55
  def update(id, data)
45
- path = "/seller/orders/#{id}"
56
+ path = "/tax_rates/#{id}"
46
57
  @client.request(:put, path, body: data)
47
58
  end
48
59
 
49
- # List orders
60
+ # Delete a tax rate
50
61
  #
51
- # Retrieves a list of orders.
62
+ # Deletes a tax rate.
52
63
  #
53
- # @param params [Hash, nil] Query parameters
64
+ # @param id [String] Resource ID
54
65
  # @return [Hash] Response data
55
- def list(params: nil)
56
- path = "/seller/orders"
57
- @client.request(:get, path, params: params)
66
+ def delete(id)
67
+ path = "/tax_rates/#{id}"
68
+ @client.request(:delete, path)
58
69
  end
59
70
 
60
- # Create an order
71
+ # Archive a tax rate
61
72
  #
62
- # Creates an order.
73
+ # Archives a tax rate. Sets status to archived.
63
74
  #
64
- # @param data [Hash] Request body
75
+ # @param id [String] Resource ID
65
76
  # @return [Hash] Response data
66
- def create(data)
67
- path = "/seller/orders"
68
- @client.request(:post, path, body: data)
77
+ def archive(id)
78
+ path = "/tax_rates/#{id}/archive"
79
+ @client.request(:post, path)
69
80
  end
70
81
 
71
82
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Billingrails
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
data/lib/billingrails.rb CHANGED
@@ -7,18 +7,19 @@ require_relative 'billingrails/errors'
7
7
  require_relative 'billingrails/client'
8
8
 
9
9
  require_relative 'billingrails/resources/accounts'
10
- require_relative 'billingrails/resources/credit_grants'
11
- require_relative 'billingrails/resources/discounts'
10
+ require_relative 'billingrails/resources/checkout_sessions'
12
11
  require_relative 'billingrails/resources/events'
13
12
  require_relative 'billingrails/resources/fees'
14
- require_relative 'billingrails/resources/invoices'
15
13
  require_relative 'billingrails/resources/meters'
16
- require_relative 'billingrails/resources/orders'
17
- require_relative 'billingrails/resources/payment_pages'
18
- require_relative 'billingrails/resources/payments'
19
14
  require_relative 'billingrails/resources/plans'
20
- require_relative 'billingrails/resources/products'
21
15
  require_relative 'billingrails/resources/subscriptions'
16
+ require_relative 'billingrails/resources/tax_rates'
17
+ require_relative 'billingrails/resources/credit_grants'
18
+ require_relative 'billingrails/resources/discounts'
19
+ require_relative 'billingrails/resources/invoices'
20
+ require_relative 'billingrails/resources/payments'
21
+ require_relative 'billingrails/resources/prices'
22
+ require_relative 'billingrails/resources/payment_links'
22
23
 
23
24
  # Main module for Billingrails SDK
24
25
  module Billingrails
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billingrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Billingrails
@@ -80,18 +80,19 @@ files:
80
80
  - lib/billingrails/client.rb
81
81
  - lib/billingrails/errors.rb
82
82
  - lib/billingrails/resources/accounts.rb
83
+ - lib/billingrails/resources/checkout_sessions.rb
83
84
  - lib/billingrails/resources/credit_grants.rb
84
85
  - lib/billingrails/resources/discounts.rb
85
86
  - lib/billingrails/resources/events.rb
86
87
  - lib/billingrails/resources/fees.rb
87
88
  - lib/billingrails/resources/invoices.rb
88
89
  - lib/billingrails/resources/meters.rb
89
- - lib/billingrails/resources/orders.rb
90
- - lib/billingrails/resources/payment_pages.rb
90
+ - lib/billingrails/resources/payment_links.rb
91
91
  - lib/billingrails/resources/payments.rb
92
92
  - lib/billingrails/resources/plans.rb
93
- - lib/billingrails/resources/products.rb
93
+ - lib/billingrails/resources/prices.rb
94
94
  - lib/billingrails/resources/subscriptions.rb
95
+ - lib/billingrails/resources/tax_rates.rb
95
96
  - lib/billingrails/version.rb
96
97
  homepage: https://github.com/billingrails/billingrails-ruby
97
98
  licenses: