Documentation
¶
Overview ¶
Package millennium is a Millennium ERP library written in Go to facilitate the integration with Millennium ERP.
Index ¶
- Constants
- type AuthType
- type HTTPMethod
- type Millennium
- func (m *Millennium) Delete(method string, params url.Values) error
- func (m *Millennium) Get(method string, params url.Values, response interface{}) (int, error)
- func (m *Millennium) Login(username string, password string, authType AuthType) error
- func (m *Millennium) Post(method string, body []byte, response interface{}) error
- func (m *Millennium) Request(r RequestMethod) (err error)
- type RequestMethod
- type ResponseError
- type ResponseGet
- type ResponseLogin
Constants ¶
const (
RetryMax = 3
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod type to communicate with Millennium
const ( GET HTTPMethod = "GET" POST HTTPMethod = "POST" DELETE HTTPMethod = "DELETE" )
HTTP methods available
type Millennium ¶
type Millennium struct {
// Server used to store the server address
ServerAddr string
// Client points to retryable http lib
Client *retryablehttp.Client
// Context
Context context.Context
Timeout time.Duration
// contains filtered or unexported fields
}
Millennium struct has the essential information to communicate with Millennium ERP
func NewClient ¶ added in v1.1.0
NewClient returns a new Millennium instance with the server address and timeout
func (*Millennium) Delete ¶
func (m *Millennium) Delete(method string, params url.Values) error
Delete requests a method using DELETE http method
func (*Millennium) Login ¶
func (m *Millennium) Login(username string, password string, authType AuthType) error
Login requests login to Millennium server server should be a valid URL with Millennium port, like: https://127.0.0.1:6018
func (*Millennium) Post ¶
func (m *Millennium) Post(method string, body []byte, response interface{}) error
Post requests a method using POST http method
func (*Millennium) Request ¶
func (m *Millennium) Request(r RequestMethod) (err error)
Request a method from Millennium
type RequestMethod ¶
type RequestMethod struct {
HTTPMethod HTTPMethod
Method string
Params url.Values
Body []byte
Response interface{}
}
RequestMethod receive data to pass to Request function
type ResponseError ¶
type ResponseError struct {
Err struct {
Code int `json:"code"`
Message struct {
Lang string `json:"lang"`
Value string `json:"value"`
} `json:"message"`
} `json:"error"`
}
ResponseError type is the standard response struct for errors
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
func (*ResponseError) SetCode ¶
func (r *ResponseError) SetCode(code int)
SetCode sets a custom error code
func (*ResponseError) SetMessage ¶
func (r *ResponseError) SetMessage(message string)
SetMessage sets a custom error message
func (*ResponseError) String ¶
func (r *ResponseError) String() string
type ResponseGet ¶
type ResponseGet struct {
Count int `json:"odata.count"`
Value *json.RawMessage `json:"value"`
}
ResponseGet type is the standard response struct from GET requests
type ResponseLogin ¶
type ResponseLogin struct {
Session string `json:"session"`
}
ResponseLogin type is the standard response struct from login requests