Skip to content

Commit

Permalink
Fixed the unmarshaling error which was occuring when a single event o…
Browse files Browse the repository at this point in the history
…r 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.
  • Loading branch information
lil-sahil committed Jun 16, 2024
1 parent 75e9217 commit 965bdb7
Showing 1 changed file with 10 additions and 12 deletions.
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

0 comments on commit 965bdb7

Please sign in to comment.