-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathpayfwd.go
60 lines (54 loc) · 1.49 KB
/
payfwd.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
package gobcy
import "strconv"
//CreatePayFwd creates a new PayFwd forwarding
//request associated with your API.Token, and
//returns a PayFwd with a BlockCypher-assigned id.
func (api *API) CreatePayFwd(payment PayFwd) (result PayFwd, err error) {
u, err := api.buildURL("/payments", nil)
if err != nil {
return
}
err = postResponse(u, &payment, &result)
return
}
//ListPayFwds returns a PayFwds slice
//associated with your API.Token.
func (api *API) ListPayFwds() (payments []PayFwd, err error) {
u, err := api.buildURL("/payments", nil)
if err != nil {
return
}
err = getResponse(u, &payments)
return
}
//ListPayFwdsPage returns a PayFwds slice
//associated with your API.Token, starting at the start index.
//Useful for paging past the 200 payment forward limit.
func (api *API) ListPayFwdsPage(start int) (payments []PayFwd, err error) {
params := map[string]string{"start": strconv.Itoa(start)}
u, err := api.buildURL("/payments", params)
if err != nil {
return
}
err = getResponse(u, &payments)
return
}
//GetPayFwd returns a PayFwd based on its id.
func (api *API) GetPayFwd(id string) (payment PayFwd, err error) {
u, err := api.buildURL("/payments/"+id, nil)
if err != nil {
return
}
err = getResponse(u, &payment)
return
}
//DeletePayFwd deletes a PayFwd request from
//BlockCypher's database, based on its id.
func (api *API) DeletePayFwd(id string) (err error) {
u, err := api.buildURL("/payments/"+id, nil)
if err != nil {
return
}
err = deleteResponse(u)
return
}