Skip to content

Commit

Permalink
ListWebhooks bug when listing all webhooks
Browse files Browse the repository at this point in the history
When listing all webhooks it should not provide the MessageStream query
parameter at all. When the parameter is empty Postmark returns an error.
  • Loading branch information
tgrosinger committed Aug 12, 2023
1 parent 5ed9b01 commit b9407aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ type Webhook struct {
// is empty it will return all webhooks for the server. A non-existent message
// stream will result in an error.
func (client *Client) ListWebhooks(ctx context.Context, messageStream string) ([]Webhook, error) {
msgStreamParam := ""
if messageStream != "" {
msgStreamParam = fmt.Sprintf("?MessageStream=%s", messageStream)
}

var res struct {
Webhooks []Webhook
}
err := client.doRequest(ctx, parameters{
Method: http.MethodGet,
Path: fmt.Sprintf("webhooks?MessageStream=%s", messageStream),
Path: "webhooks" + msgStreamParam,
TokenType: serverToken,
}, &res)
return res.Webhooks, err
Expand Down

0 comments on commit b9407aa

Please sign in to comment.