Skip to content

Commit

Permalink
fix: add missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Nov 13, 2024
1 parent c04c290 commit 6036856
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions apiclient/webhook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package apiclient

import (
"context"
"fmt"
"net/http"
"sort"

"github.com/otto8-ai/otto8/apiclient/types"
)

func (c *Client) ListWebhooks(ctx context.Context) (result types.WebhookList, _ error) {
defer func() {
sort.Slice(result.Items, func(i, j int) bool {
return result.Items[i].Metadata.Created.Time.Before(result.Items[j].Metadata.Created.Time)
})
}()

_, resp, err := c.doRequest(ctx, http.MethodGet, "/webhooks", nil)
if err != nil {
return
}
defer resp.Body.Close()

_, err = toObject(resp, &result)
if err != nil {
return result, err
}

return result, nil
}

func (c *Client) DeleteWebhook(ctx context.Context, id string) error {
_, resp, err := c.doRequest(ctx, http.MethodDelete, fmt.Sprintf("/webhooks/"+id), nil)
if err != nil {
return err
}
defer resp.Body.Close()

return nil
}

0 comments on commit 6036856

Please sign in to comment.