Documentation ¶
Index ¶
- Variables
- func Bool(v bool) *bool
- func CheckResponse(r *http.Response) error
- func Int(v int) *int
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func String(v string) *string
- func Stringify(message interface{}) string
- type Account
- type AccountMetadata
- type AccountsService
- type Address
- type CategoriesListOptions
- type CategoriesService
- type CategoriesSortOptions
- type Category
- type CategoryLocale
- type CategoryProvider
- type Client
- type ClientOpt
- type Error
- type Letter
- type LetterParameters
- type LetterRequest
- type LetterTemplate
- type LetterTemplateField
- type LetterTemplateFieldOption
- type LettersListOptions
- type LettersService
- func (s *LettersService) Create(ctx context.Context, request *LetterRequest) (*Letter, *Response, error)
- func (s *LettersService) Delete(ctx context.Context, letter string) (*Response, error)
- func (s *LettersService) DownloadDocument(ctx context.Context, letter string) (io.ReadCloser, *Response, error)
- func (s *LettersService) DownloadProofOfID(ctx context.Context, letter string, proof_of_id string) (io.ReadCloser, *Response, error)
- func (s *LettersService) Get(ctx context.Context, letter string) (*Letter, *Response, error)
- func (s *LettersService) List(ctx context.Context, opts *LettersListOptions) ([]*Letter, *Response, error)
- func (s *LettersService) MarkAsDrafted(ctx context.Context, letter string, request *MarkLetterAsDraftedRequest) (*Letter, *Response, error)
- func (s *LettersService) Update(ctx context.Context, letter string, request *LetterRequest) (*Letter, *Response, error)
- type LettersSortOptions
- type MarkLetterAsDraftedRequest
- type Metadata
- type Organization
- type OrganizationLocale
- type OrganizationProductsListOptions
- type OrganizationProductsSortOptions
- type OrganizationProvider
- type OrganizationsListOptions
- type OrganizationsService
- func (s *OrganizationsService) Get(ctx context.Context, organization string) (*Organization, *Response, error)
- func (s *OrganizationsService) GetProduct(ctx context.Context, organization string, product string) (*Product, *Response, error)
- func (s *OrganizationsService) List(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error)
- func (s *OrganizationsService) ListProducts(ctx context.Context, organization string, ...) ([]*Product, *Response, error)
- type OrganizationsSortOptions
- type Product
- type ProductLocale
- type ProductProvider
- type ProductsService
- type ProductsSortOptions
- type Provider
- type ProviderConfiguration
- type ProviderLocale
- type ProvidersListOptions
- type ProvidersService
- type ProvidersSortOptions
- type Response
- type Timestamp
- type Webhook
- type WebhooksListOptions
- type WebhooksService
- type WebhooksSortOptions
Constants ¶
This section is empty.
Variables ¶
var Endpoint = oauth2.Endpoint{
AuthURL: defaultBaseURL + "oauth/auth",
TokenURL: defaultBaseURL + "oauth/token",
}
Endpoint is GoCancel's OAuth 2.0 default endpoint.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func CheckResponse ¶
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 ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func Int32 ¶
Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.
func Int64 ¶
Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.
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.
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.
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.
type CategoriesListOptions ¶
type CategoriesService ¶
type CategoriesService service
CategoriesService provides access to the category related functions in the GoCancel API.
func (*CategoriesService) List ¶
func (s *CategoriesService) List(ctx context.Context, opts *CategoriesListOptions) ([]*Category, *Response, error)
List lists all categories
type CategoriesSortOptions ¶
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.
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 NewClient ¶
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 ¶
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 ¶
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 ¶
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 ¶
ClientOpt are options for New.
func SetBaseURL ¶
SetBaseURL is a client option for setting the base URL.
func SetRequestHeaders ¶
SetRequestHeaders sets optional HTTP headers on the client that are sent on each HTTP request.
func SetUserAgent ¶
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.
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.
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 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) 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) List ¶
func (s *LettersService) List(ctx context.Context, opts *LettersListOptions) ([]*Letter, *Response, error)
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 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 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 ¶
func (s *OrganizationsService) List(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error)
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 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.
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.
type ProductsSortOptions ¶
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.
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) List ¶
func (s *ProvidersService) List(ctx context.Context, opts *ProvidersListOptions) ([]*Provider, *Response, error)
List lists all providers
type ProvidersSortOptions ¶
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 ¶
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) UnmarshalJSON ¶
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.
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) List ¶
func (s *WebhooksService) List(ctx context.Context, opts *WebhooksListOptions) ([]*Webhook, *Response, error)
List lists all webhooks