inttegro 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +9 -0
- data/CHANGELOG.md +17 -0
- data/Dockerfile +23 -0
- data/LICENSE +21 -0
- data/README.md +104 -0
- data/Rakefile +50 -0
- data/lib/inttegro/client.rb +159 -0
- data/lib/inttegro/enums.rb +6 -0
- data/lib/inttegro/errors.rb +128 -0
- data/lib/inttegro/file_download.rb +29 -0
- data/lib/inttegro/generated/enums.rb +693 -0
- data/lib/inttegro/generated/models.rb +3840 -0
- data/lib/inttegro/generated/operations.rb +369 -0
- data/lib/inttegro/http_client.rb +639 -0
- data/lib/inttegro/models.rb +132 -0
- data/lib/inttegro/resources/apps.rb +24 -0
- data/lib/inttegro/resources/balance_transactions.rb +28 -0
- data/lib/inttegro/resources/balances.rb +16 -0
- data/lib/inttegro/resources/broadcasts.rb +28 -0
- data/lib/inttegro/resources/chimes.rb +32 -0
- data/lib/inttegro/resources/customers.rb +28 -0
- data/lib/inttegro/resources/file_links.rb +50 -0
- data/lib/inttegro/resources/file_references.rb +20 -0
- data/lib/inttegro/resources/files.rb +39 -0
- data/lib/inttegro/resources/financial_accounts.rb +104 -0
- data/lib/inttegro/resources/keys.rb +60 -0
- data/lib/inttegro/resources/message_templates.rb +78 -0
- data/lib/inttegro/resources/orders.rb +422 -0
- data/lib/inttegro/resources/otp.rb +30 -0
- data/lib/inttegro/resources/payment_methods.rb +250 -0
- data/lib/inttegro/resources/payouts.rb +200 -0
- data/lib/inttegro/resources/prices.rb +40 -0
- data/lib/inttegro/resources/products.rb +48 -0
- data/lib/inttegro/resources/purchase_intents.rb +44 -0
- data/lib/inttegro/resources/refunds.rb +36 -0
- data/lib/inttegro/resources/schedules.rb +28 -0
- data/lib/inttegro/resources/spec.rb +16 -0
- data/lib/inttegro/resources/upload_requests.rb +66 -0
- data/lib/inttegro/response_object.rb +86 -0
- data/lib/inttegro/transport_response.rb +65 -0
- data/lib/inttegro/types.rb +32 -0
- data/lib/inttegro/version.rb +6 -0
- data/lib/inttegro.rb +14 -0
- data/rbi/inttegro/generated.rbi +529 -0
- metadata +107 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 840b8af59190645ef6ac41b2ef017921552f43eafff04432ddfbb727084b3c80
|
|
4
|
+
data.tar.gz: 3a74759e94a33b8f7422c2c2e9ee75a8c32d96f21b58431b965e0baeb62783c8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e83ba193e1b1a1557f2c1202455c748475a09619be837f1d9d1a709b122b24b883ccb807b9ab4f57b731a0aaf94a1845019523de5f0e47ac54c570f051357557
|
|
7
|
+
data.tar.gz: 6cd7e942dff74db2a5f50eb841f8baefd2bf95d36df621fef4639b96401cdbc8ca95a8c5ae81c8441216770499cb21fc13019bd0b66ef1355d0a54c9539ed3d1
|
data/.dockerignore
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [1.0.0] - 2026-09-01
|
|
4
|
+
|
|
5
|
+
- Breaking: rename the gem, root module, require paths, and generated RBI namespace to `inttegro` and `Inttegro`.
|
|
6
|
+
- Add `typed: strict` Sorbet coverage, runtime signatures, and packaged RBI
|
|
7
|
+
declarations for every client resource, endpoint method, model, and enum.
|
|
8
|
+
- Remove Sorbet escape hatches from the SDK type surface, validate custom HTTP
|
|
9
|
+
adapter responses at the transport boundary, and reject generic response
|
|
10
|
+
fallbacks for documented endpoints.
|
|
11
|
+
- Generate immutable `T::Struct` request and response resources plus real
|
|
12
|
+
`T::Enum` values from the public OpenAPI contract.
|
|
13
|
+
- Add exact response typing for every documented JSON operation and local/CI
|
|
14
|
+
drift checks that fail when OpenAPI, generated models, or resource RBIs differ.
|
|
15
|
+
- Remove the financial-account archive and verification SDK methods because the
|
|
16
|
+
current API does not implement them and exposes no successful response shape.
|
|
17
|
+
- Align package metadata, examples, and the transport user agent with the public Inttegro service name.
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1.7
|
|
2
|
+
|
|
3
|
+
FROM ruby:3.3-alpine AS base
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
RUN apk add --no-cache build-base git
|
|
6
|
+
COPY Gemfile Gemfile.lock inttegro.gemspec Rakefile ./
|
|
7
|
+
COPY lib ./lib
|
|
8
|
+
COPY test ./test
|
|
9
|
+
RUN bundle config set without ''
|
|
10
|
+
RUN bundle install
|
|
11
|
+
|
|
12
|
+
# Build gem for RubyGems distribution
|
|
13
|
+
FROM base AS dist
|
|
14
|
+
RUN gem build inttegro.gemspec
|
|
15
|
+
RUN mkdir -p /out && mv ./*.gem /out/
|
|
16
|
+
|
|
17
|
+
# CI target (use in GitHub Actions)
|
|
18
|
+
FROM base AS ci
|
|
19
|
+
RUN bundle exec rake test
|
|
20
|
+
|
|
21
|
+
# Local/development target
|
|
22
|
+
FROM base AS dev
|
|
23
|
+
CMD ["sh"]
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Inttegro Financial Technologies Limited
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Inttegro Ruby SDK
|
|
2
|
+
|
|
3
|
+
The official Ruby client for building server-side Inttegro integrations.
|
|
4
|
+
|
|
5
|
+
> **Fastest, most modern path:** connect an agent to [Inttegro MCP](https://studio.inttegro.com/inttegro-mcp) at `https://mcp.inttegro.com`, then ask it to run `design_integration`. It will produce an implementation and test plan for your application. Use this SDK when you are ready to connect that plan to your Ruby service.
|
|
6
|
+
|
|
7
|
+
All official Inttegro SDKs expose the same API capabilities. This gem adds strict Sorbet types and Ruby-native resource methods.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Requires Ruby 3.0 or newer.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bundle add inttegro
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Store your secret key in the server environment:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export INTTEGRO_API_KEY="your_secret_key"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Never put the key in browser code, a mobile app, or source control. The client uses `https://api.inttegro.com` by default.
|
|
24
|
+
|
|
25
|
+
## Create a hosted checkout
|
|
26
|
+
|
|
27
|
+
Create and finalize an order, then send the customer to its hosted invoice URL:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
# typed: strict
|
|
31
|
+
|
|
32
|
+
require "inttegro"
|
|
33
|
+
|
|
34
|
+
inttegro = Inttegro::Client.new(api_key: ENV.fetch("INTTEGRO_API_KEY"))
|
|
35
|
+
|
|
36
|
+
begin
|
|
37
|
+
result = inttegro.orders.create(
|
|
38
|
+
request_meta: { idempotency_key: "checkout-cart-123" },
|
|
39
|
+
customer_data: {
|
|
40
|
+
name: "Akua Mensah",
|
|
41
|
+
email_address: "akua@example.com",
|
|
42
|
+
phone_number: "+233544998605"
|
|
43
|
+
},
|
|
44
|
+
finalize: true,
|
|
45
|
+
checkout_settings: {
|
|
46
|
+
redirect_url: "https://example.com/orders/complete",
|
|
47
|
+
cancel_url: "https://example.com/cart"
|
|
48
|
+
},
|
|
49
|
+
line_items: [{
|
|
50
|
+
type: "product",
|
|
51
|
+
product: {
|
|
52
|
+
type: Inttegro::Enums::ProductType::DIGITAL,
|
|
53
|
+
name: "Monthly subscription",
|
|
54
|
+
quantity: 1,
|
|
55
|
+
price: { currency: "ghs", value: 5000 }
|
|
56
|
+
}
|
|
57
|
+
}]
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
checkout_url = result.order.invoice&.format_value&.web&.url
|
|
61
|
+
raise "Order did not include a checkout URL" unless checkout_url
|
|
62
|
+
puts "#{result.order.id} #{checkout_url}"
|
|
63
|
+
rescue Inttegro::APIError => error
|
|
64
|
+
warn "#{error.code || 'api_error'}: #{error.detail || error.message}"
|
|
65
|
+
raise
|
|
66
|
+
end
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Amounts use integer minor units: `5000` GHS is GHS 50.00. Reuse the same idempotency key when retrying the same logical write. If you omit one, the SDK generates a UUIDv7 key for mutating calls.
|
|
70
|
+
|
|
71
|
+
## Work with the API
|
|
72
|
+
|
|
73
|
+
The SDK covers orders and checkout, customers, products and prices, purchase intents, payment methods, balances, payouts and refunds, notifications, files, application settings, keys, and country specifications. Resources use snake-case readers such as `purchase_intents` and `payment_methods`.
|
|
74
|
+
|
|
75
|
+
Ruby-specific features:
|
|
76
|
+
|
|
77
|
+
- `typed: strict` throughout the gem with signatures on every method.
|
|
78
|
+
- OpenAPI-generated `T::Struct` request and response models for exact resource shapes.
|
|
79
|
+
- OpenAPI-generated `T::Enum` classes for public API values.
|
|
80
|
+
- Typed resource methods, binary downloads, and public RBI files included in the gem.
|
|
81
|
+
- Configurable connection/read timeouts and an injectable adapter for tests.
|
|
82
|
+
|
|
83
|
+
Hash request payloads remain available for concise Ruby code. Sorbet applications can use the generated classes under `Inttegro::Models` when they want construction-time field checks.
|
|
84
|
+
|
|
85
|
+
See the [API reference](https://studio.inttegro.com/api-reference) for request fields and lifecycle rules, [errors](https://studio.inttegro.com/errors) for recovery guidance, and [idempotency](https://studio.inttegro.com/idempotency) for safe retries.
|
|
86
|
+
|
|
87
|
+
## Verify a release
|
|
88
|
+
|
|
89
|
+
The GitHub release for each version is the canonical record. It contains the exact gem uploaded to RubyGems.org, SHA-256 checksums, and GitHub and RubyGems Sigstore attestations tied to the source commit and release workflow.
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
sha256sum --check SHA256SUMS
|
|
93
|
+
gh attestation verify inttegro-1.0.0.gem \
|
|
94
|
+
--repo zebodotdev/inttegro-sdk-ruby
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Develop
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
bundle install
|
|
101
|
+
bundle exec rake test
|
|
102
|
+
bundle exec rake sorbet
|
|
103
|
+
bundle exec rake openapi:check
|
|
104
|
+
```
|
data/Rakefile
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "minitest/test_task"
|
|
5
|
+
|
|
6
|
+
Minitest::TestTask.create
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
|
|
10
|
+
RuboCop::RakeTask.new
|
|
11
|
+
|
|
12
|
+
namespace :rbi do
|
|
13
|
+
desc "Regenerate Sorbet declarations for models, enums, and resources"
|
|
14
|
+
task :generate do
|
|
15
|
+
sh "bin/generate-sorbet-rbi"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "Verify generated Sorbet declarations are current"
|
|
19
|
+
task :check do
|
|
20
|
+
sh "bin/generate-sorbet-rbi --check"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
namespace :openapi do
|
|
25
|
+
desc "Regenerate T::Struct, T::Enum, and operation types from the public OpenAPI contract"
|
|
26
|
+
task :generate do
|
|
27
|
+
sh "bin/generate-openapi-types"
|
|
28
|
+
sh "bin/generate-sorbet-rbi"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "Verify generated SDK types match the public OpenAPI contract"
|
|
32
|
+
task :check do
|
|
33
|
+
sh "bin/generate-openapi-types --check"
|
|
34
|
+
sh "bin/check-openapi-parity"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
namespace :sorbet do
|
|
39
|
+
desc "Verify the SDK is typed: strict and contains no type escape hatches"
|
|
40
|
+
task :strict do
|
|
41
|
+
sh "bin/check-sorbet-strict"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
desc "Type-check the SDK with Sorbet"
|
|
46
|
+
task sorbet: ["sorbet:strict", "openapi:check", "rbi:check"] do
|
|
47
|
+
sh "srb tc"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
task default: %i[test rubocop sorbet]
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: strict
|
|
3
|
+
|
|
4
|
+
require_relative "http_client"
|
|
5
|
+
require_relative "types"
|
|
6
|
+
require_relative "resources/orders"
|
|
7
|
+
require_relative "resources/otp"
|
|
8
|
+
require_relative "resources/chimes"
|
|
9
|
+
require_relative "resources/schedules"
|
|
10
|
+
require_relative "resources/broadcasts"
|
|
11
|
+
require_relative "resources/message_templates"
|
|
12
|
+
require_relative "resources/payment_methods"
|
|
13
|
+
require_relative "resources/payouts"
|
|
14
|
+
require_relative "resources/refunds"
|
|
15
|
+
require_relative "resources/balance_transactions"
|
|
16
|
+
require_relative "resources/financial_accounts"
|
|
17
|
+
require_relative "resources/file_references"
|
|
18
|
+
require_relative "resources/files"
|
|
19
|
+
require_relative "resources/file_links"
|
|
20
|
+
require_relative "resources/customers"
|
|
21
|
+
require_relative "resources/products"
|
|
22
|
+
require_relative "resources/prices"
|
|
23
|
+
require_relative "resources/purchase_intents"
|
|
24
|
+
require_relative "resources/spec"
|
|
25
|
+
require_relative "resources/balances"
|
|
26
|
+
require_relative "resources/upload_requests"
|
|
27
|
+
require_relative "resources/apps"
|
|
28
|
+
require_relative "resources/keys"
|
|
29
|
+
|
|
30
|
+
module Inttegro
|
|
31
|
+
# Main entry point for interacting with the Inttegro API.
|
|
32
|
+
class Client
|
|
33
|
+
extend T::Sig
|
|
34
|
+
|
|
35
|
+
sig { returns(Resources::Orders) }
|
|
36
|
+
attr_reader :orders
|
|
37
|
+
|
|
38
|
+
sig { returns(Resources::Otp) }
|
|
39
|
+
attr_reader :otp
|
|
40
|
+
|
|
41
|
+
sig { returns(Resources::Chimes) }
|
|
42
|
+
attr_reader :chimes
|
|
43
|
+
|
|
44
|
+
sig { returns(Resources::Schedules) }
|
|
45
|
+
attr_reader :schedules
|
|
46
|
+
|
|
47
|
+
sig { returns(Resources::Broadcasts) }
|
|
48
|
+
attr_reader :broadcasts
|
|
49
|
+
|
|
50
|
+
sig { returns(Resources::MessageTemplates) }
|
|
51
|
+
attr_reader :message_templates
|
|
52
|
+
|
|
53
|
+
sig { returns(Resources::PaymentMethods) }
|
|
54
|
+
attr_reader :payment_methods
|
|
55
|
+
|
|
56
|
+
sig { returns(Resources::Payouts) }
|
|
57
|
+
attr_reader :payouts
|
|
58
|
+
|
|
59
|
+
sig { returns(Resources::Refunds) }
|
|
60
|
+
attr_reader :refunds
|
|
61
|
+
|
|
62
|
+
sig { returns(Resources::BalanceTransactions) }
|
|
63
|
+
attr_reader :balance_transactions
|
|
64
|
+
|
|
65
|
+
sig { returns(Resources::FinancialAccounts) }
|
|
66
|
+
attr_reader :financial_accounts
|
|
67
|
+
|
|
68
|
+
sig { returns(Resources::FileReferences) }
|
|
69
|
+
attr_reader :file_references
|
|
70
|
+
|
|
71
|
+
sig { returns(Resources::Files) }
|
|
72
|
+
attr_reader :files
|
|
73
|
+
|
|
74
|
+
sig { returns(Resources::FileLinks) }
|
|
75
|
+
attr_reader :file_links
|
|
76
|
+
|
|
77
|
+
sig { returns(Resources::Customers) }
|
|
78
|
+
attr_reader :customers
|
|
79
|
+
|
|
80
|
+
sig { returns(Resources::Products) }
|
|
81
|
+
attr_reader :products
|
|
82
|
+
|
|
83
|
+
sig { returns(Resources::Prices) }
|
|
84
|
+
attr_reader :prices
|
|
85
|
+
|
|
86
|
+
sig { returns(Resources::PurchaseIntents) }
|
|
87
|
+
attr_reader :purchase_intents
|
|
88
|
+
|
|
89
|
+
sig { returns(Resources::Balances) }
|
|
90
|
+
attr_reader :balances
|
|
91
|
+
|
|
92
|
+
sig { returns(Resources::Apps) }
|
|
93
|
+
attr_reader :apps
|
|
94
|
+
|
|
95
|
+
sig { returns(Resources::Keys) }
|
|
96
|
+
attr_reader :keys
|
|
97
|
+
|
|
98
|
+
sig { returns(Resources::Spec) }
|
|
99
|
+
attr_reader :spec
|
|
100
|
+
|
|
101
|
+
sig { returns(Resources::UploadRequests) }
|
|
102
|
+
attr_reader :upload_requests
|
|
103
|
+
|
|
104
|
+
sig do
|
|
105
|
+
params(
|
|
106
|
+
token_value: T.nilable(String),
|
|
107
|
+
api_key: T.nilable(String),
|
|
108
|
+
token: T.nilable(String),
|
|
109
|
+
base_url: T.nilable(String),
|
|
110
|
+
read_timeout: T.nilable(Numeric),
|
|
111
|
+
open_timeout: T.nilable(Numeric),
|
|
112
|
+
adapter: T.nilable(Types::Adapter)
|
|
113
|
+
).void
|
|
114
|
+
end
|
|
115
|
+
def initialize(
|
|
116
|
+
token_value = nil,
|
|
117
|
+
api_key: nil,
|
|
118
|
+
token: nil,
|
|
119
|
+
base_url: DEFAULT_BASE_URL,
|
|
120
|
+
read_timeout: 30,
|
|
121
|
+
open_timeout: 10,
|
|
122
|
+
adapter: nil
|
|
123
|
+
)
|
|
124
|
+
provided_token = token || token_value
|
|
125
|
+
api_key ||= provided_token
|
|
126
|
+
@http = T.let(HTTPClient.new(
|
|
127
|
+
api_key: api_key,
|
|
128
|
+
base_url: base_url,
|
|
129
|
+
read_timeout: read_timeout,
|
|
130
|
+
open_timeout: open_timeout,
|
|
131
|
+
adapter: adapter
|
|
132
|
+
), HTTPClient)
|
|
133
|
+
|
|
134
|
+
@orders = T.let(Resources::Orders.new(@http), Resources::Orders)
|
|
135
|
+
@otp = T.let(Resources::Otp.new(@http), Resources::Otp)
|
|
136
|
+
@chimes = T.let(Resources::Chimes.new(@http), Resources::Chimes)
|
|
137
|
+
@schedules = T.let(Resources::Schedules.new(@http), Resources::Schedules)
|
|
138
|
+
@broadcasts = T.let(Resources::Broadcasts.new(@http), Resources::Broadcasts)
|
|
139
|
+
@message_templates = T.let(Resources::MessageTemplates.new(@http), Resources::MessageTemplates)
|
|
140
|
+
@payment_methods = T.let(Resources::PaymentMethods.new(@http), Resources::PaymentMethods)
|
|
141
|
+
@payouts = T.let(Resources::Payouts.new(@http), Resources::Payouts)
|
|
142
|
+
@refunds = T.let(Resources::Refunds.new(@http), Resources::Refunds)
|
|
143
|
+
@balance_transactions = T.let(Resources::BalanceTransactions.new(@http), Resources::BalanceTransactions)
|
|
144
|
+
@financial_accounts = T.let(Resources::FinancialAccounts.new(@http), Resources::FinancialAccounts)
|
|
145
|
+
@file_references = T.let(Resources::FileReferences.new(@http), Resources::FileReferences)
|
|
146
|
+
@files = T.let(Resources::Files.new(@http), Resources::Files)
|
|
147
|
+
@file_links = T.let(Resources::FileLinks.new(@http), Resources::FileLinks)
|
|
148
|
+
@customers = T.let(Resources::Customers.new(@http), Resources::Customers)
|
|
149
|
+
@products = T.let(Resources::Products.new(@http), Resources::Products)
|
|
150
|
+
@prices = T.let(Resources::Prices.new(@http), Resources::Prices)
|
|
151
|
+
@purchase_intents = T.let(Resources::PurchaseIntents.new(@http), Resources::PurchaseIntents)
|
|
152
|
+
@balances = T.let(Resources::Balances.new(@http), Resources::Balances)
|
|
153
|
+
@apps = T.let(Resources::Apps.new(@http), Resources::Apps)
|
|
154
|
+
@keys = T.let(Resources::Keys.new(@http), Resources::Keys)
|
|
155
|
+
@spec = T.let(Resources::Spec.new(@http), Resources::Spec)
|
|
156
|
+
@upload_requests = T.let(Resources::UploadRequests.new(@http), Resources::UploadRequests)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: strict
|
|
3
|
+
|
|
4
|
+
require "sorbet-runtime"
|
|
5
|
+
|
|
6
|
+
require_relative "types"
|
|
7
|
+
|
|
8
|
+
module Inttegro
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
|
|
11
|
+
class NetworkError < Error
|
|
12
|
+
extend T::Sig
|
|
13
|
+
|
|
14
|
+
sig { returns(T.nilable(Exception)) }
|
|
15
|
+
attr_reader :original_error
|
|
16
|
+
|
|
17
|
+
sig { params(message: String, original_error: T.nilable(Exception)).void }
|
|
18
|
+
def initialize(message, original_error = nil)
|
|
19
|
+
super(message)
|
|
20
|
+
@original_error = original_error
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class TimeoutError < NetworkError; end
|
|
25
|
+
|
|
26
|
+
class APIError < Error
|
|
27
|
+
extend T::Sig
|
|
28
|
+
|
|
29
|
+
sig { returns(Integer) }
|
|
30
|
+
attr_reader :status
|
|
31
|
+
|
|
32
|
+
sig { returns(T.nilable(String)) }
|
|
33
|
+
attr_reader :code, :type, :url, :detail, :fix_code, :cause, :body
|
|
34
|
+
|
|
35
|
+
sig { returns(Types::WireValue) }
|
|
36
|
+
attr_reader :data
|
|
37
|
+
|
|
38
|
+
sig do
|
|
39
|
+
params(
|
|
40
|
+
message: String,
|
|
41
|
+
status: Integer,
|
|
42
|
+
code: T.nilable(String),
|
|
43
|
+
type: T.nilable(String),
|
|
44
|
+
url: T.nilable(String),
|
|
45
|
+
detail: T.nilable(String),
|
|
46
|
+
fix_code: T.nilable(String),
|
|
47
|
+
cause: T.nilable(String),
|
|
48
|
+
body: T.nilable(String),
|
|
49
|
+
data: Types::WireValue
|
|
50
|
+
).void
|
|
51
|
+
end
|
|
52
|
+
def initialize(
|
|
53
|
+
message,
|
|
54
|
+
status:,
|
|
55
|
+
code: nil,
|
|
56
|
+
type: nil,
|
|
57
|
+
url: nil,
|
|
58
|
+
detail: nil,
|
|
59
|
+
fix_code: nil,
|
|
60
|
+
cause: nil,
|
|
61
|
+
body: nil,
|
|
62
|
+
data: nil
|
|
63
|
+
)
|
|
64
|
+
super(message)
|
|
65
|
+
@status = status
|
|
66
|
+
@code = code
|
|
67
|
+
@type = type
|
|
68
|
+
@url = url
|
|
69
|
+
@detail = detail
|
|
70
|
+
@fix_code = fix_code
|
|
71
|
+
@cause = cause
|
|
72
|
+
@body = body
|
|
73
|
+
@data = data
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class AuthenticationError < APIError; end
|
|
78
|
+
|
|
79
|
+
class RateLimitError < APIError
|
|
80
|
+
extend T::Sig
|
|
81
|
+
|
|
82
|
+
sig { returns(T.nilable(Integer)) }
|
|
83
|
+
attr_reader :retry_after
|
|
84
|
+
|
|
85
|
+
sig do
|
|
86
|
+
params(
|
|
87
|
+
message: String,
|
|
88
|
+
status: Integer,
|
|
89
|
+
code: T.nilable(String),
|
|
90
|
+
type: T.nilable(String),
|
|
91
|
+
url: T.nilable(String),
|
|
92
|
+
detail: T.nilable(String),
|
|
93
|
+
fix_code: T.nilable(String),
|
|
94
|
+
cause: T.nilable(String),
|
|
95
|
+
body: T.nilable(String),
|
|
96
|
+
data: Types::WireValue,
|
|
97
|
+
retry_after: T.nilable(Integer)
|
|
98
|
+
).void
|
|
99
|
+
end
|
|
100
|
+
def initialize(
|
|
101
|
+
message,
|
|
102
|
+
status:,
|
|
103
|
+
code: nil,
|
|
104
|
+
type: nil,
|
|
105
|
+
url: nil,
|
|
106
|
+
detail: nil,
|
|
107
|
+
fix_code: nil,
|
|
108
|
+
cause: nil,
|
|
109
|
+
body: nil,
|
|
110
|
+
data: nil,
|
|
111
|
+
retry_after: nil
|
|
112
|
+
)
|
|
113
|
+
super(
|
|
114
|
+
message,
|
|
115
|
+
status: status,
|
|
116
|
+
code: code,
|
|
117
|
+
type: type,
|
|
118
|
+
url: url,
|
|
119
|
+
detail: detail,
|
|
120
|
+
fix_code: fix_code,
|
|
121
|
+
cause: cause,
|
|
122
|
+
body: body,
|
|
123
|
+
data: data
|
|
124
|
+
)
|
|
125
|
+
@retry_after = retry_after
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: strict
|
|
3
|
+
|
|
4
|
+
require "sorbet-runtime"
|
|
5
|
+
|
|
6
|
+
require_relative "types"
|
|
7
|
+
|
|
8
|
+
module Inttegro
|
|
9
|
+
class FileDownload
|
|
10
|
+
extend T::Sig
|
|
11
|
+
|
|
12
|
+
sig { returns(String) }
|
|
13
|
+
attr_reader :data
|
|
14
|
+
|
|
15
|
+
sig { returns(Types::ResponseHeaders) }
|
|
16
|
+
attr_reader :headers
|
|
17
|
+
|
|
18
|
+
sig { params(data: String, headers: Types::ResponseHeaders).void }
|
|
19
|
+
def initialize(data, headers = {})
|
|
20
|
+
@data = data
|
|
21
|
+
@headers = headers
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
sig { params(path: String).returns(Integer) }
|
|
25
|
+
def save_to(path)
|
|
26
|
+
File.binwrite(path, data)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|