bexio

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnauthorizedError = errors.New("Unauthorized")
	NotFoundError     = errors.New("Not found")
)

Functions

func NewCachingTokenSource

func NewCachingTokenSource(config *oauth2.Config, token *oauth2.Token, readFunc ReadTokenFunc, saveFunc SaveTokenFunc) (oauth2.TokenSource, error)

func NewConfig

func NewConfig(clientID, clientSecret string) oauth2.Config

func OAuthLogin

func OAuthLogin(ctx context.Context, config oauth2.Config) (*oauth2.Token, error)

Types

type CachingTokenSource

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

func (*CachingTokenSource) Token

func (c *CachingTokenSource) Token() (token *oauth2.Token, err error)

Tries to read from the given read function first. If that token is not present or not valid anymore, it reads from the given token source, which should renew the token automatically. After that, the token is saved via the given save token function.

type Client

type Client struct {
	BaseUrl string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, tokenSource oauth2.TokenSource) *Client

func (*Client) Get

func (c *Client) Get(url string, query QueryParams) (*http.Response, error)

type Contact

type Contact struct {
	ID        int       `json:"id"`
	Number    string    `json:"nr"`
	Name      string    `json:"name_1"`
	Name2     string    `json:"name_2"`
	Address   string    `json:"address"`
	Postcode  string    `json:"postcode"`
	City      string    `json:"city"`
	Mail      string    `json:"mail"`
	Phone     string    `json:"phone_fixed"`
	Mobile    string    `json:"phone_mobile"`
	UpdatedAt Timestamp `json:"updated_at"`
}

func ListContacts

func ListContacts(client *Client, limit int) ([]Contact, error)

func (*Contact) FullName

func (c *Contact) FullName() string

type QueryParams

type QueryParams map[string]string

type ReadTokenFunc

type ReadTokenFunc func() (*oauth2.Token, error)

type SaveTokenFunc

type SaveTokenFunc func(*oauth2.Token) error

type Timestamp

type Timestamp struct {
	time.Time
}

func (*Timestamp) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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