gocancel

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 14 Imported by: 4

README

gocancel-go

Build Status GoDoc

gocancel-go is a Go client library for accessing the GoCancel API.

You can view the client API docs here: http://godoc.org/github.com/gocancel/gocancel-go.

You can view the GoCancel API docs here: https://app.gocxl.com/docs.

Installation

gocancel-go is compatible with modern Go releases in module mode, with Go installed:

go get github.com/gocancel/gocancel-go

will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

import "github.com/gocancel/gocancel-go"

and run go get without parameters.

Usage

import "github.com/gocancel/gocancel-go"

Construct a new client, then use the various services on the client to access different parts of the GoCancel API. For example:

client := gocancel.NewClient(nil)

// list all organizations.
organizations, _, err := client.Organizations.List(context.Background(), nil)
Authentication

The gocancel-go library does not directly handle authentication. Instead, when creating a new client, pass an http.Client that can handle authentication for you. The easiest and recommended way to do this is using the oauth2 library, but you can always use any other library that provides an http.Client. If you have a OAuth2 client ID and client secret, you can use it with the oauth2 library using:

import (
  "github.com/gocancel/gocancel-go"
  "golang.org/x/oauth2/clientcredentials"
)

func main() {
	ctx := context.Background()

	conf := &clientcredentials.Config{
		ClientID:     "... your client id ...",
		ClientSecret: "... your client secret ...",
		Scopes:       []string{"read:categories"},
		TokenURL:     gocancel.Endpoint.TokenURL,
	}
	tc := conf.Client(ctx)

	client := gocancel.NewClient(tc)

	// list all categories
	categories, _, err := client.Categories.List(ctx)
}

Note that when using an authenticated Client, all calls made by the client will include the specified OAuth client credentials. Therefore, authenticated clients should almost never be shared between different accounts.

See the oauth2 docs for complete instructions on using that library.

Testing

The API client found in gocancel-go is HTTP based. Interactions with the HTTP API can be faked by serving up your own in-memory server within your test. One benefit of using this approach is that you don’t need to define an interface in your runtime code; you can keep using the concrete struct types returned by the client library.

To fake HTTP interactions we can make use of the httptest package found in the standard library. The server URL obtained from creating the test server can be passed to the client struct by overriding the BaseURL field. This instructs the client to route all traffic to your test server rather than the live API. Here is an example of what doing this looks like:

import (
  "fmt"
  "net/http"
  "net/http/httptest"
  "net/url"

  "github.com/gocancel/gocancel-go"
)

// mux is the HTTP request multiplexer used with the test server.
mux := http.NewServeMux()

mux.HandleFunc("/api/v1/categories/foo", func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, `{"id":"foo"}`)
})

mux.HandleFunc("/api/v1/organizations/bar", func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, `{"id":"bar"}`)
})

// ts is a test HTTP server used to provide mock API responses.
ts := httptest.NewServer(mux)
defer ts.Close()

// client is the GoCancel client being tested.
client := gocancel.NewClient(nil)
url, _ := url.Parse(server.URL + "/")
// Pass the test server's URL to the API client.
client.BaseURL = url

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Endpoint = oauth2.Endpoint{
	AuthURL:  defaultBaseURL + "oauth/auth",
	TokenURL: defaultBaseURL + "oauth/token",
}

Endpoint is GoCancel's OAuth 2.0 default endpoint.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have response body, and a JSON response body that maps to Error.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int32

func Int32(v int32) *int32

Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Stringify

func Stringify(message interface{}) string

Stringify attempts to create a reasonable string representation of types in the GoCancel API library. It does things like resolve pointers to their values and omits struct fields with nil values.

Types

type Account added in v0.2.0

type Account struct {
	ID           *string    `json:"id,omitempty"`
	Name         *string    `json:"name,omitempty"`
	SandboxMode  *bool      `json:"sandbox_mode,omitempty"`
	SandboxEmail *string    `json:"sandbox_email,omitempty"`
	CreatedAt    *Timestamp `json:"created_at,omitempty"`
	UpdatedAt    *Timestamp `json:"updated_at,omitempty"`
}

Account represents a GoCancel account.

func (Account) String added in v0.2.0

func (w Account) String() string

type AccountMetadata added in v0.2.0

type AccountMetadata map[string]interface{}

AccountMetadata represents key-value attributes for a specific account.

type AccountsService added in v0.2.0

type AccountsService service

AccountsService provides access to the account related functions in the GoCancel API.

func (*AccountsService) Get added in v0.2.0

func (s *AccountsService) Get(ctx context.Context, account string) (*Account, *Response, error)

Get fetches an account.

type Address

type Address struct {
	Name               *string `json:"name,omitempty"`
	ForAttentionOf     *string `json:"for_attention_of,omitempty"`
	AddressLine1       *string `json:"address_line1,omitempty"`
	AddressLine2       *string `json:"address_line2,omitempty"`
	PostalCode         *string `json:"postal_code,omitempty"`
	DependentLocality  *string `json:"dependent_locality,omitempty"`
	Locality           *string `json:"locality,omitempty"`
	AdministrativeArea *string `json:"administrative_area,omitempty"`
	Country            *string `json:"country,omitempty"`
}

Address represents an embeddable address.

func (Address) String

func (a Address) String() string

type CategoriesListOptions

type CategoriesListOptions struct {
	Cursor   string                `url:"cursor,omitempty"`
	Limit    int                   `url:"limit,omitempty"`
	Locales  []string              `url:"locales,omitempty"`
	Metadata map[string]string     `url:"metadata,omitempty"`
	Slug     string                `url:"slug,omitempty"`
	Sort     CategoriesSortOptions `url:"sort,omitempty"`
}

type CategoriesService

type CategoriesService service

CategoriesService provides access to the category related functions in the GoCancel API.

func (*CategoriesService) Get

func (s *CategoriesService) Get(ctx context.Context, category string) (*Category, *Response, error)

Get fetches a category.

func (*CategoriesService) List

List lists all categories

type CategoriesSortOptions

type CategoriesSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

type Category

type Category struct {
	ID              *string           `json:"id,omitempty"`
	Name            *string           `json:"name,omitempty"`
	Slug            *string           `json:"slug,omitempty"`
	RequiresConsent *bool             `json:"requires_consent,omitempty"`
	Locales         []*CategoryLocale `json:"locales,omitempty"`
	Metadata        *AccountMetadata  `json:"metadata,omitempty"`
	CreatedAt       *Timestamp        `json:"created_at,omitempty"`
	UpdatedAt       *Timestamp        `json:"updated_at,omitempty"`
}

Category represents a GoCancel category.

func (Category) String

func (c Category) String() string

type CategoryLocale

type CategoryLocale struct {
	ID              *string             `json:"id,omitempty"`
	Name            *string             `json:"name,omitempty"`
	Slug            *string             `json:"slug,omitempty"`
	RequiresConsent *bool               `json:"requires_consent,omitempty"`
	Locale          *string             `json:"locale,omitempty"`
	Providers       []*CategoryProvider `json:"providers,omitempty"`
	LetterTemplate  *LetterTemplate     `json:"letter_template,omitempty"`
	Metadata        *AccountMetadata    `json:"metadata,omitempty"`
}

CategoryLocale represents the localized variant of the category.

func (CategoryLocale) String

func (o CategoryLocale) String() string

type CategoryProvider

type CategoryProvider struct {
	ID     *string `json:"id,omitempty"`
	Name   *string `json:"name,omitempty"`
	Type   *string `json:"type,omitempty"`
	Method *string `json:"method,omitempty"`
}

CategoryProvider represents the provider of the category.

func (CategoryProvider) String

func (c CategoryProvider) String() string

type Client

type Client struct {

	// Base URL for API requests. Defaults to the public GoCancel API, BaseURL should
	// always be specified with a trailing slash.
	BaseURL *url.URL

	// User agent used when communicating with the GoCancel API.
	UserAgent string

	// Services used for talking to different parts of the GoCancel API.
	Accounts      *AccountsService
	Categories    *CategoriesService
	Letters       *LettersService
	Organizations *OrganizationsService
	Products      *ProductsService
	Providers     *ProvidersService
	Webhooks      *WebhooksService
	// contains filtered or unexported fields
}

A Client manages communication with the GoCancel API.

func New

func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error)

New returns a new GoCancel API client instance.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new GoCancel API client. If a nil httpClient is provided, the http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).

Users who wish to pass their own http.Client should use this method. If you're in need of further customization, the gocancel.New method allows more options, such as setting a custom URL or a custom user agent string.

func (*Client) BareDo

func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, error)

BareDo sends an API request and lets you handle the api response. If an error or API Error occurs, the error will contain more information. Otherwise you are supposed to read and close the response's Body.

The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If v is nil, and no error hapens, the response is returned as is.

The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type ClientOpt

type ClientOpt func(*Client) error

ClientOpt are options for New.

func SetBaseURL

func SetBaseURL(bu string) ClientOpt

SetBaseURL is a client option for setting the base URL.

func SetRequestHeaders

func SetRequestHeaders(headers map[string]string) ClientOpt

SetRequestHeaders sets optional HTTP headers on the client that are sent on each HTTP request.

func SetUserAgent

func SetUserAgent(ua string) ClientOpt

SetUserAgent is a client option for setting the user agent.

type Error

type Error struct {
	Response *http.Response // HTTP response that caused this error

	Code    string `json:"code"`    // error code
	Message string `json:"message"` // error message
}

Error is the response returned when a call is unsuccessful.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (r *Error) Is(target error) bool

Is returns whether the provided error equals this error.

type Letter

type Letter struct {
	ID                    *string                `json:"id,omitempty"`
	AccountID             *string                `json:"account_id,omitempty"`
	OrganizationID        *string                `json:"organization_id,omitempty"`
	OrganizationName      *string                `json:"organization_name,omitempty"`
	ProductID             *string                `json:"product_id,omitempty"`
	ProductName           *string                `json:"product_name,omitempty"`
	ProviderID            *string                `json:"provider_id,omitempty"`
	ProviderConfiguration *ProviderConfiguration `json:"provider_configuration,omitempty"`
	Locale                *string                `json:"locale,omitempty"`
	State                 *string                `json:"state,omitempty"`
	ProofOfIDs            []*string              `json:"proof_of_ids,omitempty"`
	Parameters            *LetterParameters      `json:"parameters,omitempty"`
	Email                 *string                `json:"email,omitempty"`
	Fax                   *string                `json:"fax,omitempty"`
	Address               *Address               `json:"address,omitempty"`
	LetterTemplate        *LetterTemplate        `json:"letter_template,omitempty"`
	SignatureType         *string                `json:"signature_type,omitempty"`
	SignatureData         *string                `json:"signature_data,omitempty"`
	SandboxMode           *bool                  `json:"sandbox_mode,omitempty"`
	SandboxEmail          *string                `json:"sandbox_email,omitempty"`
	Metadata              *AccountMetadata       `json:"metadata,omitempty"`
	CreatedAt             *Timestamp             `json:"created_at,omitempty"`
	UpdatedAt             *Timestamp             `json:"updated_at,omitempty"`
}

Letter represents a GoCancel letter.

func (Letter) String

func (l Letter) String() string

type LetterParameters

type LetterParameters map[string]interface{}

LetterParameters represents key-value parameters for a letter.

type LetterRequest added in v0.2.0

type LetterRequest struct {
	OrganizationID string           `json:"organization_id,omitempty"`
	ProductID      string           `json:"product_id,omitempty"`
	ProviderID     string           `json:"provider_id,omitempty"`
	Locale         string           `json:"locale,omitempty"`
	Parameters     LetterParameters `json:"parameters,omitempty"`
	ProofOfIDs     []string         `json:"proof_of_ids,omitempty"`
	SignatureType  string           `json:"signature_type,omitempty"`
	SignatureData  string           `json:"signature_data,omitempty"`
	Consent        bool             `json:"consent,omitempty"`
	Metadata       AccountMetadata  `json:"metadata,omitempty"`
	Drafted        bool             `json:"drafted,omitempty"`
}

LetterRequest represents a base request for creating or updating a letter.

type LetterTemplate

type LetterTemplate struct {
	Template *string                `json:"template,omitempty"`
	Fields   []*LetterTemplateField `json:"fields,omitempty"`
}

LetterTemplate represents an embeddable letter template.

func (LetterTemplate) String

func (l LetterTemplate) String() string

type LetterTemplateField

type LetterTemplateField struct {
	Key      *string                      `json:"key,omitempty"`
	Type     *string                      `json:"type,omitempty"`
	Default  *string                      `json:"default,omitempty"`
	Label    *string                      `json:"label,omitempty"`
	Required *bool                        `json:"required,omitempty"`
	Position *int                         `json:"position,omitempty"`
	Options  []*LetterTemplateFieldOption `json:"options,omitempty"`
}

type LetterTemplateFieldOption

type LetterTemplateFieldOption struct {
	Value *string `json:"value,omitempty"`
	Label *string `json:"label,omitempty"`
}

type LettersListOptions

type LettersListOptions struct {
	Sort LettersSortOptions `url:"sort,omitempty"`
}

type LettersService

type LettersService service

LettersService provides access to the letter related functions in the GoCancel API.

func (*LettersService) Create

func (s *LettersService) Create(ctx context.Context, request *LetterRequest) (*Letter, *Response, error)

Create creates a letter.

func (*LettersService) Delete added in v0.2.0

func (s *LettersService) Delete(ctx context.Context, letter string) (*Response, error)

Delete deletes a letter.

func (*LettersService) DownloadDocument

func (s *LettersService) DownloadDocument(ctx context.Context, letter string) (io.ReadCloser, *Response, error)

DownloadDocument fetches a letter document as binary stream.

func (*LettersService) DownloadProofOfID

func (s *LettersService) DownloadProofOfID(ctx context.Context, letter string, proof_of_id string) (io.ReadCloser, *Response, error)

DownloadProofOfID downloads a proof of ID for a letter

func (*LettersService) Get

func (s *LettersService) Get(ctx context.Context, letter string) (*Letter, *Response, error)

Get fetches a letter.

func (*LettersService) List

List lists all letters.

func (*LettersService) MarkAsDrafted

func (s *LettersService) MarkAsDrafted(ctx context.Context, letter string, request *MarkLetterAsDraftedRequest) (*Letter, *Response, error)

MarkAsDrafted marks a letter as drafted.

func (*LettersService) Update added in v0.2.0

func (s *LettersService) Update(ctx context.Context, letter string, request *LetterRequest) (*Letter, *Response, error)

Update updates a letter.

type LettersSortOptions

type LettersSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

type MarkLetterAsDraftedRequest

type MarkLetterAsDraftedRequest struct {
	ProviderKey string `json:"provider_key,omitempty"`
}

MarkLetterAsDraftedRequest represents a `mark letter as drafted` request.

type Metadata

type Metadata struct {
	NextCursor     string `json:"next_cursor,omitempty"`
	PreviousCursor string `json:"previous_cursor,omitempty"`
}

Metadata represents the cursors for list responses.

type Organization

type Organization struct {
	ID                *string               `json:"id,omitempty"`
	CategoryID        *string               `json:"category_id,omitempty"`
	Name              *string               `json:"name,omitempty"`
	Slug              *string               `json:"slug,omitempty"`
	Email             *string               `json:"email,omitempty"`
	URL               *string               `json:"url,omitempty"`
	Phone             *string               `json:"phone,omitempty"`
	Fax               *string               `json:"fax,omitempty"`
	Address           *Address              `json:"address,omitempty"`
	RequiresConsent   *bool                 `json:"requires_consent,omitempty"`
	RequiresProofOfID *bool                 `json:"requires_proof_of_id,omitempty"`
	Locales           []*OrganizationLocale `json:"locales,omitempty"`
	Metadata          *AccountMetadata      `json:"metadata,omitempty"`
	CreatedAt         *Timestamp            `json:"created_at,omitempty"`
	UpdatedAt         *Timestamp            `json:"updated_at,omitempty"`
}

Organization represents a GoCancel organization.

func (Organization) String

func (o Organization) String() string

type OrganizationLocale

type OrganizationLocale struct {
	ID                *string                 `json:"id,omitempty"`
	Name              *string                 `json:"name,omitempty"`
	Slug              *string                 `json:"slug,omitempty"`
	Locale            *string                 `json:"locale,omitempty"`
	Email             *string                 `json:"email,omitempty"`
	URL               *string                 `json:"url,omitempty"`
	Phone             *string                 `json:"phone,omitempty"`
	Fax               *string                 `json:"fax,omitempty"`
	Address           *Address                `json:"address,omitempty"`
	RequiresConsent   *bool                   `json:"requires_consent,omitempty"`
	RequiresProofOfID *bool                   `json:"requires_proof_of_id,omitempty"`
	Providers         []*OrganizationProvider `json:"providers,omitempty"`
	LetterTemplate    *LetterTemplate         `json:"letter_template,omitempty"`
	Metadata          *AccountMetadata        `json:"metadata,omitempty"`
	CreatedAt         *Timestamp              `json:"created_at,omitempty"`
	UpdatedAt         *Timestamp              `json:"updated_at,omitempty"`
}

OrganizationLocale represents the localized variant of the organization.

func (OrganizationLocale) String

func (o OrganizationLocale) String() string

type OrganizationProductsListOptions

type OrganizationProductsListOptions struct {
	Cursor   string                          `url:"cursor,omitempty"`
	Limit    int                             `url:"limit,omitempty"`
	Locales  []string                        `url:"locales,omitempty"`
	Metadata map[string]string               `url:"metadata,omitempty"`
	Slug     string                          `url:"slug,omitempty"`
	Sort     OrganizationProductsSortOptions `url:"sort,omitempty"`
	URL      string                          `url:"url,omitempty"`
}

type OrganizationProductsSortOptions

type OrganizationProductsSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

type OrganizationProvider

type OrganizationProvider struct {
	ID        *string          `json:"id,omitempty"`
	Name      *string          `json:"name,omitempty"`
	Type      *string          `json:"type,omitempty"`
	Method    *string          `json:"method,omitempty"`
	Metadata  *AccountMetadata `json:"metadata,omitempty"`
	CreatedAt *Timestamp       `json:"created_at,omitempty"`
	UpdatedAt *Timestamp       `json:"updated_at,omitempty"`
}

OrganizationProvider represents the provider of the organization.

func (OrganizationProvider) String

func (o OrganizationProvider) String() string

type OrganizationsListOptions

type OrganizationsListOptions struct {
	Category string                   `url:"category,omitempty"`
	Cursor   string                   `url:"cursor,omitempty"`
	Limit    int                      `url:"limit,omitempty"`
	Locales  []string                 `url:"locales,omitempty"`
	Metadata map[string]string        `url:"metadata,omitempty"`
	Slug     string                   `url:"slug,omitempty"`
	Sort     OrganizationsSortOptions `url:"sort,omitempty"`
	URL      string                   `url:"url,omitempty"`
}

type OrganizationsService

type OrganizationsService service

OrganizationsService provides access to the organization related functions in the GoCancel API.

func (*OrganizationsService) Get

func (s *OrganizationsService) Get(ctx context.Context, organization string) (*Organization, *Response, error)

Get fetches a organization.

func (*OrganizationsService) GetProduct

func (s *OrganizationsService) GetProduct(ctx context.Context, organization string, product string) (*Product, *Response, error)

Get fetches a product of an organization.

func (*OrganizationsService) List

List lists all organizations

func (*OrganizationsService) ListProducts

func (s *OrganizationsService) ListProducts(ctx context.Context, organization string, opts *OrganizationProductsListOptions) ([]*Product, *Response, error)

List lists all products of an organization

type OrganizationsSortOptions

type OrganizationsSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

type Product

type Product struct {
	ID                *string          `json:"id,omitempty"`
	OrganizationID    *string          `json:"organization_id,omitempty"`
	Name              *string          `json:"name,omitempty"`
	Slug              *string          `json:"slug,omitempty"`
	Email             *string          `json:"email,omitempty"`
	URL               *string          `json:"url,omitempty"`
	Phone             *string          `json:"phone,omitempty"`
	Fax               *string          `json:"fax,omitempty"`
	Address           *Address         `json:"address,omitempty"`
	RequiresConsent   *bool            `json:"requires_consent,omitempty"`
	RequiresProofOfID *bool            `json:"requires_proof_of_id,omitempty"`
	Locales           []*ProductLocale `json:"locales,omitempty"`
	Metadata          *AccountMetadata `json:"metadata,omitempty"`
	CreatedAt         *Timestamp       `json:"created_at,omitempty"`
	UpdatedAt         *Timestamp       `json:"updated_at,omitempty"`
}

Product represents a product of an organization.

func (Product) String

func (p Product) String() string

type ProductLocale

type ProductLocale struct {
	ID                *string            `json:"id,omitempty"`
	Name              *string            `json:"name,omitempty"`
	Slug              *string            `json:"slug,omitempty"`
	Locale            *string            `json:"locale,omitempty"`
	Email             *string            `json:"email,omitempty"`
	URL               *string            `json:"url,omitempty"`
	Phone             *string            `json:"phone,omitempty"`
	Fax               *string            `json:"fax,omitempty"`
	Address           *Address           `json:"address,omitempty"`
	RequiresConsent   *bool              `json:"requires_consent,omitempty"`
	RequiresProofOfID *bool              `json:"requires_proof_of_id,omitempty"`
	Providers         []*ProductProvider `json:"providers,omitempty"`
	LetterTemplate    *LetterTemplate    `json:"letter_template,omitempty"`
	Metadata          *AccountMetadata   `json:"metadata,omitempty"`
	CreatedAt         *Timestamp         `json:"created_at,omitempty"`
	UpdatedAt         *Timestamp         `json:"updated_at,omitempty"`
}

ProductLocale represents the localized variant of the product.

func (ProductLocale) String

func (o ProductLocale) String() string

type ProductProvider

type ProductProvider struct {
	ID        *string          `json:"id,omitempty"`
	Name      *string          `json:"name,omitempty"`
	Type      *string          `json:"type,omitempty"`
	Method    *string          `json:"method,omitempty"`
	Metadata  *AccountMetadata `json:"metadata,omitempty"`
	CreatedAt *Timestamp       `json:"created_at,omitempty"`
	UpdatedAt *Timestamp       `json:"updated_at,omitempty"`
}

ProductProvider represents the provider of the product.

func (ProductProvider) String

func (o ProductProvider) String() string

type ProductsService

type ProductsService service

ProductsService provides access to the product related functions in the GoCancel API.

func (*ProductsService) Get

func (s *ProductsService) Get(ctx context.Context, product string) (*Product, *Response, error)

Get fetches a product.

type ProductsSortOptions

type ProductsSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

type Provider

type Provider struct {
	ID             *string                `json:"id,omitempty"`
	ProviderType   *string                `json:"provider_type,omitempty"`
	ProviderMethod *string                `json:"provider_method,omitempty"`
	Configuration  *ProviderConfiguration `json:"configuration,omitempty"`
	Locales        []*ProviderLocale      `json:"locales,omitempty"`
	CreatedAt      *Timestamp             `json:"created_at,omitempty"`
	UpdatedAt      *Timestamp             `json:"updated_at,omitempty"`
}

Provider represents a GoCancel provider.

func (Provider) String

func (p Provider) String() string

type ProviderConfiguration

type ProviderConfiguration map[string]interface{}

type ProviderLocale

type ProviderLocale struct {
	ID            *string                `json:"id,omitempty"`
	Locale        *string                `json:"locale,omitempty"`
	Configuration *ProviderConfiguration `json:"configuration,omitempty"`
	CreatedAt     *Timestamp             `json:"created_at,omitempty"`
	UpdatedAt     *Timestamp             `json:"updated_at,omitempty"`
}

type ProvidersListOptions

type ProvidersListOptions struct {
	Cursor string               `url:"cursor,omitempty"`
	Limit  int                  `url:"limit,omitempty"`
	Sort   ProvidersSortOptions `url:"sort,omitempty"`
}

type ProvidersService

type ProvidersService service

ProvidersService provides access to the provider related functions in the GoCancel API.

func (*ProvidersService) Get

func (s *ProvidersService) Get(ctx context.Context, provider string) (*Provider, *Response, error)

Get fetches a provider.

func (*ProvidersService) List

List lists all providers

type ProvidersSortOptions

type ProvidersSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

type Response

type Response struct {
	*http.Response

	// For APIs that support cursor pagination, the metadata field is populated with the
	// cursor values for paginating through a list of items.
	Metadata *Metadata
}

Response is a GoCancel API response. This wraps the standard http.Response returned from GoCancel and provides convenient access to things like cursors.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as an RFC3339 timestamp. All exported methods of time.Time can be called on Timestamp.

func (Timestamp) Equal

func (t Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 format.

type Webhook

type Webhook struct {
	ID        *string          `json:"id,omitempty"`
	AccountID *string          `json:"account_id,omitempty"`
	Url       *string          `json:"url,omitempty"`
	Events    []*string        `json:"events,omitempty"`
	Locales   []*string        `json:"locales,omitempty"`
	Metadata  *AccountMetadata `json:"metadata,omitempty"`
	Active    *bool            `json:"active,omitempty"`
	CreatedAt *Timestamp       `json:"created_at,omitempty"`
	UpdatedAt *Timestamp       `json:"updated_at,omitempty"`
}

Webhook represents a GoCancel webhook.

func (Webhook) String

func (w Webhook) String() string

type WebhooksListOptions

type WebhooksListOptions struct {
	// Active filters webhooks by their status.
	Active  bool                `url:"active,omitempty"`
	Cursor  string              `url:"cursor,omitempty"`
	Events  []string            `url:"events,omitempty"`
	Limit   int                 `url:"limit,omitempty"`
	Locales []string            `url:"locales,omitempty"`
	Sort    WebhooksSortOptions `url:"sort,omitempty"`
}

WebhooksListOptions specifies the optional parameters to the WebhooksService.List method.

type WebhooksService

type WebhooksService service

WebhooksService provides access to the webhook related functions in the GoCancel API.

func (*WebhooksService) Get

func (s *WebhooksService) Get(ctx context.Context, webhook string) (*Webhook, *Response, error)

Get fetches a webhook.

func (*WebhooksService) List

List lists all webhooks

type WebhooksSortOptions

type WebhooksSortOptions struct {
	CreatedAt string `url:"created_at,omitempty"`
	UpdatedAt string `url:"updated_at,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL