package
2.0.1
Repository: https://github.com/kable-io/kable-go.git
Documentation: pkg.go.dev

# README

Go API client for openapi

The Kable API allows developers to manage customers and API keys and record events about their API.

API Host and Environments

Kable is accessible in Live and Test environments for authentication and metering of client API requests. You will have separate API keys to access each environment.

You should only use Kable's Live environment for your own production data. All other configured environments should use Kable's Test environment.

API Protocols and Headers

All requests to the Kable API are made over HTTPS TLS v1.2+ to ensure security. Calls made over HTTP will fail. Any requests without proper authentication will also fail.

The Kable API uses standard JSON for requests and responses. Be sure to set both the Content-Type and Accept headers on each request to application/json.

Each Kable API response includes a requestId as the X-REQUEST-ID response header. The requestId is included regardless whether the API request succeeded or failed. You can use this requestId to help with debugging or when contacting support regarding a specific API call.

API Keys

There are two types of API keys on Kable.

Kable Keys

Kable Keys are the keys you, the Kable customer, use to interact with Kable. These keys help us ensure that only you are interacting with Kable on your behalf. You can find your keys on the Company page of the dashboard after you sign up.

Kable Keys should be included in every request to the Kable API. You must provide your client ID as the KABLE-CLIENT-ID header and your secret key as the KABLE-CLIENT-SECRET header on each request to Kable. If you are using a language-specific Kable library, you will initialize the SDK using these keys.

Customer Keys

Customer Keys are the keys your customers use to interact with your API. Customer Keys are authenticated by Kable when a customer makes a request to your API if you use Kable's authentication services. Customers must provide their client ID (defined as clientId when you create the customer) as the X-CLIENT-ID header and their secret key as the X-API-KEY header on each request to your API that Kable is to authenticate.

API Versioning

All Kable endpoints are versioned. After the host, each API can be found at /api/vX/... where X is the API version.

We strive to ensure that changes to the Kable API are backward compatible. Sometimes, though, we must break from older design paradigms to make the product better. When this happens, a new version of the API is released.

The current version of Kable is v1.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.2.1
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/GIT_USER_ID/GIT_REPO_ID/openapi"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://live.kable.io/api/v1

ClassMethodHTTP requestDescription
CreditGrantsApiCreateCreditGrantPost /customers/{customerId}/credits/createcreate a new credit grant for a customer
CreditGrantsApiGetCustomerCreditBalanceGet /customers/{customerId}/credits/balanceget a customer's credit balance
CustomersApiAddCustomerPaymentMethodPost /customers/{customerId}/payment_methods/addadd a customer payment method
CustomersApiAddCustomerPlansPost /customers/{customerId}/plans/addadd a plan(s) to a customer
CustomersApiCancelCustomerPost /customers/{customerId}/cancelcancel a customer
CustomersApiCreateCustomerPost /customers/createcreate a customer
CustomersApiDeleteCustomerPost /customers/{customerId}/deletedelete a customer
CustomersApiGetAllCustomersGet /customersget all customers
CustomersApiGetCustomerGet /customers/{customerId}get customer
CustomersApiRemoveCustomerPlansPost /customers/{customerId}/plans/removeremove a plan(s) from a customer
CustomersApiUpdateCustomerPost /customers/{customerId}/updateupdate a customer
DimensionsApiCreateDimensionPost /dimensions/createcreate a dimension
DimensionsApiDeleteDimensionPost /dimensions/{dimensionId}/deletedelete a dimension
DimensionsApiGetAllDimensionsGet /dimensionsget all dimensions
DimensionsApiGetDimensionGet /dimensions/{dimensionId}get dimension
DimensionsApiUpdateDimensionPost /dimensions/{dimensionId}/updateupdate a dimension
EventsApiCreateEventsPost /events/createrecord events
PlansApiCreatePlanPost /plans/createcreate a plan
PlansApiDeletePlanPost /plans/{planId}/deletedelete a plan
PlansApiGetAllPlansGet /plansget all plans
PlansApiGetPlanGet /plans/{planId}get plan
PlansApiUpdatePlanPost /plans/{planId}/updateupdate a plan
TokensApiCreateTokenPost /tokens/createcreate a token
UsageApiGetUsagePost /usage/getget usage metrics

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]