1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
package lulu
import (
_ "embed"
"testing"
"time"
"github.com/shopspring/decimal"
)
//go:embed testdata/getprintjobsresp.json
var getPrintJobsRespJson string
func TestUnmarshalGetPrintJobsResp(t *testing.T) {
want := getPrintJobsResp{
Count: 1,
Next: "https://api.lulu.com/resources/?page=1&page_size=1",
Prev: "https://api.lulu.com/resources/?page=1&page_size=1",
Results: []PrintJob{{
Contact: MustParseEmailAddress("test@test.com"),
Cost: PrintJobCost{
LineItemCosts: nil,
ShipCost: FulfillmentCost{
TotalCostExclTax: decimal.RequireFromString("132.74"),
TotalCostInclTax: decimal.RequireFromString("132.74"),
TotalTax: decimal.RequireFromString("0.00"),
TaxRate: decimal.RequireFromString("0.000000"),
},
FulfillmentCost: FulfillmentCost{
TotalCostExclTax: decimal.RequireFromString("0.75"),
TotalCostInclTax: decimal.RequireFromString("0.81"),
TotalTax: decimal.RequireFromString("0.06"),
TaxRate: decimal.RequireFromString("0.080000"),
},
Fees: []Fee{{
Currency: "USD",
Type: "HANDLING_FEE",
Sku: "HANDLING_FEE_6",
TaxRate: decimal.RequireFromString("0.088750"),
TotalCostExclTax: decimal.RequireFromString("4.00"),
TotalCostInclTax: decimal.RequireFromString("4.36"),
TotalTax: decimal.RequireFromString("0.36"),
}},
TotalCostExclTax: decimal.RequireFromString("123.45"),
TotalCostInclTax: decimal.RequireFromString("678.00"),
TotalTax: decimal.RequireFromString("0.123400"),
},
Created: mustParseTime(time.RFC3339, "2017-08-07T08:47:26.485456Z"),
Modified: mustParseTime(time.RFC3339, "2017-08-07T08:47:26.485490Z"),
EstimatedShippingDates: EstimatedShippingDates{
ArrivalMax: MustParseDate("2017-08-12"),
ArrivalMin: MustParseDate("2017-08-10"),
DispatchMax: MustParseDate("2017-08-09"),
DispatchMin: MustParseDate("2017-08-07"),
},
ExternalId: "demo-time",
Id: 1,
LineItems: []LineItem{{
ExternalId: "item-reference-1",
Id: 1,
PrintableId: "",
PrintableNormalization: PrintableNormalization{
Cover: NormalizationJob{
SrcMd5Sum: "e78512c777e7f5841fe8f1992cefb898",
SrcUrl: "https://www.dropbox.com/sh/p3zh22vzsaegiri/AADP367j0bTWlt8fCu-_tm2ia/161025/139056_cover.pdf?dl=1",
},
Interior: NormalizationJob{
SrcMd5Sum: "7f8af20c296747689756f8e310135d79",
SrcUrl: "https://www.dropbox.com/sh/p3zh22vzsaegiri/AACOUn3LFKsITDzylh13bQpsa/161025/thesis2.pdf?dl=1",
},
},
Quantity: 20,
Status: LineItemStatus{
Messages: LineItemStatusMessages{
Info: "Line-item is currently being validated",
},
Status: OrderCreated,
},
Title: "My Book",
}},
ProductionDelay: 120 * time.Minute,
ProductionDue: time.Time{},
AddressValidation: ShippingAddressValidation{
Address: ShippingAddress{
City: "Lübeck",
Country: "DE",
IsBusiness: false,
Name: "Hans Dampf",
Phone: "844-212-0689",
PostCode: "23552",
State: "",
Street1: "Holstenstr. 40",
Street2: "",
},
Suggested: ShippingAddress{
Country: "DE",
State: "",
PostCode: "23552",
City: "Lübeck",
Street1: "Holstenstraße 40",
Street2: "",
},
Warnings: []ShippingAddressWarning{{
Type: "validation_warning",
Path: "external",
Code: "REPLACED",
Msg: "street1: Holstenstr. 40 -> Holstenstraße 40",
}},
},
ShipOpt: Mail,
}},
}
requireUnmarshalJsonEq(t, want, getPrintJobsRespJson)
}
|