-
Notifications
You must be signed in to change notification settings - Fork 2
/
publickey.go
76 lines (61 loc) · 1.76 KB
/
publickey.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
package files_sdk
import (
"encoding/json"
"time"
lib "github.com/Files-com/files-sdk-go/lib"
)
type PublicKey struct {
Id int64 `json:"id,omitempty"`
Title string `json:"title,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
UserId int64 `json:"user_id,omitempty"`
PublicKey string `json:"public_key,omitempty"`
}
type PublicKeyCollection []PublicKey
type PublicKeyListParams struct {
UserId int64 `url:"user_id,omitempty" required:"false"`
Cursor string `url:"cursor,omitempty" required:"false"`
PerPage int64 `url:"per_page,omitempty" required:"false"`
lib.ListParams
}
type PublicKeyFindParams struct {
Id int64 `url:"-,omitempty" required:"true"`
}
type PublicKeyCreateParams struct {
UserId int64 `url:"user_id,omitempty" required:"false"`
Title string `url:"title,omitempty" required:"true"`
PublicKey string `url:"public_key,omitempty" required:"true"`
}
type PublicKeyUpdateParams struct {
Id int64 `url:"-,omitempty" required:"true"`
Title string `url:"title,omitempty" required:"true"`
}
type PublicKeyDeleteParams struct {
Id int64 `url:"-,omitempty" required:"true"`
}
func (p *PublicKey) UnmarshalJSON(data []byte) error {
type publicKey PublicKey
var v publicKey
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = PublicKey(v)
return nil
}
func (p *PublicKeyCollection) UnmarshalJSON(data []byte) error {
type publicKeys []PublicKey
var v publicKeys
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = PublicKeyCollection(v)
return nil
}
func (p *PublicKeyCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*p))
for i, v := range *p {
ret[i] = v
}
return &ret
}