diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-16 14:04:39 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-16 14:04:39 -0400 |
| commit | e39f8f5b075b67ae3c63cc3ee7c5b7e81271b530 (patch) | |
| tree | 9fd0aa2204ba5af2bc8b1d9ce0a1848f35a18f78 /lulu.go | |
| parent | 45914474e6d25b97e51f7858ddb5c78438d386d7 (diff) | |
| download | lulu-e39f8f5b075b67ae3c63cc3ee7c5b7e81271b530.zip | |
reprint
Diffstat (limited to 'lulu.go')
| -rw-r--r-- | lulu.go | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -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 { |