-
Notifications
You must be signed in to change notification settings - Fork 0
/
ya360.go
76 lines (58 loc) · 1.19 KB
/
ya360.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 ya360
import "fmt"
// Ya360 contains Yandex 360 parameters
type Ya360 struct {
s Settings
}
// Settings contain settings for node connections
type Settings struct {
URL string
OAuth string
OrgID int64
}
type MemberIDType struct {
ID string `json:"id"`
Type MemberType `json:"type"`
}
type Error struct {
Code int
Text string
}
type errorRx struct {
Code int `json:"code"`
Details []errorRxDetails `json:"details"`
Message string `json:"message"`
}
type errorRxDetails struct {
Type string `json:"@type"`
}
type MemberType string
const (
MemberTypeUser MemberType = "user"
MemberTypeGroup MemberType = "group"
MemberTypeDepartment MemberType = "department"
)
func (t MemberType) String() string {
return string(t)
}
type Order string
const (
OrderByID Order = "id"
OrderByName Order = "name"
)
func (d Order) String() string {
return string(d)
}
const YaHostDefault = "https://api360.yandex.net"
// Init returns parametrized Node object
func Init(s Settings) Ya360 {
if len(s.URL) == 0 {
s.URL = YaHostDefault
}
return Ya360{
s: s,
}
}
func (e Error) Error() string {
return fmt.Sprintf("%d, %s", e.Code, e.Text)
}