From 965bdb704bbc4db5f73c7f180ffb6f9b1ca2c7b6 Mon Sep 17 00:00:00 2001 From: lil-sahil Date: Sat, 15 Jun 2024 20:40:34 -0400 Subject: [PATCH 1/2] Fixed the unmarshaling error which was occuring when a single event or a fanout event was created. The issue was occuring due to the fact that the APIResponse from these two endpoints results in a null value being returned for the data field. This resulted in an unmarshaling error in the parseAPIResponse function. --- event.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/event.go b/event.go index be09989..439aa05 100644 --- a/event.go +++ b/event.go @@ -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) { From e151c963ce9287674d2f502b1637c69738127c53 Mon Sep 17 00:00:00 2001 From: lil-sahil Date: Sat, 15 Jun 2024 21:52:45 -0400 Subject: [PATCH 2/2] Enhance Subscription API to include additional filtering options. --- subscription.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subscription.go b/subscription.go index cda49d2..fdf9646 100644 --- a/subscription.go +++ b/subscription.go @@ -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 {