55 "net/http"
66)
77
8- func (c * Client ) CreateWebhook (ctx context.Context , webhook UpsertWebhook ) (* Webhook , error ) {
8+ func (c * Client ) CreateWebhook (ctx context.Context , webhook CreateWebhook ) (* Webhook , error ) {
99 resp , err := c .CallHttp (ctx ,
1010 Endpoint (http .MethodPost , pathWebhooks ),
1111 AcceptJson (),
@@ -39,7 +39,7 @@ func (c *Client) GetWebhook(ctx context.Context, webhookID string) (*Webhook, er
3939 return CompletedObjectOrError [Webhook ](resp )
4040}
4141
42- func (c * Client ) UpdateWebhook (ctx context.Context , webhookID string , webhook UpsertWebhook ) (* Webhook , error ) {
42+ func (c * Client ) UpdateWebhook (ctx context.Context , webhookID string , webhook UpdateWebhook ) (* Webhook , error ) {
4343 resp , err := c .CallHttp (ctx ,
4444 Endpoint (http .MethodPut , pathWebhook , webhookID ),
4545 AcceptJson (),
@@ -61,3 +61,41 @@ func (c *Client) DeleteWebhook(ctx context.Context, webhookID string) error {
6161
6262 return CompletedNilOrError (resp )
6363}
64+
65+ // PingWebhook sends a test event to the webhook URL to verify it is working.
66+ // The ping will send an event with type `event.test` and a null data payload.
67+ func (c * Client ) PingWebhook (ctx context.Context , webhookID string ) (* WebhookPing , error ) {
68+ resp , err := c .CallHttp (ctx ,
69+ Endpoint (http .MethodPost , pathWebhookPing , webhookID ),
70+ AcceptJson ())
71+ if err != nil {
72+ return nil , err
73+ }
74+
75+ return CompletedObjectOrError [WebhookPing ](resp )
76+ }
77+
78+ // GetWebhookSecret retrieves the signing secret for a webhook.
79+ // Use this secret to verify the signature of incoming webhook payloads.
80+ func (c * Client ) GetWebhookSecret (ctx context.Context , webhookID string ) (* WebhookSecret , error ) {
81+ resp , err := c .CallHttp (ctx ,
82+ Endpoint (http .MethodGet , pathWebhookSecret , webhookID ),
83+ AcceptJson ())
84+ if err != nil {
85+ return nil , err
86+ }
87+
88+ return CompletedObjectOrError [WebhookSecret ](resp )
89+ }
90+
91+ // ListWebhookEventTypes returns all available webhook event types that can be subscribed to.
92+ func (c * Client ) ListWebhookEventTypes (ctx context.Context ) ([]WebhookEventType , error ) {
93+ resp , err := c .CallHttp (ctx ,
94+ Endpoint (http .MethodGet , pathEventTypes ),
95+ AcceptJson ())
96+ if err != nil {
97+ return nil , err
98+ }
99+
100+ return CompletedListOrError [WebhookEventType ](resp )
101+ }
0 commit comments