Project

spaire

0.0
The project is in a healthy, maintained state
Ruby SDK for the Spaire API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 5.27.0
>= 0
~> 1.73.2
~> 0.6.12872
~> 0.17.10
~> 0.2.0

Runtime

>= 0.2.0, < 1.0
>= 2.14.1
~> 0.6.12872
 Project Readme

spaire

Developer-friendly & type-safe Ruby SDK specifically catered to leverage spaire API.

Built by Speakeasy License: MIT



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 spaire

SDK 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
end

Authentication

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
end

Per-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
end

Available Resources and Operations

Available methods
  • list - 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 - List Custom Fields
  • create - Create Custom Field
  • get - Get Custom Field
  • delete - Delete Custom Field
  • update - Update Custom Field
  • list - List Customer Meters
  • get - Get Customer Meter
  • list - List Benefit Grants
  • get - Get Benefit Grant
  • update - Update Benefit Grant
  • list - List Meters
  • get - Get Customer Meter
  • list - List Downloadables
  • get - Get Organization
  • list - List Subscriptions
  • get - Get Subscription
  • cancel - Cancel Subscription
  • update - Update Subscription
  • list - List Wallets
  • get - Get Wallet
  • create - Create Customer Session
  • list - List Disputes
  • get - Get Dispute
  • list - List Event Types
  • update - Update Event Type
  • create - Create Member Session
  • get - Get Metrics
  • limits - Get Metrics Limits
  • list - List Organizations
  • create - Create Organization
  • get - Get Organization
  • update - Update Organization
  • list - List Payments
  • get - Get Payment
  • list - List Subscriptions
  • create - Create Subscription
  • export - Export Subscriptions
  • get - Get Subscription
  • revoke - Revoke Subscription
  • update - Update Subscription

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
end

Server 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
end

Override 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
end

Development

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.

SDK Created by Speakeasy