package sentio import ( "fmt" "strings" "time" ) type OrderListCriteria struct { Status string Limit uint Symbols []string After *time.Time Until *time.Time Side *string } func (criteria OrderListCriteria) Values() map[string]string { var values = make(map[string]string) if criteria.Limit < 1 { criteria.Limit = 500 } if criteria.Symbols != nil && len(criteria.Symbols) > 0 { values["symbols"] = strings.Join(criteria.Symbols, ",") } if criteria.After == nil { t := time.Now().Add(-time.Hour * 24).Round(time.Hour * 24) criteria.After = &t } if criteria.Until != nil && !criteria.Until.IsZero() { values["until"] = criteria.Until.In(time.UTC).Format(time.RFC3339) } if criteria.Side != nil { values["side"] = *criteria.Side } values["status"] = "all" values["nested"] = "true" values["limit"] = fmt.Sprintf("%d", criteria.Limit) values["after"] = criteria.After.In(time.UTC).Format(time.RFC3339) values["direction"] = "asc" return values }