First major code push
Preparing for version 0.1.0 Contains a real README, the test framework, and the API implementation
This commit is contained in:
63
likes_api.go
Normal file
63
likes_api.go
Normal file
@ -0,0 +1,63 @@
|
||||
package groupme
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GroupMe documentation: https://dev.groupme.com/docs/v3#likes
|
||||
|
||||
////////// Endpoints //////////
|
||||
const (
|
||||
// Used to build other endpoints
|
||||
likesEndpointRoot = "/messages/%s/%s"
|
||||
|
||||
createLikeEndpoint = likesEndpointRoot + "/like" // POST
|
||||
destroyLikeEndpoint = likesEndpointRoot + "/unlike" // POST
|
||||
)
|
||||
|
||||
////////// API Requests /////////
|
||||
|
||||
// Create
|
||||
|
||||
/*
|
||||
CreateLike -
|
||||
|
||||
Like a message.
|
||||
|
||||
Parameters:
|
||||
conversationID - required, ID(string)
|
||||
messageID - required, ID(string)
|
||||
*/
|
||||
func (c *Client) CreateLike(conversationID, messageID ID) error {
|
||||
url := fmt.Sprintf(c.endpointBase+createLikeEndpoint, conversationID, messageID)
|
||||
|
||||
httpReq, err := http.NewRequest("POST", url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.do(httpReq, nil)
|
||||
}
|
||||
|
||||
// Destroy
|
||||
|
||||
/*
|
||||
DestroyLike -
|
||||
|
||||
Unlike a message.
|
||||
|
||||
Parameters:
|
||||
conversationID - required, ID(string)
|
||||
messageID - required, ID(string)
|
||||
*/
|
||||
func (c *Client) DestroyLike(conversationID, messageID ID) error {
|
||||
url := fmt.Sprintf(c.endpointBase+destroyLikeEndpoint, conversationID, messageID)
|
||||
|
||||
httpReq, err := http.NewRequest("POST", url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.do(httpReq, nil)
|
||||
}
|
Reference in New Issue
Block a user