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

feat: added idempotency key to event params #49

Merged
merged 1 commit into from
Sep 8, 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
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
Loading