Developer-friendly & type-safe Ruby SDK specifically catered to leverage Kintsugi's tax API.
The SDK can be installed using RubyGems:
gem install kintsugi_sdkrequire 'kintsugi_sdk'
Models = ::KintsugiSDK::Models
s = ::KintsugiSDK::OpenApiSDK.new
req = Models::Shared::AddressBase.new(
phone: '555-123-4567',
street_1: '1600 Amphitheatre Parkway',
street_2: 'Building 40',
city: 'Mountain View',
county: 'Santa Clara',
state: 'CA',
postal_code: '94043',
country: Models::Shared::CountryCodeEnum::US,
full_address: '1600 Amphitheatre Parkway, Mountain View, CA 94043'
)
res = s.address_validation.search(request: req, security: Models::Ops::SearchV1AddressValidationSearchPostSecurity.new(
api_key_header: '<YOUR_API_KEY_HERE>'
))
unless res.nil?
# handle response
endThis SDK supports the following security schemes globally:
| Name | Type | Scheme |
|---|---|---|
api_key_header |
apiKey | API key |
custom_header |
apiKey | API key |
You can set the security parameters through the security optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
require 'kintsugi_sdk'
Models = ::KintsugiSDK::Models
s = ::KintsugiSDK::OpenApiSDK.new(
security: Models::Shared::Security.new(
api_key_header: '<YOUR_API_KEY_HERE>',
custom_header: '<YOUR_API_KEY_HERE>'
)
)
req = Models::Shared::ValidationAddress.new(
line1: '1600 Amphitheatre Parkway',
line2: '',
line3: '',
city: 'Mountain View',
state: 'CA',
postal_code: '94043',
id: 215,
county: '',
full_address: '1600 Amphitheatre Parkway, Mountain View, CA 94043'
)
res = s.address_validation.suggestions(request: req)
unless res.nil?
# handle response
endSome operations in this SDK require the security scheme to be specified at the request level. For example:
require 'kintsugi_sdk'
Models = ::KintsugiSDK::Models
s = ::KintsugiSDK::OpenApiSDK.new
req = Models::Shared::AddressBase.new(
phone: '555-123-4567',
street_1: '1600 Amphitheatre Parkway',
street_2: 'Building 40',
city: 'Mountain View',
county: 'Santa Clara',
state: 'CA',
postal_code: '94043',
country: Models::Shared::CountryCodeEnum::US,
full_address: '1600 Amphitheatre Parkway, Mountain View, CA 94043'
)
res = s.address_validation.search(request: req, security: Models::Ops::SearchV1AddressValidationSearchPostSecurity.new(
api_key_header: '<YOUR_API_KEY_HERE>'
))
unless res.nil?
# handle response
endAvailable methods
- search - Search
- suggestions - Suggestions
- list - Get Customers
- create - Create Customer
- get - Get Customer By Id
- update - Update Customer
- get_by_external_id - Get Customer By External Id
- get_transactions - Get Transactions By Customer Id
- create_transaction - Create Transaction By Customer Id
- list - Get Exemptions
- create - Create Exemption
- get - Get Exemption By Id
- upload_certificate - Upload Exemption Certificate
- get_attachments - Get Attachments For Exemption
- list - Get Nexus For Org
- estimate_tax - Estimate Tax
- list - Get Transactions
- create - Create Transaction
- get_by_external_id - Get Transaction By External Id
- update - Update Transaction
- get_by_id - Get Transaction By Id
- get_by_filing_id - Get Transactions By Filing Id
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error.
By default an API error will raise a Errors::APIError, which has the following properties:
| Property | Type | Description |
|---|---|---|
message |
string | The error message |
status_code |
int | The HTTP status code |
raw_response |
Faraday::Response | The raw HTTP response |
body |
string | The response content |
When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the search method throws the following exceptions:
| Error Type | Status Code | Content Type |
|---|---|---|
| Models::Errors::ErrorResponse | 401 | application/json |
| Models::Errors::BackendSrcAddressValidationResponsesValidationErrorResponse | 422 | application/json |
| Models::Errors::ErrorResponse | 500 | application/json |
| Errors::APIError | 4XX, 5XX | */* |
require 'kintsugi_sdk'
Models = ::KintsugiSDK::Models
s = ::KintsugiSDK::OpenApiSDK.new
begin
req = Models::Shared::AddressBase.new(
phone: '555-123-4567',
street_1: '1600 Amphitheatre Parkway',
street_2: 'Building 40',
city: 'Mountain View',
county: 'Santa Clara',
state: 'CA',
postal_code: '94043',
country: Models::Shared::CountryCodeEnum::US,
full_address: '1600 Amphitheatre Parkway, Mountain View, CA 94043'
)
res = s.address_validation.search(request: req, security: Models::Ops::SearchV1AddressValidationSearchPostSecurity.new(
api_key_header: '<YOUR_API_KEY_HERE>'
))
unless res.nil?
# handle response
end
rescue Models::Errors::ErrorResponse => e
# handle e.container data
raise e
rescue Models::Errors::BackendSrcAddressValidationResponsesValidationErrorResponse => e
# handle e.container data
raise e
rescue Models::Errors::ErrorResponse => e
# handle e.container data
raise e
rescue Errors::APIError => e
# handle default exception
raise e
endThe default server can be overridden globally by passing a URL to the server_url (String) optional parameter when initializing the SDK client instance. For example:
require 'kintsugi_sdk'
Models = ::KintsugiSDK::Models
s = ::KintsugiSDK::OpenApiSDK.new(
server_url: 'https://api.trykintsugi.com'
)
req = Models::Shared::AddressBase.new(
phone: '555-123-4567',
street_1: '1600 Amphitheatre Parkway',
street_2: 'Building 40',
city: 'Mountain View',
county: 'Santa Clara',
state: 'CA',
postal_code: '94043',
country: Models::Shared::CountryCodeEnum::US,
full_address: '1600 Amphitheatre Parkway, Mountain View, CA 94043'
)
res = s.address_validation.search(request: req, security: Models::Ops::SearchV1AddressValidationSearchPostSecurity.new(
api_key_header: '<YOUR_API_KEY_HERE>'
))
unless res.nil?
# handle response
endThe SDK provides comprehensive debug logging capabilities to help you troubleshoot API requests and responses. When enabled, debug logging will output detailed information about HTTP requests and responses, including headers and body content.
You can enable debug logging in two ways:
Pass debug_logging: true when initializing the SDK:
require 'kintsugi_sdk'
Models = ::KintsugiSDK::Models
s = ::KintsugiSDK::OpenApiSDK.new(
debug_logging: true,
security: Models::Shared::Security.new(
api_key_header: '<YOUR_API_KEY_HERE>',
),
)
# All API calls will now log request/response details
req = Models::Shared::AddressBase.new(
phone: '555-123-4567',
street_1: '1600 Amphitheatre Parkway',
city: 'Mountain View',
state: 'CA',
postal_code: '94043',
country: Models::Shared::CountryCodeEnum::US,
)
res = s.address_validation.search(request: req)Set the KINTSUGI_DEBUG environment variable to true:
export KINTSUGI_DEBUG=true
ruby your_script.rbOr inline:
KINTSUGI_DEBUG=true ruby your_script.rbWhen debug logging is enabled, you'll see detailed output like this:
D, [2024-01-15T10:30:45.123456 #12345] DEBUG -- : --> POST https://api.trykintsugi.com/v1/address-validation/search
D, [2024-01-15T10:30:45.123456 #12345] DEBUG -- : Content-Type: "application/json"
D, [2024-01-15T10:30:45.123456 #12345] DEBUG -- : Authorization: "Bearer ***"
D, [2024-01-15T10:30:45.123456 #12345] DEBUG -- :
D, [2024-01-15T10:30:45.123456 #12345] DEBUG -- : {"phone":"555-123-4567","street_1":"1600 Amphitheatre Parkway"...}
D, [2024-01-15T10:30:45.234567 #12345] DEBUG -- :
D, [2024-01-15T10:30:45.234567 #12345] DEBUG -- : <-- 200 https://api.trykintsugi.com/v1/address-validation/search
D, [2024-01-15T10:30:45.234567 #12345] DEBUG -- : Content-Type: "application/json"
D, [2024-01-15T10:30:45.234567 #12345] DEBUG -- :
D, [2024-01-15T10:30:45.234567 #12345] DEBUG -- : {"validated_address":{"street_1":"1600 Amphitheatre Pkwy"...}}
Debug logging is disabled by default. To explicitly disable it:
s = ::KintsugiSDK::OpenApiSDK.new(
debug_logging: false, # Explicitly disabled
security: Models::Shared::Security.new(
api_key_header: '<YOUR_API_KEY_HERE>',
),
)Or unset the environment variable:
unset KINTSUGI_DEBUGThis SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.