mirror of
https://github.com/plutov/paypal.git
synced 2025-02-02 15:10:36 +01:00
add GetWebhookEventTypes
This commit is contained in:
parent
cc8b3cee69
commit
e83fd911e0
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
5
types.go
5
types.go
|
@ -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
|
||||
|
|
16
webhooks.go
16
webhooks.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user