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 +4 -4
- data/CHANGELOG.md +0 -1
- data/README.md +1 -1
- data/lib/billingrails/client.rb +15 -31
- data/lib/billingrails/resources/accounts.rb +27 -27
- data/lib/billingrails/resources/{payment_pages.rb → checkout_sessions.rb} +14 -25
- data/lib/billingrails/resources/credit_grants.rb +26 -26
- data/lib/billingrails/resources/events.rb +2 -2
- data/lib/billingrails/resources/fees.rb +36 -14
- data/lib/billingrails/resources/invoices.rb +12 -12
- data/lib/billingrails/resources/meters.rb +4 -4
- data/lib/billingrails/resources/{products.rb → payment_links.rb} +14 -14
- data/lib/billingrails/resources/payments.rb +24 -1
- data/lib/billingrails/resources/plans.rb +4 -4
- data/lib/billingrails/resources/prices.rb +84 -0
- data/lib/billingrails/resources/subscriptions.rb +29 -17
- data/lib/billingrails/resources/{orders.rb → tax_rates.rb} +37 -26
- data/lib/billingrails/version.rb +1 -1
- data/lib/billingrails.rb +8 -7
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0afc8782d1a0cb29269523d547085dc3be039a06a01799f02fb45da80f7955ad
|
|
4
|
+
data.tar.gz: 0c6137d1ef84e8b8c2bd6af4f620070412e9779a11a08483477e240a8df8c6bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
[](https://rubygems.org/gems/billingrails)
|
|
4
4
|
[](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
|
|
data/lib/billingrails/client.rb
CHANGED
|
@@ -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, :
|
|
37
|
-
attr_reader :
|
|
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::
|
|
33
|
+
@payment_pages = Resources::PaymentLinks.new(self)
|
|
34
|
+
@checkout_sessions = Resources::CheckoutSessions.new(client)
|
|
58
35
|
|
|
59
|
-
|
|
60
|
-
@
|
|
61
|
-
@
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
|
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
|
-
#
|
|
8
|
-
class
|
|
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
|
-
#
|
|
14
|
+
# Create a checkout session
|
|
15
15
|
#
|
|
16
|
-
#
|
|
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
|
|
32
|
-
path = "/
|
|
20
|
+
def create(data)
|
|
21
|
+
path = "/checkout_sessions"
|
|
33
22
|
@client.request(:post, path, body: data)
|
|
34
23
|
end
|
|
35
24
|
|
|
36
|
-
# Retrieve
|
|
25
|
+
# Retrieve a checkout session
|
|
37
26
|
#
|
|
38
|
-
# Retrieves a
|
|
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
|
|
44
|
-
path = "/
|
|
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
|
|
37
|
+
# Update a checkout session
|
|
49
38
|
#
|
|
50
|
-
# Updates a
|
|
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
|
|
56
|
-
path = "/
|
|
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
|
-
#
|
|
14
|
+
# List credit grants
|
|
15
15
|
#
|
|
16
|
-
#
|
|
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
|
|
22
|
-
path = "/credit_grants
|
|
23
|
-
@client.request(:
|
|
19
|
+
def list()
|
|
20
|
+
path = "/credit_grants"
|
|
21
|
+
@client.request(:get, path)
|
|
24
22
|
end
|
|
25
23
|
|
|
26
|
-
#
|
|
24
|
+
# Create a credit grant
|
|
27
25
|
#
|
|
28
|
-
#
|
|
26
|
+
# Creates a credit grant.
|
|
29
27
|
#
|
|
30
|
-
# @param
|
|
28
|
+
# @param data [Hash] Request body
|
|
31
29
|
# @return [Hash] Response data
|
|
32
|
-
def
|
|
33
|
-
path = "/credit_grants
|
|
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
|
|
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
|
-
#
|
|
47
|
+
# Apply credit grant
|
|
50
48
|
#
|
|
51
|
-
#
|
|
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
|
|
55
|
-
path = "/credit_grants"
|
|
56
|
-
@client.request(:
|
|
54
|
+
def apply(id, data)
|
|
55
|
+
path = "/credit_grants/#{id}/apply"
|
|
56
|
+
@client.request(:post, path, body: data)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
#
|
|
59
|
+
# Expire credit grant
|
|
60
60
|
#
|
|
61
|
-
#
|
|
61
|
+
# Expires a credit grant.
|
|
62
62
|
#
|
|
63
|
-
# @param
|
|
63
|
+
# @param id [String] Resource ID
|
|
64
64
|
# @return [Hash] Response data
|
|
65
|
-
def
|
|
66
|
-
path = "/credit_grants"
|
|
67
|
-
@client.request(:post, path
|
|
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
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
66
|
+
path = "/fees/#{id}"
|
|
46
67
|
@client.request(:delete, path)
|
|
47
68
|
end
|
|
48
69
|
|
|
49
|
-
#
|
|
70
|
+
# Archive a fee
|
|
50
71
|
#
|
|
51
|
-
#
|
|
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
|
|
55
|
-
path = "/
|
|
56
|
-
@client.request(:
|
|
76
|
+
def archive(id)
|
|
77
|
+
path = "/fees/#{id}/archive"
|
|
78
|
+
@client.request(:post, path)
|
|
57
79
|
end
|
|
58
80
|
|
|
59
|
-
#
|
|
81
|
+
# Unarchive a fee
|
|
60
82
|
#
|
|
61
|
-
#
|
|
83
|
+
# Restores an archived fee to active status.
|
|
62
84
|
#
|
|
63
|
-
# @param
|
|
85
|
+
# @param id [String] Resource ID
|
|
64
86
|
# @return [Hash] Response data
|
|
65
|
-
def
|
|
66
|
-
path = "/
|
|
67
|
-
@client.request(:post, path
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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
|
-
#
|
|
8
|
-
class
|
|
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
|
|
14
|
+
# List payment links
|
|
15
15
|
#
|
|
16
|
-
# Retrieves a list of
|
|
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 = "/
|
|
21
|
+
path = "/payment_links"
|
|
22
22
|
@client.request(:get, path, params: params)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# Create
|
|
25
|
+
# Create payment link
|
|
26
26
|
#
|
|
27
|
-
# Creates a
|
|
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 = "/
|
|
32
|
+
path = "/payment_links"
|
|
33
33
|
@client.request(:post, path, body: data)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
# Retrieve
|
|
36
|
+
# Retrieve payment link
|
|
37
37
|
#
|
|
38
|
-
# Retrieves a
|
|
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 = "/
|
|
44
|
+
path = "/payment_links/#{id}"
|
|
45
45
|
@client.request(:get, path, params: params)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
# Update
|
|
48
|
+
# Update payment link
|
|
49
49
|
#
|
|
50
|
-
# Updates a
|
|
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 = "/
|
|
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,
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
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 = "/
|
|
56
|
+
path = "/subscriptions/#{id}"
|
|
35
57
|
@client.request(:put, path, body: data)
|
|
36
58
|
end
|
|
37
59
|
|
|
38
|
-
#
|
|
60
|
+
# Resume a paused subscription
|
|
39
61
|
#
|
|
40
|
-
#
|
|
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
|
|
56
|
-
path = "/
|
|
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
|
-
#
|
|
8
|
-
class
|
|
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
|
-
#
|
|
14
|
+
# List tax rates
|
|
15
15
|
#
|
|
16
|
-
#
|
|
16
|
+
# Retrieve a list of tax rates.
|
|
17
17
|
#
|
|
18
|
-
# @param
|
|
18
|
+
# @param params [Hash, nil] Query parameters
|
|
19
19
|
# @return [Hash] Response data
|
|
20
|
-
def
|
|
21
|
-
path = "/
|
|
22
|
-
@client.request(:
|
|
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
|
|
36
|
+
# Retrieve tax rate
|
|
26
37
|
#
|
|
27
|
-
# Retrieves
|
|
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 = "/
|
|
44
|
+
path = "/tax_rates/#{id}"
|
|
34
45
|
@client.request(:get, path, params: params)
|
|
35
46
|
end
|
|
36
47
|
|
|
37
|
-
# Update
|
|
48
|
+
# Update a tax rate
|
|
38
49
|
#
|
|
39
|
-
# Updates
|
|
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 = "/
|
|
56
|
+
path = "/tax_rates/#{id}"
|
|
46
57
|
@client.request(:put, path, body: data)
|
|
47
58
|
end
|
|
48
59
|
|
|
49
|
-
#
|
|
60
|
+
# Delete a tax rate
|
|
50
61
|
#
|
|
51
|
-
#
|
|
62
|
+
# Deletes a tax rate.
|
|
52
63
|
#
|
|
53
|
-
# @param
|
|
64
|
+
# @param id [String] Resource ID
|
|
54
65
|
# @return [Hash] Response data
|
|
55
|
-
def
|
|
56
|
-
path = "/
|
|
57
|
-
@client.request(:
|
|
66
|
+
def delete(id)
|
|
67
|
+
path = "/tax_rates/#{id}"
|
|
68
|
+
@client.request(:delete, path)
|
|
58
69
|
end
|
|
59
70
|
|
|
60
|
-
#
|
|
71
|
+
# Archive a tax rate
|
|
61
72
|
#
|
|
62
|
-
#
|
|
73
|
+
# Archives a tax rate. Sets status to archived.
|
|
63
74
|
#
|
|
64
|
-
# @param
|
|
75
|
+
# @param id [String] Resource ID
|
|
65
76
|
# @return [Hash] Response data
|
|
66
|
-
def
|
|
67
|
-
path = "/
|
|
68
|
-
@client.request(:post, path
|
|
77
|
+
def archive(id)
|
|
78
|
+
path = "/tax_rates/#{id}/archive"
|
|
79
|
+
@client.request(:post, path)
|
|
69
80
|
end
|
|
70
81
|
|
|
71
82
|
end
|
data/lib/billingrails/version.rb
CHANGED
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/
|
|
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.
|
|
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/
|
|
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/
|
|
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:
|