-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebhooks.go
More file actions
36 lines (31 loc) · 920 Bytes
/
webhooks.go
File metadata and controls
36 lines (31 loc) · 920 Bytes
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
package lnbot
import (
"context"
"fmt"
"net/url"
)
// WebhooksService handles wallet-scoped webhook operations.
type WebhooksService struct {
c *Client
prefix string
}
// Create registers a new webhook endpoint.
func (s *WebhooksService) Create(ctx context.Context, params *CreateWebhookParams) (*WebhookWithSecret, error) {
var v WebhookWithSecret
if err := s.c.post(ctx, s.prefix+"/webhooks", params, &v); err != nil {
return nil, err
}
return &v, nil
}
// List returns all registered webhooks for the wallet.
func (s *WebhooksService) List(ctx context.Context) ([]Webhook, error) {
var v []Webhook
if err := s.c.get(ctx, s.prefix+"/webhooks", &v); err != nil {
return nil, err
}
return v, nil
}
// Delete removes a webhook endpoint.
func (s *WebhooksService) Delete(ctx context.Context, id string) error {
return s.c.del(ctx, fmt.Sprintf("%s/webhooks/%s", s.prefix, url.PathEscape(id)))
}