aboutsummaryrefslogtreecommitdiffstats
path: root/lulu.go
diff options
context:
space:
mode:
Diffstat (limited to 'lulu.go')
-rw-r--r--lulu.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/lulu.go b/lulu.go
index 64fd1fc..643b65d 100644
--- a/lulu.go
+++ b/lulu.go
@@ -315,10 +315,30 @@ func (c *Client) GetPrintJob(id uint64) (PrintJob, error) {
//
// https://api.lulu.com/docs/#tag/Print-Jobs/operation/Print-Jobs_create
func (c *Client) Print(contact EmailAddress, externalId string, productionDelay time.Duration, addr ShippingAddress, shipOpt ShippingLevel, items []Printable) (PrintJob, error) {
+ job, err := print(c, contact, externalId, productionDelay, addr, shipOpt, items)
+ if err != nil {
+ err = pkgErr(err)
+ }
+ return job, err
+}
+
+// Reprint creates a print job, printing books whose PrintableIds are
+// known from a prior order. See also: Print().
+//
+// https://api.lulu.com/docs/#tag/Print-Jobs/operation/Print-Jobs_reprint
+func (c *Client) Reprint(contact EmailAddress, externalId string, productionDelay time.Duration, addr ShippingAddress, shipOpt ShippingLevel, items []Reprintable) (PrintJob, error) {
+ job, err := print(c, contact, externalId, productionDelay, addr, shipOpt, items)
+ if err != nil {
+ err = pkgErr(err)
+ }
+ return job, err
+}
+
+func print[P Printable | Reprintable](c *Client, contact EmailAddress, externalId string, productionDelay time.Duration, addr ShippingAddress, shipOpt ShippingLevel, items []P) (PrintJob, error) {
if err := verifyProductionDelay(productionDelay); err != nil {
- return PrintJob{}, pkgErr(err)
+ return PrintJob{}, err
}
- req := printReq[Printable]{
+ req := printReq[P]{
Contact: contact,
ExternalId: externalId,
LineItems: items,
@@ -328,10 +348,7 @@ func (c *Client) Print(contact EmailAddress, externalId string, productionDelay
}
var job PrintJob
err := c.postDecode(printJobsPath, req, http.StatusCreated, &job)
- if err != nil {
- return job, pkgErr(err)
- }
- return job, nil
+ return job, err
}
func verifyProductionDelay(delay time.Duration) error {