-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwork.go
65 lines (55 loc) · 1.76 KB
/
work.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package lytics
import (
"encoding/json"
"strconv"
"time"
)
const (
workEndpoint = "work/:id" // state
workListEndpoint = "work"
)
type Work struct {
Id string `json:"id"`
Aid int `json:"aid"`
AccountId string `json:"account_id"`
UserId string `json:"user_id"`
WorkStateVersion int `json:"work_state_version"`
Config json.RawMessage `json:"config,omitempty"`
WorkflowId string `json:"workflow_id"`
Workflow string `json:"workflow"`
Tag string `json:"tag"`
Updated time.Time `json:"updated"`
Created time.Time `json:"created"`
AuthIds []string `json:"auth_ids,omitempty"`
Hidden bool `json:"hidden"`
RuntimeOverride string `json:"runtime"`
VerboseLogging bool `json:"verbose_logging"`
StatusCode string `json:"statuscode"`
}
// GetWork returns a single work
// https://www.getlytics.com/developers/rest-api#work-get
func (l *Client) GetWork(id string, state bool) (Work, error) {
res := ApiResp{}
data := Work{}
// make the request
err := l.Get(parseLyticsURL(workEndpoint, map[string]string{"id": id, "state": strconv.FormatBool(state)}), nil, nil, &res, &data)
if err != nil {
return data, err
}
return data, nil
}
// GetWorks returns all works
// https://www.getlytics.com/developers/rest-api#work
func (l *Client) GetWorks() ([]Work, error) {
res := ApiResp{}
data := []Work{}
// make the request
err := l.Get(workListEndpoint, nil, nil, &res, &data)
if err != nil {
return data, err
}
return data, nil
}
// Other Available Endpoints
// * POST create work
// * DELETE remove work