added add / remove friend functions.
This commit is contained in:
parent
eb561040dd
commit
330cdf6984
30
client.go
30
client.go
@ -282,3 +282,33 @@ func (c Client) FetchRelationships() ([]*UserRelations, error) {
|
|||||||
err = json.Unmarshal(resp, &relationshipDatas)
|
err = json.Unmarshal(resp, &relationshipDatas)
|
||||||
return relationshipDatas, err
|
return relationshipDatas, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send friend request. / Accept friend request.
|
||||||
|
// User relations struct only will have status. id is not defined for this function.
|
||||||
|
func (c Client) AddFriend(username string) (*UserRelations, error) {
|
||||||
|
relationshipData := &UserRelations{}
|
||||||
|
|
||||||
|
resp, err := c.Request("PUT", "/users/"+username+"/friend", []byte{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return relationshipData, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(resp, relationshipData)
|
||||||
|
return relationshipData, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deny friend request. / Remove friend.
|
||||||
|
// User relations struct only will have status. id is not defined for this function.
|
||||||
|
func (c Client) RemoveFriend(username string) (*UserRelations, error) {
|
||||||
|
relationshipData := &UserRelations{}
|
||||||
|
|
||||||
|
resp, err := c.Request("DELETE", "/users/"+username+"/friend", []byte{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return relationshipData, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(resp, relationshipData)
|
||||||
|
return relationshipData, err
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user