Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Oct 10, 2024
1 parent 6a363d4 commit f5f8dd6
Show file tree
Hide file tree
Showing 49 changed files with 17,237 additions and 6,017 deletions.
12 changes: 6 additions & 6 deletions attempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
)

type AttemptListRequest struct {
EventId []*string `json:"-"`
OrderBy *AttemptListRequestOrderBy `json:"-"`
Dir *AttemptListRequestDir `json:"-"`
Limit *int `json:"-"`
Next *string `json:"-"`
Prev *string `json:"-"`
EventId []*string `json:"-" url:"event_id,omitempty"`
OrderBy *AttemptListRequestOrderBy `json:"-" url:"order_by,omitempty"`
Dir *AttemptListRequestDir `json:"-" url:"dir,omitempty"`
Limit *int `json:"-" url:"limit,omitempty"`
Next *string `json:"-" url:"next,omitempty"`
Prev *string `json:"-" url:"prev,omitempty"`
}

type AttemptListRequestDir string
Expand Down
129 changes: 72 additions & 57 deletions attempt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,59 @@ import (
context "context"
json "encoding/json"
errors "errors"
fmt "fmt"
hookdeckgosdk "github.com/hookdeck/hookdeck-go-sdk"
core "github.com/hookdeck/hookdeck-go-sdk/core"
option "github.com/hookdeck/hookdeck-go-sdk/option"
io "io"
http "net/http"
url "net/url"
)

type Client struct {
baseURL string
httpClient core.HTTPClient
header http.Header
baseURL string
caller *core.Caller
header http.Header
}

func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
baseURL: options.BaseURL,
caller: core.NewCaller(
&core.CallerParams{
Client: options.HTTPClient,
MaxAttempts: options.MaxAttempts,
},
),
header: options.ToHeader(),
}
}

func (c *Client) List(ctx context.Context, request *hookdeckgosdk.AttemptListRequest) (*hookdeckgosdk.EventAttemptPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2024-03-01"
func (c *Client) List(
ctx context.Context,
request *hookdeckgosdk.AttemptListRequest,
opts ...option.RequestOption,
) (*hookdeckgosdk.EventAttemptPaginatedResult, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.hookdeck.com/2024-09-01"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "attempts"

queryParams := make(url.Values)
for _, value := range request.EventId {
queryParams.Add("event_id", fmt.Sprintf("%v", *value))
}
if request.OrderBy != nil {
queryParams.Add("order_by", fmt.Sprintf("%v", *request.OrderBy))
}
if request.Dir != nil {
queryParams.Add("dir", fmt.Sprintf("%v", *request.Dir))
}
if request.Limit != nil {
queryParams.Add("limit", fmt.Sprintf("%v", *request.Limit))
if options.BaseURL != "" {
baseURL = options.BaseURL
}
if request.Next != nil {
queryParams.Add("next", fmt.Sprintf("%v", *request.Next))
}
if request.Prev != nil {
queryParams.Add("prev", fmt.Sprintf("%v", *request.Prev))
endpointURL := baseURL + "/attempts"

queryParams, err := core.QueryValues(request)
if err != nil {
return nil, err
}
if len(queryParams) > 0 {
endpointURL += "?" + queryParams.Encode()
}

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
Expand Down Expand Up @@ -90,28 +87,42 @@ func (c *Client) List(ctx context.Context, request *hookdeckgosdk.AttemptListReq
}

var response *hookdeckgosdk.EventAttemptPaginatedResult
if err := core.DoRequest(
if err := c.caller.Call(
ctx,
c.httpClient,
endpointURL,
http.MethodGet,
nil,
&response,
false,
c.header,
errorDecoder,
&core.CallParams{
URL: endpointURL,
Method: http.MethodGet,
MaxAttempts: options.MaxAttempts,
Headers: headers,
BodyProperties: options.BodyProperties,
QueryParameters: options.QueryParameters,
Client: options.HTTPClient,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return response, err
return nil, err
}
return response, nil
}

func (c *Client) Retrieve(ctx context.Context, id string) (*hookdeckgosdk.EventAttempt, error) {
baseURL := "https://api.hookdeck.com/2024-03-01"
func (c *Client) Retrieve(
ctx context.Context,
id string,
opts ...option.RequestOption,
) (*hookdeckgosdk.EventAttempt, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.hookdeck.com/2024-09-01"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"attempts/%v", id)
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := core.EncodeURL(baseURL+"/attempts/%v", id)

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand All @@ -133,18 +144,22 @@ func (c *Client) Retrieve(ctx context.Context, id string) (*hookdeckgosdk.EventA
}

var response *hookdeckgosdk.EventAttempt
if err := core.DoRequest(
if err := c.caller.Call(
ctx,
c.httpClient,
endpointURL,
http.MethodGet,
nil,
&response,
true,
c.header,
errorDecoder,
&core.CallParams{
URL: endpointURL,
Method: http.MethodGet,
MaxAttempts: options.MaxAttempts,
Headers: headers,
BodyProperties: options.BodyProperties,
QueryParameters: options.QueryParameters,
Client: options.HTTPClient,
Response: &response,
ResponseIsOptional: true,
ErrorDecoder: errorDecoder,
},
); err != nil {
return response, err
return nil, err
}
return response, nil
}
40 changes: 20 additions & 20 deletions bookmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ import (

type BookmarkCreateRequest struct {
// ID of the event data to bookmark
EventDataId string `json:"event_data_id"`
EventDataId string `json:"event_data_id" url:"-"`
// ID of the associated connection
WebhookId string `json:"webhook_id"`
WebhookId string `json:"webhook_id" url:"-"`
// Descriptive name of the bookmark
Label string `json:"label"`
Label string `json:"label" url:"-"`
// A unique, human-friendly name for the bookmark
Name *core.Optional[string] `json:"name,omitempty"`
Name *core.Optional[string] `json:"name,omitempty" url:"-"`
}

type BookmarkListRequest struct {
Id []*string `json:"-"`
Name []*string `json:"-"`
WebhookId []*string `json:"-"`
EventDataId []*string `json:"-"`
Label []*string `json:"-"`
LastUsedAt *time.Time `json:"-"`
OrderBy *BookmarkListRequestOrderBy `json:"-"`
Dir *BookmarkListRequestDir `json:"-"`
Limit *int `json:"-"`
Next *string `json:"-"`
Prev *string `json:"-"`
Id []*string `json:"-" url:"id,omitempty"`
Name []*string `json:"-" url:"name,omitempty"`
WebhookId []*string `json:"-" url:"webhook_id,omitempty"`
EventDataId []*string `json:"-" url:"event_data_id,omitempty"`
Label []*string `json:"-" url:"label,omitempty"`
LastUsedAt *time.Time `json:"-" url:"last_used_at,omitempty"`
OrderBy *BookmarkListRequestOrderBy `json:"-" url:"order_by,omitempty"`
Dir *BookmarkListRequestDir `json:"-" url:"dir,omitempty"`
Limit *int `json:"-" url:"limit,omitempty"`
Next *string `json:"-" url:"next,omitempty"`
Prev *string `json:"-" url:"prev,omitempty"`
}

type BookmarkTriggerRequest struct {
// Bookmark target
Target *core.Optional[BookmarkTriggerRequestTarget] `json:"target,omitempty"`
Target *core.Optional[BookmarkTriggerRequestTarget] `json:"target,omitempty" url:"-"`
}

type BookmarkListRequestDir string
Expand Down Expand Up @@ -104,11 +104,11 @@ func (b BookmarkTriggerRequestTarget) Ptr() *BookmarkTriggerRequestTarget {

type BookmarkUpdateRequest struct {
// ID of the event data to bookmark
EventDataId *core.Optional[string] `json:"event_data_id,omitempty"`
EventDataId *core.Optional[string] `json:"event_data_id,omitempty" url:"-"`
// ID of the associated connection
WebhookId *core.Optional[string] `json:"webhook_id,omitempty"`
WebhookId *core.Optional[string] `json:"webhook_id,omitempty" url:"-"`
// Descriptive name of the bookmark
Label *core.Optional[string] `json:"label,omitempty"`
Label *core.Optional[string] `json:"label,omitempty" url:"-"`
// A unique, human-friendly name for the bookmark
Name *core.Optional[string] `json:"name,omitempty"`
Name *core.Optional[string] `json:"name,omitempty" url:"-"`
}
Loading

0 comments on commit f5f8dd6

Please sign in to comment.