-
Notifications
You must be signed in to change notification settings - Fork 2
/
request.go
79 lines (65 loc) · 2.2 KB
/
request.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package files_sdk
import (
"encoding/json"
lib "github.com/Files-com/files-sdk-go/v2/lib"
)
type Request struct {
Id int64 `json:"id,omitempty"`
Path string `json:"path,omitempty"`
Source string `json:"source,omitempty"`
Destination string `json:"destination,omitempty"`
AutomationId string `json:"automation_id,omitempty"`
UserDisplayName string `json:"user_display_name,omitempty"`
UserIds string `json:"user_ids,omitempty"`
GroupIds string `json:"group_ids,omitempty"`
}
type RequestCollection []Request
type RequestListParams struct {
Cursor string `url:"cursor,omitempty" required:"false"`
PerPage int64 `url:"per_page,omitempty" required:"false"`
SortBy json.RawMessage `url:"sort_by,omitempty" required:"false"`
Mine *bool `url:"mine,omitempty" required:"false"`
Path string `url:"path,omitempty" required:"false"`
lib.ListParams
}
type RequestGetFolderParams struct {
Cursor string `url:"cursor,omitempty" required:"false"`
PerPage int64 `url:"per_page,omitempty" required:"false"`
SortBy json.RawMessage `url:"sort_by,omitempty" required:"false"`
Mine *bool `url:"mine,omitempty" required:"false"`
Path string `url:"-,omitempty" required:"true"`
}
type RequestCreateParams struct {
Path string `url:"path,omitempty" required:"true"`
Destination string `url:"destination,omitempty" required:"true"`
UserIds string `url:"user_ids,omitempty" required:"false"`
GroupIds string `url:"group_ids,omitempty" required:"false"`
}
type RequestDeleteParams struct {
Id int64 `url:"-,omitempty" required:"true"`
}
func (r *Request) UnmarshalJSON(data []byte) error {
type request Request
var v request
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Request(v)
return nil
}
func (r *RequestCollection) UnmarshalJSON(data []byte) error {
type requests []Request
var v requests
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = RequestCollection(v)
return nil
}
func (r *RequestCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*r))
for i, v := range *r {
ret[i] = v
}
return &ret
}