From e39f8f5b075b67ae3c63cc3ee7c5b7e81271b530 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sat, 16 May 2026 14:04:39 -0400 Subject: reprint --- lulu.go | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'lulu.go') 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 { -- cgit v1.2.3