aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--cover.go4
-rw-r--r--interior.go2
-rw-r--r--print.go14
-rw-r--r--ship.go23
-rw-r--r--ship_test.go51
6 files changed, 92 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 59689ef..ce6ef7e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-GEN = $(addsuffix _gen.go, cover interior pkgid)
+GEN = $(addsuffix _gen.go, cover interior pkgid ship)
TEST = $(wildcard *_test.go)
SRC = $(filter-out ${GEN} ${TEST}, $(wildcard *.go))
diff --git a/cover.go b/cover.go
index ba2bc2a..a44ebab 100644
--- a/cover.go
+++ b/cover.go
@@ -38,7 +38,7 @@ func (s CoverValidationStatus) IsFinal() bool {
// coverDimensionsReq is the json body of a /cover-dimensions/ request.
type coverDimensionsReq struct {
- PkgId PkgId `json:"pod_package_id"`
+ Mfg PkgId `json:"pod_package_id"`
NPages uint `json:"interior_page_count"`
Unit Unit `json:"unit"`
}
@@ -46,7 +46,7 @@ type coverDimensionsReq struct {
// validateCoverReq is the json body of a /validate-cover/ request.
type validateCoverReq struct {
SrcUrl string `json:"source_url"`
- PkgId PkgId `json:"pod_package_id"`
+ Mfg PkgId `json:"pod_package_id"`
NPages uint `json:"interior_page_count"`
}
diff --git a/interior.go b/interior.go
index 19417e5..b1cdce7 100644
--- a/interior.go
+++ b/interior.go
@@ -26,7 +26,7 @@ func (s InteriorValidationStatus) IsFinal() bool {
// validateInteriorReq is the json body of a /validate-interior/ request.
type validateInteriorReq struct {
SrcUrl string `json:"source_url"`
- PkgId PkgId `json:"pod_package_id"`
+ Mfg PkgId `json:"pod_package_id"`
}
// validateInteriorReq is the json body of a /validate-interior/ request without the optional pod_package_id.
diff --git a/print.go b/print.go
new file mode 100644
index 0000000..829a5ef
--- /dev/null
+++ b/print.go
@@ -0,0 +1,14 @@
+package lulu
+
+// printJobCostReq is the json body of a /print-job-cost-calculations/ request.
+type printJobCostReq struct {
+ LineItems []CostCalcLineItem `json:"line_items"`
+ ShipAddr ShippingAddress `json:"shipping_address"`
+ ShipOpt ShippingLevel `json:"shipping_option"`
+}
+
+type CostCalcLineItem struct {
+ NPages uint `json:"page_count"`
+ Mfg PkgId `json:"pod_package_id"`
+ Quantity uint
+}
diff --git a/ship.go b/ship.go
new file mode 100644
index 0000000..a31724e
--- /dev/null
+++ b/ship.go
@@ -0,0 +1,23 @@
+package lulu
+
+//go:generate go run github.com/yawnak/string-enumer -t ShippingLevel --text -o ./ship_gen.go .
+
+// ShippingLevel is the quality/speed with which a package is shipped.
+type ShippingLevel string
+
+const (
+ Mail ShippingLevel = "MAIL" // Slowest ship method. Depending on the destination, tracking might not be available.
+ PriorityMail ShippingLevel = "PRIORITY_MAIL" // Priority mail shipping
+ Ground ShippingLevel = "GROUND" // Courier based shipping using ground transportation in the US.
+ Expedited ShippingLevel = "EXPEDITED" // Expedited (2nd day) delivery via air mail or equivalent.
+ Express ShippingLevel = "EXPRESS" // Overnight delivery. Fastest shipping available.
+)
+
+type ShippingAddress struct {
+ City string `json:"city"` // Lübeck
+ CountryCode string `json:"country_code"` // DE
+ PostCode string `json:"postcode"` // 23552
+ StateCode string `json:"state_code"`
+ Street1 string `json:"street1"` // Holstenstr. 40
+ Phone string `json:"phone_number"` // 844-212-0689
+}
diff --git a/ship_test.go b/ship_test.go
new file mode 100644
index 0000000..b91e671
--- /dev/null
+++ b/ship_test.go
@@ -0,0 +1,51 @@
+package lulu
+
+import (
+ "testing"
+)
+
+func TestMarshalUnmarshalShippingAddress(t *testing.T) {
+ for _, pair := range []struct {
+ j string
+ addr ShippingAddress
+ }{
+ {
+ `{
+ "city": "Lübeck",
+ "country_code": "DE",
+ "postcode": "23552",
+ "state_code": "",
+ "street1": "Holstenstr. 40",
+ "phone_number": "844-212-0689"
+ }`,
+ ShippingAddress{
+ "Lübeck",
+ "DE",
+ "23552",
+ "", // TODO: does the API mind if this is "" instead of null?
+ "Holstenstr. 40",
+ "844-212-0689",
+ },
+ }, {
+ `{
+ "city": "Anytown",
+ "country_code": "CA",
+ "postcode": "A1A 1A1",
+ "state_code": "QC",
+ "street1": "123 Fake Street",
+ "phone_number": "123-456-7890"
+ }`,
+ ShippingAddress{
+ "Anytown",
+ "CA",
+ "A1A 1A1",
+ "QC",
+ "123 Fake Street",
+ "123-456-7890",
+ },
+ },
+ } {
+ requireMarshalJsonEq(t, pair.j, pair.addr)
+ requireUnmarshalJsonEq(t, pair.addr, pair.j)
+ }
+}