add GetWebhookEventTypes

This commit is contained in:
Thomas Frössman 2021-01-03 21:20:12 +01:00
parent cc8b3cee69
commit e83fd911e0
3 changed files with 35 additions and 0 deletions

View File

@ -401,3 +401,17 @@ func TestSubscription(t *testing.T) {
assert.NotEqual(t, "", subDetails.ID)
}
func TestGetWebhookEventTypes(t *testing.T) {
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
c.GetAccessToken(context.Background())
r, err := c.GetWebhookEventTypes(context.Background())
assert.Equal(t, nil, err)
assert.GreaterOrEqual(t, len(r.EventTypes), 1)
for _, v := range r.EventTypes {
assert.GreaterOrEqual(t, len(v.Name), 1)
assert.GreaterOrEqual(t, len(v.Description), 1)
assert.GreaterOrEqual(t, len(v.Status), 1)
}
}

View File

@ -1027,6 +1027,10 @@ type (
VerificationStatus string `json:"verification_status,omitempty"`
}
WebhookEventTypesResponse struct {
EventTypes []WebhookEventType `json:"event_types"`
}
// Webhook strunct
Webhook struct {
ID string `json:"id"`
@ -1052,6 +1056,7 @@ type (
WebhookEventType struct {
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status,omitempty"`
}
// CreateWebhookRequest struct

View File

@ -123,3 +123,19 @@ func (c *Client) VerifyWebhookSignature(ctx context.Context, httpReq *http.Reque
return response, nil
}
// GetWebhooksEventTypes - Lists all webhook event types.
// Endpoint: GET /v1/notifications/webhooks-event-types
func (c *Client) GetWebhookEventTypes(ctx context.Context) (*WebhookEventTypesResponse, error) {
req, err := c.NewRequest(ctx, http.MethodGet, fmt.Sprintf("%s%s", c.APIBase, "/v1/notifications/webhooks-event-types"), nil)
q := req.URL.Query()
req.URL.RawQuery = q.Encode()
resp := &WebhookEventTypesResponse{}
if err != nil {
return nil, err
}
err = c.SendWithAuth(req, resp)
return resp, err
}