From 56523fc6a304c09f252449342b10c52f7836c4aa Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Wed, 13 May 2026 10:44:57 -0400 Subject: create print job --- print.go | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 9 deletions(-) (limited to 'print.go') diff --git a/print.go b/print.go index 4302e6e..8532fff 100644 --- a/print.go +++ b/print.go @@ -11,6 +11,47 @@ const ( MaxProductionDelay = 48 * time.Hour ) +type printReq struct { + Contact EmailAddress `json:"contact_email"` + ExternalId string `json:"external_id"` + LineItems []Printable `json:"line_items"` + ProductionDelayMins uint `json:"production_delay"` + ShipAddr ShippingAddress `json:"shipping_address"` + ShipOpt ShippingLevel `json:"shipping_level"` +} + +// PrintableId uniquely identifies a book to be printed: a "printable". A +// printable consists of a cover and an interior file as well as a +// PodPkgId which specifies the manufacturing options. +type PrintableId string + +// Printable is a book to be printed. +type Printable struct { + // Arbitrary string to identify and connect a print job to your + // systems. Set it to an order number, a purchase order or + // whatever else works for your particular use case. + ExternalId string `json:"external_id"` + + // Interior and cover files have to be specified with a URL from + // which Lulu can download the files. Using encoded basic + // authentication in the URL is ok. All files processed by Lulu + // will be validated and normalized before sending them to + // production. If problems with the file occur, the PrintJob will + // be rejected or cancelled and an error message will be + // displayed. + CoverUrl string `json:"cover"` + InteriorUrl string `json:"interior"` + + // Manufacturing options. + Mfg PkgId `json:"pod_package_id"` + + // The number of copies to print. + Quantity uint `json:"quantity"` + + // The title of the book. Must not exceed 255 bytes. + Title string `json:"title"` +} + type getPrintJobsResp struct { Count uint `json:"count"` Next string `json:"next"` @@ -60,6 +101,8 @@ type PrintJob struct { // ISO 3166-1 alpha-2 country code of the tax country determined for this job TaxCountry string `json:"tax_country"` + + Status PrintJobStatus `json:"status"` } func (pj *PrintJob) UnmarshalJSON(data []byte) error { @@ -77,13 +120,7 @@ func (pj *PrintJob) UnmarshalJSON(data []byte) error { return nil } -type EstimatedShippingDates struct { - ArrivalMax Date `json:"arrival_max"` - ArrivalMin Date `json:"arrival_min"` - DispatchMax Date `json:"dispatch_max"` - DispatchMin Date `json:"dispatch_min"` -} - +// LineItem represents a book that should be printed: a "printable" for short. type LineItem struct { // Arbitrary string to identify and connect a print job to your // systems. Set it to an order number, a purchase order or @@ -98,7 +135,7 @@ type LineItem struct { Mfg PkgId `json:"pod_package_id"` // Id of the printable. It can be used instead of PrintableNormalization. - PrintableId string `json:"printable_id"` + PrintableId PrintableId `json:"printable_id"` // Normalization process of the cover and interior source files. PrintableNormalization PrintableNormalization `json:"printable_normalization"` @@ -121,6 +158,13 @@ type LineItem struct { Carrier string `json:"carrier_name"` } +type EstimatedShippingDates struct { + ArrivalMax Date `json:"arrival_max"` + ArrivalMin Date `json:"arrival_min"` + DispatchMax Date `json:"dispatch_max"` + DispatchMin Date `json:"dispatch_min"` +} + // PrintableNormalization represents the normalization processes of the // interior and cover source files. type PrintableNormalization struct { @@ -146,7 +190,7 @@ type NormalizedFile struct { type LineItemStatus struct { Messages LineItemStatusMessages `json:"messages"` - Status OrderStatus `json:"name"` + Status ItemStatus `json:"name"` } type LineItemStatusMessages struct { @@ -191,3 +235,9 @@ func (msgs *LineItemStatusMessages) UnmarshalJSON(data []byte) error { return nil } + +type PrintJobStatus struct { + Changed time.Time `json:"changed"` // time of the last status change + Msg string `json:"message"` + Status OrderStatus `json:"name"` +} -- cgit v1.2.3