-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathwebhooks.go
More file actions
72 lines (62 loc) · 2.81 KB
/
webhooks.go
File metadata and controls
72 lines (62 loc) · 2.81 KB
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
62
63
64
65
66
67
68
69
70
71
72
// Code generated by oagen. DO NOT EDIT.
package workos
import (
"context"
"fmt"
"net/url"
)
// WebhookService handles Webhooks operations.
type WebhookService struct {
client *Client
}
// WebhooksListEndpointsParams contains the parameters for ListEndpoints.
type WebhooksListEndpointsParams struct {
PaginationParams
}
// ListEndpoints list Webhook Endpoints
// Get a list of all of your existing webhook endpoints.
func (s *WebhookService) ListEndpoints(ctx context.Context, params *WebhooksListEndpointsParams, opts ...RequestOption) *Iterator[WebhookEndpoint] {
return newIterator[WebhookEndpoint](ctx, s.client, "GET", "/webhook_endpoints", params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// WebhooksCreateEndpointParams contains the parameters for CreateEndpoint.
type WebhooksCreateEndpointParams struct {
// EndpointURL is the HTTPS URL where webhooks will be sent.
EndpointURL string `json:"endpoint_url" url:"-"`
// Events is the events that the Webhook Endpoint is subscribed to.
Events []CreateWebhookEndpointEvents `json:"events" url:"-"`
}
// CreateEndpoint create a Webhook Endpoint
// Create a new webhook endpoint to receive event notifications.
func (s *WebhookService) CreateEndpoint(ctx context.Context, params *WebhooksCreateEndpointParams, opts ...RequestOption) (*WebhookEndpoint, error) {
var result WebhookEndpoint
_, err := s.client.request(ctx, "POST", "/webhook_endpoints", nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// WebhooksUpdateEndpointParams contains the parameters for UpdateEndpoint.
type WebhooksUpdateEndpointParams struct {
// EndpointURL is the HTTPS URL where webhooks will be sent.
EndpointURL *string `json:"endpoint_url,omitempty" url:"-"`
// Status is whether the Webhook Endpoint is enabled or disabled.
Status *UpdateWebhookEndpointStatus `json:"status,omitempty" url:"-"`
// Events is the events that the Webhook Endpoint is subscribed to.
Events []UpdateWebhookEndpointEvents `json:"events,omitempty" url:"-"`
}
// UpdateEndpoint update a Webhook Endpoint
// Update the properties of an existing webhook endpoint.
func (s *WebhookService) UpdateEndpoint(ctx context.Context, id string, params *WebhooksUpdateEndpointParams, opts ...RequestOption) (*WebhookEndpoint, error) {
var result WebhookEndpoint
_, err := s.client.request(ctx, "PATCH", fmt.Sprintf("/webhook_endpoints/%s", url.PathEscape(id)), nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// DeleteEndpoint delete a Webhook Endpoint
// Delete an existing webhook endpoint.
func (s *WebhookService) DeleteEndpoint(ctx context.Context, id string, opts ...RequestOption) error {
_, err := s.client.request(ctx, "DELETE", fmt.Sprintf("/webhook_endpoints/%s", url.PathEscape(id)), nil, nil, nil, opts)
return err
}