-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccount.go
90 lines (80 loc) · 2.66 KB
/
account.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
80
81
82
83
84
85
86
87
88
89
90
package wunderlist
import (
"encoding/json"
)
type Account struct {
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Email string `json:"email"`
Avatar string `json:"avatar"`
Token string `json:"token"`
EmailConfirmed bool `json:"email_confirmed"`
ConfirmationState string `json:"confirmation_state"`
Product string `json:"product"`
Channel string `json:"channel"`
TermsAcceptedAt string `json:"terms_accepted_at"`
CreateAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type Settings struct {
AccountLocale string `json:"account_locale"`
Background string `json:"background"`
InboxName string `json:"inbox"`
MigratedWunderlistOneUser string `json:"migrated_wunderlist_one_user"`
Wl1InboxId string `json:"wl1:inbox_id"`
WunderlistTimezoneOffset string `json:"wunderlist_timezone_offset"`
}
type Friend struct {
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Email string `json:"email"`
Avatar string `json:"avatar"`
CreateAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type ShareContact struct {
Id string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Avatar string `json:"avatar"`
}
type Share struct {
Id string `json:"id"`
Type string `json:"type"`
ResourceType string `json:"resource_type"`
ResourceTitle string `json:"resource_title"`
ResourceId string `json:"resource_id"`
LocalIdentifier string `json:"local_identifier"`
Sender *ShareContact `json:"sender"`
Recipient *ShareContact `json:"recipient"`
AcceptedAt string `json:"accepted_at"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// Account returns struct with user account information
func (c *Client) Account() (Account, error) {
data := Account{}
body, _ := c.GetRequest("me")
err := json.Unmarshal(body, &data)
return data, err
}
func (c *Client) Settings() (Settings, error) {
data := Settings{}
body, _ := c.GetRequest("me/settings")
err := json.Unmarshal(body, &data)
return data, err
}
func (c *Client) Friends() ([]Friend, error) {
data := []Friend{}
body, _ := c.GetRequest("me/friends")
err := json.Unmarshal(body, &data)
return data, err
}
func (c *Client) Shares() ([]Share, error) {
data := []Share{}
body, _ := c.GetRequest("me/shares")
err := json.Unmarshal(body, &data)
return data, err
}