togai

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: MIT Imports: 9 Imported by: 0

README

go-togai

A Golang library for Togai APIs

Documentation

Index

Constants

View Source
const (
	JSON_TYPE                 = "application/json"
	ACCEPT_HTTP_HEADER        = "accept"
	CONTENT_TYPE_HTTP_HEADER  = "content-type"
	AUTHORIZATION_HTTP_HEADER = "authorization"
)
View Source
const (
	NEXT_TOKEN_QUERY_PARAM = "nextToken"
	PAGE_SIZE_QUERY_PARAM  = "pageSize"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// Identifier of the account
	Id string `json:"id"`
	// Name of the Account
	Name string `json:"name"`
	// Use [ISO 4217] currency code in which the account must be invoiced.
	// For example: AED is the currency code for United Arab Emirates dirham.
	//
	// [ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217
	InvoiceCurrency string `json:"invoiceCurrency,omitempty"`
	// Aliases are tags that are associated with an account. Multiple aliases are allowed for a single account.
	Aliases []string `json:"aliases"`
	// Account Settings
	Settings []Setting `json:"settings"`
}

type AccountAlias added in v0.0.2

type AccountAlias struct {
	Alias  string `json:"alias"`
	Status string `json:"status"`
}

type CreateAccountOutput added in v0.0.2

type CreateAccountOutput struct {
	// Identifier of the account
	Id string `json:"id"`
	// Name of the Account
	Name string `json:"name"`
	// Status of the account
	Status string `json:"status"`
	// Use [ISO 4217] currency code in which the account must be invoiced.
	// For example: AED is the currency code for United Arab Emirates dirham.
	//
	// [ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217
	InvoiceCurrency string `json:"invoiceCurrency"`
	// Aliases are tags that are associated with an account. Multiple aliases are allowed for a single account.
	Aliases []AccountAlias `json:"aliases"`
	// Account Settings
	Settings []Setting `json:"settings"`
}

type CreateCustomerOutput added in v0.0.2

type CreateCustomerOutput struct {
	// Customer identifier
	Id string `json:"id"`
	// Name of the Customer
	Name string `json:"name"`
	// Primary email of the customer
	PrimaryEmail string `json:"primaryEmail"`
	// Billing address of the customer
	BillingAddress string `json:"billingAddress"`
	// Customer Settings
	Settings []Setting `json:"settings"`
	// Payload to create [Account]
	Account CreateAccountOutput `json:"account"`
}

type Customer

type Customer struct {
	// Customer identifier
	Id string `json:"id"`
	// Name of the Customer
	Name string `json:"name"`
	// Primary email of the customer
	PrimaryEmail string `json:"primaryEmail"`
	// Billing address of the customer
	BillingAddress string `json:"billingAddress"`
	// Status of the customer
	Status string `json:"status"`
	// Time at which the customer was created
	CreatedAt time.Time `json:"createdAt"`
	// Time at which the customer was last updated
	UpdatedAt time.Time `json:"updatedAt"`
}

type CustomerWithAccount added in v0.0.3

type CustomerWithAccount struct {
	// Customer identifier
	Id string `json:"id"`
	// Name of the Customer
	Name string `json:"name"`
	// Primary email of the customer
	PrimaryEmail string `json:"primaryEmail"`
	// Billing address of the customer
	BillingAddress string `json:"billingAddress"`
	// Customer Settings
	Settings []Setting `json:"settings"`
	// Payload to create [Account]
	Account Account `json:"account"`
}

The primary use case of creating Customers and Accounts is to have the ability to track usage and revenue at the granular level.

The Customers and Accounts are parent and child relationships. By default, Togai creates an Account for every Customer you create with the Customer ID and Customer Name same for the Account. You can also define the Account ID and Account Name by passing to the respective fields as given in the body parameters.

You can use Customers and Accounts for Company and Users relationship, Customer and Multiple environments like staging, sandbox, and production, or any similar use case.

Learn more from Customer Management

type ListCustomersOutput added in v0.0.3

type ListCustomersOutput struct {
	Data      []Customer `json:"data"`
	NextToken string     `json:"nextToken"`
}

type Namespace added in v0.0.2

type Namespace string
const (
	UserNamespace  Namespace = "USER"
	TogaiNamespace Namespace = "TOGAI"
)

type Setting

type Setting struct {
	Id        string          `json:"id"`
	Value     string          `json:"value"`
	Namespace Namespace       `json:"namespace"`
	Name      string          `json:"name"`
	DataType  SettingDataType `json:"dataType"`
}

type SettingDataType

type SettingDataType string
const (
	StringSettingDataType    SettingDataType = "STRING"
	NumericSettingDataType   SettingDataType = "NUMERIC"
	JsonSettingDataType      SettingDataType = "JSON"
	JsonLogicSettingDataType SettingDataType = "JSON_LOGIC"
)

type Status added in v0.0.3

type Status struct {
	Success bool `json:"success"`
}

type TogaiClient

type TogaiClient struct {
	// contains filtered or unexported fields
}

func NewTogaiClient

func NewTogaiClient(apiBaseUrl string, apiToken string) (*TogaiClient, error)

func (*TogaiClient) CreateAccount added in v0.0.3

func (c *TogaiClient) CreateAccount(customerId string, account Account) (*CreateAccountOutput, error)

CreateAccount creates the given account

func (*TogaiClient) CreateCustomer

func (c *TogaiClient) CreateCustomer(customer CustomerWithAccount) (*CreateCustomerOutput, error)

CreateCustomer creates the given customer

func (*TogaiClient) DeleteAccount added in v0.0.3

func (c *TogaiClient) DeleteAccount(customerId string, accountId string) error

func (*TogaiClient) DeleteCustomer added in v0.0.3

func (c *TogaiClient) DeleteCustomer(customerId string) error

func (*TogaiClient) GetCustomer added in v0.0.3

func (c *TogaiClient) GetCustomer(customerId string) (*Customer, error)

func (*TogaiClient) ListCustomers added in v0.0.3

func (c *TogaiClient) ListCustomers(nextToken string, pageSize int) (*ListCustomersOutput, error)

func (*TogaiClient) UpdateCustomer added in v0.0.3

func (c *TogaiClient) UpdateCustomer(customer UpdateCustomerInput) (*Customer, error)

UpdateCustomer updates the given customer

type UpdateCustomerInput added in v0.0.3

type UpdateCustomerInput struct {
	Id string `json:"-"`
	// Name of the Customer
	Name *string `json:"name,omitempty"`
	// Primary email of the customer
	PrimaryEmail *string `json:"primaryEmail,omitempty"`
	// Billing address of the customer
	BillingAddress *string `json:"billingAddress,omitempty"`
}

Jump to

Keyboard shortcuts

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