Skip to content

Commit

Permalink
Merge pull request #254 from enumag/patch-1
Browse files Browse the repository at this point in the history
Add GetWebhookSigningSecret
  • Loading branch information
nukosuke committed Feb 7, 2023
2 parents 790f26d + 5c7b5e6 commit 74f90f9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions zendesk/mock/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions zendesk/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type WebhookAPI interface {
GetWebhook(ctx context.Context, webhookID string) (*Webhook, error)
UpdateWebhook(ctx context.Context, webhookID string, hook *Webhook) error
DeleteWebhook(ctx context.Context, webhookID string) error
GetWebhookSigningSecret(ctx context.Context, webhookID string) (*WebhookSigningSecret, error)
}

// CreateWebhook creates new webhook.
Expand Down Expand Up @@ -115,3 +116,24 @@ func (z *Client) DeleteWebhook(ctx context.Context, webhookID string) error {

return nil
}

// GetWebhookSigningSecret gets the signing secret of specified webhook.
//
// https://developer.zendesk.com/api-reference/event-connectors/webhooks/webhooks/#show-webhook-signing-secret
func (z *Client) GetWebhookSigningSecret(ctx context.Context, webhookID string) (*WebhookSigningSecret, error) {
var result struct {
SigningSecret *WebhookSigningSecret `json:"signing_secret"`
}

body, err := z.get(ctx, fmt.Sprintf("/webhooks/%s/signing_secret", webhookID))
if err != nil {
return nil, err
}

err = json.Unmarshal(body, &result)
if err != nil {
return nil, err
}

return result.SigningSecret, nil
}

0 comments on commit 74f90f9

Please sign in to comment.