core

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VERSION sdk version
	VERSION = "v1.2.3"
	// GATEWAY api gateway
	GATEWAY = "https://openapi.dataoke.com/api/"
)

Variables

This section is empty.

Functions

func PutResponse

func PutResponse(r *Response)

PutResponse put response to sync.Pool

Types

type Client

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

Client sdk client

func NewClient

func NewClient(appKey string, appSecret string) *Client

NewClient returns a sdk Client instance

func (*Client) Get

func (c *Client) Get(req Request, resp interface{}) error

Get http get

func (*Client) Post

func (c *Client) Post(req Request, resp interface{}) error

Post http post

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool)

SetDebug set debug mode for Client

func (*Client) SetHttpClient

func (c *Client) SetHttpClient(clt *http.Client)

SetHttpClient set custom http.Client for Client

func (*Client) SetVersion

func (c *Client) SetVersion(version string)

SetVersion change Client version

type Request

type Request interface {
	Values(url.Values)
	Url() string
}

Request api request interface

type Response

type Response struct {
	RequestID string          `json:"requestId,omitempty"`
	Time      int64           `json:"time,omitempty"`
	Code      int             `json:"code,omitempty"`
	Msg       string          `json:"msg,omitempty"`
	Data      json.RawMessage `json:"data,omitempty"`
}

Response api response

func GetResponse

func GetResponse() *Response

GetResponse get response from sync.Pool

func (Response) Decode

func (r Response) Decode(resp interface{}) error

Decode api response result

func (Response) Error

func (r Response) Error() string

Error implement error interface

func (Response) IsError

func (r Response) IsError() bool

IsError check api response is error

Jump to

Keyboard shortcuts

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