billingrails 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 533de1c2ddd178a3ce99a071fb42338e66ccd8b0d17ea93c3166ed89d56412b5
4
+ data.tar.gz: 64ebd4646a1309903e4ebb263a7477d72fd50fb0340504e2bb2cbab574c24e8a
5
+ SHA512:
6
+ metadata.gz: e1efb59f2b63b4474cb7e2f75e95017dddfbf7ce6970352327c2dd6e44a9e5026eb8833e095010f5d9898c3ee4629f642282dd78a4a8fc7ca3aa0b2fd836a431
7
+ data.tar.gz: d3b5487d232aa5d22c8415fe21c365b6bfc79997bfef9f594f86eef8a37c47b3b31a7ea7c0626cae8802ac9e781d13966182116aa17e91edde5320be8716e55e
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-01-23
9
+
10
+ ### Added
11
+ - Initial release of Billingrails Ruby SDK
12
+ - Complete API client with authentication
13
+ - Resource-based API structure
14
+ - Nested namespaces for biller and seller resources
15
+ - Comprehensive error handling
16
+ - Retry logic with exponential backoff
17
+ - Full test coverage
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Billingrails
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # Billingrails Ruby SDK
2
+
3
+ Official Ruby SDK for the Billingrails API - Flexible, composable, and intuitive API-first commerce platform.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'billingrails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ gem install billingrails
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require 'billingrails'
29
+
30
+ # Initialize the client
31
+ client = Billingrails::Client.new(
32
+ api_key: 'your_api_key_here',
33
+ base_url: 'https://api.billingrails.com/v1' # optional
34
+ )
35
+
36
+ # Access top-level resources
37
+ accounts = client.accounts.list
38
+ account = client.accounts.get('account_id')
39
+
40
+ # Access nested biller resources
41
+ events = client.biller.events.list
42
+ meters = client.biller.meters.list
43
+ plans = client.biller.plans.list
44
+ subscriptions = client.biller.subscriptions.list
45
+
46
+ # Access nested seller resources
47
+ products = client.seller.products.list
48
+ orders = client.seller.orders.list
49
+
50
+ # Create resources
51
+ new_account = client.accounts.create(
52
+ name: 'Acme Corp',
53
+ email: 'billing@acme.com'
54
+ )
55
+
56
+ # Update resources
57
+ updated_account = client.accounts.update(
58
+ 'account_id',
59
+ name: 'Acme Corporation'
60
+ )
61
+
62
+ # Delete resources
63
+ client.accounts.delete('account_id')
64
+ ```
65
+
66
+ ## Error Handling
67
+
68
+ The SDK provides specific error classes for different types of errors:
69
+
70
+ ```ruby
71
+ begin
72
+ client.accounts.get('invalid_id')
73
+ rescue Billingrails::NotFoundError => e
74
+ puts "Resource not found: #{e.message}"
75
+ rescue Billingrails::AuthenticationError => e
76
+ puts "Authentication failed: #{e.message}"
77
+ rescue Billingrails::RateLimitError => e
78
+ puts "Rate limit exceeded: #{e.message}"
79
+ rescue Billingrails::ApiError => e
80
+ puts "API error: #{e.message}"
81
+ puts "Status: #{e.status}"
82
+ puts "Code: #{e.code}"
83
+ rescue Billingrails::ConnectionError => e
84
+ puts "Connection error: #{e.message}"
85
+ end
86
+ ```
87
+
88
+ ## Configuration
89
+
90
+ You can configure the client with the following options:
91
+
92
+ ```ruby
93
+ client = Billingrails::Client.new(
94
+ api_key: 'your_api_key',
95
+ base_url: 'https://api.billingrails.com/v1', # Custom base URL
96
+ timeout: 60 # Request timeout in seconds (default: 30)
97
+ )
98
+ ```
99
+
100
+ ## Development
101
+
102
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
103
+
104
+ ## Contributing
105
+
106
+ Bug reports and pull requests are welcome on GitHub at https://github.com/billingrails/billingrails-ruby.
107
+
108
+ ## License
109
+
110
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'json'
5
+ require 'uri'
6
+
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
+ # Main client for interacting with the Billingrails API
31
+ class Client
32
+ DEFAULT_BASE_URL = 'https://api.billingrails.com/v1'
33
+ DEFAULT_TIMEOUT = 30
34
+
35
+ attr_reader :api_key, :base_url, :timeout
36
+ attr_reader :accounts, :credit_grants, :discounts, :fees, :invoices, :payments, :payment_pages
37
+ attr_reader :biller, :seller
38
+
39
+ # Initialize a new client
40
+ #
41
+ # @param api_key [String] Your API key
42
+ # @param base_url [String] Base URL for API requests
43
+ # @param timeout [Integer] Request timeout in seconds
44
+ def initialize(api_key:, base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT)
45
+ @api_key = api_key
46
+ @base_url = base_url.chomp('/')
47
+ @timeout = timeout
48
+ validate_config!
49
+
50
+ # Initialize top-level resources
51
+ @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
+ @invoices = Resources::Invoices.new(self)
56
+ @payments = Resources::Payments.new(self)
57
+ @payment_pages = Resources::PaymentPages.new(self)
58
+
59
+ # Initialize nested namespaces
60
+ @biller = BillerNamespace.new(self)
61
+ @seller = SellerNamespace.new(self)
62
+ end
63
+
64
+ # Make an HTTP request
65
+ #
66
+ # @param method [Symbol] HTTP method (:get, :post, :put, :patch, :delete)
67
+ # @param path [String] API endpoint path
68
+ # @param body [Hash, nil] Request body
69
+ # @param params [Hash, nil] Query parameters
70
+ # @return [Hash] Parsed response body
71
+ def request(method, path, body: nil, params: nil)
72
+ uri = build_uri(path, params)
73
+ request = build_request(method, uri, body)
74
+
75
+ response = execute_request(uri, request)
76
+ handle_response(response)
77
+ end
78
+
79
+ private
80
+
81
+ def validate_config!
82
+ raise ArgumentError, 'api_key is required' if @api_key.nil? || @api_key.empty?
83
+ end
84
+
85
+ def build_uri(path, params)
86
+ uri = URI.parse("#{@base_url}#{path}")
87
+ if params && !params.empty?
88
+ uri.query = URI.encode_www_form(params)
89
+ end
90
+ uri
91
+ end
92
+
93
+ def build_request(method, uri, body)
94
+ request_class = case method
95
+ when :get then Net::HTTP::Get
96
+ when :post then Net::HTTP::Post
97
+ when :put then Net::HTTP::Put
98
+ when :patch then Net::HTTP::Patch
99
+ when :delete then Net::HTTP::Delete
100
+ else raise ArgumentError, "Unsupported HTTP method: #{method}"
101
+ end
102
+
103
+ request = request_class.new(uri)
104
+ request['Authorization'] = "Bearer #{@api_key}"
105
+ request['Content-Type'] = 'application/json'
106
+ request['Accept'] = 'application/json'
107
+ request['User-Agent'] = "Billingrails Ruby SDK/#{VERSION}"
108
+
109
+ if body
110
+ request.body = JSON.generate(body)
111
+ end
112
+
113
+ request
114
+ end
115
+
116
+ def execute_request(uri, request)
117
+ http = Net::HTTP.new(uri.host, uri.port)
118
+ http.use_ssl = uri.scheme == 'https'
119
+ http.read_timeout = @timeout
120
+ http.open_timeout = @timeout
121
+
122
+ begin
123
+ http.request(request)
124
+ rescue StandardError => e
125
+ raise ConnectionError, "Failed to connect to API: #{e.message}"
126
+ end
127
+ end
128
+
129
+ def handle_response(response)
130
+ case response.code.to_i
131
+ when 200..299
132
+ return {} if response.body.nil? || response.body.empty?
133
+ JSON.parse(response.body)
134
+ when 400
135
+ handle_error_response(response, InvalidRequestError)
136
+ when 401
137
+ handle_error_response(response, AuthenticationError)
138
+ when 404
139
+ handle_error_response(response, NotFoundError)
140
+ when 429
141
+ handle_error_response(response, RateLimitError)
142
+ when 500..599
143
+ handle_error_response(response, ServerError)
144
+ else
145
+ handle_error_response(response, ApiError)
146
+ end
147
+ end
148
+
149
+ def handle_error_response(response, error_class)
150
+ error_data = JSON.parse(response.body) rescue {}
151
+ message = error_data['message'] || response.message
152
+
153
+ raise error_class.new(
154
+ message,
155
+ status: response.code.to_i,
156
+ code: error_data['error']['code'],
157
+ type: error_data['error']['type'],
158
+ details: error_data['error']['details']
159
+ )
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Billingrails
4
+ # Base error class for all SDK errors
5
+ class Error < StandardError; end
6
+
7
+ # API error with detailed information
8
+ class ApiError < Error
9
+ attr_reader :status, :code, :type, :details
10
+
11
+ def initialize(message, status: nil, code: nil, type: nil, details: nil)
12
+ super(message)
13
+ @status = status
14
+ @code = code
15
+ @type = type
16
+ @details = details
17
+ end
18
+ end
19
+
20
+ # Network or connection errors
21
+ class ConnectionError < Error; end
22
+
23
+ # Invalid request errors
24
+ class InvalidRequestError < ApiError; end
25
+
26
+ # Authentication errors
27
+ class AuthenticationError < ApiError; end
28
+
29
+ # Resource not found errors
30
+ class NotFoundError < ApiError; end
31
+
32
+ # Rate limit errors
33
+ class RateLimitError < ApiError; end
34
+
35
+ # Server errors
36
+ class ServerError < ApiError; end
37
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ module Billingrails
6
+ module Resources
7
+ # Accounts resource
8
+ class Accounts
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Retrieve an account
15
+ #
16
+ # Retrieves an account by ID.
17
+ #
18
+ # @param id [String] Resource ID
19
+ # @param params [Hash, nil] Query parameters
20
+ # @return [Hash] Response data
21
+ def retrieve(id, params: nil)
22
+ path = "/accounts/#{id}"
23
+ @client.request(:get, path, params: params)
24
+ end
25
+
26
+ # Update an account
27
+ #
28
+ # Updates an account.
29
+ #
30
+ # @param id [String] Resource ID
31
+ # @param data [Hash] Request body
32
+ # @return [Hash] Response data
33
+ def update(id, data)
34
+ path = "/accounts/#{id}"
35
+ @client.request(:put, path, body: data)
36
+ end
37
+
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
+ # Get balances
51
+ #
52
+ # Retrieve credit balances for an account.
53
+ #
54
+ # @param id [String] Resource ID
55
+ # @param params [Hash, nil] Query parameters
56
+ # @return [Hash] Response data
57
+ def get_balances(id, params: nil)
58
+ path = "/accounts/#{id}/balances"
59
+ @client.request(:get, path, params: params)
60
+ end
61
+
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
74
+ #
75
+ # Creates an account.
76
+ #
77
+ # @param data [Hash] Request body
78
+ # @return [Hash] Response data
79
+ def create(data)
80
+ path = "/accounts"
81
+ @client.request(:post, path, body: data)
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -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
+ # Credit grants resource
8
+ class CreditGrants
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Apply credit grant
15
+ #
16
+ # Applies a credit grant to an invoice or logs an external usage.
17
+ #
18
+ # @param id [String] Resource ID
19
+ # @param data [Hash] Request body
20
+ # @return [Hash] Response data
21
+ def apply_credit_grant(id, data)
22
+ path = "/credit_grants/#{id}/apply"
23
+ @client.request(:post, path, body: data)
24
+ end
25
+
26
+ # Expire credit grant
27
+ #
28
+ # Expires a credit grant.
29
+ #
30
+ # @param id [String] Resource ID
31
+ # @return [Hash] Response data
32
+ def expire_credit_grant(id)
33
+ path = "/credit_grants/#{id}/expire"
34
+ @client.request(:post, path)
35
+ end
36
+
37
+ # Retrieve a credit grant
38
+ #
39
+ # Retrieves a credit grant by ID.
40
+ #
41
+ # @param id [String] Resource ID
42
+ # @param params [Hash, nil] Query parameters
43
+ # @return [Hash] Response data
44
+ def retrieve_credit_grant(id, params: nil)
45
+ path = "/credit_grants/#{id}"
46
+ @client.request(:get, path, params: params)
47
+ end
48
+
49
+ # List credit grants
50
+ #
51
+ # Retrieves a list of credit grants.
52
+ #
53
+ # @return [Hash] Response data
54
+ def list_credit_grants()
55
+ path = "/credit_grants"
56
+ @client.request(:get, path)
57
+ end
58
+
59
+ # Create a credit grant
60
+ #
61
+ # Creates a credit grant.
62
+ #
63
+ # @param data [Hash] Request body
64
+ # @return [Hash] Response data
65
+ def create_credit_grant(data)
66
+ path = "/credit_grants"
67
+ @client.request(:post, path, body: data)
68
+ end
69
+
70
+ # Reverse credit grant transaction
71
+ #
72
+ # Reverses a credit grant usage.
73
+ #
74
+ # @param id [String] Resource ID
75
+ # @param data [Hash] Request body
76
+ # @return [Hash] Response data
77
+ def reverse_credit_grant_transaction(id, data)
78
+ path = "/credit_grants/#{id}/reverse_transaction"
79
+ @client.request(:post, path, body: data)
80
+ end
81
+
82
+ end
83
+ end
84
+ 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
+ # Discounts resource
8
+ class Discounts
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # List discounts
15
+ #
16
+ # Retrieve a list of discounts.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/discounts"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create a discount
26
+ #
27
+ # Creates a discount.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/discounts"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
36
+ # Retrieve discount
37
+ #
38
+ # Retrieves a discount 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 = "/discounts/#{id}"
45
+ @client.request(:get, path, params: params)
46
+ end
47
+
48
+ # Update a discount
49
+ #
50
+ # Updates a discount.
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 = "/discounts/#{id}"
57
+ @client.request(:put, path, body: data)
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -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
+ # Events resource
8
+ class Events
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Ingest event
15
+ #
16
+ # Ingests an event.
17
+ #
18
+ # @param data [Hash] Request body
19
+ # @return [Hash] Response data
20
+ def ingest(data)
21
+ path = "/biller/events/ingest"
22
+ @client.request(:post, path, body: data)
23
+ end
24
+
25
+ # Ingest batch events
26
+ #
27
+ # Ingests batch events.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def ingest_batch(data)
32
+ path = "/biller/events/batch"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ module Billingrails
6
+ module Resources
7
+ # Fees resource
8
+ class Fees
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Retrieve fee
15
+ #
16
+ # Retrieves a fee by ID.
17
+ #
18
+ # @param id [String] Resource ID
19
+ # @param params [Hash, nil] Query parameters
20
+ # @return [Hash] Response data
21
+ def retrieve(id, params: nil)
22
+ path = "/biller/fees/#{id}"
23
+ @client.request(:get, path, params: params)
24
+ end
25
+
26
+ # Update a fee
27
+ #
28
+ # Updates a fee.
29
+ #
30
+ # @param id [String] Resource ID
31
+ # @param data [Hash] Request body
32
+ # @return [Hash] Response data
33
+ def update(id, data)
34
+ path = "/biller/fees/#{id}"
35
+ @client.request(:put, path, body: data)
36
+ end
37
+
38
+ # Delete a fee
39
+ #
40
+ # Deletes a fee.
41
+ #
42
+ # @param id [String] Resource ID
43
+ # @return [Hash] Response data
44
+ def delete(id)
45
+ path = "/biller/fees/#{id}"
46
+ @client.request(:delete, path)
47
+ end
48
+
49
+ # List fees
50
+ #
51
+ # Retrieve a list of fees.
52
+ #
53
+ # @return [Hash] Response data
54
+ def list()
55
+ path = "/biller/fees"
56
+ @client.request(:get, path)
57
+ end
58
+
59
+ # Create a fee
60
+ #
61
+ # Creates a fee.
62
+ #
63
+ # @param data [Hash] Request body
64
+ # @return [Hash] Response data
65
+ def create(data)
66
+ path = "/biller/fees"
67
+ @client.request(:post, path, body: data)
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ module Billingrails
6
+ module Resources
7
+ # Invoices resource
8
+ class Invoices
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # List invoices
15
+ #
16
+ # Retrieves a list of invoices.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/invoices"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create an invoice
26
+ #
27
+ # Creates an invoice.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/invoices"
33
+ @client.request(:post, path, body: data)
34
+ end
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
+ # Retrieve invoice
49
+ #
50
+ # Retrieves an invoice by ID.
51
+ #
52
+ # @param id [String] Resource ID
53
+ # @param params [Hash, nil] Query parameters
54
+ # @return [Hash] Response data
55
+ def retrieve(id, params: nil)
56
+ path = "/invoices/#{id}"
57
+ @client.request(:get, path, params: params)
58
+ end
59
+
60
+ # Update an invoice
61
+ #
62
+ # Updates an invoice.
63
+ #
64
+ # @param id [String] Resource ID
65
+ # @param data [Hash] Request body
66
+ # @return [Hash] Response data
67
+ def update(id, data)
68
+ path = "/invoices/#{id}"
69
+ @client.request(:put, path, body: data)
70
+ end
71
+
72
+ end
73
+ end
74
+ 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
+ # Meters resource
8
+ class Meters
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # List meters
15
+ #
16
+ # Retrieves a list of meters.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/biller/meters"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create a meter
26
+ #
27
+ # Creates a meter.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/biller/meters"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
36
+ # Retrieve a meter
37
+ #
38
+ # Retrieves meter 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 = "/biller/meters/#{id}"
45
+ @client.request(:get, path, params: params)
46
+ end
47
+
48
+ # Update a meter
49
+ #
50
+ # Updates a meter.
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 = "/biller/meters/#{id}"
57
+ @client.request(:put, path, body: data)
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ module Billingrails
6
+ module Resources
7
+ # Orders resource
8
+ class Orders
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Cancel an order
15
+ #
16
+ # Cancels an order.
17
+ #
18
+ # @param id [String] Resource ID
19
+ # @return [Hash] Response data
20
+ def cancel(id)
21
+ path = "/seller/orders/#{id}/cancel"
22
+ @client.request(:post, path)
23
+ end
24
+
25
+ # Retrieve an order
26
+ #
27
+ # Retrieves an order 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 = "/seller/orders/#{id}"
34
+ @client.request(:get, path, params: params)
35
+ end
36
+
37
+ # Update an order
38
+ #
39
+ # Updates an order.
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 = "/seller/orders/#{id}"
46
+ @client.request(:put, path, body: data)
47
+ end
48
+
49
+ # List orders
50
+ #
51
+ # Retrieves a list of orders.
52
+ #
53
+ # @param params [Hash, nil] Query parameters
54
+ # @return [Hash] Response data
55
+ def list(params: nil)
56
+ path = "/seller/orders"
57
+ @client.request(:get, path, params: params)
58
+ end
59
+
60
+ # Create an order
61
+ #
62
+ # Creates an order.
63
+ #
64
+ # @param data [Hash] Request body
65
+ # @return [Hash] Response data
66
+ def create(data)
67
+ path = "/seller/orders"
68
+ @client.request(:post, path, body: data)
69
+ end
70
+
71
+ end
72
+ end
73
+ 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
+ # Payment pages resource
8
+ class PaymentPages
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # List payment pages
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.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create_payment_page(data)
32
+ path = "/payment_pages"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
36
+ # Retrieve payment page
37
+ #
38
+ # Retrieves a payment page by ID.
39
+ #
40
+ # @param id [String] Resource ID
41
+ # @param params [Hash, nil] Query parameters
42
+ # @return [Hash] Response data
43
+ def retrieve_payment_page(id, params: nil)
44
+ path = "/payment_pages/#{id}"
45
+ @client.request(:get, path, params: params)
46
+ end
47
+
48
+ # Update payment page
49
+ #
50
+ # Updates a payment page.
51
+ #
52
+ # @param id [String] Resource ID
53
+ # @param data [Hash] Request body
54
+ # @return [Hash] Response data
55
+ def update_payment_page(id, data)
56
+ path = "/payment_pages/#{id}"
57
+ @client.request(:put, path, body: data)
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ module Billingrails
6
+ module Resources
7
+ # Payments resource
8
+ class Payments
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Create a payment
15
+ #
16
+ # Create an online or offline payment for an invoice, order, payment request, or credit grant.
17
+ #
18
+ # @param data [Hash] Request body
19
+ # @return [Hash] Response data
20
+ def create(data)
21
+ path = "/payments"
22
+ @client.request(:post, path, body: data)
23
+ end
24
+
25
+ end
26
+ end
27
+ 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
+ # Plans resource
8
+ class Plans
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # List plans
15
+ #
16
+ # Retrieves a list of plans.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/biller/plans"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create a plan
26
+ #
27
+ # Creates a plan.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/biller/plans"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
36
+ # Retrieve a plan
37
+ #
38
+ # Retrieves plan 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 = "/biller/plans/#{id}"
45
+ @client.request(:get, path, params: params)
46
+ end
47
+
48
+ # Update a plan
49
+ #
50
+ # Updates a plan.
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 = "/biller/plans/#{id}"
57
+ @client.request(:put, path, body: data)
58
+ end
59
+
60
+ end
61
+ end
62
+ 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
+ # Products resource
8
+ class Products
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # List products
15
+ #
16
+ # Retrieves a list of products.
17
+ #
18
+ # @param params [Hash, nil] Query parameters
19
+ # @return [Hash] Response data
20
+ def list(params: nil)
21
+ path = "/seller/products"
22
+ @client.request(:get, path, params: params)
23
+ end
24
+
25
+ # Create a product
26
+ #
27
+ # Creates a product.
28
+ #
29
+ # @param data [Hash] Request body
30
+ # @return [Hash] Response data
31
+ def create(data)
32
+ path = "/seller/products"
33
+ @client.request(:post, path, body: data)
34
+ end
35
+
36
+ # Retrieve a product
37
+ #
38
+ # Retrieves a product 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 = "/seller/products/#{id}"
45
+ @client.request(:get, path, params: params)
46
+ end
47
+
48
+ # Update a product
49
+ #
50
+ # Updates a product.
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 = "/seller/products/#{id}"
57
+ @client.request(:put, path, body: data)
58
+ end
59
+
60
+ end
61
+ end
62
+ 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
+ # Subscriptions resource
8
+ class Subscriptions
9
+ # @param client [Client] The API client
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Retrieve subscription
15
+ #
16
+ # Retrieves a subscription by ID.
17
+ #
18
+ # @param id [String] Resource ID
19
+ # @param params [Hash, nil] Query parameters
20
+ # @return [Hash] Response data
21
+ def retrieve(id, params: nil)
22
+ path = "/biller/subscriptions/#{id}"
23
+ @client.request(:get, path, params: params)
24
+ end
25
+
26
+ # Update a subscription
27
+ #
28
+ # Updates a subscription.
29
+ #
30
+ # @param id [String] Resource ID
31
+ # @param data [Hash] Request body
32
+ # @return [Hash] Response data
33
+ def update(id, data)
34
+ path = "/biller/subscriptions/#{id}"
35
+ @client.request(:put, path, body: data)
36
+ end
37
+
38
+ # List subscriptions
39
+ #
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.
52
+ #
53
+ # @param data [Hash] Request body
54
+ # @return [Hash] Response data
55
+ def create(data)
56
+ path = "/biller/subscriptions"
57
+ @client.request(:post, path, body: data)
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Billingrails
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated. Do not edit manually.
4
+
5
+ require_relative 'billingrails/version'
6
+ require_relative 'billingrails/errors'
7
+ require_relative 'billingrails/client'
8
+
9
+ require_relative 'billingrails/resources/accounts'
10
+ require_relative 'billingrails/resources/credit_grants'
11
+ require_relative 'billingrails/resources/discounts'
12
+ require_relative 'billingrails/resources/events'
13
+ require_relative 'billingrails/resources/fees'
14
+ require_relative 'billingrails/resources/invoices'
15
+ 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
+ require_relative 'billingrails/resources/plans'
20
+ require_relative 'billingrails/resources/products'
21
+ require_relative 'billingrails/resources/subscriptions'
22
+
23
+ # Main module for Billingrails SDK
24
+ module Billingrails
25
+ class Error < StandardError; end
26
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: billingrails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Billingrails
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rake
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '13.0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '13.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rubocop
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: webmock
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ description: Flexible, composable, and intuitive API-first commerce platform SDK for
69
+ Ruby
70
+ email:
71
+ - support@billingrails.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - CHANGELOG.md
77
+ - LICENSE
78
+ - README.md
79
+ - lib/billingrails.rb
80
+ - lib/billingrails/client.rb
81
+ - lib/billingrails/errors.rb
82
+ - lib/billingrails/resources/accounts.rb
83
+ - lib/billingrails/resources/credit_grants.rb
84
+ - lib/billingrails/resources/discounts.rb
85
+ - lib/billingrails/resources/events.rb
86
+ - lib/billingrails/resources/fees.rb
87
+ - lib/billingrails/resources/invoices.rb
88
+ - lib/billingrails/resources/meters.rb
89
+ - lib/billingrails/resources/orders.rb
90
+ - lib/billingrails/resources/payment_pages.rb
91
+ - lib/billingrails/resources/payments.rb
92
+ - lib/billingrails/resources/plans.rb
93
+ - lib/billingrails/resources/products.rb
94
+ - lib/billingrails/resources/subscriptions.rb
95
+ - lib/billingrails/version.rb
96
+ homepage: https://github.com/billingrails/billingrails-ruby
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ homepage_uri: https://github.com/billingrails/billingrails-ruby
101
+ source_code_uri: https://github.com/billingrails/billingrails-ruby
102
+ changelog_uri: https://github.com/billingrails/billingrails-ruby/blob/main/CHANGELOG.md
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.7.0
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 4.0.4
118
+ specification_version: 4
119
+ summary: Official Ruby SDK for Billingrails API
120
+ test_files: []