Skip to content

Commit

Permalink
Merge pull request #49 from frain-dev/subomi/fix/patch-idempotency-ke…
Browse files Browse the repository at this point in the history
…y-on-event-params

feat: added idempotency key to event params
  • Loading branch information
subomi authored Sep 8, 2024
2 parents ad5d77d + b93455e commit dde519a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
11 changes: 6 additions & 5 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ type ListEventResponse struct {

type EventParams struct {
ListParams
Query string `url:"query"`
SourceID string `url:"sourceId"`
EndpointID []string `url:"endpointId"`
StartDate time.Time `url:"startDate" layout:"2006-01-02T15:04:05"`
EndDate time.Time `url:"endDate" layout:"2006-01-02T15:04:05"`
Query string `url:"query"`
IdempotencyKey string `url:"idempotencyKey"`
SourceID string `url:"sourceId"`
EndpointID []string `url:"endpointId"`
StartDate time.Time `url:"startDate" layout:"2006-01-02T15:04:05"`
EndDate time.Time `url:"endDate" layout:"2006-01-02T15:04:05"`
}

type BatchReplayOptions struct {
Expand Down
23 changes: 12 additions & 11 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

const (
URL = "http://localhost:5005/api/v1"
projectID = "01HS1672A88250D57J8SZV4P3A"
projectID = "01J6WQ1D48XW1JDV5Y7GZ6HAH6"
endpointID = "01HCB4CWTVAVWWJDJEASHGXPA6"
apiKey = "CO.tsmEVYn1muY1pU9t.wOB1pNEP92gnjlV7BUYz944TK9dRyYRvEzp9AR6jLy0r9Dk8WIqZ0JUhJuNq0IRm"
apiKey = "CO.94y8aWryXhkkT2fP.o5OhQAana2hq2R9onWvAN805kbHDVHLXu9nYcPec3IDAoJ9sj462ot8CbtIHxSZI"
kUsername = "k-username"
kPassword = "k-password"
awsKey = "aws-key"
Expand All @@ -38,15 +38,15 @@ func main() {
//fmt.Println("Retrieving all endpoints")
//retrieveAllEndpoints(ctx, c)

//fmt.Println("Retrieveing all events")
//retrieveAllEvents(ctx, c)
fmt.Println("Retrieveing all events")
retrieveAllEvents(ctx, c)

fmt.Println("creating portal link")
createPortalLink(ctx, c)
//fmt.Println("creating portal link")
//createPortalLink(ctx, c)
}

func createEvent(ctx context.Context, c *convoy.Client) {
event, err := c.Events.Create(ctx, &convoy.CreateEventRequest{
err := c.Events.Create(ctx, &convoy.CreateEventRequest{
EndpointID: endpointID,
EventType: "test.customer.event",
Data: []byte(`{"event_type": "test.event", "data": { "Hello": "World", "Test": "Data" }}`),
Expand All @@ -57,8 +57,8 @@ func createEvent(ctx context.Context, c *convoy.Client) {
return
}

log.Printf("\nEndpoint event created - %+v\n", event)
log.Printf("\nEndpoint event data - %+v\n", string(event.Data))
//log.Printf("\nEndpoint event created - %+v\n", event)
//log.Printf("\nEndpoint event data - %+v\n", string(event.Data))
}

func createEndpoint(ctx context.Context, c *convoy.Client) {
Expand Down Expand Up @@ -98,8 +98,9 @@ func retrieveAllEndpoints(ctx context.Context, c *convoy.Client) {

func retrieveAllEvents(ctx context.Context, c *convoy.Client) {
query := &convoy.EventParams{
StartDate: time.Now().Add(time.Duration(-24) * time.Hour),
EndDate: time.Now(),
IdempotencyKey: "subomi-new",
StartDate: time.Now().Add(time.Duration(-24) * time.Hour).UTC(),
EndDate: time.Now().UTC(),
}
events, err := c.Events.All(ctx, query)
if err != nil {
Expand Down

0 comments on commit dde519a

Please sign in to comment.