-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_responses.go
61 lines (55 loc) · 1.81 KB
/
api_responses.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package goplurk
import (
"fmt"
"strconv"
)
type APIResponses struct {
client *Client
}
func (u *APIResponses) Get(plurkId int64, fromResoponse int64, count int64) (*Responses, error) {
var body = map[string]string{}
body["plurk_id"] = strconv.FormatInt(plurkId, 10)
body["from_response"] = strconv.FormatInt(fromResoponse, 10)
body["count"] = strconv.FormatInt(count, 10)
responses := &Responses{}
if err := u.client.Engine.CallAPIUnmarshal("/APP/Responses/get", body, responses); err != nil {
return nil, err
} else {
return responses, nil
}
}
func (u *APIResponses) GetById(plurkId int64, fromResoponseId int64, count int64) (*Responses, error) {
var body = map[string]string{}
body["plurk_id"] = strconv.FormatInt(plurkId, 10)
body["from_response_id"] = strconv.FormatInt(fromResoponseId, 10)
body["count"] = strconv.FormatInt(count, 10)
responses := &Responses{}
if err := u.client.Engine.CallAPIUnmarshal("/APP/Responses/getById", body, responses); err != nil {
return nil, err
} else {
return responses, nil
}
}
func (u *APIResponses) ResponseAdd(plurkId int64, qualifier string, content string) (*Response, error) {
var body = map[string]string{}
body["plurk_id"] = strconv.FormatInt(plurkId, 10)
body["qualifier"] = qualifier
body["content"] = content
response := &Response{}
if err := u.client.Engine.CallAPIUnmarshal("/APP/Responses/responseAdd", body, response); err != nil {
return nil, err
} else {
return response, nil
}
}
func (u *APIResponses) ResponseDelete(responseId int64, plurkId int64) error {
_, err := u.client.Engine.CallAPI("/APP/Responses/responseDelete", map[string]string{
"response_id": strconv.FormatInt(responseId, 10),
"plurk_id": strconv.FormatInt(plurkId, 10),
})
if err != nil {
return fmt.Errorf("failed to delete response: %v", err)
} else {
return nil
}
}