forked from blockcypher/gobcy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.go
45 lines (41 loc) · 1 KB
/
hook.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
package gobcy
//CreateHook creates a new WebHook associated
//with your API.Token, and returns a WebHook
//with a BlockCypher-assigned id.
func (api *API) CreateHook(hook Hook) (result Hook, err error) {
u, err := api.buildURL("/hooks", nil)
if err != nil {
return
}
err = postResponse(u, &hook, &result)
return
}
//ListHooks returns a slice of WebHooks
//associated with your API.Token.
func (api *API) ListHooks() (hooks []Hook, err error) {
u, err := api.buildURL("/hooks", nil)
if err != nil {
return
}
err = getResponse(u, &hooks)
return
}
//GetHook returns a WebHook by its id.
func (api *API) GetHook(id string) (hook Hook, err error) {
u, err := api.buildURL("/hooks/"+id, nil)
if err != nil {
return
}
err = getResponse(u, &hook)
return
}
//DeleteHook deletes a WebHook notification
//from BlockCypher's database, based on its id.
func (api *API) DeleteHook(id string) (err error) {
u, err := api.buildURL("/hooks/"+id, nil)
if err != nil {
return
}
err = deleteResponse(u)
return
}