client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoHTTP

func DoHTTP(method, uri string, auths string, body io.Reader) ([]byte, error)

Types

type Client

type Client struct {
	*TokenHolder
	// contains filtered or unexported fields
}

func NewClient

func NewClient(urlToken string) *Client

func (*Client) Do

func (c *Client) Do(method, uri string, body io.Reader) ([]byte, error)

func (*Client) Get

func (c *Client) Get(uri string) ([]byte, error)

func (*Client) GetJSON

func (c *Client) GetJSON(uri string, obj interface{}) error

func (*Client) Post

func (c *Client) Post(uri string, data []byte) ([]byte, error)

func (*Client) PostJSON

func (c *Client) PostJSON(uri string, data []byte, obj interface{}) error

func (*Client) SetAuth

func (c *Client) SetAuth(auths string)

func (*Client) SetContentType

func (c *Client) SetContentType(ctype string)

type Error

type Error struct {
	ErrCode int    `json:"errcode,omitempty"`
	ErrMsg  string `json:"errmsg,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type,omitempty"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Error
}

type TokenHolder

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

func NewTokenHolder

func NewTokenHolder(baseUrl string) *TokenHolder

func (*TokenHolder) Expired

func (th *TokenHolder) Expired() bool

func (*TokenHolder) GetAuthToken

func (th *TokenHolder) GetAuthToken() (token string, err error)

func (*TokenHolder) SetAuth

func (th *TokenHolder) SetAuth(auths string)

func (*TokenHolder) SetCorp

func (th *TokenHolder) SetCorp(id, secret string)

func (*TokenHolder) Valid

func (th *TokenHolder) Valid() bool

Jump to

Keyboard shortcuts

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