billingrails 0.1.8 → 0.1.9
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/lib/billingrails/client.rb +8 -6
- data/lib/billingrails/resources/accounts.rb +3 -3
- data/lib/billingrails/resources/charges.rb +38 -0
- data/lib/billingrails/resources/checkout_sessions.rb +1 -1
- data/lib/billingrails/resources/credit_assets.rb +62 -0
- data/lib/billingrails/resources/credit_grants.rb +11 -0
- data/lib/billingrails/resources/discounts.rb +23 -1
- data/lib/billingrails/resources/invoices.rb +1 -1
- data/lib/billingrails/resources/meters.rb +34 -1
- data/lib/billingrails/resources/payment_links.rb +1 -1
- data/lib/billingrails/resources/plans.rb +1 -1
- data/lib/billingrails/resources/prices.rb +1 -1
- data/lib/billingrails/resources/products.rb +12 -1
- data/lib/billingrails/resources/subscriptions.rb +1 -1
- data/lib/billingrails/resources/tax_rates.rb +12 -1
- data/lib/billingrails/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f1d9e790d2510fb2aa89b43a81bb643780f2377689528e3d97d61314c59d870
|
|
4
|
+
data.tar.gz: 789edc239059684982662e1baa312f393299aa96882e94f86df99d9c2ffb1f48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3809d7264f627bc016ca510e3288fb8745681a26b75d748ec6150aa61ea4e454563495cb1878761fc393141d17c9f5bbc1fa323139bffb2229d34723648db2e8
|
|
7
|
+
data.tar.gz: 84f35fea9faf6e8fe8c50d7fb47b5f230d1ea15d9169dcd0a0516abd3b6ba50ea5336d70379107832cfaaae9ae88b15534d8226eaf4d1582a38f569e9f403bcd
|
data/lib/billingrails/client.rb
CHANGED
|
@@ -14,9 +14,9 @@ module Billingrails
|
|
|
14
14
|
RETRYABLE_HTTP_STATUSES = [429, 500, 502, 503, 504].freeze
|
|
15
15
|
|
|
16
16
|
attr_reader :api_key, :base_url, :timeout, :max_retries
|
|
17
|
-
attr_reader :accounts, :invoices, :payments, :payment_links
|
|
18
|
-
attr_reader :
|
|
19
|
-
attr_reader :discounts, :
|
|
17
|
+
attr_reader :accounts, :invoices, :charges, :payments, :payment_links, :checkout_sessions
|
|
18
|
+
attr_reader :products, :prices, :plans, :subscriptions, :meters, :events
|
|
19
|
+
attr_reader :credit_grants, :credit_assets, :discounts, :tax_rates
|
|
20
20
|
|
|
21
21
|
# Initialize a new client
|
|
22
22
|
#
|
|
@@ -34,18 +34,20 @@ module Billingrails
|
|
|
34
34
|
# Initialize top-level resources
|
|
35
35
|
@accounts = Resources::Accounts.new(self)
|
|
36
36
|
@invoices = Resources::Invoices.new(self)
|
|
37
|
+
@charges = Resources::Charges.new(self)
|
|
37
38
|
@payments = Resources::Payments.new(self)
|
|
38
|
-
@
|
|
39
|
+
@payment_links = Resources::PaymentLinks.new(self)
|
|
39
40
|
@checkout_sessions = Resources::CheckoutSessions.new(self)
|
|
40
41
|
|
|
41
|
-
@subscriptions = Resources::Subscriptions.new(self)
|
|
42
42
|
@products = Resources::Products.new(self)
|
|
43
43
|
@prices = Resources::Prices.new(self)
|
|
44
44
|
@plans = Resources::Plans.new(self)
|
|
45
|
-
@
|
|
45
|
+
@subscriptions = Resources::Subscriptions.new(self)
|
|
46
46
|
@meters = Resources::Meters.new(self)
|
|
47
|
+
@events = Resources::Events.new(self)
|
|
47
48
|
|
|
48
49
|
@credit_grants = Resources::CreditGrants.new(self)
|
|
50
|
+
@credit_assets = Resources::CreditAssets.new(self)
|
|
49
51
|
@discounts = Resources::Discounts.new(self)
|
|
50
52
|
@tax_rates = Resources::TaxRates.new(self)
|
|
51
53
|
end
|
|
@@ -54,7 +54,7 @@ module Billingrails
|
|
|
54
54
|
# @return [Hash] Response data
|
|
55
55
|
def update(id, data)
|
|
56
56
|
path = "/accounts/#{id}"
|
|
57
|
-
@client.request(:
|
|
57
|
+
@client.request(:patch, path, body: data)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# Get balances
|
|
@@ -76,8 +76,8 @@ module Billingrails
|
|
|
76
76
|
# @param id [String] Resource ID
|
|
77
77
|
# @param data [Hash] Request body
|
|
78
78
|
# @return [Hash] Response data
|
|
79
|
-
def
|
|
80
|
-
path = "/accounts/#{id}/
|
|
79
|
+
def debit_balance(id, data)
|
|
80
|
+
path = "/accounts/#{id}/debit_balance"
|
|
81
81
|
@client.request(:post, path, body: data)
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated. Do not edit manually.
|
|
4
|
+
|
|
5
|
+
module Billingrails
|
|
6
|
+
module Resources
|
|
7
|
+
# Charges resource
|
|
8
|
+
class Charges
|
|
9
|
+
# @param client [Client] The API client
|
|
10
|
+
def initialize(client)
|
|
11
|
+
@client = client
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Settle a charge
|
|
15
|
+
#
|
|
16
|
+
# Marks a charge in `ready` status as settled. Typically used when confirming usage outside automatic credit settlement.
|
|
17
|
+
#
|
|
18
|
+
# @param id [String] Resource ID
|
|
19
|
+
# @return [Hash] Response data
|
|
20
|
+
def settle(id)
|
|
21
|
+
path = "/charges/#{id}/settle"
|
|
22
|
+
@client.request(:post, path)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Discard a charge
|
|
26
|
+
#
|
|
27
|
+
# Discards a `ready`charge.
|
|
28
|
+
#
|
|
29
|
+
# @param id [String] Resource ID
|
|
30
|
+
# @return [Hash] Response data
|
|
31
|
+
def discard(id)
|
|
32
|
+
path = "/charges/#{id}"
|
|
33
|
+
@client.request(:delete, path)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is auto-generated. Do not edit manually.
|
|
4
|
+
|
|
5
|
+
module Billingrails
|
|
6
|
+
module Resources
|
|
7
|
+
# Credit assets resource
|
|
8
|
+
class CreditAssets
|
|
9
|
+
# @param client [Client] The API client
|
|
10
|
+
def initialize(client)
|
|
11
|
+
@client = client
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# List credit assets
|
|
15
|
+
#
|
|
16
|
+
# Retrieves a list of credit assets.
|
|
17
|
+
#
|
|
18
|
+
# @param params [Hash, nil] Query parameters
|
|
19
|
+
# @return [Hash] Response data
|
|
20
|
+
def list(params: nil)
|
|
21
|
+
path = "/credit_assets"
|
|
22
|
+
@client.request(:get, path, params: params)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Create a credit asset
|
|
26
|
+
#
|
|
27
|
+
# Creates a credit asset.
|
|
28
|
+
#
|
|
29
|
+
# @param data [Hash] Request body
|
|
30
|
+
# @return [Hash] Response data
|
|
31
|
+
def create(data)
|
|
32
|
+
path = "/credit_assets"
|
|
33
|
+
@client.request(:post, path, body: data)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Retrieve a credit asset
|
|
37
|
+
#
|
|
38
|
+
# Retrieves a credit asset by ID or code.
|
|
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 = "/credit_assets/#{id}"
|
|
45
|
+
@client.request(:get, path, params: params)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Update a credit asset
|
|
49
|
+
#
|
|
50
|
+
# Updates a credit asset.
|
|
51
|
+
#
|
|
52
|
+
# @param id [String] Resource ID
|
|
53
|
+
# @param data [Hash] Request body
|
|
54
|
+
# @return [Hash] Response data
|
|
55
|
+
def update(id, data)
|
|
56
|
+
path = "/credit_assets/#{id}"
|
|
57
|
+
@client.request(:patch, path, body: data)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -67,6 +67,17 @@ module Billingrails
|
|
|
67
67
|
@client.request(:post, path)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
# Void credit grant
|
|
71
|
+
#
|
|
72
|
+
# Voids a credit grant that is pending or granted with its full balance unused.
|
|
73
|
+
#
|
|
74
|
+
# @param id [String] Resource ID
|
|
75
|
+
# @return [Hash] Response data
|
|
76
|
+
def void(id)
|
|
77
|
+
path = "/credit_grants/#{id}/void"
|
|
78
|
+
@client.request(:post, path)
|
|
79
|
+
end
|
|
80
|
+
|
|
70
81
|
# Reverse credit grant transaction
|
|
71
82
|
#
|
|
72
83
|
# Reverses a credit grant usage.
|
|
@@ -54,7 +54,29 @@ module Billingrails
|
|
|
54
54
|
# @return [Hash] Response data
|
|
55
55
|
def update(id, data)
|
|
56
56
|
path = "/discounts/#{id}"
|
|
57
|
-
@client.request(:
|
|
57
|
+
@client.request(:patch, path, body: data)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Archive a discount
|
|
61
|
+
#
|
|
62
|
+
# Archives a discount.
|
|
63
|
+
#
|
|
64
|
+
# @param id [String] Resource ID
|
|
65
|
+
# @return [Hash] Response data
|
|
66
|
+
def archive(id)
|
|
67
|
+
path = "/discounts/#{id}/archive"
|
|
68
|
+
@client.request(:post, path)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Unarchive a discount
|
|
72
|
+
#
|
|
73
|
+
# Unarchives a discount.
|
|
74
|
+
#
|
|
75
|
+
# @param id [String] Resource ID
|
|
76
|
+
# @return [Hash] Response data
|
|
77
|
+
def unarchive(id)
|
|
78
|
+
path = "/discounts/#{id}/unarchive"
|
|
79
|
+
@client.request(:post, path)
|
|
58
80
|
end
|
|
59
81
|
|
|
60
82
|
end
|
|
@@ -54,7 +54,40 @@ module Billingrails
|
|
|
54
54
|
# @return [Hash] Response data
|
|
55
55
|
def update(id, data)
|
|
56
56
|
path = "/meters/#{id}"
|
|
57
|
-
@client.request(:
|
|
57
|
+
@client.request(:patch, path, body: data)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Delete a meter
|
|
61
|
+
#
|
|
62
|
+
# Deletes a meter when no subscription uses a price associated with it.
|
|
63
|
+
#
|
|
64
|
+
# @param id [String] Resource ID
|
|
65
|
+
# @return [Hash] Response data
|
|
66
|
+
def delete(id)
|
|
67
|
+
path = "/meters/#{id}"
|
|
68
|
+
@client.request(:delete, path)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Archive a meter
|
|
72
|
+
#
|
|
73
|
+
# Archives a meter.
|
|
74
|
+
#
|
|
75
|
+
# @param id [String] Resource ID
|
|
76
|
+
# @return [Hash] Response data
|
|
77
|
+
def archive(id)
|
|
78
|
+
path = "/meters/#{id}/archive"
|
|
79
|
+
@client.request(:post, path)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Unarchive a meter
|
|
83
|
+
#
|
|
84
|
+
# Restores an archived meter.
|
|
85
|
+
#
|
|
86
|
+
# @param id [String] Resource ID
|
|
87
|
+
# @return [Hash] Response data
|
|
88
|
+
def unarchive(id)
|
|
89
|
+
path = "/meters/#{id}/unarchive"
|
|
90
|
+
@client.request(:post, path)
|
|
58
91
|
end
|
|
59
92
|
|
|
60
93
|
end
|
|
@@ -54,7 +54,18 @@ module Billingrails
|
|
|
54
54
|
# @return [Hash] Response data
|
|
55
55
|
def update(id, data)
|
|
56
56
|
path = "/products/#{id}"
|
|
57
|
-
@client.request(:
|
|
57
|
+
@client.request(:patch, path, body: data)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Delete a product
|
|
61
|
+
#
|
|
62
|
+
# Deletes a product when it is not used in any subscription and not referenced on invoices.
|
|
63
|
+
#
|
|
64
|
+
# @param id [String] Resource ID
|
|
65
|
+
# @return [Hash] Response data
|
|
66
|
+
def delete(id)
|
|
67
|
+
path = "/products/#{id}"
|
|
68
|
+
@client.request(:delete, path)
|
|
58
69
|
end
|
|
59
70
|
|
|
60
71
|
# Archive a product
|
|
@@ -54,7 +54,7 @@ module Billingrails
|
|
|
54
54
|
# @return [Hash] Response data
|
|
55
55
|
def update(id, data)
|
|
56
56
|
path = "/tax_rates/#{id}"
|
|
57
|
-
@client.request(:
|
|
57
|
+
@client.request(:patch, path, body: data)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# Delete a tax rate
|
|
@@ -79,6 +79,17 @@ module Billingrails
|
|
|
79
79
|
@client.request(:post, path)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
# Unarchive a tax rate
|
|
83
|
+
#
|
|
84
|
+
# Unarchives a tax rate.
|
|
85
|
+
#
|
|
86
|
+
# @param id [String] Resource ID
|
|
87
|
+
# @return [Hash] Response data
|
|
88
|
+
def unarchive(id)
|
|
89
|
+
path = "/tax_rates/#{id}/unarchive"
|
|
90
|
+
@client.request(:post, path)
|
|
91
|
+
end
|
|
92
|
+
|
|
82
93
|
end
|
|
83
94
|
end
|
|
84
95
|
end
|
data/lib/billingrails/version.rb
CHANGED
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.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Billingrails
|
|
@@ -80,7 +80,9 @@ files:
|
|
|
80
80
|
- lib/billingrails/client.rb
|
|
81
81
|
- lib/billingrails/errors.rb
|
|
82
82
|
- lib/billingrails/resources/accounts.rb
|
|
83
|
+
- lib/billingrails/resources/charges.rb
|
|
83
84
|
- lib/billingrails/resources/checkout_sessions.rb
|
|
85
|
+
- lib/billingrails/resources/credit_assets.rb
|
|
84
86
|
- lib/billingrails/resources/credit_grants.rb
|
|
85
87
|
- lib/billingrails/resources/discounts.rb
|
|
86
88
|
- lib/billingrails/resources/events.rb
|