From 9010ebe8a581fb9db7bc6e97d40ff062fb18495f Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 12 May 2026 15:35:06 -0400 Subject: unmarshal GET /print-jobs response --- lulu.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lulu.go') diff --git a/lulu.go b/lulu.go index 302bfc5..a7a6cdd 100644 --- a/lulu.go +++ b/lulu.go @@ -24,6 +24,7 @@ const ( coverDimensionsPath = "/cover-dimensions" validateCoverPath = "/validate-cover" printJobCostPath = "/print-job-cost-calculations" + printJobPath = " /print-jobs" ) // ApiUrl is the location of the API server. It is set to the sandbox @@ -155,7 +156,7 @@ func (c *Client) GetCoverValidation(id uint) (CoverValidationRecord, error) { // actually creating a print job. // // https://api.lulu.com/docs/#tag/Print-Job-Cost-Calculations/operation/Print-Job-cost-calculations_create -func (c *Client) PrintJobCost(items []PrintJobCostLineItem, addr ShippingAddress, shipOpt ShippingLevel) (PrintJobCost, error) { +func (c *Client) PrintJobCost(items []PrintJobCostLineItem, addr ShippingAddress, shipOpt ShippingLevel) (PrintJobCost, ShippingAddressValidation, error) { reqAddr := printJobCostReqShipAddr{ City: addr.City, Country: addr.Country, @@ -165,12 +166,25 @@ func (c *Client) PrintJobCost(items []PrintJobCostLineItem, addr ShippingAddress Phone: addr.Phone, } payload := printJobCostReq{items, reqAddr, shipOpt} - var cost PrintJobCost - err := c.postDecode(printJobCostPath, payload, http.StatusCreated, &cost) + + var resp printJobCostResp + err := c.postDecode(printJobCostPath, payload, http.StatusCreated, &resp) if err != nil { - return cost, pkgErr(err) + return PrintJobCost{}, ShippingAddressValidation{}, pkgErr(err) } - return cost, nil + return resp.cost(), resp.AddressValidation, nil +} + +// PrintJobs retrieves a list of all print jobs that have been created, +// filtered by a set of optional query parameters. +// +// https://api.lulu.com/docs/#tag/Print-Jobs/operation/Print-Jobs_list +func (c *Client) PrintJobs(queries ...PrintJobQuery) ([]PrintJob, error) { + //q := parsePrintJobQueries(queries) + //page := 1 + + // TODO + return nil, fmt.Errorf("not implemented") } // getDecode sends a GET request and unmarshals the response. -- cgit v1.2.3