diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-12 15:35:06 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-12 15:37:29 -0400 |
| commit | 9010ebe8a581fb9db7bc6e97d40ff062fb18495f (patch) | |
| tree | 4301a455762a59d4951507c8a8781e99c6f91c6d /query.go | |
| parent | 329257be8d9fb05d3dcea49823acea0f878ed52c (diff) | |
| download | lulu-9010ebe8a581fb9db7bc6e97d40ff062fb18495f.zip | |
unmarshal GET /print-jobs response
Diffstat (limited to 'query.go')
| -rw-r--r-- | query.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/query.go b/query.go new file mode 100644 index 0000000..cf56bdd --- /dev/null +++ b/query.go @@ -0,0 +1,76 @@ +package lulu + +import "time" + +type printJobQueries struct { + creatAfter, creatBefore, modAfter, modBefore *time.Time + status *OrderStatus + id, orderId *uint + excludeLineItems bool +} + +func parsePrintJobQueries(qs []PrintJobQuery) printJobQueries { + var q printJobQueries + for i := range qs { + qs[i](&q) + } + return q +} + +type PrintJobQuery func(*printJobQueries) + +// Include only print jobs created after t. +func FilterCreatedAfter(t time.Time) PrintJobQuery { + return func(q *printJobQueries) { + q.creatAfter = &t + } +} + +// Include only print jobs created before t. +func FilterCreatedBefore(t time.Time) PrintJobQuery { + return func(q *printJobQueries) { + q.creatBefore = &t + } +} + +// Include only print jobs modified after t. +func FilterModifiedAfter(t time.Time) PrintJobQuery { + return func(q *printJobQueries) { + q.modAfter = &t + } +} + +// Include only print jobs modified before t. +func FilterModifiedBefore(t time.Time) PrintJobQuery { + return func(q *printJobQueries) { + q.modBefore = &t + } +} + +// Include only print jobs with status s. +func FilterStatus(s OrderStatus) PrintJobQuery { + return func(q *printJobQueries) { + q.status = &s + } +} + +// Include only print jobs with the given id. +func FilterId(id uint) PrintJobQuery { + return func(q *printJobQueries) { + q.id = &id + } +} + +// Include only print jobs with the given order_id. +func FilterOrderId(orderId uint) PrintJobQuery { + return func(q *printJobQueries) { + q.orderId = &orderId + } +} + +// Leave the list of line items out of the print jobs response. +func ExcludeLineItems() PrintJobQuery { + return func(q *printJobQueries) { + q.excludeLineItems = true + } +} |