-
Notifications
You must be signed in to change notification settings - Fork 2
/
session.go
58 lines (47 loc) · 1.92 KB
/
session.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
package files_sdk
import (
"encoding/json"
lib "github.com/Files-com/files-sdk-go/v2/lib"
)
type Session struct {
Id string `json:"id,omitempty" path:"id"`
Language string `json:"language,omitempty" path:"language"`
ReadOnly *bool `json:"read_only,omitempty" path:"read_only"`
SftpInsecureCiphers *bool `json:"sftp_insecure_ciphers,omitempty" path:"sftp_insecure_ciphers"`
Username string `json:"username,omitempty" path:"username"`
Password string `json:"password,omitempty" path:"password"`
Otp string `json:"otp,omitempty" path:"otp"`
PartialSessionId string `json:"partial_session_id,omitempty" path:"partial_session_id"`
}
type SessionCollection []Session
type SessionCreateParams struct {
Username string `url:"username,omitempty" required:"false" json:"username,omitempty" path:"username"`
Password string `url:"password,omitempty" required:"false" json:"password,omitempty" path:"password"`
Otp string `url:"otp,omitempty" required:"false" json:"otp,omitempty" path:"otp"`
PartialSessionId string `url:"partial_session_id,omitempty" required:"false" json:"partial_session_id,omitempty" path:"partial_session_id"`
}
func (s *Session) UnmarshalJSON(data []byte) error {
type session Session
var v session
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
}
*s = Session(v)
return nil
}
func (s *SessionCollection) UnmarshalJSON(data []byte) error {
type sessions SessionCollection
var v sessions
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
}
*s = SessionCollection(v)
return nil
}
func (s *SessionCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*s))
for i, v := range *s {
ret[i] = v
}
return &ret
}