common

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	//MaxIdleConns for Erply API
	MaxIdleConns = 25

	//MaxConnsPerHost for Erply API
	MaxConnsPerHost = 25
)
View Source
const (
	BaseUrl = "https://%s.erply.com/api/"
)
View Source
const (
	MaxBulkRequestsCount = 100
)

Variables

This section is empty.

Functions

func ConvertStructToMap added in v1.4.0

func ConvertStructToMap(input interface{}) (map[string]interface{}, error)

func GetBaseURL

func GetBaseURL(cc string) string

func GetBaseURLFromAuthFunc added in v1.3.1

func GetBaseURLFromAuthFunc(f AuthFunc) string

func GetDefaultHTTPClient

func GetDefaultHTTPClient() *http.Client

func IsJSONResponseOK

func IsJSONResponseOK(responseStatus *common.Status) bool

Types

type AuthFunc added in v1.3.1

type AuthFunc func(string) url.Values

type BodyMock

type BodyMock struct {
	Body       io.Reader
	WasClosed  bool
	CloseError error
}

BodyMock implements resp.Body

func NewMockFromStr

func NewMockFromStr(body string) *BodyMock

NewFromStr creates BodyMock from a string

func NewMockFromStruct

func NewMockFromStruct(input interface{}) *BodyMock

NewFromStruct creates BodyMock from a struct converted to json or string

func (*BodyMock) Close

func (bm *BodyMock) Close() error

Close io.Closer implementation

func (*BodyMock) Read

func (bm *BodyMock) Read(p []byte) (n int, err error)

Read io.Reader implementation

type BulkInput added in v1.3.1

type BulkInput struct {
	MethodName string
	Filters    map[string]interface{}
}

type Client

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

func NewClient

func NewClient(sk, cc, partnerKey string, httpCli *http.Client, headersForEveryRequestFunc AuthFunc) *Client

func (*Client) Close

func (cli *Client) Close()

func (*Client) SendRequest

func (cli *Client) SendRequest(ctx context.Context, apiMethod string, filters map[string]string) (*http.Response, error)

func (*Client) SendRequestBulk added in v1.3.1

func (cli *Client) SendRequestBulk(ctx context.Context, inputs []BulkInput, filters map[string]string) (*http.Response, error)

type ClientMock

type ClientMock struct {
	ErrToGive      error
	ResponseToGive *http.Response
	Requests       []*http.Request
	Lock           sync.Mutex
}

ClientMock mocks HttpClient interface

func (*ClientMock) Do

func (cm *ClientMock) Do(req *http.Request) (*http.Response, error)

Do HttpClient interface implementation

Jump to

Keyboard shortcuts

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