Skip to content

Commit

Permalink
go: Move openapi re-exports to svix.go (#1629)
Browse files Browse the repository at this point in the history
… and a small fix for a warning I got locally

Part of svix/monorepo-private#9576.
  • Loading branch information
svix-jplatte authored Jan 9, 2025
2 parents 5c864fd + df69adb commit 59170d7
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 100 deletions.
7 changes: 0 additions & 7 deletions go/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import (
"github.com/svix/svix-webhooks/go/internal/openapi"
)

type (
ListResponseApplicationOut = openapi.ListResponseApplicationOut
ApplicationIn = openapi.ApplicationIn
ApplicationOut = openapi.ApplicationOut
ApplicationPatch = openapi.ApplicationPatch
)

type Application struct {
api *openapi.APIClient
}
Expand Down
6 changes: 0 additions & 6 deletions go/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ type Authentication struct {
api *openapi.APIClient
}

type (
AppPortalAccessIn = openapi.AppPortalAccessIn
AppPortalAccessOut = openapi.AppPortalAccessOut
DashboardAccessOut = openapi.DashboardAccessOut
)

func (a *Authentication) AppPortalAccess(ctx context.Context, appId string, appPortalAccessIn *AppPortalAccessIn) (*AppPortalAccessOut, error) {
return a.AppPortalAccessWithOptions(ctx, appId, appPortalAccessIn, nil)
}
Expand Down
9 changes: 2 additions & 7 deletions go/backgroundtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import (
"github.com/svix/svix-webhooks/go/internal/openapi"
)

type (
ListResponseBackgroundTaskOut = openapi.ListResponseBackgroundTaskOut
BackgroundTaskOut = openapi.BackgroundTaskOut
)

type BackgroundTask struct {
api *openapi.APIClient
}
Expand All @@ -19,8 +14,8 @@ type BackgroundTaskListOptions struct {
Iterator *string
Limit *int32
Order *Ordering
Status *openapi.BackgroundTaskStatus
Task *openapi.BackgroundTaskType
Status *BackgroundTaskStatus
Task *BackgroundTaskType
}

func (a *BackgroundTask) List(ctx context.Context, options *BackgroundTaskListOptions) (*ListResponseBackgroundTaskOut, error) {
Expand Down
22 changes: 0 additions & 22 deletions go/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,6 @@ import (
"github.com/svix/svix-webhooks/go/internal/openapi"
)

type (
ListResponseEndpointOut = openapi.ListResponseEndpointOut
EndpointIn = openapi.EndpointIn
EndpointUpdate = openapi.EndpointUpdate
EndpointOut = openapi.EndpointOut
EndpointPatch = openapi.EndpointPatch
EndpointSecretOut = openapi.EndpointSecretOut
EndpointSecretRotateIn = openapi.EndpointSecretRotateIn
EndpointTransformationIn = openapi.EndpointTransformationIn
RecoverIn = openapi.RecoverIn
ReplayIn = openapi.ReplayIn
EndpointHeadersIn = openapi.EndpointHeadersIn
EndpointHeadersPatchIn = openapi.EndpointHeadersPatchIn
EndpointHeadersOut = openapi.EndpointHeadersOut
EndpointStats = openapi.EndpointStats
EndpointTransformationOut = openapi.EndpointTransformationOut
EventExampleIn = openapi.EventExampleIn
Ordering = openapi.Ordering
RecoverOut = openapi.RecoverOut
ReplayOut = openapi.ReplayOut
)

type Endpoint struct {
api *openapi.APIClient
}
Expand Down
11 changes: 0 additions & 11 deletions go/event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ type EventType struct {
api *openapi.APIClient
}

type (
ListResponseEventTypeOut = openapi.ListResponseEventTypeOut
EventTypeIn = openapi.EventTypeIn
EventTypeOut = openapi.EventTypeOut
EventTypePatch = openapi.EventTypePatch
EventTypeUpdate = openapi.EventTypeUpdate
EventTypeImportOpenApiIn = openapi.EventTypeImportOpenApiIn
EventTypeImportOpenApiOut = openapi.EventTypeImportOpenApiOut
EventTypeImportOpenApiOutData = openapi.EventTypeImportOpenApiOutData
)

type EventTypeListOptions struct {
// Limit the number of returned items
Limit *int32
Expand Down
8 changes: 0 additions & 8 deletions go/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import (
"github.com/svix/svix-webhooks/go/internal/openapi"
)

type (
ListResponseIntegrationOut = openapi.ListResponseIntegrationOut
IntegrationIn = openapi.IntegrationIn
IntegrationUpdate = openapi.IntegrationUpdate
IntegrationOut = openapi.IntegrationOut
IntegrationKeyOut = openapi.IntegrationKeyOut
)

type Integration struct {
api *openapi.APIClient
}
Expand Down
6 changes: 0 additions & 6 deletions go/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ type Message struct {
api *openapi.APIClient
}

type (
ListResponseMessageOut = openapi.ListResponseMessageOut
MessageIn = openapi.MessageIn
MessageOut = openapi.MessageOut
)

type MessageListOptions struct {
// Limit the number of returned items
Limit *int32
Expand Down
13 changes: 0 additions & 13 deletions go/message_attempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ type MessageAttempt struct {
api *openapi.APIClient
}

type (
MessageStatus = openapi.MessageStatus
StatusCodeClass = openapi.StatusCodeClass
ListResponseMessageAttemptOut = openapi.ListResponseMessageAttemptOut
MessageAttemptOut = openapi.MessageAttemptOut
ListResponseEndpointMessageOut = openapi.ListResponseEndpointMessageOut
EndpointMessageOut = openapi.EndpointMessageOut
ListResponseMessageEndpointOut = openapi.ListResponseMessageEndpointOut
MessageEndpointOut = openapi.MessageEndpointOut
ListResponseMessageAttemptEndpointOut = openapi.ListResponseMessageAttemptEndpointOut
MessageAttemptEndpointOut = openapi.MessageAttemptEndpointOut
)

type MessageAttemptListOptions struct {
Iterator *string
Limit *int32
Expand Down
9 changes: 0 additions & 9 deletions go/operational_webhook_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ import (
"github.com/svix/svix-webhooks/go/internal/openapi"
)

type (
ListResponseOperationalWebhookEndpointOut = openapi.ListResponseOperationalWebhookEndpointOut
OperationalWebhookEndpointIn = openapi.OperationalWebhookEndpointIn
OperationalWebhookEndpointUpdate = openapi.OperationalWebhookEndpointUpdate
OperationalWebhookEndpointOut = openapi.OperationalWebhookEndpointOut
OperationalWebhookEndpointSecretOut = openapi.OperationalWebhookEndpointSecretOut
OperationalWebhookEndpointSecretIn = openapi.OperationalWebhookEndpointSecretIn
)

type OperationalWebhookEndpoint struct {
api *openapi.APIClient
}
Expand Down
6 changes: 0 additions & 6 deletions go/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ type Statistics struct {
api *openapi.APIClient
}

type (
AppUsageStatsIn = openapi.AppUsageStatsIn
AppUsageStatsOut = openapi.AppUsageStatsOut
AggregateEventTypesOut = openapi.AggregateEventTypesOut
)

func (s *Statistics) AggregateAppStats(ctx context.Context, appUsageStatsIn *AppUsageStatsIn, options *PostOptions) (*AppUsageStatsOut, error) {
req := s.api.StatisticsAPI.V1StatisticsAggregateAppStats(ctx)
if appUsageStatsIn != nil {
Expand Down
65 changes: 65 additions & 0 deletions go/svix.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,71 @@ type (
Statistics *Statistics
OperationalWebhookEndpoint *OperationalWebhookEndpoint
}
AggregateEventTypesOut = openapi.AggregateEventTypesOut
ApplicationIn = openapi.ApplicationIn
ApplicationOut = openapi.ApplicationOut
ApplicationPatch = openapi.ApplicationPatch
AppPortalAccessIn = openapi.AppPortalAccessIn
AppPortalAccessOut = openapi.AppPortalAccessOut
AppUsageStatsIn = openapi.AppUsageStatsIn
AppUsageStatsOut = openapi.AppUsageStatsOut
BackgroundTaskOut = openapi.BackgroundTaskOut
BackgroundTaskStatus = openapi.BackgroundTaskStatus
BackgroundTaskType = openapi.BackgroundTaskType
DashboardAccessOut = openapi.DashboardAccessOut
EndpointHeadersIn = openapi.EndpointHeadersIn
EndpointHeadersOut = openapi.EndpointHeadersOut
EndpointHeadersPatchIn = openapi.EndpointHeadersPatchIn
EndpointIn = openapi.EndpointIn
EndpointMessageOut = openapi.EndpointMessageOut
EndpointOut = openapi.EndpointOut
EndpointPatch = openapi.EndpointPatch
EndpointSecretOut = openapi.EndpointSecretOut
EndpointSecretRotateIn = openapi.EndpointSecretRotateIn
EndpointStats = openapi.EndpointStats
EndpointTransformationIn = openapi.EndpointTransformationIn
EndpointTransformationOut = openapi.EndpointTransformationOut
EndpointUpdate = openapi.EndpointUpdate
EventExampleIn = openapi.EventExampleIn
EventTypeImportOpenApiIn = openapi.EventTypeImportOpenApiIn
EventTypeImportOpenApiOut = openapi.EventTypeImportOpenApiOut
EventTypeImportOpenApiOutData = openapi.EventTypeImportOpenApiOutData
EventTypeIn = openapi.EventTypeIn
EventTypeOut = openapi.EventTypeOut
EventTypePatch = openapi.EventTypePatch
EventTypeUpdate = openapi.EventTypeUpdate
IntegrationIn = openapi.IntegrationIn
IntegrationKeyOut = openapi.IntegrationKeyOut
IntegrationOut = openapi.IntegrationOut
IntegrationUpdate = openapi.IntegrationUpdate
ListResponseApplicationOut = openapi.ListResponseApplicationOut
ListResponseBackgroundTaskOut = openapi.ListResponseBackgroundTaskOut
ListResponseEndpointMessageOut = openapi.ListResponseEndpointMessageOut
ListResponseEndpointOut = openapi.ListResponseEndpointOut
ListResponseEventTypeOut = openapi.ListResponseEventTypeOut
ListResponseIntegrationOut = openapi.ListResponseIntegrationOut
ListResponseMessageAttemptEndpointOut = openapi.ListResponseMessageAttemptEndpointOut
ListResponseMessageAttemptOut = openapi.ListResponseMessageAttemptOut
ListResponseMessageEndpointOut = openapi.ListResponseMessageEndpointOut
ListResponseMessageOut = openapi.ListResponseMessageOut
ListResponseOperationalWebhookEndpointOut = openapi.ListResponseOperationalWebhookEndpointOut
MessageAttemptEndpointOut = openapi.MessageAttemptEndpointOut
MessageAttemptOut = openapi.MessageAttemptOut
MessageEndpointOut = openapi.MessageEndpointOut
MessageIn = openapi.MessageIn
MessageOut = openapi.MessageOut
MessageStatus = openapi.MessageStatus
OperationalWebhookEndpointIn = openapi.OperationalWebhookEndpointIn
OperationalWebhookEndpointOut = openapi.OperationalWebhookEndpointOut
OperationalWebhookEndpointSecretIn = openapi.OperationalWebhookEndpointSecretIn
OperationalWebhookEndpointSecretOut = openapi.OperationalWebhookEndpointSecretOut
OperationalWebhookEndpointUpdate = openapi.OperationalWebhookEndpointUpdate
Ordering = openapi.Ordering
RecoverIn = openapi.RecoverIn
RecoverOut = openapi.RecoverOut
ReplayIn = openapi.ReplayIn
ReplayOut = openapi.ReplayOut
StatusCodeClass = openapi.StatusCodeClass
)

var defaultHTTPClient = &http.Client{
Expand Down
10 changes: 5 additions & 5 deletions go/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const webhookSecretPrefix = "whsec_"
var tolerance time.Duration = 5 * time.Minute

var (
errRequiredHeaders = fmt.Errorf("Missing Required Headers")
errInvalidHeaders = fmt.Errorf("Invalid Signature Headers")
errNoMatchingSignature = fmt.Errorf("No matching signature found")
errMessageTooOld = fmt.Errorf("Message timestamp too old")
errMessageTooNew = fmt.Errorf("Message timestamp too new")
errRequiredHeaders = fmt.Errorf("missing required headers")
errInvalidHeaders = fmt.Errorf("invalid signature headers")
errNoMatchingSignature = fmt.Errorf("no matching signature found")
errMessageTooOld = fmt.Errorf("message timestamp too old")
errMessageTooNew = fmt.Errorf("message timestamp too new")
)

func NewWebhook(secret string) (*Webhook, error) {
Expand Down

0 comments on commit 59170d7

Please sign in to comment.