Documentation
¶
Index ¶
Constants ¶
const ( DateFormat = "2006-01-02" TimeFormat = "15:04:05" DateTimeFormat = DateFormat + " " + TimeFormat )
Variables ¶
var (
ErrInvalidCredentials = errors.New("invalid credentials")
)
Functions ¶
func DecodeResult ¶
DecodeResult takes a buffer, decodes the intermediate JsonRpcResponse and then the contained "result" field into "result".
Types ¶
type ActionReason ¶
func (ActionReason) MarshalJSON ¶
func (reason ActionReason) MarshalJSON() ([]byte, error)
func (*ActionReason) String ¶
func (reason *ActionReason) String() string
func (*ActionReason) UnmarshalJSON ¶
func (reason *ActionReason) UnmarshalJSON(b []byte) error
type Attendance ¶
type Attendance struct {
// ID is an unique ID for each attendance entry
ID int `json:"id,omitempty"`
// DateTime is the entry timestamp in UTC
// Format: '2006-01-02 15:04:05'
DateTime *Date `json:"name,omitempty"`
// Action is either "sign_in" or "sign_out"
Action string `json:"action,omitempty"`
// Reason describes the "action reason" from Odoo.
//
// Example raw values returned from Odoo:
// * `false` (if no specific reason given)
// * `[1, "Outside office hours"]`
// * `[2, "Outside office hours"]`
// * `[3, "Sick / Medical Consultation"]`
// * `[4, "Sick / Medical Consultation"]`
// * `[5, "Authorities"]`
// * `[6, "Authorities"]`
// * `[27, "Requested Public Service"]`
// * `[28, "Requested Public Service"]`
//
// NOTE: This field has special meaning when calculating the overtime.
Reason *ActionReason `json:"action_desc,omitempty"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the base struct that holds information required to talk to Odoo
func (Client) Login ¶
Login tries to authenticate the user against Odoo. It returns a session if authentication was successful, or an error if the credentials were wrong, encoding or sending the request, or decoding the request failed.
func (Client) ReadAllAttendances ¶
func (c Client) ReadAllAttendances(sid string, uid int) ([]Attendance, error)
type Date ¶ added in v0.2.0
Date is an Odoo-specific format of a timestamp
func (Date) IsWithinMonth ¶ added in v0.2.0
func (Date) MarshalJSON ¶ added in v0.2.0
func (*Date) UnmarshalJSON ¶ added in v0.2.0
type Filter ¶
type Filter []interface{}
Filter to use in queries, usually in the format of [predicate, operator, value], eg ["employee_id.user_id.id", "=", 123]
type JsonRpcError ¶
type JsonRpcRequest ¶
type JsonRpcRequest struct {
// ID should be a randomly generated value, either as a string or int. The
// server will return this value in the response.
ID string `json:"id,omitempty"`
// Jsonrpc is always set to "2.0"
Jsonrpc string `json:"jsonrpc,omitempty"`
// Method to call, usually just "call"
Method string `json:"method,omitempty"`
// Params includes the actual request payload.
Params interface{} `json:"params,omitempty"`
}
JsonRpcRequest represents a generic json-rpc request
func NewJsonRpcRequest ¶
func NewJsonRpcRequest(params interface{}) *JsonRpcRequest
NewJsonRpcRequest returns a JSON RPC request with its protocol fileds populated:
* "id" will be set to a random UUID * "jsonrpc" will be set to "2.0" * "method" will be set to "call" * "params" will be set to whatever was passed in
type JsonRpcResponse ¶
type JsonRpcResponse struct {
// ID that was sent with the request
ID string `json:"id,omitempty"`
// Jsonrpc is always set to "2.0"
Jsonrpc string `json:"jsonrpc,omitempty"`
// Result payload
Result *json.RawMessage `json:"result,omitempty"`
// Optional eror field
Error *JsonRpcError `json:"error,omitempty"`
}
type Leave ¶
type Leave struct {
// ID is an unique ID for each leave entry
ID int `json:"id"`
// DateFrom is the starting timestamp of the leave in UTC
// Format: DateTimeFormat
DateFrom *Date `json:"date_from"`
// DateTo is the ending timestamp of the leave in UTC
// Format: DateTimeFormat
DateTo *Date `json:"date_to"`
// Type describes the "leave type" from Odoo.
//
// Example raw values returned from Odoo:
// * `false` (if no specific reason given)
// * `[4, "Unpaid"]`
// * `[5, "Military Service"]`
// * `[7, "Special Occasions"]`
// * `[9, "Public Holiday"]`
// * `[16, "Legal Leaves 2020"]`
// * `[17, "Legal Leaves 2021"]`
Type *LeaveType `json:"holiday_status_id,omitempty"`
// State is the leave request state.
// Example raw values returned from Odoo:
// * `draft` (To Submit)
// * `confirm` (To Approve)
// * `validate` (Approved)
State string `json:"state,omitempty"`
}
func (Leave) SplitByDay ¶ added in v0.2.0
type LeaveType ¶ added in v0.2.0
func (LeaveType) MarshalJSON ¶ added in v0.2.0
func (*LeaveType) UnmarshalJSON ¶ added in v0.2.0
type ReadModelRequest ¶
type ReadModelRequest struct {
Model string `json:"model,omitempty"`
Domain []Filter `json:"domain,omitempty"`
Fields []string `json:"fields,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
ReadModelRequest is used as "params" in requests to "dataset/search_read" endpoints.
type Session ¶
type Session struct {
// ID is the session ID.
// Is always set, no matter the authentication outcome.
ID string `json:"session_id,omitempty"`
// UID is the user's ID as an int, or the boolean `false` if authentication
// failed.
UID int `json:"uid,omitempty"`
// Username is usually set to the LoginName that was sent in the request.
// Is always set, no matter the authentication outcome.
Username string `json:"username,omitempty"`
}
Session information