-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
686bcef
commit a3cd6b4
Showing
52 changed files
with
13,229 additions
and
17,286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package api | ||
|
||
import ( | ||
fmt "fmt" | ||
) | ||
|
||
type AttemptListRequest struct { | ||
EventId *string `json:"-"` | ||
OrderBy *AttemptListRequestOrderBy `json:"-"` | ||
Dir *AttemptListRequestDir `json:"-"` | ||
Limit *int `json:"-"` | ||
Next *string `json:"-"` | ||
Prev *string `json:"-"` | ||
} | ||
|
||
type AttemptListRequestDir string | ||
|
||
const ( | ||
AttemptListRequestDirAsc AttemptListRequestDir = "asc" | ||
AttemptListRequestDirDesc AttemptListRequestDir = "desc" | ||
) | ||
|
||
func NewAttemptListRequestDirFromString(s string) (AttemptListRequestDir, error) { | ||
switch s { | ||
case "asc": | ||
return AttemptListRequestDirAsc, nil | ||
case "desc": | ||
return AttemptListRequestDirDesc, nil | ||
} | ||
var t AttemptListRequestDir | ||
return "", fmt.Errorf("%s is not a valid %T", s, t) | ||
} | ||
|
||
func (a AttemptListRequestDir) Ptr() *AttemptListRequestDir { | ||
return &a | ||
} | ||
|
||
type AttemptListRequestOrderBy string | ||
|
||
const ( | ||
AttemptListRequestOrderByCreatedAt AttemptListRequestOrderBy = "created_at" | ||
) | ||
|
||
func NewAttemptListRequestOrderByFromString(s string) (AttemptListRequestOrderBy, error) { | ||
switch s { | ||
case "created_at": | ||
return AttemptListRequestOrderByCreatedAt, nil | ||
} | ||
var t AttemptListRequestOrderBy | ||
return "", fmt.Errorf("%s is not a valid %T", s, t) | ||
} | ||
|
||
func (a AttemptListRequestOrderBy) Ptr() *AttemptListRequestOrderBy { | ||
return &a | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package attempt | ||
|
||
import ( | ||
bytes "bytes" | ||
context "context" | ||
json "encoding/json" | ||
errors "errors" | ||
fmt "fmt" | ||
hookdeckgosdk "github.com/hookdeck/hookdeck-go-sdk" | ||
core "github.com/hookdeck/hookdeck-go-sdk/core" | ||
io "io" | ||
http "net/http" | ||
url "net/url" | ||
) | ||
|
||
type Client struct { | ||
baseURL string | ||
httpClient core.HTTPClient | ||
header http.Header | ||
} | ||
|
||
func NewClient(opts ...core.ClientOption) *Client { | ||
options := core.NewClientOptions() | ||
for _, opt := range opts { | ||
opt(options) | ||
} | ||
return &Client{ | ||
baseURL: options.BaseURL, | ||
httpClient: options.HTTPClient, | ||
header: options.ToHeader(), | ||
} | ||
} | ||
|
||
func (c *Client) List(ctx context.Context, request *hookdeckgosdk.AttemptListRequest) (*hookdeckgosdk.EventAttemptPaginatedResult, error) { | ||
baseURL := "https://api.hookdeck.com" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
endpointURL := baseURL + "/" + "2023-07-01/attempts" | ||
|
||
queryParams := make(url.Values) | ||
if request.EventId != nil { | ||
queryParams.Add("event_id", fmt.Sprintf("%v", *request.EventId)) | ||
} | ||
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 request.Next != nil { | ||
queryParams.Add("next", fmt.Sprintf("%v", *request.Next)) | ||
} | ||
if request.Prev != nil { | ||
queryParams.Add("prev", fmt.Sprintf("%v", *request.Prev)) | ||
} | ||
if len(queryParams) > 0 { | ||
endpointURL += "?" + queryParams.Encode() | ||
} | ||
|
||
errorDecoder := func(statusCode int, body io.Reader) error { | ||
raw, err := io.ReadAll(body) | ||
if err != nil { | ||
return err | ||
} | ||
apiError := core.NewAPIError(statusCode, errors.New(string(raw))) | ||
decoder := json.NewDecoder(bytes.NewReader(raw)) | ||
switch statusCode { | ||
case 400: | ||
value := new(hookdeckgosdk.BadRequestError) | ||
value.APIError = apiError | ||
if err := decoder.Decode(value); err != nil { | ||
return apiError | ||
} | ||
return value | ||
case 422: | ||
value := new(hookdeckgosdk.UnprocessableEntityError) | ||
value.APIError = apiError | ||
if err := decoder.Decode(value); err != nil { | ||
return apiError | ||
} | ||
return value | ||
} | ||
return apiError | ||
} | ||
|
||
var response *hookdeckgosdk.EventAttemptPaginatedResult | ||
if err := core.DoRequest( | ||
ctx, | ||
c.httpClient, | ||
endpointURL, | ||
http.MethodGet, | ||
nil, | ||
&response, | ||
false, | ||
c.header, | ||
errorDecoder, | ||
); err != nil { | ||
return response, err | ||
} | ||
return response, nil | ||
} | ||
|
||
func (c *Client) Retrieve(ctx context.Context, id string) (*hookdeckgosdk.EventAttempt, error) { | ||
baseURL := "https://api.hookdeck.com" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
endpointURL := fmt.Sprintf(baseURL+"/"+"2023-07-01/attempts/%v", id) | ||
|
||
errorDecoder := func(statusCode int, body io.Reader) error { | ||
raw, err := io.ReadAll(body) | ||
if err != nil { | ||
return err | ||
} | ||
apiError := core.NewAPIError(statusCode, errors.New(string(raw))) | ||
decoder := json.NewDecoder(bytes.NewReader(raw)) | ||
switch statusCode { | ||
case 404: | ||
value := new(hookdeckgosdk.NotFoundError) | ||
value.APIError = apiError | ||
if err := decoder.Decode(value); err != nil { | ||
return apiError | ||
} | ||
return value | ||
} | ||
return apiError | ||
} | ||
|
||
var response *hookdeckgosdk.EventAttempt | ||
if err := core.DoRequest( | ||
ctx, | ||
c.httpClient, | ||
endpointURL, | ||
http.MethodGet, | ||
nil, | ||
&response, | ||
true, | ||
c.header, | ||
errorDecoder, | ||
); err != nil { | ||
return response, err | ||
} | ||
return response, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package api | ||
|
||
import ( | ||
fmt "fmt" | ||
core "github.com/hookdeck/hookdeck-go-sdk/core" | ||
time "time" | ||
) | ||
|
||
type BookmarkCreateRequest struct { | ||
// ID of the event data to bookmark | ||
EventDataId string `json:"event_data_id"` | ||
// ID of the associated connection | ||
WebhookId string `json:"webhook_id"` | ||
// Descriptive name of the bookmark | ||
Label string `json:"label"` | ||
// A unique, human-friendly name for the bookmark | ||
Name *core.Optional[string] `json:"name,omitempty"` | ||
} | ||
|
||
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:"-"` | ||
} | ||
|
||
type BookmarkTriggerRequest struct { | ||
// Bookmark target | ||
Target *core.Optional[BookmarkTriggerRequestTarget] `json:"target,omitempty"` | ||
} | ||
|
||
type BookmarkListRequestDir string | ||
|
||
const ( | ||
BookmarkListRequestDirAsc BookmarkListRequestDir = "asc" | ||
BookmarkListRequestDirDesc BookmarkListRequestDir = "desc" | ||
) | ||
|
||
func NewBookmarkListRequestDirFromString(s string) (BookmarkListRequestDir, error) { | ||
switch s { | ||
case "asc": | ||
return BookmarkListRequestDirAsc, nil | ||
case "desc": | ||
return BookmarkListRequestDirDesc, nil | ||
} | ||
var t BookmarkListRequestDir | ||
return "", fmt.Errorf("%s is not a valid %T", s, t) | ||
} | ||
|
||
func (b BookmarkListRequestDir) Ptr() *BookmarkListRequestDir { | ||
return &b | ||
} | ||
|
||
type BookmarkListRequestOrderBy string | ||
|
||
const ( | ||
BookmarkListRequestOrderByCreatedAt BookmarkListRequestOrderBy = "created_at" | ||
) | ||
|
||
func NewBookmarkListRequestOrderByFromString(s string) (BookmarkListRequestOrderBy, error) { | ||
switch s { | ||
case "created_at": | ||
return BookmarkListRequestOrderByCreatedAt, nil | ||
} | ||
var t BookmarkListRequestOrderBy | ||
return "", fmt.Errorf("%s is not a valid %T", s, t) | ||
} | ||
|
||
func (b BookmarkListRequestOrderBy) Ptr() *BookmarkListRequestOrderBy { | ||
return &b | ||
} | ||
|
||
// Bookmark target | ||
type BookmarkTriggerRequestTarget string | ||
|
||
const ( | ||
BookmarkTriggerRequestTargetHttp BookmarkTriggerRequestTarget = "http" | ||
BookmarkTriggerRequestTargetCli BookmarkTriggerRequestTarget = "cli" | ||
) | ||
|
||
func NewBookmarkTriggerRequestTargetFromString(s string) (BookmarkTriggerRequestTarget, error) { | ||
switch s { | ||
case "http": | ||
return BookmarkTriggerRequestTargetHttp, nil | ||
case "cli": | ||
return BookmarkTriggerRequestTargetCli, nil | ||
} | ||
var t BookmarkTriggerRequestTarget | ||
return "", fmt.Errorf("%s is not a valid %T", s, t) | ||
} | ||
|
||
func (b BookmarkTriggerRequestTarget) Ptr() *BookmarkTriggerRequestTarget { | ||
return &b | ||
} | ||
|
||
type BookmarkUpdateRequest struct { | ||
// ID of the event data to bookmark | ||
EventDataId *core.Optional[string] `json:"event_data_id,omitempty"` | ||
// ID of the associated connection | ||
WebhookId *core.Optional[string] `json:"webhook_id,omitempty"` | ||
// Descriptive name of the bookmark | ||
Label *core.Optional[string] `json:"label,omitempty"` | ||
// A unique, human-friendly name for the bookmark | ||
Name *core.Optional[string] `json:"name,omitempty"` | ||
} |
Oops, something went wrong.