spaire
Developer-friendly & type-safe Ruby SDK specifically catered to leverage spaire API.
Important
This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Summary
Spaire API: Spaire HTTP and Webhooks API
Read the docs at https://docs.spairehq.com/api-reference
Table of Contents
- spaire
- SDK Installation
- SDK Example Usage
- Authentication
- Available Resources and Operations
- Error Handling
- Server Selection
- Development
- Maturity
- Contributions
SDK Installation
The SDK can be installed using RubyGems:
gem install spaireSDK Example Usage
Example
require "spaire"
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Spaire.new(
access_token: "<YOUR_BEARER_TOKEN_HERE>"
)
res = s.organizations.list(page: 1, limit: 10)
unless res.list_resource_organization.nil?
# handle response
endAuthentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
access_token |
http | HTTP Bearer |
To authenticate with the API the access_token parameter must be set when initializing the SDK client instance. For example:
require "spaire"
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Spaire.new(
access_token: "<YOUR_BEARER_TOKEN_HERE>"
)
res = s.organizations.list(page: 1, limit: 10)
unless res.list_resource_organization.nil?
# handle response
endPer-Operation Security Schemes
Some operations in this SDK require the security scheme to be specified at the request level. For example:
require "spaire"
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Spaire.new
req = Models::Operations::CustomerPortalBenefitGrantsListRequest.new
res = s.customer_portal.benefit_grants.list(
request: req,
security: Models::Operations::CustomerPortalBenefitGrantsListSecurity.new
)
unless res.list_resource_customer_benefit_grant.nil?
# handle response
endAvailable Resources and Operations
- list - List Benefit Grants
- list - List Benefits
- create - Create Benefit
- get - Get Benefit
- delete - Delete Benefit
- update - Update Benefit
- grants - List Benefit Grants
- list - List Checkout Links
- create - Create Checkout Link
- get - Get Checkout Link
- delete - Delete Checkout Link
- update - Update Checkout Link
- list - List Checkout Sessions
- create - Create Checkout Session
- get - Get Checkout Session
- client_get - Get Checkout Session from Client
- list_client_invoices - List Client Invoices
- create_client_invoice - Create Client Invoice
- get_client_invoice - Get Client Invoice
- download_client_invoice_pdf - Download Client Invoice PDF
- finalize_client_invoice - Finalize Client Invoice
- send_client_invoice - Send Client Invoice
- mark_client_invoice_paid - Mark Client Invoice as Paid
- void_client_invoice - Void Client Invoice
- list - List Custom Fields
- create - Create Custom Field
- get - Get Custom Field
- delete - Delete Custom Field
- update - Update Custom Field
- introspect - Introspect Customer Session
- get_authenticated_user - Get Authenticated Portal User
- get - Get Customer
- update - Update Customer
- list_payment_methods - List Customer Payment Methods
- add_payment_method - Add Customer Payment Method
- confirm_payment_method - Confirm Customer Payment Method
- delete_payment_method - Delete Customer Payment Method
- list - List Downloadables
- list - List License Keys
- get - Get License Key
- validate - Validate License Key
- activate - Activate License Key
- deactivate - Deactivate License Key
- list_members - List Members
- add_member - Add Member
- remove_member - Remove Member
- update_member - Update Member
- list - List Orders
- get - Get Order
- update - Update Order
- invoice - Get Order Invoice
- get_payment_status - Get Order Payment Status
- confirm_retry_payment - Confirm Retry Payment
- get - Get Organization
- list_seats - List Seats
- assign_seat - Assign Seat
- revoke_seat - Revoke Seat
- resend_invitation - Resend Invitation
- list_claimed_subscriptions - List Claimed Subscriptions
- list - List Subscriptions
- get - Get Subscription
- cancel - Cancel Subscription
- update - Update Subscription
- list_seats - List Seats
- assign_seat - Assign Seat
- revoke_seat - Revoke Seat
- resend_invitation - Resend Invitation
- get_claim_info - Get Claim Info
- claim_seat - Claim Seat
- create - Create Customer Session
- list - List Customers
- create - Create Customer
- export - Export Customers
- get - Get Customer
- delete - Delete Customer
- update - Update Customer
- get_external - Get Customer by External ID
- delete_external - Delete Customer by External ID
- update_external - Update Customer by External ID
- get_state - Get Customer State
- get_state_external - Get Customer State by External ID
- list - List Discounts
- create - Create Discount
- get - Get Discount
- delete - Delete Discount
- update - Update Discount
- list - List Events
- list_names - List Event Names
- get - Get Event
- ingest - Ingest Events
- list - List Files
- create - Create File
- uploaded - Complete File Upload
- delete - Delete File
- update - Update File
- list - List License Keys
- get - Get License Key
- update - Update License Key
- get_activation - Get Activation
- validate - Validate License Key
- activate - Activate License Key
- deactivate - Deactivate License Key
- create - Create Member Session
- list_members - List Members
- create_member - Create Member
- get_member - Get Member
- delete_member - Delete Member
- update_member - Update Member
- list - List Meters
- create - Create Meter
- get - Get Meter
- update - Update Meter
- quantities - Get Meter Quantities
- authorize - Authorize
- token - Request Token
- revoke - Revoke Token
- introspect - Introspect Token
- userinfo - Get User Info
- list - List Orders
- export - Export Subscriptions
- get - Get Order
- update - Update Order
- invoice - Get Order Invoice
- list - List Organizations
- create - Create Organization
- get - Get Organization
- update - Update Organization
- list - List Products
- create - Create Product
- get - Get Product
- update - Update Product
- update_benefits - Update Product Benefits
- list - List Subscriptions
- create - Create Subscription
- export - Export Subscriptions
- get - Get Subscription
- revoke - Revoke Subscription
- update - Update Subscription
- list_webhook_endpoints - List Webhook Endpoints
- create_webhook_endpoint - Create Webhook Endpoint
- get_webhook_endpoint - Get Webhook Endpoint
- delete_webhook_endpoint - Delete Webhook Endpoint
- update_webhook_endpoint - Update Webhook Endpoint
- reset_webhook_endpoint_secret - Reset Webhook Endpoint Secret
- list_webhook_deliveries - List Webhook Deliveries
- redeliver_webhook_event - Redeliver Webhook Event
Error Handling
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 list method throws the following exceptions:
| Error Type | Status Code | Content Type |
|---|---|---|
| Models::Errors::HTTPValidationError | 422 | application/json |
| Errors::APIError | 4XX, 5XX | */* |
Example
require "spaire"
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Spaire.new(
access_token: "<YOUR_BEARER_TOKEN_HERE>"
)
begin
res = s.organizations.list(page: 1, limit: 10)
unless res.list_resource_organization.nil?
# handle response
end
rescue Models::Errors::HTTPValidationError => e
# handle e.container data
raise e
rescue Errors::APIError => e
# handle default exception
raise e
endServer Selection
Select Server by Name
You can override the default server globally by passing a server name to the server (Symbol) optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
| Name | Server | Description |
|---|---|---|
production |
https://api.spairehq.com |
Production environment |
Example
require "spaire"
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Spaire.new(
server: "production",
access_token: "<YOUR_BEARER_TOKEN_HERE>"
)
res = s.organizations.list(page: 1, limit: 10)
unless res.list_resource_organization.nil?
# handle response
endOverride Server URL Per-Client
The default server can also be overridden globally by passing a URL to the server_url (String) optional parameter when initializing the SDK client instance. For example:
require "spaire"
Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Spaire.new(
server_url: "https://api.spairehq.com",
access_token: "<YOUR_BEARER_TOKEN_HERE>"
)
res = s.organizations.list(page: 1, limit: 10)
unless res.list_resource_organization.nil?
# handle response
endDevelopment
Maturity
This 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.
Contributions
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.