togai

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 6 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"
)

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"`
	// 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"`
	// 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 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 TogaiClient

type TogaiClient struct {
	ApiBaseUrl string
	ApiToken   string
	// contains filtered or unexported fields
}

func NewTogaiClient

func NewTogaiClient(ApiBaseUrl string, ApiToken string) *TogaiClient

func (*TogaiClient) CreateCustomer

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

TODO: Move URL and Token to togai client struct. Convert this function into a method on togai client struct and use url and token from there. Use http client from the togai client struct

Jump to

Keyboard shortcuts

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