Skip to content

Commit

Permalink
feat: update trigger_new_sales.go file
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymesC committed Jul 22, 2024
1 parent fae3948 commit 588c9f3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions internal/connectors/cin7/trigger_new_sales.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,15 @@ func (t *TriggerNewSales) Run(ctx *sdk.RunContext) (sdk.JSON, error) {
applicationKey := ctx.Auth.Extra["key"]

lastRunTime := ctx.Metadata.LastRun
if lastRunTime == nil {
defaultTime := time.Now().Add(-24 * time.Hour).Format(time.RFC3339)
parsedTime, err := time.Parse(time.RFC3339, defaultTime)
if err != nil {
log.Fatalf("Error parsing default time: %v", err)
}
lastRunTime = &parsedTime

var fromDate string
if lastRunTime != nil {
fromDate = lastRunTime.Format(time.RFC3339)
}

queryParams := map[string]interface{}{
"Page": "1",
"Limit": "100",
"CreatedSince": lastRunTime.Format(time.RFC3339),
"Page": 1,
"CreatedSince": fromDate,
}

response, err := fetchData(endpoint, accountID, applicationKey, queryParams)
Expand Down

0 comments on commit 588c9f3

Please sign in to comment.