98 } |
98 } |
99 |
99 |
100 // GetAccount returns an account entity |
100 // GetAccount returns an account entity |
101 // The returned value can be nil if there is an error or if the |
101 // The returned value can be nil if there is an error or if the |
102 // requested ID does not exist. |
102 // requested ID does not exist. |
103 func (g *Client) GetAccount(id int) (*Account, error) { |
103 func (g *Client) GetAccount(accountID int) (*Account, error) { |
104 account, err := g.getSingleAccount("account", id) |
104 account, err := g.getSingleAccount("account", accountID) |
105 if err != nil { |
105 if err != nil { |
106 return nil, err |
106 return nil, err |
107 } |
107 } |
108 if account != nil && account.ID == 0 { |
108 if account != nil && account.ID == 0 { |
109 return nil, ErrEntityNotFound |
109 return nil, ErrEntityNotFound |
134 o := &getAccountsOptions{ID: accountID} |
134 o := &getAccountsOptions{ID: accountID} |
135 return g.getMultipleAccounts("following", o) |
135 return g.getMultipleAccounts("following", o) |
136 } |
136 } |
137 |
137 |
138 // FollowAccount follows an account |
138 // FollowAccount follows an account |
139 func (g *Client) FollowAccount(id int) error { |
139 func (g *Client) FollowAccount(accountID int) error { |
140 account, err := g.getSingleAccount("follow", id) |
140 account, err := g.getSingleAccount("follow", accountID) |
141 if err != nil { |
141 if err != nil { |
142 return err |
142 return err |
143 } |
143 } |
144 if account != nil && account.ID != id { |
144 if account != nil && account.ID != accountID { |
145 return ErrEntityNotFound |
145 return ErrEntityNotFound |
146 } |
146 } |
147 return nil |
147 return nil |
148 } |
148 } |
149 |
149 |
150 // UnfollowAccount unfollows an account |
150 // UnfollowAccount unfollows an account |
151 func (g *Client) UnfollowAccount(id int) error { |
151 func (g *Client) UnfollowAccount(accountID int) error { |
152 account, err := g.getSingleAccount("unfollow", id) |
152 account, err := g.getSingleAccount("unfollow", accountID) |
153 if err != nil { |
153 if err != nil { |
154 return err |
154 return err |
155 } |
155 } |
156 if account != nil && account.ID != id { |
156 if account != nil && account.ID != accountID { |
157 return ErrEntityNotFound |
157 return ErrEntityNotFound |
158 } |
158 } |
159 return nil |
159 return nil |
160 } |
160 } |
161 |
161 |
178 } |
178 } |
179 return &account, nil |
179 return &account, nil |
180 } |
180 } |
181 |
181 |
182 // BlockAccount blocks an account |
182 // BlockAccount blocks an account |
183 func (g *Client) BlockAccount(id int) error { |
183 func (g *Client) BlockAccount(accountID int) error { |
184 account, err := g.getSingleAccount("block", id) |
184 account, err := g.getSingleAccount("block", accountID) |
185 if err != nil { |
185 if err != nil { |
186 return err |
186 return err |
187 } |
187 } |
188 if account != nil && account.ID != id { |
188 if account != nil && account.ID != accountID { |
189 return ErrEntityNotFound |
189 return ErrEntityNotFound |
190 } |
190 } |
191 return nil |
191 return nil |
192 } |
192 } |
193 |
193 |
194 // UnblockAccount unblocks an account |
194 // UnblockAccount unblocks an account |
195 func (g *Client) UnblockAccount(id int) error { |
195 func (g *Client) UnblockAccount(accountID int) error { |
196 account, err := g.getSingleAccount("unblock", id) |
196 account, err := g.getSingleAccount("unblock", accountID) |
197 if err != nil { |
197 if err != nil { |
198 return err |
198 return err |
199 } |
199 } |
200 if account != nil && account.ID != id { |
200 if account != nil && account.ID != accountID { |
201 return ErrEntityNotFound |
201 return ErrEntityNotFound |
202 } |
202 } |
203 return nil |
203 return nil |
204 } |
204 } |
205 |
205 |
206 // MuteAccount mutes an account |
206 // MuteAccount mutes an account |
207 func (g *Client) MuteAccount(id int) error { |
207 func (g *Client) MuteAccount(accountID int) error { |
208 account, err := g.getSingleAccount("mute", id) |
208 account, err := g.getSingleAccount("mute", accountID) |
209 if err != nil { |
209 if err != nil { |
210 return err |
210 return err |
211 } |
211 } |
212 if account != nil && account.ID != id { |
212 if account != nil && account.ID != accountID { |
213 return ErrEntityNotFound |
213 return ErrEntityNotFound |
214 } |
214 } |
215 return nil |
215 return nil |
216 } |
216 } |
217 |
217 |
218 // UnmuteAccount unmutes an account |
218 // UnmuteAccount unmutes an account |
219 func (g *Client) UnmuteAccount(id int) error { |
219 func (g *Client) UnmuteAccount(accountID int) error { |
220 account, err := g.getSingleAccount("unmute", id) |
220 account, err := g.getSingleAccount("unmute", accountID) |
221 if err != nil { |
221 if err != nil { |
222 return err |
222 return err |
223 } |
223 } |
224 if account != nil && account.ID != id { |
224 if account != nil && account.ID != accountID { |
225 return ErrEntityNotFound |
225 return ErrEntityNotFound |
226 } |
226 } |
227 return nil |
227 return nil |
228 } |
228 } |
229 |
229 |