Skip to content

Commit

Permalink
fix: typo in webhook.EventTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgacsal committed Oct 1, 2024
1 parent 70c112d commit db06a75
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions openmeter/notification/webhook/svix.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ func newSvixWebhookHandler(config SvixConfig) (Handler, error) {
}

func (h svixWebhookHandler) RegisterEventTypes(ctx context.Context, params RegisterEventTypesInputs) error {
for _, evenType := range params.EvenTypes {
for _, eventType := range params.EventTypes {
input := &svix.EventTypeUpdate{
Description: evenType.Description,
Description: eventType.Description,
FeatureFlag: *svix.NullableString(nil),
GroupName: *svix.NullableString(&evenType.GroupName),
Schemas: evenType.Schemas,
GroupName: *svix.NullableString(&eventType.GroupName),
Schemas: eventType.Schemas,
}

_, err := h.client.EventType.Update(ctx, evenType.Name, input)
_, err := h.client.EventType.Update(ctx, eventType.Name, input)
if err != nil {
err = unwrapSvixError(err)

Expand Down
12 changes: 6 additions & 6 deletions openmeter/notification/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (i SendMessageInput) Validate() error {
}

type RegisterEventTypesInputs struct {
EvenTypes []EventType
EventTypes []EventType
AllowUpdate bool
}

Expand Down Expand Up @@ -271,7 +271,7 @@ const (
type Config struct {
SvixConfig

RegisterEvenTypes []EventType
RegisterEventTypes []EventType
RegistrationTimeout time.Duration
SkipRegistrationOnError bool

Expand All @@ -283,8 +283,8 @@ func New(config Config) (Handler, error) {
return nil, errors.New("logger is required")
}

if config.RegisterEvenTypes == nil {
config.RegisterEvenTypes = NotificationEventTypes
if config.RegisterEventTypes == nil {
config.RegisterEventTypes = NotificationEventTypes
}

if config.RegistrationTimeout == 0 {
Expand All @@ -296,12 +296,12 @@ func New(config Config) (Handler, error) {
return nil, fmt.Errorf("failed to initialize Svix webhook handler: %w", err)
}

if len(config.RegisterEvenTypes) > 0 {
if len(config.RegisterEventTypes) > 0 {
ctx, cancel := context.WithTimeout(context.Background(), config.RegistrationTimeout)
defer cancel()

err = handler.RegisterEventTypes(ctx, RegisterEventTypesInputs{
EvenTypes: config.RegisterEvenTypes,
EventTypes: config.RegisterEventTypes,
})
if err != nil {
if config.SkipRegistrationOnError {
Expand Down
2 changes: 1 addition & 1 deletion test/notification/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type WebhookTestSuite struct {

func (s *WebhookTestSuite) Setup(ctx context.Context, t *testing.T) {
err := s.Env.NotificationWebhook().RegisterEventTypes(ctx, notificationwebhook.RegisterEventTypesInputs{
EvenTypes: notificationwebhook.NotificationEventTypes,
EventTypes: notificationwebhook.NotificationEventTypes,
})
assert.NoError(t, err, "Registering event types must not fail")
}
Expand Down

0 comments on commit db06a75

Please sign in to comment.