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