aboutsummaryrefslogtreecommitdiffstats
path: root/cost.go
diff options
context:
space:
mode:
Diffstat (limited to 'cost.go')
-rw-r--r--cost.go37
1 files changed, 13 insertions, 24 deletions
diff --git a/cost.go b/cost.go
index de2080e..2e10669 100644
--- a/cost.go
+++ b/cost.go
@@ -2,13 +2,8 @@ package lulu
import "github.com/shopspring/decimal"
-type PrintJobCostLineItem struct {
- NPages uint `json:"page_count"`
- Mfg PkgId `json:"pod_package_id"`
- Quantity uint `json:"quantity"`
-}
-
-type PrintJobCost struct {
+// Cost is the cost of a print job.
+type Cost struct {
Fees []Fee `json:"fees"`
LineItemCosts []LineItemCost `json:"line_item_costs"`
ShipCost FulfillmentCost `json:"shipping_cost"`
@@ -54,25 +49,19 @@ type Discount struct {
Description string `json:"description"`
}
-type printJobCostReq struct {
- LineItems []PrintJobCostLineItem `json:"line_items"`
- ShipAddr printJobCostReqShipAddr `json:"shipping_address"`
- ShipOpt ShippingLevel `json:"shipping_option"`
+type CostLineItem struct {
+ NPages uint `json:"page_count"`
+ Mfg PkgId `json:"pod_package_id"`
+ Quantity uint `json:"quantity"`
}
-// printJobCostReqShipAddr is a subset of a shipping address. It is
-// necessary because the API returns an error if the address in a
-// /print-job-cost-calculations/ request has any extra fields.
-type printJobCostReqShipAddr struct {
- City string `json:"city"`
- Country string `json:"country_code"`
- PostCode string `json:"postcode"`
- State string `json:"state_code"`
- Street1 string `json:"street1"`
- Phone PhoneNumber `json:"phone_number"`
+type costReq struct {
+ Items []CostLineItem `json:"line_items"`
+ ShipAddr ShippingAddress `json:"shipping_address"`
+ ShipOpt ShippingLevel `json:"shipping_option"`
}
-type printJobCostResp struct {
+type costResp struct {
AddressValidation ShippingAddressValidation `json:"shipping_address"`
Fees []Fee `json:"fees"`
LineItemCosts []LineItemCost `json:"line_item_costs"`
@@ -85,8 +74,8 @@ type printJobCostResp struct {
Currency string `json:"currency"`
}
-func (resp printJobCostResp) cost() PrintJobCost {
- return PrintJobCost{
+func (resp costResp) cost() Cost {
+ return Cost{
Fees: resp.Fees,
LineItemCosts: resp.LineItemCosts,
ShipCost: resp.ShipCost,