From daaa03d83a90977c32a91e5b7ec3abcecc1bfee3 Mon Sep 17 00:00:00 2001 From: Subomi Oluwalana Date: Thu, 3 Oct 2024 18:09:55 +0100 Subject: [PATCH] feat: added broadcast method for sending events --- event.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/event.go b/event.go index b832de8..0ce425b 100644 --- a/event.go +++ b/event.go @@ -33,6 +33,13 @@ type CreateFanoutEventRequest struct { Data json.RawMessage `json:"data"` } +type CreateBroadcastEventRequest struct { + EventType string `json:"event_type"` + CustomHeaders map[string]string `json:"custom_headers"` + IdempotencyKey string `json:"idempotency_key"` + Data json.RawMessage `json:"data"` +} + type CreateDynamicEventRequest struct { Endpoint string `json:"endpoint"` Subscription string `json:"subscription"` @@ -120,6 +127,20 @@ func (e *Event) FanoutEvent(ctx context.Context, body *CreateFanoutEventRequest) return nil } +func (e *Event) BroadcastEvent(ctx context.Context, body *CreateBroadcastEventRequest) error { + url, err := addOptions(e.generateUrl()+"/broadcast", nil) + if err != nil { + return err + } + + err = postJSON(ctx, e.client, url, body, nil) + if err != nil { + return err + } + + return nil +} + func (e *Event) Find(ctx context.Context, eventID string) (*EventResponse, error) { url, err := addOptions(e.generateUrl()+"/"+eventID, nil) if err != nil {