common

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 12 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/"
)

Variables

This section is empty.

Functions

func GetBaseURL

func GetBaseURL(cc string) string

func GetDefaultHTTPClient

func GetDefaultHTTPClient() *http.Client

func IsJSONResponseOK

func IsJSONResponseOK(responseStatus *Status) bool

Types

type Address

type Address struct {
	AddressID  int         `json:"addressID"`
	OwnerID    int         `json:"ownerID"`
	TypeID     interface{} `json:"typeID"`
	Address2   string      `json:"address2"`
	Address    string      `json:"address"`
	Street     string      `json:"street"`
	PostalCode string      `json:"postalCode"`
	City       string      `json:"city"`
	State      string      `json:"state"`
	Country    string      `json:"country"`
}

Address from getAddresses

type Addresses

type Addresses []Address

Addresses from getAddresses

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 Client

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

func NewClient

func NewClient(sk, cc, partnerKey string, httpCli *http.Client) *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)

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

type ObjAttribute

type ObjAttribute struct {
	AttributeName  string `json:"attributeName"`
	AttributeType  string `json:"attributeType"`
	AttributeValue string `json:"attributeValue"`
}

type Status

type Status struct {
	Request           string  `json:"request"`
	RequestUnixTime   int     `json:"requestUnixTime"`
	ResponseStatus    string  `json:"responseStatus"`
	ErrorCode         int     `json:"errorCode"`
	ErrorField        string  `json:"errorField"`
	GenerationTime    float64 `json:"generationTime"`
	RecordsTotal      int     `json:"recordsTotal"`
	RecordsInResponse int     `json:"recordsInResponse"`
}

Jump to

Keyboard shortcuts

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