From e3110b9454bbd287c4c64b0cacfcc97bdfe318fa Mon Sep 17 00:00:00 2001
From: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
Date: Wed, 23 Aug 2023 08:56:35 +0000
Subject: [PATCH] Release v0.0.28
---
attempts/client.go | 27 +++---
bookmarks.go | 13 +--
bookmarks/client.go | 57 +++++------
bulk_retry_events.go | 3 +-
bulk_retry_ignored_events.go | 3 +-
bulk_retry_requests.go | 3 +-
bulkretryevents/client.go | 46 ++++-----
bulkretryignoredevents/client.go | 46 ++++-----
bulkretryrequests/client.go | 46 ++++-----
client/client.go | 161 ++++++++-----------------------
client/client_test.go | 18 ++--
connections.go | 35 +++----
connections/client.go | 75 ++++++--------
core/client_option.go | 2 +-
core/optional.go | 36 +++++++
core/optional_test.go | 131 +++++++++++++++++++++++++
destinations.go | 51 +++++-----
destinations/client.go | 65 ++++++-------
doc.go | 2 +-
errors.go | 12 +++
events/client.go | 42 ++++----
integrations.go | 16 +--
integrations/client.go | 62 +++++-------
issue_triggers.go | 19 ++--
issues/client.go | 44 ++++-----
issuetriggers/client.go | 63 +++++-------
notifications/client.go | 24 ++---
optional.go | 22 +++++
requests/client.go | 59 +++++------
sources.go | 27 +++---
sources/client.go | 65 ++++++-------
transformations.go | 17 ++--
transformations/client.go | 69 ++++++-------
33 files changed, 681 insertions(+), 680 deletions(-)
create mode 100644 core/optional.go
create mode 100644 core/optional_test.go
create mode 100644 optional.go
diff --git a/attempts/client.go b/attempts/client.go
index b13cd62..603e155 100644
--- a/attempts/client.go
+++ b/attempts/client.go
@@ -15,30 +15,25 @@ import (
url "net/url"
)
-type Client interface {
- GetAttempts(ctx context.Context, request *hookdeckgosdk.GetAttemptsRequest) (*hookdeckgosdk.EventAttemptPaginatedResult, error)
- GetAttempt(ctx context.Context, id string) (*hookdeckgosdk.EventAttempt, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetAttempts(ctx context.Context, request *hookdeckgosdk.GetAttemptsRequest) (*hookdeckgosdk.EventAttemptPaginatedResult, error) {
+func (c *Client) GetAttempts(ctx context.Context, request *hookdeckgosdk.GetAttemptsRequest) (*hookdeckgosdk.EventAttemptPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -80,14 +75,14 @@ func (c *client) GetAttempts(ctx context.Context, request *hookdeckgosdk.GetAtte
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -111,7 +106,7 @@ func (c *client) GetAttempts(ctx context.Context, request *hookdeckgosdk.GetAtte
return response, nil
}
-func (c *client) GetAttempt(ctx context.Context, id string) (*hookdeckgosdk.EventAttempt, error) {
+func (c *Client) GetAttempt(ctx context.Context, id string) (*hookdeckgosdk.EventAttempt, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -130,7 +125,7 @@ func (c *client) GetAttempt(ctx context.Context, id string) (*hookdeckgosdk.Even
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/bookmarks.go b/bookmarks.go
index e9dc240..439e52b 100644
--- a/bookmarks.go
+++ b/bookmarks.go
@@ -3,6 +3,7 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
@@ -14,7 +15,7 @@ type CreateBookmarkRequest struct {
// Descriptive name of the bookmark `<= 255 characters`
Label string `json:"label"`
// A unique, human-friendly name for the bookmark `<= 155 characters`
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
}
type GetBookmarksRequest struct {
@@ -33,16 +34,16 @@ type GetBookmarksRequest struct {
type TriggerBookmarkRequest struct {
// Bookmark target
- Target *TriggerBookmarkRequestTarget `json:"target,omitempty"`
+ Target *core.Optional[TriggerBookmarkRequestTarget] `json:"target,omitempty"`
}
type UpdateBookmarkRequest struct {
// ID of the event data to bookmark `<= 255 characters`
- EventDataId *string `json:"event_data_id,omitempty"`
+ EventDataId *core.Optional[string] `json:"event_data_id,omitempty"`
// ID of the associated connection `<= 255 characters`
- WebhookId *string `json:"webhook_id,omitempty"`
+ WebhookId *core.Optional[string] `json:"webhook_id,omitempty"`
// Descriptive name of the bookmark `<= 255 characters`
- Label *string `json:"label,omitempty"`
+ Label *core.Optional[string] `json:"label,omitempty"`
// A unique, human-friendly name for the bookmark `<= 155 characters`
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
}
diff --git a/bookmarks/client.go b/bookmarks/client.go
index b9fa6b7..bed24ce 100644
--- a/bookmarks/client.go
+++ b/bookmarks/client.go
@@ -16,34 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetBookmarks(ctx context.Context, request *hookdeckgosdk.GetBookmarksRequest) (*hookdeckgosdk.BookmarkPaginatedResult, error)
- CreateBookmark(ctx context.Context, request *hookdeckgosdk.CreateBookmarkRequest) (*hookdeckgosdk.Bookmark, error)
- GetBookmark(ctx context.Context, id string) (*hookdeckgosdk.Bookmark, error)
- UpdateBookmark(ctx context.Context, id string, request *hookdeckgosdk.UpdateBookmarkRequest) (*hookdeckgosdk.Bookmark, error)
- DeleteBookmark(ctx context.Context, id string) (*hookdeckgosdk.DeletedBookmarkResponse, error)
- TriggerBookmark(ctx context.Context, id string, request *hookdeckgosdk.TriggerBookmarkRequest) (hookdeckgosdk.EventArray, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetBookmarks(ctx context.Context, request *hookdeckgosdk.GetBookmarksRequest) (*hookdeckgosdk.BookmarkPaginatedResult, error) {
+func (c *Client) GetBookmarks(ctx context.Context, request *hookdeckgosdk.GetBookmarksRequest) (*hookdeckgosdk.BookmarkPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -100,14 +91,14 @@ func (c *client) GetBookmarks(ctx context.Context, request *hookdeckgosdk.GetBoo
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -131,7 +122,7 @@ func (c *client) GetBookmarks(ctx context.Context, request *hookdeckgosdk.GetBoo
return response, nil
}
-func (c *client) CreateBookmark(ctx context.Context, request *hookdeckgosdk.CreateBookmarkRequest) (*hookdeckgosdk.Bookmark, error) {
+func (c *Client) CreateBookmark(ctx context.Context, request *hookdeckgosdk.CreateBookmarkRequest) (*hookdeckgosdk.Bookmark, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -150,14 +141,14 @@ func (c *client) CreateBookmark(ctx context.Context, request *hookdeckgosdk.Crea
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -181,7 +172,7 @@ func (c *client) CreateBookmark(ctx context.Context, request *hookdeckgosdk.Crea
return response, nil
}
-func (c *client) GetBookmark(ctx context.Context, id string) (*hookdeckgosdk.Bookmark, error) {
+func (c *Client) GetBookmark(ctx context.Context, id string) (*hookdeckgosdk.Bookmark, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -200,7 +191,7 @@ func (c *client) GetBookmark(ctx context.Context, id string) (*hookdeckgosdk.Boo
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -224,7 +215,7 @@ func (c *client) GetBookmark(ctx context.Context, id string) (*hookdeckgosdk.Boo
return response, nil
}
-func (c *client) UpdateBookmark(ctx context.Context, id string, request *hookdeckgosdk.UpdateBookmarkRequest) (*hookdeckgosdk.Bookmark, error) {
+func (c *Client) UpdateBookmark(ctx context.Context, id string, request *hookdeckgosdk.UpdateBookmarkRequest) (*hookdeckgosdk.Bookmark, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -243,21 +234,21 @@ func (c *client) UpdateBookmark(ctx context.Context, id string, request *hookdec
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -281,7 +272,7 @@ func (c *client) UpdateBookmark(ctx context.Context, id string, request *hookdec
return response, nil
}
-func (c *client) DeleteBookmark(ctx context.Context, id string) (*hookdeckgosdk.DeletedBookmarkResponse, error) {
+func (c *Client) DeleteBookmark(ctx context.Context, id string) (*hookdeckgosdk.DeletedBookmarkResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -300,7 +291,7 @@ func (c *client) DeleteBookmark(ctx context.Context, id string) (*hookdeckgosdk.
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -324,7 +315,7 @@ func (c *client) DeleteBookmark(ctx context.Context, id string) (*hookdeckgosdk.
return response, nil
}
-func (c *client) TriggerBookmark(ctx context.Context, id string, request *hookdeckgosdk.TriggerBookmarkRequest) (hookdeckgosdk.EventArray, error) {
+func (c *Client) TriggerBookmark(ctx context.Context, id string, request *hookdeckgosdk.TriggerBookmarkRequest) (hookdeckgosdk.EventArray, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -343,21 +334,21 @@ func (c *client) TriggerBookmark(ctx context.Context, id string, request *hookde
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/bulk_retry_events.go b/bulk_retry_events.go
index ab1f2bc..2bd51bd 100644
--- a/bulk_retry_events.go
+++ b/bulk_retry_events.go
@@ -3,12 +3,13 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
type CreateEventBulkRetryRequest struct {
// Filter properties for the events to be included in the bulk retry
- Query *CreateEventBulkRetryRequestQuery `json:"query,omitempty"`
+ Query *core.Optional[CreateEventBulkRetryRequestQuery] `json:"query,omitempty"`
}
type GetEventBulkRetriesRequest struct {
diff --git a/bulk_retry_ignored_events.go b/bulk_retry_ignored_events.go
index 7e9ff13..0457fca 100644
--- a/bulk_retry_ignored_events.go
+++ b/bulk_retry_ignored_events.go
@@ -3,12 +3,13 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
type CreateIgnoredEventBulkRetryRequest struct {
// Filter by the bulk retry ignored event query object
- Query *CreateIgnoredEventBulkRetryRequestQuery `json:"query,omitempty"`
+ Query *core.Optional[CreateIgnoredEventBulkRetryRequestQuery] `json:"query,omitempty"`
}
type GetIgnoredEventBulkRetriesRequest struct {
diff --git a/bulk_retry_requests.go b/bulk_retry_requests.go
index 882dfad..49be027 100644
--- a/bulk_retry_requests.go
+++ b/bulk_retry_requests.go
@@ -3,12 +3,13 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
type CreateRequestBulkRetryRequest struct {
// Filter properties for the events to be included in the bulk retry, use query parameters of [Requests](#requests)
- Query *CreateRequestBulkRetryRequestQuery `json:"query,omitempty"`
+ Query *core.Optional[CreateRequestBulkRetryRequestQuery] `json:"query,omitempty"`
}
type GetRequestBulkRetriesRequest struct {
diff --git a/bulkretryevents/client.go b/bulkretryevents/client.go
index fa75d4a..1ec9556 100644
--- a/bulkretryevents/client.go
+++ b/bulkretryevents/client.go
@@ -16,33 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetEventBulkRetries(ctx context.Context, request *hookdeckgosdk.GetEventBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error)
- CreateEventBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateEventBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error)
- GenerateEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateEventBulkRetryPlanResponse, error)
- GetEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error)
- CancelEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetEventBulkRetries(ctx context.Context, request *hookdeckgosdk.GetEventBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error) {
+func (c *Client) GetEventBulkRetries(ctx context.Context, request *hookdeckgosdk.GetEventBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -99,14 +91,14 @@ func (c *client) GetEventBulkRetries(ctx context.Context, request *hookdeckgosdk
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -130,7 +122,7 @@ func (c *client) GetEventBulkRetries(ctx context.Context, request *hookdeckgosdk
return response, nil
}
-func (c *client) CreateEventBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateEventBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) CreateEventBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateEventBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -149,14 +141,14 @@ func (c *client) CreateEventBulkRetry(ctx context.Context, request *hookdeckgosd
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -180,7 +172,7 @@ func (c *client) CreateEventBulkRetry(ctx context.Context, request *hookdeckgosd
return response, nil
}
-func (c *client) GenerateEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateEventBulkRetryPlanResponse, error) {
+func (c *Client) GenerateEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateEventBulkRetryPlanResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -199,14 +191,14 @@ func (c *client) GenerateEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -230,7 +222,7 @@ func (c *client) GenerateEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk
return response, nil
}
-func (c *client) GetEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) GetEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -249,7 +241,7 @@ func (c *client) GetEventBulkRetry(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -273,7 +265,7 @@ func (c *client) GetEventBulkRetry(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) CancelEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) CancelEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -292,7 +284,7 @@ func (c *client) CancelEventBulkRetry(ctx context.Context, id string) (*hookdeck
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/bulkretryignoredevents/client.go b/bulkretryignoredevents/client.go
index 972133c..ab888b6 100644
--- a/bulkretryignoredevents/client.go
+++ b/bulkretryignoredevents/client.go
@@ -16,33 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetIgnoredEventBulkRetries(ctx context.Context, request *hookdeckgosdk.GetIgnoredEventBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error)
- CreateIgnoredEventBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateIgnoredEventBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error)
- GenerateIgnoredEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateIgnoredEventBulkRetryPlanResponse, error)
- GetIgnoredEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error)
- CancelIgnoredEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetIgnoredEventBulkRetries(ctx context.Context, request *hookdeckgosdk.GetIgnoredEventBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error) {
+func (c *Client) GetIgnoredEventBulkRetries(ctx context.Context, request *hookdeckgosdk.GetIgnoredEventBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -99,14 +91,14 @@ func (c *client) GetIgnoredEventBulkRetries(ctx context.Context, request *hookde
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -130,7 +122,7 @@ func (c *client) GetIgnoredEventBulkRetries(ctx context.Context, request *hookde
return response, nil
}
-func (c *client) CreateIgnoredEventBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateIgnoredEventBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) CreateIgnoredEventBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateIgnoredEventBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -149,14 +141,14 @@ func (c *client) CreateIgnoredEventBulkRetry(ctx context.Context, request *hookd
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -180,7 +172,7 @@ func (c *client) CreateIgnoredEventBulkRetry(ctx context.Context, request *hookd
return response, nil
}
-func (c *client) GenerateIgnoredEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateIgnoredEventBulkRetryPlanResponse, error) {
+func (c *Client) GenerateIgnoredEventBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateIgnoredEventBulkRetryPlanResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -199,14 +191,14 @@ func (c *client) GenerateIgnoredEventBulkRetryPlan(ctx context.Context) (*hookde
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -230,7 +222,7 @@ func (c *client) GenerateIgnoredEventBulkRetryPlan(ctx context.Context) (*hookde
return response, nil
}
-func (c *client) GetIgnoredEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) GetIgnoredEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -249,7 +241,7 @@ func (c *client) GetIgnoredEventBulkRetry(ctx context.Context, id string) (*hook
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -273,7 +265,7 @@ func (c *client) GetIgnoredEventBulkRetry(ctx context.Context, id string) (*hook
return response, nil
}
-func (c *client) CancelIgnoredEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) CancelIgnoredEventBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -292,7 +284,7 @@ func (c *client) CancelIgnoredEventBulkRetry(ctx context.Context, id string) (*h
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/bulkretryrequests/client.go b/bulkretryrequests/client.go
index 805125e..2171ad5 100644
--- a/bulkretryrequests/client.go
+++ b/bulkretryrequests/client.go
@@ -16,33 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetRequestBulkRetries(ctx context.Context, request *hookdeckgosdk.GetRequestBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error)
- CreateRequestBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateRequestBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error)
- GenerateRequestBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateRequestBulkRetryPlanResponse, error)
- GetRequestBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error)
- CancelRequestBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetRequestBulkRetries(ctx context.Context, request *hookdeckgosdk.GetRequestBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error) {
+func (c *Client) GetRequestBulkRetries(ctx context.Context, request *hookdeckgosdk.GetRequestBulkRetriesRequest) (*hookdeckgosdk.BatchOperationPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -99,14 +91,14 @@ func (c *client) GetRequestBulkRetries(ctx context.Context, request *hookdeckgos
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -130,7 +122,7 @@ func (c *client) GetRequestBulkRetries(ctx context.Context, request *hookdeckgos
return response, nil
}
-func (c *client) CreateRequestBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateRequestBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) CreateRequestBulkRetry(ctx context.Context, request *hookdeckgosdk.CreateRequestBulkRetryRequest) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -149,14 +141,14 @@ func (c *client) CreateRequestBulkRetry(ctx context.Context, request *hookdeckgo
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -180,7 +172,7 @@ func (c *client) CreateRequestBulkRetry(ctx context.Context, request *hookdeckgo
return response, nil
}
-func (c *client) GenerateRequestBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateRequestBulkRetryPlanResponse, error) {
+func (c *Client) GenerateRequestBulkRetryPlan(ctx context.Context) (*hookdeckgosdk.GenerateRequestBulkRetryPlanResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -199,14 +191,14 @@ func (c *client) GenerateRequestBulkRetryPlan(ctx context.Context) (*hookdeckgos
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -230,7 +222,7 @@ func (c *client) GenerateRequestBulkRetryPlan(ctx context.Context) (*hookdeckgos
return response, nil
}
-func (c *client) GetRequestBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) GetRequestBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -249,7 +241,7 @@ func (c *client) GetRequestBulkRetry(ctx context.Context, id string) (*hookdeckg
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -273,7 +265,7 @@ func (c *client) GetRequestBulkRetry(ctx context.Context, id string) (*hookdeckg
return response, nil
}
-func (c *client) CancelRequestBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
+func (c *Client) CancelRequestBulkRetry(ctx context.Context, id string) (*hookdeckgosdk.BatchOperation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -292,7 +284,7 @@ func (c *client) CancelRequestBulkRetry(ctx context.Context, id string) (*hookde
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/client/client.go b/client/client.go
index 065a7d2..b4d6481 100644
--- a/client/client.go
+++ b/client/client.go
@@ -22,128 +22,51 @@ import (
http "net/http"
)
-type Client interface {
- IssueTriggers() issuetriggers.Client
- Attempts() attempts.Client
- Bookmarks() bookmarks.Client
- Destinations() destinations.Client
- BulkRetryEvents() bulkretryevents.Client
- Events() events.Client
- BulkRetryIgnoredEvents() bulkretryignoredevents.Client
- Integrations() integrations.Client
- Issues() issues.Client
- Requests() requests.Client
- BulkRetryRequests() bulkretryrequests.Client
- Sources() sources.Client
- Notifications() notifications.Client
- Transformations() transformations.Client
- Connections() connections.Client
-}
-
-func NewClient(opts ...core.ClientOption) Client {
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
+
+ IssueTriggers *issuetriggers.Client
+ Attempts *attempts.Client
+ Bookmarks *bookmarks.Client
+ Destinations *destinations.Client
+ BulkRetryEvents *bulkretryevents.Client
+ Events *events.Client
+ BulkRetryIgnoredEvents *bulkretryignoredevents.Client
+ Integrations *integrations.Client
+ Issues *issues.Client
+ Requests *requests.Client
+ BulkRetryRequests *bulkretryrequests.Client
+ Sources *sources.Client
+ Notifications *notifications.Client
+ Transformations *transformations.Client
+ Connections *connections.Client
+}
+
+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(),
- issueTriggersClient: issuetriggers.NewClient(opts...),
- attemptsClient: attempts.NewClient(opts...),
- bookmarksClient: bookmarks.NewClient(opts...),
- destinationsClient: destinations.NewClient(opts...),
- bulkRetryEventsClient: bulkretryevents.NewClient(opts...),
- eventsClient: events.NewClient(opts...),
- bulkRetryIgnoredEventsClient: bulkretryignoredevents.NewClient(opts...),
- integrationsClient: integrations.NewClient(opts...),
- issuesClient: issues.NewClient(opts...),
- requestsClient: requests.NewClient(opts...),
- bulkRetryRequestsClient: bulkretryrequests.NewClient(opts...),
- sourcesClient: sources.NewClient(opts...),
- notificationsClient: notifications.NewClient(opts...),
- transformationsClient: transformations.NewClient(opts...),
- connectionsClient: connections.NewClient(opts...),
+ return &Client{
+ baseURL: options.BaseURL,
+ httpClient: options.HTTPClient,
+ header: options.ToHeader(),
+ IssueTriggers: issuetriggers.NewClient(opts...),
+ Attempts: attempts.NewClient(opts...),
+ Bookmarks: bookmarks.NewClient(opts...),
+ Destinations: destinations.NewClient(opts...),
+ BulkRetryEvents: bulkretryevents.NewClient(opts...),
+ Events: events.NewClient(opts...),
+ BulkRetryIgnoredEvents: bulkretryignoredevents.NewClient(opts...),
+ Integrations: integrations.NewClient(opts...),
+ Issues: issues.NewClient(opts...),
+ Requests: requests.NewClient(opts...),
+ BulkRetryRequests: bulkretryrequests.NewClient(opts...),
+ Sources: sources.NewClient(opts...),
+ Notifications: notifications.NewClient(opts...),
+ Transformations: transformations.NewClient(opts...),
+ Connections: connections.NewClient(opts...),
}
}
-
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
- issueTriggersClient issuetriggers.Client
- attemptsClient attempts.Client
- bookmarksClient bookmarks.Client
- destinationsClient destinations.Client
- bulkRetryEventsClient bulkretryevents.Client
- eventsClient events.Client
- bulkRetryIgnoredEventsClient bulkretryignoredevents.Client
- integrationsClient integrations.Client
- issuesClient issues.Client
- requestsClient requests.Client
- bulkRetryRequestsClient bulkretryrequests.Client
- sourcesClient sources.Client
- notificationsClient notifications.Client
- transformationsClient transformations.Client
- connectionsClient connections.Client
-}
-
-func (c *client) IssueTriggers() issuetriggers.Client {
- return c.issueTriggersClient
-}
-
-func (c *client) Attempts() attempts.Client {
- return c.attemptsClient
-}
-
-func (c *client) Bookmarks() bookmarks.Client {
- return c.bookmarksClient
-}
-
-func (c *client) Destinations() destinations.Client {
- return c.destinationsClient
-}
-
-func (c *client) BulkRetryEvents() bulkretryevents.Client {
- return c.bulkRetryEventsClient
-}
-
-func (c *client) Events() events.Client {
- return c.eventsClient
-}
-
-func (c *client) BulkRetryIgnoredEvents() bulkretryignoredevents.Client {
- return c.bulkRetryIgnoredEventsClient
-}
-
-func (c *client) Integrations() integrations.Client {
- return c.integrationsClient
-}
-
-func (c *client) Issues() issues.Client {
- return c.issuesClient
-}
-
-func (c *client) Requests() requests.Client {
- return c.requestsClient
-}
-
-func (c *client) BulkRetryRequests() bulkretryrequests.Client {
- return c.bulkRetryRequestsClient
-}
-
-func (c *client) Sources() sources.Client {
- return c.sourcesClient
-}
-
-func (c *client) Notifications() notifications.Client {
- return c.notificationsClient
-}
-
-func (c *client) Transformations() transformations.Client {
- return c.transformationsClient
-}
-
-func (c *client) Connections() connections.Client {
- return c.connectionsClient
-}
diff --git a/client/client_test.go b/client/client_test.go
index cf80533..4a3ba01 100644
--- a/client/client_test.go
+++ b/client/client_test.go
@@ -11,16 +11,16 @@ import (
func TestNewClient(t *testing.T) {
t.Run("default", func(t *testing.T) {
c := NewClient()
- assert.Empty(t, c.(*client).baseURL)
- assert.Equal(t, http.DefaultClient, c.(*client).httpClient)
+ assert.Empty(t, c.baseURL)
+ assert.Equal(t, http.DefaultClient, c.httpClient)
})
t.Run("base url", func(t *testing.T) {
c := NewClient(
ClientWithBaseURL("test.co"),
)
- assert.Equal(t, "test.co", c.(*client).baseURL)
- assert.Equal(t, http.DefaultClient, c.(*client).httpClient)
+ assert.Equal(t, "test.co", c.baseURL)
+ assert.Equal(t, http.DefaultClient, c.httpClient)
})
t.Run("http client", func(t *testing.T) {
@@ -30,8 +30,8 @@ func TestNewClient(t *testing.T) {
c := NewClient(
ClientWithHTTPClient(httpClient),
)
- assert.Empty(t, c.(*client).baseURL)
- assert.Equal(t, httpClient, c.(*client).httpClient)
+ assert.Empty(t, c.baseURL)
+ assert.Equal(t, httpClient, c.httpClient)
})
t.Run("http header", func(t *testing.T) {
@@ -40,8 +40,8 @@ func TestNewClient(t *testing.T) {
c := NewClient(
ClientWithHTTPHeader(header),
)
- assert.Empty(t, c.(*client).baseURL)
- assert.Equal(t, http.DefaultClient, c.(*client).httpClient)
- assert.Equal(t, "test", c.(*client).header.Get("X-API-Tenancy"))
+ assert.Empty(t, c.baseURL)
+ assert.Equal(t, http.DefaultClient, c.httpClient)
+ assert.Equal(t, "test", c.header.Get("X-API-Tenancy"))
})
}
diff --git a/connections.go b/connections.go
index fd1a26d..26e38db 100644
--- a/connections.go
+++ b/connections.go
@@ -3,23 +3,24 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
type CreateConnectionRequest struct {
// A unique name of the connection for the source
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
// Description for the connection
- Description *string `json:"description,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
// ID of a destination to bind to the connection
- DestinationId *string `json:"destination_id,omitempty"`
+ DestinationId *core.Optional[string] `json:"destination_id,omitempty"`
// ID of a source to bind to the connection
- SourceId *string `json:"source_id,omitempty"`
+ SourceId *core.Optional[string] `json:"source_id,omitempty"`
// Destination input object
- Destination *CreateConnectionRequestDestination `json:"destination,omitempty"`
+ Destination *core.Optional[CreateConnectionRequestDestination] `json:"destination,omitempty"`
// Source input object
- Source *CreateConnectionRequestSource `json:"source,omitempty"`
- Rules []*Rule `json:"rules,omitempty"`
+ Source *core.Optional[CreateConnectionRequestSource] `json:"source,omitempty"`
+ Rules []*Rule `json:"rules,omitempty"`
}
type GetConnectionsRequest struct {
@@ -40,24 +41,24 @@ type GetConnectionsRequest struct {
type UpdateConnectionRequest struct {
// `<= 155 characters`
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
// Description for the connection
- Description *string `json:"description,omitempty"`
- Rules []*Rule `json:"rules,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
+ Rules []*Rule `json:"rules,omitempty"`
}
type UpsertConnectionRequest struct {
// A unique name of the connection for the source
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
// Description for the connection
- Description *string `json:"description,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
// ID of a destination to bind to the connection
- DestinationId *string `json:"destination_id,omitempty"`
+ DestinationId *core.Optional[string] `json:"destination_id,omitempty"`
// ID of a source to bind to the connection
- SourceId *string `json:"source_id,omitempty"`
+ SourceId *core.Optional[string] `json:"source_id,omitempty"`
// Destination input object
- Destination *UpsertConnectionRequestDestination `json:"destination,omitempty"`
+ Destination *core.Optional[UpsertConnectionRequestDestination] `json:"destination,omitempty"`
// Source input object
- Source *UpsertConnectionRequestSource `json:"source,omitempty"`
- Rules []*Rule `json:"rules,omitempty"`
+ Source *core.Optional[UpsertConnectionRequestSource] `json:"source,omitempty"`
+ Rules []*Rule `json:"rules,omitempty"`
}
diff --git a/connections/client.go b/connections/client.go
index 7694113..be0cfed 100644
--- a/connections/client.go
+++ b/connections/client.go
@@ -16,38 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetConnections(ctx context.Context, request *hookdeckgosdk.GetConnectionsRequest) (*hookdeckgosdk.ConnectionPaginatedResult, error)
- CreateConnection(ctx context.Context, request *hookdeckgosdk.CreateConnectionRequest) (*hookdeckgosdk.Connection, error)
- UpsertConnection(ctx context.Context, request *hookdeckgosdk.UpsertConnectionRequest) (*hookdeckgosdk.Connection, error)
- GetConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error)
- UpdateConnection(ctx context.Context, id string, request *hookdeckgosdk.UpdateConnectionRequest) (*hookdeckgosdk.Connection, error)
- DeleteConnection(ctx context.Context, id string) (*hookdeckgosdk.DeleteConnectionResponse, error)
- ArchiveConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error)
- UnarchiveConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error)
- PauseConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error)
- UnpauseConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetConnections(ctx context.Context, request *hookdeckgosdk.GetConnectionsRequest) (*hookdeckgosdk.ConnectionPaginatedResult, error) {
+func (c *Client) GetConnections(ctx context.Context, request *hookdeckgosdk.GetConnectionsRequest) (*hookdeckgosdk.ConnectionPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -110,14 +97,14 @@ func (c *client) GetConnections(ctx context.Context, request *hookdeckgosdk.GetC
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -141,7 +128,7 @@ func (c *client) GetConnections(ctx context.Context, request *hookdeckgosdk.GetC
return response, nil
}
-func (c *client) CreateConnection(ctx context.Context, request *hookdeckgosdk.CreateConnectionRequest) (*hookdeckgosdk.Connection, error) {
+func (c *Client) CreateConnection(ctx context.Context, request *hookdeckgosdk.CreateConnectionRequest) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -160,14 +147,14 @@ func (c *client) CreateConnection(ctx context.Context, request *hookdeckgosdk.Cr
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -191,7 +178,7 @@ func (c *client) CreateConnection(ctx context.Context, request *hookdeckgosdk.Cr
return response, nil
}
-func (c *client) UpsertConnection(ctx context.Context, request *hookdeckgosdk.UpsertConnectionRequest) (*hookdeckgosdk.Connection, error) {
+func (c *Client) UpsertConnection(ctx context.Context, request *hookdeckgosdk.UpsertConnectionRequest) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -210,14 +197,14 @@ func (c *client) UpsertConnection(ctx context.Context, request *hookdeckgosdk.Up
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -241,7 +228,7 @@ func (c *client) UpsertConnection(ctx context.Context, request *hookdeckgosdk.Up
return response, nil
}
-func (c *client) GetConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
+func (c *Client) GetConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -260,7 +247,7 @@ func (c *client) GetConnection(ctx context.Context, id string) (*hookdeckgosdk.C
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -284,7 +271,7 @@ func (c *client) GetConnection(ctx context.Context, id string) (*hookdeckgosdk.C
return response, nil
}
-func (c *client) UpdateConnection(ctx context.Context, id string, request *hookdeckgosdk.UpdateConnectionRequest) (*hookdeckgosdk.Connection, error) {
+func (c *Client) UpdateConnection(ctx context.Context, id string, request *hookdeckgosdk.UpdateConnectionRequest) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -303,21 +290,21 @@ func (c *client) UpdateConnection(ctx context.Context, id string, request *hookd
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -341,7 +328,7 @@ func (c *client) UpdateConnection(ctx context.Context, id string, request *hookd
return response, nil
}
-func (c *client) DeleteConnection(ctx context.Context, id string) (*hookdeckgosdk.DeleteConnectionResponse, error) {
+func (c *Client) DeleteConnection(ctx context.Context, id string) (*hookdeckgosdk.DeleteConnectionResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -360,7 +347,7 @@ func (c *client) DeleteConnection(ctx context.Context, id string) (*hookdeckgosd
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -384,7 +371,7 @@ func (c *client) DeleteConnection(ctx context.Context, id string) (*hookdeckgosd
return response, nil
}
-func (c *client) ArchiveConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
+func (c *Client) ArchiveConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -403,7 +390,7 @@ func (c *client) ArchiveConnection(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -427,7 +414,7 @@ func (c *client) ArchiveConnection(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) UnarchiveConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
+func (c *Client) UnarchiveConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -446,7 +433,7 @@ func (c *client) UnarchiveConnection(ctx context.Context, id string) (*hookdeckg
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -470,7 +457,7 @@ func (c *client) UnarchiveConnection(ctx context.Context, id string) (*hookdeckg
return response, nil
}
-func (c *client) PauseConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
+func (c *Client) PauseConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -489,7 +476,7 @@ func (c *client) PauseConnection(ctx context.Context, id string) (*hookdeckgosdk
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -513,7 +500,7 @@ func (c *client) PauseConnection(ctx context.Context, id string) (*hookdeckgosdk
return response, nil
}
-func (c *client) UnpauseConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
+func (c *Client) UnpauseConnection(ctx context.Context, id string) (*hookdeckgosdk.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -532,7 +519,7 @@ func (c *client) UnpauseConnection(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/core/client_option.go b/core/client_option.go
index f022715..d8fa079 100644
--- a/core/client_option.go
+++ b/core/client_option.go
@@ -43,6 +43,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
headers := c.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/hookdeck/hookdeck-go-sdk")
- headers.Set("X-Fern-SDK-Version", "0.0.27")
+ headers.Set("X-Fern-SDK-Version", "0.0.28")
return headers
}
diff --git a/core/optional.go b/core/optional.go
new file mode 100644
index 0000000..85ab541
--- /dev/null
+++ b/core/optional.go
@@ -0,0 +1,36 @@
+package core
+
+import (
+ "encoding/json"
+ "fmt"
+)
+
+// Optional is a wrapper used to distinguish zero values from
+// null or omitted fields.
+//
+// To instantiate an Optional, use the `Optional()` and `Null()`
+// helpers exported from the root package.
+type Optional[T any] struct {
+ Value T
+ Null bool
+}
+
+func (o *Optional[T]) String() string {
+ if o == nil {
+ return ""
+ }
+ if s, ok := any(o.Value).(fmt.Stringer); ok {
+ return s.String()
+ }
+ return fmt.Sprintf("%#v", o.Value)
+}
+
+func (o *Optional[T]) MarshalJSON() ([]byte, error) {
+ if o == nil {
+ return nil, nil
+ }
+ if o.Null {
+ return []byte("null"), nil
+ }
+ return json.Marshal(&o.Value)
+}
diff --git a/core/optional_test.go b/core/optional_test.go
new file mode 100644
index 0000000..453e01a
--- /dev/null
+++ b/core/optional_test.go
@@ -0,0 +1,131 @@
+package core
+
+import (
+ "encoding/json"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+type OptionalRequest struct {
+ Id string `json:"id"`
+ Filter *Optional[string] `json:"filter,omitempty"`
+ Reference *Optional[Reference] `json:"reference,omitempty"`
+}
+
+type Reference struct {
+ Id string `json:"id"`
+ Tags []string `json:"tags"`
+}
+
+func (r *Reference) MarshalJSON() ([]byte, error) {
+ type embed Reference
+ var marshaler = struct {
+ embed
+ Extra string `json:"extra"`
+ }{
+ embed: embed(*r),
+ Extra: "metadata",
+ }
+ return json.Marshal(marshaler)
+}
+
+func TestOptional(t *testing.T) {
+ tests := []struct {
+ desc string
+ giveOptional *Optional[any]
+ wantBytes []byte
+ }{
+ {
+ desc: "primitive",
+ giveOptional: &Optional[any]{
+ Value: "foo",
+ },
+ wantBytes: []byte(`"foo"`),
+ },
+ {
+ desc: "null primitive",
+ giveOptional: &Optional[any]{
+ Null: true,
+ },
+ wantBytes: []byte("null"),
+ },
+ {
+ desc: "object",
+ giveOptional: &Optional[any]{
+ Value: &OptionalRequest{
+ Id: "xyz",
+ Filter: &Optional[string]{
+ Value: "foo",
+ },
+ },
+ },
+ wantBytes: []byte(`{"id":"xyz","filter":"foo"}`),
+ },
+ {
+ desc: "null object",
+ giveOptional: &Optional[any]{
+ Value: &OptionalRequest{
+ Id: "xyz",
+ Filter: &Optional[string]{
+ Null: true,
+ },
+ },
+ },
+ wantBytes: []byte(`{"id":"xyz","filter":null}`),
+ },
+ {
+ desc: "empty object",
+ giveOptional: &Optional[any]{
+ Value: &OptionalRequest{
+ Id: "xyz",
+ },
+ },
+ wantBytes: []byte(`{"id":"xyz"}`),
+ },
+ {
+ desc: "nested object",
+ giveOptional: &Optional[any]{
+ Value: &OptionalRequest{
+ Id: "xyz",
+ Reference: &Optional[Reference]{
+ Value: Reference{
+ Id: "abc",
+ Tags: []string{"one", "two", "three"},
+ },
+ },
+ },
+ },
+ wantBytes: []byte(`{"id":"xyz","reference":{"id":"abc","tags":["one","two","three"],"extra":"metadata"}}`),
+ },
+ {
+ desc: "null nested object",
+ giveOptional: &Optional[any]{
+ Value: &OptionalRequest{
+ Id: "xyz",
+ Reference: &Optional[Reference]{
+ Null: true,
+ },
+ },
+ },
+ wantBytes: []byte(`{"id":"xyz","reference":null}`),
+ },
+ {
+ desc: "empty nested object",
+ giveOptional: &Optional[any]{
+ Value: &OptionalRequest{
+ Id: "xyz",
+ },
+ },
+ wantBytes: []byte(`{"id":"xyz"}`),
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.desc, func(t *testing.T) {
+ bytes, err := json.Marshal(test.giveOptional)
+ require.NoError(t, err)
+ assert.Equal(t, test.wantBytes, bytes)
+ })
+ }
+}
diff --git a/destinations.go b/destinations.go
index 38567b4..3049e3a 100644
--- a/destinations.go
+++ b/destinations.go
@@ -3,6 +3,7 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
@@ -10,18 +11,18 @@ type CreateDestinationRequest struct {
// Name for the destination `<= 155 characters`
Name string `json:"name"`
// Description for the destination
- Description *string `json:"description,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
// Endpoint of the destination
- Url *string `json:"url,omitempty"`
+ Url *core.Optional[string] `json:"url,omitempty"`
// Path for the CLI destination
- CliPath *string `json:"cli_path,omitempty"`
+ CliPath *core.Optional[string] `json:"cli_path,omitempty"`
// Period to rate limit attempts
- RateLimitPeriod *CreateDestinationRequestRateLimitPeriod `json:"rate_limit_period,omitempty"`
+ RateLimitPeriod *core.Optional[CreateDestinationRequestRateLimitPeriod] `json:"rate_limit_period,omitempty"`
// Limit event attempts to receive per period
- RateLimit *int `json:"rate_limit,omitempty"`
- HttpMethod *DestinationHttpMethod `json:"http_method,omitempty"`
- AuthMethod *DestinationAuthMethodConfig `json:"auth_method,omitempty"`
- PathForwardingDisabled *bool `json:"path_forwarding_disabled,omitempty"`
+ RateLimit *core.Optional[int] `json:"rate_limit,omitempty"`
+ HttpMethod *core.Optional[DestinationHttpMethod] `json:"http_method,omitempty"`
+ AuthMethod *core.Optional[DestinationAuthMethodConfig] `json:"auth_method,omitempty"`
+ PathForwardingDisabled *core.Optional[bool] `json:"path_forwarding_disabled,omitempty"`
}
type GetDestinationsRequest struct {
@@ -40,36 +41,36 @@ type GetDestinationsRequest struct {
type UpdateDestinationRequest struct {
// Name for the destination `<= 155 characters`
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
// Description for the destination
- Description *string `json:"description,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
// Endpoint of the destination
- Url *string `json:"url,omitempty"`
+ Url *core.Optional[string] `json:"url,omitempty"`
// Path for the CLI destination
- CliPath *string `json:"cli_path,omitempty"`
+ CliPath *core.Optional[string] `json:"cli_path,omitempty"`
// Period to rate limit attempts
- RateLimitPeriod *UpdateDestinationRequestRateLimitPeriod `json:"rate_limit_period,omitempty"`
+ RateLimitPeriod *core.Optional[UpdateDestinationRequestRateLimitPeriod] `json:"rate_limit_period,omitempty"`
// Limit event attempts to receive per period
- RateLimit *int `json:"rate_limit,omitempty"`
- HttpMethod *DestinationHttpMethod `json:"http_method,omitempty"`
- AuthMethod *DestinationAuthMethodConfig `json:"auth_method,omitempty"`
- PathForwardingDisabled *bool `json:"path_forwarding_disabled,omitempty"`
+ RateLimit *core.Optional[int] `json:"rate_limit,omitempty"`
+ HttpMethod *core.Optional[DestinationHttpMethod] `json:"http_method,omitempty"`
+ AuthMethod *core.Optional[DestinationAuthMethodConfig] `json:"auth_method,omitempty"`
+ PathForwardingDisabled *core.Optional[bool] `json:"path_forwarding_disabled,omitempty"`
}
type UpsertDestinationRequest struct {
// Name for the destination `<= 155 characters`
Name string `json:"name"`
// Description for the destination
- Description *string `json:"description,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
// Endpoint of the destination
- Url *string `json:"url,omitempty"`
+ Url *core.Optional[string] `json:"url,omitempty"`
// Path for the CLI destination
- CliPath *string `json:"cli_path,omitempty"`
+ CliPath *core.Optional[string] `json:"cli_path,omitempty"`
// Period to rate limit attempts
- RateLimitPeriod *UpsertDestinationRequestRateLimitPeriod `json:"rate_limit_period,omitempty"`
+ RateLimitPeriod *core.Optional[UpsertDestinationRequestRateLimitPeriod] `json:"rate_limit_period,omitempty"`
// Limit event attempts to receive per period
- RateLimit *int `json:"rate_limit,omitempty"`
- HttpMethod *DestinationHttpMethod `json:"http_method,omitempty"`
- AuthMethod *DestinationAuthMethodConfig `json:"auth_method,omitempty"`
- PathForwardingDisabled *bool `json:"path_forwarding_disabled,omitempty"`
+ RateLimit *core.Optional[int] `json:"rate_limit,omitempty"`
+ HttpMethod *core.Optional[DestinationHttpMethod] `json:"http_method,omitempty"`
+ AuthMethod *core.Optional[DestinationAuthMethodConfig] `json:"auth_method,omitempty"`
+ PathForwardingDisabled *core.Optional[bool] `json:"path_forwarding_disabled,omitempty"`
}
diff --git a/destinations/client.go b/destinations/client.go
index 45dc00a..1fc6510 100644
--- a/destinations/client.go
+++ b/destinations/client.go
@@ -16,36 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetDestinations(ctx context.Context, request *hookdeckgosdk.GetDestinationsRequest) (*hookdeckgosdk.DestinationPaginatedResult, error)
- CreateDestination(ctx context.Context, request *hookdeckgosdk.CreateDestinationRequest) (*hookdeckgosdk.Destination, error)
- UpsertDestination(ctx context.Context, request *hookdeckgosdk.UpsertDestinationRequest) (*hookdeckgosdk.Destination, error)
- GetDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error)
- UpdateDestination(ctx context.Context, id string, request *hookdeckgosdk.UpdateDestinationRequest) (*hookdeckgosdk.Destination, error)
- DeleteDestination(ctx context.Context, id string) (*hookdeckgosdk.DeleteDestinationResponse, error)
- ArchiveDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error)
- UnarchiveDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetDestinations(ctx context.Context, request *hookdeckgosdk.GetDestinationsRequest) (*hookdeckgosdk.DestinationPaginatedResult, error) {
+func (c *Client) GetDestinations(ctx context.Context, request *hookdeckgosdk.GetDestinationsRequest) (*hookdeckgosdk.DestinationPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -102,14 +91,14 @@ func (c *client) GetDestinations(ctx context.Context, request *hookdeckgosdk.Get
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -133,7 +122,7 @@ func (c *client) GetDestinations(ctx context.Context, request *hookdeckgosdk.Get
return response, nil
}
-func (c *client) CreateDestination(ctx context.Context, request *hookdeckgosdk.CreateDestinationRequest) (*hookdeckgosdk.Destination, error) {
+func (c *Client) CreateDestination(ctx context.Context, request *hookdeckgosdk.CreateDestinationRequest) (*hookdeckgosdk.Destination, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -152,14 +141,14 @@ func (c *client) CreateDestination(ctx context.Context, request *hookdeckgosdk.C
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -183,7 +172,7 @@ func (c *client) CreateDestination(ctx context.Context, request *hookdeckgosdk.C
return response, nil
}
-func (c *client) UpsertDestination(ctx context.Context, request *hookdeckgosdk.UpsertDestinationRequest) (*hookdeckgosdk.Destination, error) {
+func (c *Client) UpsertDestination(ctx context.Context, request *hookdeckgosdk.UpsertDestinationRequest) (*hookdeckgosdk.Destination, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -202,14 +191,14 @@ func (c *client) UpsertDestination(ctx context.Context, request *hookdeckgosdk.U
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -233,7 +222,7 @@ func (c *client) UpsertDestination(ctx context.Context, request *hookdeckgosdk.U
return response, nil
}
-func (c *client) GetDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error) {
+func (c *Client) GetDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -252,7 +241,7 @@ func (c *client) GetDestination(ctx context.Context, id string) (*hookdeckgosdk.
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -276,7 +265,7 @@ func (c *client) GetDestination(ctx context.Context, id string) (*hookdeckgosdk.
return response, nil
}
-func (c *client) UpdateDestination(ctx context.Context, id string, request *hookdeckgosdk.UpdateDestinationRequest) (*hookdeckgosdk.Destination, error) {
+func (c *Client) UpdateDestination(ctx context.Context, id string, request *hookdeckgosdk.UpdateDestinationRequest) (*hookdeckgosdk.Destination, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -295,21 +284,21 @@ func (c *client) UpdateDestination(ctx context.Context, id string, request *hook
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -333,7 +322,7 @@ func (c *client) UpdateDestination(ctx context.Context, id string, request *hook
return response, nil
}
-func (c *client) DeleteDestination(ctx context.Context, id string) (*hookdeckgosdk.DeleteDestinationResponse, error) {
+func (c *Client) DeleteDestination(ctx context.Context, id string) (*hookdeckgosdk.DeleteDestinationResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -352,7 +341,7 @@ func (c *client) DeleteDestination(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -376,7 +365,7 @@ func (c *client) DeleteDestination(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) ArchiveDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error) {
+func (c *Client) ArchiveDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -395,7 +384,7 @@ func (c *client) ArchiveDestination(ctx context.Context, id string) (*hookdeckgo
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -419,7 +408,7 @@ func (c *client) ArchiveDestination(ctx context.Context, id string) (*hookdeckgo
return response, nil
}
-func (c *client) UnarchiveDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error) {
+func (c *Client) UnarchiveDestination(ctx context.Context, id string) (*hookdeckgosdk.Destination, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -438,7 +427,7 @@ func (c *client) UnarchiveDestination(ctx context.Context, id string) (*hookdeck
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/doc.go b/doc.go
index ee6eb9f..43fc39f 100644
--- a/doc.go
+++ b/doc.go
@@ -1,4 +1,4 @@
// This file was auto-generated by Fern from our API Definition.
-// A request represent a webhook received by Hookdeck.
+// An event is any request that Hookdeck receives from a source.
package api
diff --git a/errors.go b/errors.go
index a288526..28435cb 100644
--- a/errors.go
+++ b/errors.go
@@ -26,6 +26,10 @@ func (b *BadRequestError) MarshalJSON() ([]byte, error) {
return json.Marshal(b.Body)
}
+func (b *BadRequestError) Unwrap() error {
+ return b.APIError
+}
+
type NotFoundError struct {
*core.APIError
Body *ApiErrorResponse
@@ -45,6 +49,10 @@ func (n *NotFoundError) MarshalJSON() ([]byte, error) {
return json.Marshal(n.Body)
}
+func (n *NotFoundError) Unwrap() error {
+ return n.APIError
+}
+
type UnprocessableEntityError struct {
*core.APIError
Body *ApiErrorResponse
@@ -63,3 +71,7 @@ func (u *UnprocessableEntityError) UnmarshalJSON(data []byte) error {
func (u *UnprocessableEntityError) MarshalJSON() ([]byte, error) {
return json.Marshal(u.Body)
}
+
+func (u *UnprocessableEntityError) Unwrap() error {
+ return u.APIError
+}
diff --git a/events/client.go b/events/client.go
index 0a169da..2852af9 100644
--- a/events/client.go
+++ b/events/client.go
@@ -16,33 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetEvents(ctx context.Context, request *hookdeckgosdk.GetEventsRequest) (*hookdeckgosdk.EventPaginatedResult, error)
- GetEvent(ctx context.Context, id string) (*hookdeckgosdk.Event, error)
- GetRequestRawBody(ctx context.Context, id string) (*hookdeckgosdk.RawBody, error)
- RetryEvent(ctx context.Context, id string) (*hookdeckgosdk.RetriedEvent, error)
- MuteEvent(ctx context.Context, id string) (*hookdeckgosdk.Event, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetEvents(ctx context.Context, request *hookdeckgosdk.GetEventsRequest) (*hookdeckgosdk.EventPaginatedResult, error) {
+func (c *Client) GetEvents(ctx context.Context, request *hookdeckgosdk.GetEventsRequest) (*hookdeckgosdk.EventPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -147,14 +139,14 @@ func (c *client) GetEvents(ctx context.Context, request *hookdeckgosdk.GetEvents
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -178,7 +170,7 @@ func (c *client) GetEvents(ctx context.Context, request *hookdeckgosdk.GetEvents
return response, nil
}
-func (c *client) GetEvent(ctx context.Context, id string) (*hookdeckgosdk.Event, error) {
+func (c *Client) GetEvent(ctx context.Context, id string) (*hookdeckgosdk.Event, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -197,7 +189,7 @@ func (c *client) GetEvent(ctx context.Context, id string) (*hookdeckgosdk.Event,
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -221,7 +213,7 @@ func (c *client) GetEvent(ctx context.Context, id string) (*hookdeckgosdk.Event,
return response, nil
}
-func (c *client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgosdk.RawBody, error) {
+func (c *Client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgosdk.RawBody, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -240,7 +232,7 @@ func (c *client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -264,7 +256,7 @@ func (c *client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) RetryEvent(ctx context.Context, id string) (*hookdeckgosdk.RetriedEvent, error) {
+func (c *Client) RetryEvent(ctx context.Context, id string) (*hookdeckgosdk.RetriedEvent, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -283,7 +275,7 @@ func (c *client) RetryEvent(ctx context.Context, id string) (*hookdeckgosdk.Retr
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -307,7 +299,7 @@ func (c *client) RetryEvent(ctx context.Context, id string) (*hookdeckgosdk.Retr
return response, nil
}
-func (c *client) MuteEvent(ctx context.Context, id string) (*hookdeckgosdk.Event, error) {
+func (c *Client) MuteEvent(ctx context.Context, id string) (*hookdeckgosdk.Event, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -326,7 +318,7 @@ func (c *client) MuteEvent(ctx context.Context, id string) (*hookdeckgosdk.Event
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/integrations.go b/integrations.go
index 6b8591d..e123dd7 100644
--- a/integrations.go
+++ b/integrations.go
@@ -2,12 +2,16 @@
package api
+import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
+)
+
type CreateIntegrationRequest struct {
// Label of the integration
- Label *string `json:"label,omitempty"`
+ Label *core.Optional[string] `json:"label,omitempty"`
// Decrypted Key/Value object of the associated configuration for that provider
- Configs *CreateIntegrationRequestConfigs `json:"configs,omitempty"`
- Provider *IntegrationProvider `json:"provider,omitempty"`
+ Configs *core.Optional[CreateIntegrationRequestConfigs] `json:"configs,omitempty"`
+ Provider *core.Optional[IntegrationProvider] `json:"provider,omitempty"`
// List of features to enable (see features list above)
Features []IntegrationFeature `json:"features,omitempty"`
}
@@ -19,10 +23,10 @@ type GetIntegrationsRequest struct {
type UpdateIntegrationRequest struct {
// Label of the integration
- Label *string `json:"label,omitempty"`
+ Label *core.Optional[string] `json:"label,omitempty"`
// Decrypted Key/Value object of the associated configuration for that provider
- Configs *UpdateIntegrationRequestConfigs `json:"configs,omitempty"`
- Provider *IntegrationProvider `json:"provider,omitempty"`
+ Configs *core.Optional[UpdateIntegrationRequestConfigs] `json:"configs,omitempty"`
+ Provider *core.Optional[IntegrationProvider] `json:"provider,omitempty"`
// List of features to enable (see features list above)
Features []IntegrationFeature `json:"features,omitempty"`
}
diff --git a/integrations/client.go b/integrations/client.go
index 87e4329..3e7b855 100644
--- a/integrations/client.go
+++ b/integrations/client.go
@@ -15,35 +15,25 @@ import (
url "net/url"
)
-type Client interface {
- GetIntegrations(ctx context.Context, request *hookdeckgosdk.GetIntegrationsRequest) (*hookdeckgosdk.IntegrationPaginatedResult, error)
- CreateIntegration(ctx context.Context, request *hookdeckgosdk.CreateIntegrationRequest) (*hookdeckgosdk.Integration, error)
- GetIntegration(ctx context.Context, id string) (*hookdeckgosdk.Integration, error)
- UpdateIntegration(ctx context.Context, id string, request *hookdeckgosdk.UpdateIntegrationRequest) (*hookdeckgosdk.Integration, error)
- DeleteIntegration(ctx context.Context, id string) (*hookdeckgosdk.DeletedIntegration, error)
- AttachIntegrationToSource(ctx context.Context, id string, sourceId string) (*hookdeckgosdk.AttachedIntegrationToSource, error)
- DetachIntegrationToSource(ctx context.Context, id string, sourceId string) (*hookdeckgosdk.DetachedIntegrationFromSource, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetIntegrations(ctx context.Context, request *hookdeckgosdk.GetIntegrationsRequest) (*hookdeckgosdk.IntegrationPaginatedResult, error) {
+func (c *Client) GetIntegrations(ctx context.Context, request *hookdeckgosdk.GetIntegrationsRequest) (*hookdeckgosdk.IntegrationPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -73,14 +63,14 @@ func (c *client) GetIntegrations(ctx context.Context, request *hookdeckgosdk.Get
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -104,7 +94,7 @@ func (c *client) GetIntegrations(ctx context.Context, request *hookdeckgosdk.Get
return response, nil
}
-func (c *client) CreateIntegration(ctx context.Context, request *hookdeckgosdk.CreateIntegrationRequest) (*hookdeckgosdk.Integration, error) {
+func (c *Client) CreateIntegration(ctx context.Context, request *hookdeckgosdk.CreateIntegrationRequest) (*hookdeckgosdk.Integration, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -123,14 +113,14 @@ func (c *client) CreateIntegration(ctx context.Context, request *hookdeckgosdk.C
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -154,7 +144,7 @@ func (c *client) CreateIntegration(ctx context.Context, request *hookdeckgosdk.C
return response, nil
}
-func (c *client) GetIntegration(ctx context.Context, id string) (*hookdeckgosdk.Integration, error) {
+func (c *Client) GetIntegration(ctx context.Context, id string) (*hookdeckgosdk.Integration, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -173,7 +163,7 @@ func (c *client) GetIntegration(ctx context.Context, id string) (*hookdeckgosdk.
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -197,7 +187,7 @@ func (c *client) GetIntegration(ctx context.Context, id string) (*hookdeckgosdk.
return response, nil
}
-func (c *client) UpdateIntegration(ctx context.Context, id string, request *hookdeckgosdk.UpdateIntegrationRequest) (*hookdeckgosdk.Integration, error) {
+func (c *Client) UpdateIntegration(ctx context.Context, id string, request *hookdeckgosdk.UpdateIntegrationRequest) (*hookdeckgosdk.Integration, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -216,21 +206,21 @@ func (c *client) UpdateIntegration(ctx context.Context, id string, request *hook
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -254,7 +244,7 @@ func (c *client) UpdateIntegration(ctx context.Context, id string, request *hook
return response, nil
}
-func (c *client) DeleteIntegration(ctx context.Context, id string) (*hookdeckgosdk.DeletedIntegration, error) {
+func (c *Client) DeleteIntegration(ctx context.Context, id string) (*hookdeckgosdk.DeletedIntegration, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -273,7 +263,7 @@ func (c *client) DeleteIntegration(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -297,7 +287,7 @@ func (c *client) DeleteIntegration(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) AttachIntegrationToSource(ctx context.Context, id string, sourceId string) (*hookdeckgosdk.AttachedIntegrationToSource, error) {
+func (c *Client) AttachIntegrationToSource(ctx context.Context, id string, sourceId string) (*hookdeckgosdk.AttachedIntegrationToSource, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -316,14 +306,14 @@ func (c *client) AttachIntegrationToSource(ctx context.Context, id string, sourc
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -347,7 +337,7 @@ func (c *client) AttachIntegrationToSource(ctx context.Context, id string, sourc
return response, nil
}
-func (c *client) DetachIntegrationToSource(ctx context.Context, id string, sourceId string) (*hookdeckgosdk.DetachedIntegrationFromSource, error) {
+func (c *Client) DetachIntegrationToSource(ctx context.Context, id string, sourceId string) (*hookdeckgosdk.DetachedIntegrationFromSource, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -366,14 +356,14 @@ func (c *client) DetachIntegrationToSource(ctx context.Context, id string, sourc
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/issue_triggers.go b/issue_triggers.go
index 307eded..233035b 100644
--- a/issue_triggers.go
+++ b/issue_triggers.go
@@ -3,16 +3,17 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
type CreateIssueTriggerRequest struct {
Type IssueType `json:"type,omitempty"`
// Configuration object for the specific issue type selected
- Configs *CreateIssueTriggerRequestConfigs `json:"configs,omitempty"`
- Channels *IssueTriggerChannels `json:"channels,omitempty"`
+ Configs *core.Optional[CreateIssueTriggerRequestConfigs] `json:"configs,omitempty"`
+ Channels *core.Optional[IssueTriggerChannels] `json:"channels,omitempty"`
// Optional unique name to use as reference when using the API
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
}
type GetIssueTriggersRequest struct {
@@ -28,19 +29,19 @@ type GetIssueTriggersRequest struct {
type UpdateIssueTriggerRequest struct {
// Configuration object for the specific issue type selected
- Configs *UpdateIssueTriggerRequestConfigs `json:"configs,omitempty"`
- Channels *IssueTriggerChannels `json:"channels,omitempty"`
+ Configs *core.Optional[UpdateIssueTriggerRequestConfigs] `json:"configs,omitempty"`
+ Channels *core.Optional[IssueTriggerChannels] `json:"channels,omitempty"`
// Date when the issue trigger was disabled
- DisabledAt *time.Time `json:"disabled_at,omitempty"`
+ DisabledAt *core.Optional[time.Time] `json:"disabled_at,omitempty"`
// Optional unique name to use as reference when using the API
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
}
type UpsertIssueTriggerRequest struct {
Type IssueType `json:"type,omitempty"`
// Configuration object for the specific issue type selected
- Configs *UpsertIssueTriggerRequestConfigs `json:"configs,omitempty"`
- Channels *IssueTriggerChannels `json:"channels,omitempty"`
+ Configs *core.Optional[UpsertIssueTriggerRequestConfigs] `json:"configs,omitempty"`
+ Channels *core.Optional[IssueTriggerChannels] `json:"channels,omitempty"`
// Required unique name to use as reference when using the API `<= 255 characters`
Name string `json:"name"`
}
diff --git a/issues/client.go b/issues/client.go
index 26b56f1..c38f3fb 100644
--- a/issues/client.go
+++ b/issues/client.go
@@ -16,33 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetIssues(ctx context.Context, request *hookdeckgosdk.GetIssuesRequest) (*hookdeckgosdk.IssueWithDataPaginatedResult, error)
- GetIssueCount(ctx context.Context, request *hookdeckgosdk.GetIssueCountRequest) (*hookdeckgosdk.IssueCount, error)
- GetIssue(ctx context.Context, id string) (*hookdeckgosdk.IssueWithData, error)
- UpdateIssue(ctx context.Context, id string, request *hookdeckgosdk.UpdateIssueRequest) (*hookdeckgosdk.Issue, error)
- DismissIssue(ctx context.Context, id string) (*hookdeckgosdk.Issue, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetIssues(ctx context.Context, request *hookdeckgosdk.GetIssuesRequest) (*hookdeckgosdk.IssueWithDataPaginatedResult, error) {
+func (c *Client) GetIssues(ctx context.Context, request *hookdeckgosdk.GetIssuesRequest) (*hookdeckgosdk.IssueWithDataPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -108,14 +100,14 @@ func (c *client) GetIssues(ctx context.Context, request *hookdeckgosdk.GetIssues
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -139,7 +131,7 @@ func (c *client) GetIssues(ctx context.Context, request *hookdeckgosdk.GetIssues
return response, nil
}
-func (c *client) GetIssueCount(ctx context.Context, request *hookdeckgosdk.GetIssueCountRequest) (*hookdeckgosdk.IssueCount, error) {
+func (c *Client) GetIssueCount(ctx context.Context, request *hookdeckgosdk.GetIssueCountRequest) (*hookdeckgosdk.IssueCount, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -205,7 +197,7 @@ func (c *client) GetIssueCount(ctx context.Context, request *hookdeckgosdk.GetIs
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -229,7 +221,7 @@ func (c *client) GetIssueCount(ctx context.Context, request *hookdeckgosdk.GetIs
return response, nil
}
-func (c *client) GetIssue(ctx context.Context, id string) (*hookdeckgosdk.IssueWithData, error) {
+func (c *Client) GetIssue(ctx context.Context, id string) (*hookdeckgosdk.IssueWithData, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -248,7 +240,7 @@ func (c *client) GetIssue(ctx context.Context, id string) (*hookdeckgosdk.IssueW
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -272,7 +264,7 @@ func (c *client) GetIssue(ctx context.Context, id string) (*hookdeckgosdk.IssueW
return response, nil
}
-func (c *client) UpdateIssue(ctx context.Context, id string, request *hookdeckgosdk.UpdateIssueRequest) (*hookdeckgosdk.Issue, error) {
+func (c *Client) UpdateIssue(ctx context.Context, id string, request *hookdeckgosdk.UpdateIssueRequest) (*hookdeckgosdk.Issue, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -291,14 +283,14 @@ func (c *client) UpdateIssue(ctx context.Context, id string, request *hookdeckgo
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -322,7 +314,7 @@ func (c *client) UpdateIssue(ctx context.Context, id string, request *hookdeckgo
return response, nil
}
-func (c *client) DismissIssue(ctx context.Context, id string) (*hookdeckgosdk.Issue, error) {
+func (c *Client) DismissIssue(ctx context.Context, id string) (*hookdeckgosdk.Issue, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -341,7 +333,7 @@ func (c *client) DismissIssue(ctx context.Context, id string) (*hookdeckgosdk.Is
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/issuetriggers/client.go b/issuetriggers/client.go
index a8659f4..c43df70 100644
--- a/issuetriggers/client.go
+++ b/issuetriggers/client.go
@@ -16,36 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetIssueTriggers(ctx context.Context, request *hookdeckgosdk.GetIssueTriggersRequest) (*hookdeckgosdk.IssueTriggerPaginatedResult, error)
- CreateIssueTrigger(ctx context.Context, request *hookdeckgosdk.CreateIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error)
- UpsertIssueTrigger(ctx context.Context, request *hookdeckgosdk.UpsertIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error)
- GetIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error)
- UpdateIssueTrigger(ctx context.Context, id string, request *hookdeckgosdk.UpdateIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error)
- DeleteIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.DeletedIssueTriggerResponse, error)
- DisableIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error)
- EnableIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetIssueTriggers(ctx context.Context, request *hookdeckgosdk.GetIssueTriggersRequest) (*hookdeckgosdk.IssueTriggerPaginatedResult, error) {
+func (c *Client) GetIssueTriggers(ctx context.Context, request *hookdeckgosdk.GetIssueTriggersRequest) (*hookdeckgosdk.IssueTriggerPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -93,14 +82,14 @@ func (c *client) GetIssueTriggers(ctx context.Context, request *hookdeckgosdk.Ge
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -124,7 +113,7 @@ func (c *client) GetIssueTriggers(ctx context.Context, request *hookdeckgosdk.Ge
return response, nil
}
-func (c *client) CreateIssueTrigger(ctx context.Context, request *hookdeckgosdk.CreateIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error) {
+func (c *Client) CreateIssueTrigger(ctx context.Context, request *hookdeckgosdk.CreateIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -143,14 +132,14 @@ func (c *client) CreateIssueTrigger(ctx context.Context, request *hookdeckgosdk.
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -174,7 +163,7 @@ func (c *client) CreateIssueTrigger(ctx context.Context, request *hookdeckgosdk.
return response, nil
}
-func (c *client) UpsertIssueTrigger(ctx context.Context, request *hookdeckgosdk.UpsertIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error) {
+func (c *Client) UpsertIssueTrigger(ctx context.Context, request *hookdeckgosdk.UpsertIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -193,14 +182,14 @@ func (c *client) UpsertIssueTrigger(ctx context.Context, request *hookdeckgosdk.
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -224,7 +213,7 @@ func (c *client) UpsertIssueTrigger(ctx context.Context, request *hookdeckgosdk.
return response, nil
}
-func (c *client) GetIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error) {
+func (c *Client) GetIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -243,7 +232,7 @@ func (c *client) GetIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -267,7 +256,7 @@ func (c *client) GetIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk
return response, nil
}
-func (c *client) UpdateIssueTrigger(ctx context.Context, id string, request *hookdeckgosdk.UpdateIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error) {
+func (c *Client) UpdateIssueTrigger(ctx context.Context, id string, request *hookdeckgosdk.UpdateIssueTriggerRequest) (*hookdeckgosdk.IssueTrigger, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -286,14 +275,14 @@ func (c *client) UpdateIssueTrigger(ctx context.Context, id string, request *hoo
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -317,7 +306,7 @@ func (c *client) UpdateIssueTrigger(ctx context.Context, id string, request *hoo
return response, nil
}
-func (c *client) DeleteIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.DeletedIssueTriggerResponse, error) {
+func (c *Client) DeleteIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.DeletedIssueTriggerResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -336,7 +325,7 @@ func (c *client) DeleteIssueTrigger(ctx context.Context, id string) (*hookdeckgo
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -360,7 +349,7 @@ func (c *client) DeleteIssueTrigger(ctx context.Context, id string) (*hookdeckgo
return response, nil
}
-func (c *client) DisableIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error) {
+func (c *Client) DisableIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -379,7 +368,7 @@ func (c *client) DisableIssueTrigger(ctx context.Context, id string) (*hookdeckg
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -403,7 +392,7 @@ func (c *client) DisableIssueTrigger(ctx context.Context, id string) (*hookdeckg
return response, nil
}
-func (c *client) EnableIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error) {
+func (c *Client) EnableIssueTrigger(ctx context.Context, id string) (*hookdeckgosdk.IssueTrigger, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -422,7 +411,7 @@ func (c *client) EnableIssueTrigger(ctx context.Context, id string) (*hookdeckgo
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/notifications/client.go b/notifications/client.go
index 581e33d..5429337 100644
--- a/notifications/client.go
+++ b/notifications/client.go
@@ -10,31 +10,25 @@ import (
http "net/http"
)
-type Client interface {
- ListCustomDomains(ctx context.Context, teamId string) (hookdeckgosdk.ListCustomDomainSchema, error)
- AddCustomDomain(ctx context.Context, teamId string, request *hookdeckgosdk.AddCustomHostname) (*hookdeckgosdk.AddCustomHostname, error)
- DeleteCustomDomain(ctx context.Context, teamId string, domainId string) (*hookdeckgosdk.DeleteCustomDomainSchema, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) ListCustomDomains(ctx context.Context, teamId string) (hookdeckgosdk.ListCustomDomainSchema, error) {
+func (c *Client) ListCustomDomains(ctx context.Context, teamId string) (hookdeckgosdk.ListCustomDomainSchema, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -58,7 +52,7 @@ func (c *client) ListCustomDomains(ctx context.Context, teamId string) (hookdeck
return response, nil
}
-func (c *client) AddCustomDomain(ctx context.Context, teamId string, request *hookdeckgosdk.AddCustomHostname) (*hookdeckgosdk.AddCustomHostname, error) {
+func (c *Client) AddCustomDomain(ctx context.Context, teamId string, request *hookdeckgosdk.AddCustomHostname) (*hookdeckgosdk.AddCustomHostname, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -82,7 +76,7 @@ func (c *client) AddCustomDomain(ctx context.Context, teamId string, request *ho
return response, nil
}
-func (c *client) DeleteCustomDomain(ctx context.Context, teamId string, domainId string) (*hookdeckgosdk.DeleteCustomDomainSchema, error) {
+func (c *Client) DeleteCustomDomain(ctx context.Context, teamId string, domainId string) (*hookdeckgosdk.DeleteCustomDomainSchema, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
diff --git a/optional.go b/optional.go
new file mode 100644
index 0000000..f2a7b6e
--- /dev/null
+++ b/optional.go
@@ -0,0 +1,22 @@
+// This file was auto-generated by Fern from our API Definition.
+
+package api
+
+import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
+)
+
+// Optional initializes an optional field.
+func Optional[T any](value T) *core.Optional[T] {
+ return &core.Optional[T]{
+ Value: value,
+ }
+}
+
+// Null initializes an optional field that will be sent as
+// an explicit null value.
+func Null[T any]() *core.Optional[T] {
+ return &core.Optional[T]{
+ Null: true,
+ }
+}
diff --git a/requests/client.go b/requests/client.go
index fb9ee05..2440fba 100644
--- a/requests/client.go
+++ b/requests/client.go
@@ -16,34 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetRequests(ctx context.Context, request *hookdeckgosdk.GetRequestsRequest) (*hookdeckgosdk.RequestPaginatedResult, error)
- GetRequest(ctx context.Context, id string) (*hookdeckgosdk.Request, error)
- GetRequestRawBody(ctx context.Context, id string) (*hookdeckgosdk.RawBody, error)
- RetryRequest(ctx context.Context, id string, request *hookdeckgosdk.RetryRequestRequest) (*hookdeckgosdk.RetryRequest, error)
- GetRequestEvents(ctx context.Context, id string, request *hookdeckgosdk.GetRequestEventsRequest) (*hookdeckgosdk.EventPaginatedResult, error)
- GetRequestIgnoredEvents(ctx context.Context, id string, request *hookdeckgosdk.GetRequestIgnoredEventsRequest) (*hookdeckgosdk.IgnoredEventPaginatedResult, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetRequests(ctx context.Context, request *hookdeckgosdk.GetRequestsRequest) (*hookdeckgosdk.RequestPaginatedResult, error) {
+func (c *Client) GetRequests(ctx context.Context, request *hookdeckgosdk.GetRequestsRequest) (*hookdeckgosdk.RequestPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -127,14 +118,14 @@ func (c *client) GetRequests(ctx context.Context, request *hookdeckgosdk.GetRequ
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -158,7 +149,7 @@ func (c *client) GetRequests(ctx context.Context, request *hookdeckgosdk.GetRequ
return response, nil
}
-func (c *client) GetRequest(ctx context.Context, id string) (*hookdeckgosdk.Request, error) {
+func (c *Client) GetRequest(ctx context.Context, id string) (*hookdeckgosdk.Request, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -177,7 +168,7 @@ func (c *client) GetRequest(ctx context.Context, id string) (*hookdeckgosdk.Requ
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -201,7 +192,7 @@ func (c *client) GetRequest(ctx context.Context, id string) (*hookdeckgosdk.Requ
return response, nil
}
-func (c *client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgosdk.RawBody, error) {
+func (c *Client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgosdk.RawBody, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -220,7 +211,7 @@ func (c *client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -244,7 +235,7 @@ func (c *client) GetRequestRawBody(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) RetryRequest(ctx context.Context, id string, request *hookdeckgosdk.RetryRequestRequest) (*hookdeckgosdk.RetryRequest, error) {
+func (c *Client) RetryRequest(ctx context.Context, id string, request *hookdeckgosdk.RetryRequestRequest) (*hookdeckgosdk.RetryRequest, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -263,21 +254,21 @@ func (c *client) RetryRequest(ctx context.Context, id string, request *hookdeckg
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -301,7 +292,7 @@ func (c *client) RetryRequest(ctx context.Context, id string, request *hookdeckg
return response, nil
}
-func (c *client) GetRequestEvents(ctx context.Context, id string, request *hookdeckgosdk.GetRequestEventsRequest) (*hookdeckgosdk.EventPaginatedResult, error) {
+func (c *Client) GetRequestEvents(ctx context.Context, id string, request *hookdeckgosdk.GetRequestEventsRequest) (*hookdeckgosdk.EventPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -406,21 +397,21 @@ func (c *client) GetRequestEvents(ctx context.Context, id string, request *hookd
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -444,7 +435,7 @@ func (c *client) GetRequestEvents(ctx context.Context, id string, request *hookd
return response, nil
}
-func (c *client) GetRequestIgnoredEvents(ctx context.Context, id string, request *hookdeckgosdk.GetRequestIgnoredEventsRequest) (*hookdeckgosdk.IgnoredEventPaginatedResult, error) {
+func (c *Client) GetRequestIgnoredEvents(ctx context.Context, id string, request *hookdeckgosdk.GetRequestIgnoredEventsRequest) (*hookdeckgosdk.IgnoredEventPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -486,21 +477,21 @@ func (c *client) GetRequestIgnoredEvents(ctx context.Context, id string, request
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/sources.go b/sources.go
index 051c655..f9f6599 100644
--- a/sources.go
+++ b/sources.go
@@ -3,6 +3,7 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
@@ -10,10 +11,10 @@ type CreateSourceRequest struct {
// A unique name for the source `<= 155 characters`
Name string `json:"name"`
// Description for the source
- Description *string `json:"description,omitempty"`
- AllowedHttpMethods *SourceAllowedHttpMethod `json:"allowed_http_methods,omitempty"`
- CustomResponse *SourceCustomResponse `json:"custom_response,omitempty"`
- Verification *VerificationConfig `json:"verification,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
+ AllowedHttpMethods *core.Optional[SourceAllowedHttpMethod] `json:"allowed_http_methods,omitempty"`
+ CustomResponse *core.Optional[SourceCustomResponse] `json:"custom_response,omitempty"`
+ Verification *core.Optional[VerificationConfig] `json:"verification,omitempty"`
}
type GetSourceRequest struct {
@@ -34,20 +35,20 @@ type GetSourcesRequest struct {
type UpdateSourceRequest struct {
// A unique name for the source `<= 155 characters`
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
// Description for the source
- Description *string `json:"description,omitempty"`
- AllowedHttpMethods *SourceAllowedHttpMethod `json:"allowed_http_methods,omitempty"`
- CustomResponse *SourceCustomResponse `json:"custom_response,omitempty"`
- Verification *VerificationConfig `json:"verification,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
+ AllowedHttpMethods *core.Optional[SourceAllowedHttpMethod] `json:"allowed_http_methods,omitempty"`
+ CustomResponse *core.Optional[SourceCustomResponse] `json:"custom_response,omitempty"`
+ Verification *core.Optional[VerificationConfig] `json:"verification,omitempty"`
}
type UpsertSourceRequest struct {
// A unique name for the source `<= 155 characters`
Name string `json:"name"`
// Description for the source
- Description *string `json:"description,omitempty"`
- AllowedHttpMethods *SourceAllowedHttpMethod `json:"allowed_http_methods,omitempty"`
- CustomResponse *SourceCustomResponse `json:"custom_response,omitempty"`
- Verification *VerificationConfig `json:"verification,omitempty"`
+ Description *core.Optional[string] `json:"description,omitempty"`
+ AllowedHttpMethods *core.Optional[SourceAllowedHttpMethod] `json:"allowed_http_methods,omitempty"`
+ CustomResponse *core.Optional[SourceCustomResponse] `json:"custom_response,omitempty"`
+ Verification *core.Optional[VerificationConfig] `json:"verification,omitempty"`
}
diff --git a/sources/client.go b/sources/client.go
index 3cecc17..e7d09ce 100644
--- a/sources/client.go
+++ b/sources/client.go
@@ -16,36 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetSources(ctx context.Context, request *hookdeckgosdk.GetSourcesRequest) (*hookdeckgosdk.SourcePaginatedResult, error)
- CreateSource(ctx context.Context, request *hookdeckgosdk.CreateSourceRequest) (*hookdeckgosdk.Source, error)
- UpsertSource(ctx context.Context, request *hookdeckgosdk.UpsertSourceRequest) (*hookdeckgosdk.Source, error)
- GetSource(ctx context.Context, id string, request *hookdeckgosdk.GetSourceRequest) (*hookdeckgosdk.Source, error)
- UpdateSource(ctx context.Context, id string, request *hookdeckgosdk.UpdateSourceRequest) (*hookdeckgosdk.Source, error)
- DeleteSource(ctx context.Context, id string) (*hookdeckgosdk.DeleteSourceResponse, error)
- ArchiveSource(ctx context.Context, id string) (*hookdeckgosdk.Source, error)
- UnarchiveSource(ctx context.Context, id string) (*hookdeckgosdk.Source, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetSources(ctx context.Context, request *hookdeckgosdk.GetSourcesRequest) (*hookdeckgosdk.SourcePaginatedResult, error) {
+func (c *Client) GetSources(ctx context.Context, request *hookdeckgosdk.GetSourcesRequest) (*hookdeckgosdk.SourcePaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -96,14 +85,14 @@ func (c *client) GetSources(ctx context.Context, request *hookdeckgosdk.GetSourc
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -127,7 +116,7 @@ func (c *client) GetSources(ctx context.Context, request *hookdeckgosdk.GetSourc
return response, nil
}
-func (c *client) CreateSource(ctx context.Context, request *hookdeckgosdk.CreateSourceRequest) (*hookdeckgosdk.Source, error) {
+func (c *Client) CreateSource(ctx context.Context, request *hookdeckgosdk.CreateSourceRequest) (*hookdeckgosdk.Source, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -146,14 +135,14 @@ func (c *client) CreateSource(ctx context.Context, request *hookdeckgosdk.Create
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -177,7 +166,7 @@ func (c *client) CreateSource(ctx context.Context, request *hookdeckgosdk.Create
return response, nil
}
-func (c *client) UpsertSource(ctx context.Context, request *hookdeckgosdk.UpsertSourceRequest) (*hookdeckgosdk.Source, error) {
+func (c *Client) UpsertSource(ctx context.Context, request *hookdeckgosdk.UpsertSourceRequest) (*hookdeckgosdk.Source, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -196,14 +185,14 @@ func (c *client) UpsertSource(ctx context.Context, request *hookdeckgosdk.Upsert
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -227,7 +216,7 @@ func (c *client) UpsertSource(ctx context.Context, request *hookdeckgosdk.Upsert
return response, nil
}
-func (c *client) GetSource(ctx context.Context, id string, request *hookdeckgosdk.GetSourceRequest) (*hookdeckgosdk.Source, error) {
+func (c *Client) GetSource(ctx context.Context, id string, request *hookdeckgosdk.GetSourceRequest) (*hookdeckgosdk.Source, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -254,7 +243,7 @@ func (c *client) GetSource(ctx context.Context, id string, request *hookdeckgosd
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -278,7 +267,7 @@ func (c *client) GetSource(ctx context.Context, id string, request *hookdeckgosd
return response, nil
}
-func (c *client) UpdateSource(ctx context.Context, id string, request *hookdeckgosdk.UpdateSourceRequest) (*hookdeckgosdk.Source, error) {
+func (c *Client) UpdateSource(ctx context.Context, id string, request *hookdeckgosdk.UpdateSourceRequest) (*hookdeckgosdk.Source, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -297,21 +286,21 @@ func (c *client) UpdateSource(ctx context.Context, id string, request *hookdeckg
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -335,7 +324,7 @@ func (c *client) UpdateSource(ctx context.Context, id string, request *hookdeckg
return response, nil
}
-func (c *client) DeleteSource(ctx context.Context, id string) (*hookdeckgosdk.DeleteSourceResponse, error) {
+func (c *Client) DeleteSource(ctx context.Context, id string) (*hookdeckgosdk.DeleteSourceResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -354,7 +343,7 @@ func (c *client) DeleteSource(ctx context.Context, id string) (*hookdeckgosdk.De
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -378,7 +367,7 @@ func (c *client) DeleteSource(ctx context.Context, id string) (*hookdeckgosdk.De
return response, nil
}
-func (c *client) ArchiveSource(ctx context.Context, id string) (*hookdeckgosdk.Source, error) {
+func (c *Client) ArchiveSource(ctx context.Context, id string) (*hookdeckgosdk.Source, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -397,7 +386,7 @@ func (c *client) ArchiveSource(ctx context.Context, id string) (*hookdeckgosdk.S
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -421,7 +410,7 @@ func (c *client) ArchiveSource(ctx context.Context, id string) (*hookdeckgosdk.S
return response, nil
}
-func (c *client) UnarchiveSource(ctx context.Context, id string) (*hookdeckgosdk.Source, error) {
+func (c *Client) UnarchiveSource(ctx context.Context, id string) (*hookdeckgosdk.Source, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -440,7 +429,7 @@ func (c *client) UnarchiveSource(ctx context.Context, id string) (*hookdeckgosdk
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
diff --git a/transformations.go b/transformations.go
index da89a51..f1cada8 100644
--- a/transformations.go
+++ b/transformations.go
@@ -3,6 +3,7 @@
package api
import (
+ core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)
@@ -39,23 +40,23 @@ type GetTransformationsRequest struct {
type TestTransformationRequest struct {
// Key-value environment variables to be passed to the transformation
- Env *TestTransformationRequestEnv `json:"env,omitempty"`
+ Env *core.Optional[TestTransformationRequestEnv] `json:"env,omitempty"`
// ID of the connection to use for the execution `context`
- WebhookId *string `json:"webhook_id,omitempty"`
+ WebhookId *core.Optional[string] `json:"webhook_id,omitempty"`
// JavaScript code to be executed
- Code *string `json:"code,omitempty"`
+ Code *core.Optional[string] `json:"code,omitempty"`
// Transformation ID
- TransformationId *string `json:"transformation_id,omitempty"`
+ TransformationId *core.Optional[string] `json:"transformation_id,omitempty"`
// Request input to use for the transformation execution
- Request *TestTransformationRequestRequest `json:"request,omitempty"`
- EventId *string `json:"event_id,omitempty"`
+ Request *core.Optional[TestTransformationRequestRequest] `json:"request,omitempty"`
+ EventId *core.Optional[string] `json:"event_id,omitempty"`
}
type UpdateTransformationRequest struct {
// A unique, human-friendly name for the transformation `<= 155 characters`
- Name *string `json:"name,omitempty"`
+ Name *core.Optional[string] `json:"name,omitempty"`
// JavaScript code to be executed
- Code *string `json:"code,omitempty"`
+ Code *core.Optional[string] `json:"code,omitempty"`
// Key-value environment variables to be passed to the transformation
Env map[string]*UpdateTransformationRequestEnvValue `json:"env,omitempty"`
}
diff --git a/transformations/client.go b/transformations/client.go
index 73574cf..fc07cf3 100644
--- a/transformations/client.go
+++ b/transformations/client.go
@@ -16,36 +16,25 @@ import (
time "time"
)
-type Client interface {
- GetTransformations(ctx context.Context, request *hookdeckgosdk.GetTransformationsRequest) (*hookdeckgosdk.TransformationPaginatedResult, error)
- CreateTransformation(ctx context.Context, request *hookdeckgosdk.CreateTransformationRequest) (*hookdeckgosdk.Transformation, error)
- UpsertTransformation(ctx context.Context, request *hookdeckgosdk.UpsertTransformationRequest) (*hookdeckgosdk.Transformation, error)
- GetTransformation(ctx context.Context, id string) (*hookdeckgosdk.Transformation, error)
- UpdateTransformation(ctx context.Context, id string, request *hookdeckgosdk.UpdateTransformationRequest) (*hookdeckgosdk.Transformation, error)
- TestTransformation(ctx context.Context, request *hookdeckgosdk.TestTransformationRequest) (*hookdeckgosdk.TransformationExecutorOutput, error)
- GetTransformationExecutions(ctx context.Context, id string, request *hookdeckgosdk.GetTransformationExecutionsRequest) (*hookdeckgosdk.TransformationExecutionPaginatedResult, error)
- GetTransformationExecution(ctx context.Context, id string, executionId string) (*hookdeckgosdk.TransformationExecution, error)
+type Client struct {
+ baseURL string
+ httpClient core.HTTPClient
+ header http.Header
}
-func NewClient(opts ...core.ClientOption) Client {
+func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
- return &client{
+ return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}
-type client struct {
- baseURL string
- httpClient core.HTTPClient
- header http.Header
-}
-
-func (c *client) GetTransformations(ctx context.Context, request *hookdeckgosdk.GetTransformationsRequest) (*hookdeckgosdk.TransformationPaginatedResult, error) {
+func (c *Client) GetTransformations(ctx context.Context, request *hookdeckgosdk.GetTransformationsRequest) (*hookdeckgosdk.TransformationPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -90,14 +79,14 @@ func (c *client) GetTransformations(ctx context.Context, request *hookdeckgosdk.
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -121,7 +110,7 @@ func (c *client) GetTransformations(ctx context.Context, request *hookdeckgosdk.
return response, nil
}
-func (c *client) CreateTransformation(ctx context.Context, request *hookdeckgosdk.CreateTransformationRequest) (*hookdeckgosdk.Transformation, error) {
+func (c *Client) CreateTransformation(ctx context.Context, request *hookdeckgosdk.CreateTransformationRequest) (*hookdeckgosdk.Transformation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -140,14 +129,14 @@ func (c *client) CreateTransformation(ctx context.Context, request *hookdeckgosd
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -171,7 +160,7 @@ func (c *client) CreateTransformation(ctx context.Context, request *hookdeckgosd
return response, nil
}
-func (c *client) UpsertTransformation(ctx context.Context, request *hookdeckgosdk.UpsertTransformationRequest) (*hookdeckgosdk.Transformation, error) {
+func (c *Client) UpsertTransformation(ctx context.Context, request *hookdeckgosdk.UpsertTransformationRequest) (*hookdeckgosdk.Transformation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -190,14 +179,14 @@ func (c *client) UpsertTransformation(ctx context.Context, request *hookdeckgosd
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -221,7 +210,7 @@ func (c *client) UpsertTransformation(ctx context.Context, request *hookdeckgosd
return response, nil
}
-func (c *client) GetTransformation(ctx context.Context, id string) (*hookdeckgosdk.Transformation, error) {
+func (c *Client) GetTransformation(ctx context.Context, id string) (*hookdeckgosdk.Transformation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -240,7 +229,7 @@ func (c *client) GetTransformation(ctx context.Context, id string) (*hookdeckgos
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -264,7 +253,7 @@ func (c *client) GetTransformation(ctx context.Context, id string) (*hookdeckgos
return response, nil
}
-func (c *client) UpdateTransformation(ctx context.Context, id string, request *hookdeckgosdk.UpdateTransformationRequest) (*hookdeckgosdk.Transformation, error) {
+func (c *Client) UpdateTransformation(ctx context.Context, id string, request *hookdeckgosdk.UpdateTransformationRequest) (*hookdeckgosdk.Transformation, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -283,21 +272,21 @@ func (c *client) UpdateTransformation(ctx context.Context, id string, request *h
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -321,7 +310,7 @@ func (c *client) UpdateTransformation(ctx context.Context, id string, request *h
return response, nil
}
-func (c *client) TestTransformation(ctx context.Context, request *hookdeckgosdk.TestTransformationRequest) (*hookdeckgosdk.TransformationExecutorOutput, error) {
+func (c *Client) TestTransformation(ctx context.Context, request *hookdeckgosdk.TestTransformationRequest) (*hookdeckgosdk.TransformationExecutorOutput, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -340,14 +329,14 @@ func (c *client) TestTransformation(ctx context.Context, request *hookdeckgosdk.
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -371,7 +360,7 @@ func (c *client) TestTransformation(ctx context.Context, request *hookdeckgosdk.
return response, nil
}
-func (c *client) GetTransformationExecutions(ctx context.Context, id string, request *hookdeckgosdk.GetTransformationExecutionsRequest) (*hookdeckgosdk.TransformationExecutionPaginatedResult, error) {
+func (c *Client) GetTransformationExecutions(ctx context.Context, id string, request *hookdeckgosdk.GetTransformationExecutionsRequest) (*hookdeckgosdk.TransformationExecutionPaginatedResult, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -422,14 +411,14 @@ func (c *client) GetTransformationExecutions(ctx context.Context, id string, req
value := new(hookdeckgosdk.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
case 422:
value := new(hookdeckgosdk.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}
@@ -453,7 +442,7 @@ func (c *client) GetTransformationExecutions(ctx context.Context, id string, req
return response, nil
}
-func (c *client) GetTransformationExecution(ctx context.Context, id string, executionId string) (*hookdeckgosdk.TransformationExecution, error) {
+func (c *Client) GetTransformationExecution(ctx context.Context, id string, executionId string) (*hookdeckgosdk.TransformationExecution, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
@@ -472,7 +461,7 @@ func (c *client) GetTransformationExecution(ctx context.Context, id string, exec
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
- return err
+ return apiError
}
return value
}