diff options
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 + } +} |