author | Mikael Berthe <mikael@lilotux.net> |
Sat, 15 Apr 2017 10:26:36 +0200 | |
changeset 120 | 579912e9d0ef |
parent 110 | 0ee4bfc17cc8 |
child 130 | c450bb73f59a |
permissions | -rw-r--r-- |
8 | 1 |
package gondole |
103 | 2 |
|
3 |
import ( |
|
4 |
"fmt" |
|
5 |
"strconv" |
|
6 |
||
7 |
"github.com/sendgrid/rest" |
|
8 |
) |
|
9 |
||
108 | 10 |
// updateStatusOptions contains option fields for POST and DELETE API calls |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
11 |
type updateStatusOptions struct { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
12 |
// The ID is used for most commands |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
13 |
ID int |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
14 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
15 |
// The following fields are used for posting a new status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
16 |
Status string |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
17 |
InReplyToID int |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
18 |
MediaIDs []int |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
19 |
Sensitive bool |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
20 |
SpoilerText string |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
21 |
Visibility string // "direct", "private", "unlisted" or "public" |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
22 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
23 |
|
103 | 24 |
// queryStatusData queries the statuses API |
120 | 25 |
// The operation 'op' can be empty or "status" (the status itself), "context", |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
26 |
// "card", "reblogged_by", "favourited_by". |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
27 |
// The data argument will receive the object(s) returned by the API server. |
120 | 28 |
func (g *Client) queryStatusData(statusID int, op string, data interface{}) error { |
103 | 29 |
if statusID < 1 { |
30 |
return ErrInvalidID |
|
31 |
} |
|
32 |
||
120 | 33 |
endPoint := "statuses/" + strconv.Itoa(statusID) |
34 |
||
35 |
if op != "" && op != "status" { |
|
36 |
switch op { |
|
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
37 |
case "context", "card", "reblogged_by", "favourited_by": |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
38 |
default: |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
39 |
return ErrInvalidParameter |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
40 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
41 |
|
120 | 42 |
endPoint += "/" + op |
103 | 43 |
} |
44 |
||
120 | 45 |
return g.apiCall(endPoint, rest.Get, nil, data) |
103 | 46 |
} |
47 |
||
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
48 |
// updateStatusData updates the statuses |
120 | 49 |
// The operation 'op' can be empty or "status" (to post a status), "delete" |
50 |
// (for deleting a status), "reblog", "unreblog", "favourite", "unfavourite". |
|
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
51 |
// The data argument will receive the object(s) returned by the API server. |
120 | 52 |
func (g *Client) updateStatusData(op string, opts updateStatusOptions, data interface{}) error { |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
53 |
method := rest.Post |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
54 |
endPoint := "statuses" |
120 | 55 |
params := make(apiCallParams) |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
56 |
|
120 | 57 |
switch op { |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
58 |
case "", "status": |
120 | 59 |
op = "status" |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
60 |
if opts.Status == "" { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
61 |
return ErrInvalidParameter |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
62 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
63 |
switch opts.Visibility { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
64 |
case "", "direct", "private", "unlisted", "public": |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
65 |
// Okay |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
66 |
default: |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
67 |
return ErrInvalidParameter |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
68 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
69 |
if len(opts.MediaIDs) > 4 { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
70 |
return fmt.Errorf("too many (>4) media IDs") |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
71 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
72 |
case "delete": |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
73 |
method = rest.Delete |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
74 |
if opts.ID < 1 { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
75 |
return ErrInvalidID |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
76 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
77 |
endPoint += "/" + strconv.Itoa(opts.ID) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
78 |
case "reblog", "unreblog", "favourite", "unfavourite": |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
79 |
if opts.ID < 1 { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
80 |
return ErrInvalidID |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
81 |
} |
120 | 82 |
endPoint += "/" + strconv.Itoa(opts.ID) + "/" + op |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
83 |
default: |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
84 |
return ErrInvalidParameter |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
85 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
86 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
87 |
// Form items for a new toot |
120 | 88 |
if op == "status" { |
89 |
params["status"] = opts.Status |
|
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
90 |
if opts.InReplyToID > 0 { |
120 | 91 |
params["in_reply_to_id"] = strconv.Itoa(opts.InReplyToID) |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
92 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
93 |
for i, id := range opts.MediaIDs { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
94 |
qID := fmt.Sprintf("media_ids[%d]", i+1) |
120 | 95 |
params[qID] = strconv.Itoa(id) |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
96 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
97 |
if opts.Sensitive { |
120 | 98 |
params["sensitive"] = "true" |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
99 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
100 |
if opts.SpoilerText != "" { |
120 | 101 |
params["spoiler_text"] = opts.SpoilerText |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
102 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
103 |
if opts.Visibility != "" { |
120 | 104 |
params["visibility"] = opts.Visibility |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
105 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
106 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
107 |
|
120 | 108 |
return g.apiCall(endPoint, method, params, data) |
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
109 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
110 |
|
103 | 111 |
// GetStatus returns a status |
112 |
// The returned status can be nil if there is an error or if the |
|
113 |
// requested ID does not exist. |
|
114 |
func (g *Client) GetStatus(id int) (*Status, error) { |
|
115 |
var status Status |
|
116 |
||
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
117 |
if err := g.queryStatusData(id, "status", &status); err != nil { |
103 | 118 |
return nil, err |
119 |
} |
|
120 |
if status.ID == 0 { |
|
121 |
return nil, ErrEntityNotFound |
|
122 |
} |
|
123 |
return &status, nil |
|
124 |
} |
|
125 |
||
126 |
// GetStatusContext returns a status context |
|
127 |
func (g *Client) GetStatusContext(id int) (*Context, error) { |
|
128 |
var context Context |
|
129 |
if err := g.queryStatusData(id, "context", &context); err != nil { |
|
130 |
return nil, err |
|
131 |
} |
|
132 |
return &context, nil |
|
133 |
} |
|
134 |
||
135 |
// GetStatusCard returns a status card |
|
136 |
func (g *Client) GetStatusCard(id int) (*Card, error) { |
|
137 |
var card Card |
|
138 |
if err := g.queryStatusData(id, "card", &card); err != nil { |
|
139 |
return nil, err |
|
140 |
} |
|
141 |
return &card, nil |
|
142 |
} |
|
143 |
||
144 |
// GetStatusRebloggedBy returns a list of the accounts who reblogged a status |
|
145 |
func (g *Client) GetStatusRebloggedBy(id int) ([]Account, error) { |
|
146 |
var accounts []Account |
|
147 |
err := g.queryStatusData(id, "reblogged_by", &accounts) |
|
148 |
return accounts, err |
|
149 |
} |
|
150 |
||
151 |
// GetStatusFavouritedBy returns a list of the accounts who favourited a status |
|
152 |
func (g *Client) GetStatusFavouritedBy(id int) ([]Account, error) { |
|
153 |
var accounts []Account |
|
154 |
err := g.queryStatusData(id, "favourited_by", &accounts) |
|
155 |
return accounts, err |
|
156 |
} |
|
105
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
157 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
158 |
// PostStatus posts a new "toot" |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
159 |
// All parameters but "text" can be empty. |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
160 |
// Visibility must be empty, or one of "direct", "private", "unlisted" and "public". |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
161 |
func (g *Client) PostStatus(text string, inReplyTo int, mediaIDs []int, sensitive bool, spoilerText string, visibility string) (*Status, error) { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
162 |
var status Status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
163 |
o := updateStatusOptions{ |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
164 |
Status: text, |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
165 |
InReplyToID: inReplyTo, |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
166 |
MediaIDs: mediaIDs, |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
167 |
Sensitive: sensitive, |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
168 |
SpoilerText: spoilerText, |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
169 |
Visibility: visibility, |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
170 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
171 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
172 |
err := g.updateStatusData("status", o, &status) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
173 |
if err != nil { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
174 |
return nil, err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
175 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
176 |
if status.ID == 0 { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
177 |
return nil, ErrEntityNotFound // TODO Change error message |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
178 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
179 |
return &status, err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
180 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
181 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
182 |
// DeleteStatus deletes a status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
183 |
func (g *Client) DeleteStatus(id int) error { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
184 |
var status Status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
185 |
o := updateStatusOptions{ID: id} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
186 |
err := g.updateStatusData("delete", o, &status) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
187 |
return err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
188 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
189 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
190 |
// ReblogStatus reblogs a status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
191 |
func (g *Client) ReblogStatus(id int) error { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
192 |
var status Status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
193 |
o := updateStatusOptions{ID: id} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
194 |
err := g.updateStatusData("reblog", o, &status) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
195 |
return err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
196 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
197 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
198 |
// UnreblogStatus unreblogs a status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
199 |
func (g *Client) UnreblogStatus(id int) error { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
200 |
var status Status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
201 |
o := updateStatusOptions{ID: id} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
202 |
err := g.updateStatusData("unreblog", o, &status) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
203 |
return err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
204 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
205 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
206 |
// FavouriteStatus favourites a status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
207 |
func (g *Client) FavouriteStatus(id int) error { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
208 |
var status Status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
209 |
o := updateStatusOptions{ID: id} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
210 |
err := g.updateStatusData("favourite", o, &status) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
211 |
return err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
212 |
} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
213 |
|
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
214 |
// UnfavouriteStatus unfavourites a status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
215 |
func (g *Client) UnfavouriteStatus(id int) error { |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
216 |
var status Status |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
217 |
o := updateStatusOptions{ID: id} |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
218 |
err := g.updateStatusData("unfavourite", o, &status) |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
219 |
return err |
e2a16e19eb8b
Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents:
103
diff
changeset
|
220 |
} |