Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Unmarshaling error for Event creation & Feature - Include filtering options for Subscription API #45

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,32 @@ func (e *Event) All(ctx context.Context, query *EventParams) (*ListEventResponse
return respPtr, nil
}

func (e *Event) Create(ctx context.Context, body *CreateEventRequest) (*EventResponse, error) {
func (e *Event) Create(ctx context.Context, body *CreateEventRequest) error {
url, err := addOptions(e.generateUrl(), nil)
if err != nil {
return nil, err
return err
}

respPtr := &EventResponse{}
err = postJSON(ctx, e.client, url, body, respPtr)
err = postJSON(ctx, e.client, url, body, nil)
if err != nil {
return nil, err
return err
}

return respPtr, nil
return nil
}

func (e *Event) FanoutEvent(ctx context.Context, body *CreateFanoutEventRequest) (*EventResponse, error) {
func (e *Event) FanoutEvent(ctx context.Context, body *CreateFanoutEventRequest) error {
url, err := addOptions(e.generateUrl()+"/fanout", nil)
if err != nil {
return nil, err
return err
}

respPtr := &EventResponse{}
err = postJSON(ctx, e.client, url, body, respPtr)
err = postJSON(ctx, e.client, url, body, nil)
if err != nil {
return nil, err
return err
}

return respPtr, nil
return nil
}

func (e *Event) Find(ctx context.Context, eventID string) (*EventResponse, error) {
Expand Down
6 changes: 6 additions & 0 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ type RetryConfiguration struct {
RetryCount int `json:"retry_count"`
}

type Filter struct {
Body map[string]interface{} `json:"body"`
Headers map[string]interface{} `json:"headers"`
}

type FilterConfiguration struct {
EventTypes []string `json:"event_types" bson:"event_types,omitempty"`
Filter Filter `json:"filter" bson:"filter,omitempty"`
}

type SubscriptionResponse struct {
Expand Down
Loading