Skip to content

Commit

Permalink
feat: implement the delete webhook config endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
vitords committed Oct 24, 2023
1 parent ff47c70 commit c1f4aee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Client interface {
ctx context.Context,
request *UpdateWebhookConfigRequest,
) (*UpdateWebhookConfigResponse, error)
DeleteWebhookConfig(ctx context.Context) error
}

// clientImpl to the Monta Partner API.
Expand Down
13 changes: 9 additions & 4 deletions client_webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net/url"
)

const webhooksConfigBasePath = "/v1/webhooks/config"

// GetWebhookConfigResponse is the response output from the [Client.GetWebhookConfig] method.
type GetWebhookConfigResponse struct {
// A HTTPS URL to send the webhook payload to when an event occurs.
Expand All @@ -19,9 +21,8 @@ type GetWebhookConfigResponse struct {

// GetWebhookConfig to get your webhook config.
func (c *clientImpl) GetWebhookConfig(ctx context.Context) (*GetWebhookConfigResponse, error) {
path := "/v1/webhooks/config"
query := url.Values{}
return doGet[GetWebhookConfigResponse](ctx, c, path, query)
return doGet[GetWebhookConfigResponse](ctx, c, webhooksConfigBasePath, query)
}

// UpdateWebhookConfigRequest is the request input to the [Client.UpdateWebhookConfig] method.
Expand Down Expand Up @@ -49,10 +50,14 @@ func (c *clientImpl) UpdateWebhookConfig(
ctx context.Context,
request *UpdateWebhookConfigRequest,
) (*UpdateWebhookConfigResponse, error) {
path := "/v1/webhooks/config"
var requestBody bytes.Buffer
if err := json.NewEncoder(&requestBody).Encode(&request); err != nil {
return nil, err
}
return doPut[UpdateWebhookConfigResponse](ctx, c, path, &requestBody)
return doPut[UpdateWebhookConfigResponse](ctx, c, webhooksConfigBasePath, &requestBody)
}

// DeleteWebhookConfig to delete a webhook config.
func (c *clientImpl) DeleteWebhookConfig(ctx context.Context) error {
return doDelete(ctx, c, webhooksConfigBasePath)
}

0 comments on commit c1f4aee

Please sign in to comment.