-
Notifications
You must be signed in to change notification settings - Fork 1
/
daptin_client.go
48 lines (38 loc) · 1.28 KB
/
daptin_client.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
package daptin_go_client
import "github.com/go-resty/resty/v2"
type JsonApiObject map[string]interface{}
type DaptinQueryParameters map[string]interface{}
type DaptinActionResponse struct {
ResponseType string
Attributes map[string]interface{}
}
type DaptinClient interface {
FindOne(tableName string, referenceId string, parameters DaptinQueryParameters) (JsonApiObject, error)
FindAll(tableName string, parameters DaptinQueryParameters) ([]JsonApiObject, error)
Create(tableName string, attributes JsonApiObject) (JsonApiObject, error)
Update(tableName, referenceId string, object JsonApiObject) (JsonApiObject, error)
Delete(tableName string, referenceId string) error
Execute(actionName string, tableName string, attributes JsonApiObject) ([]DaptinActionResponse, error)
SetDebug(bool)
}
type World struct {
Name string
}
type DaptinClientHelper interface {
GetAllWorld() []World
}
func NewDaptinClient(endpoint string, debug bool) DaptinClient {
return &daptinClientImpl{
endpoint: endpoint,
restyClient: resty.New(),
debug: debug,
}
}
func NewDaptinClientWithAuthToken(endpoint string, authToken string, debug bool) DaptinClient {
return &daptinClientImpl{
restyClient: resty.New(),
endpoint: endpoint,
authToken: authToken,
debug: debug,
}
}