-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcredit_notes_test.go
82 lines (78 loc) · 1.57 KB
/
credit_notes_test.go
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
package invoiced
import (
"encoding/json"
"testing"
)
func TestUnMarshalCreditNoteObject(t *testing.T) {
s := `{
"balance": 51.15,
"closed": false,
"created_at": 1415229884,
"currency": "usd",
"customer": 15444,
"date": 1416290400,
"discounts": [],
"draft": false,
"id": 2048,
"invoice": 46225,
"items": [
{
"amount": 45,
"catalog_item": null,
"description": null,
"discountable": true,
"discounts": [],
"id": 7,
"metadata": {},
"name": "Copy Paper, Case",
"object": "line_item",
"quantity": 1,
"taxable": true,
"taxes": [],
"type": "product",
"unit_cost": 45
},
{
"amount": 10,
"catalog_item": "delivery",
"description": null,
"discountable": true,
"discounts": [],
"id": 8,
"metadata": {},
"name": "Delivery",
"object": "line_item",
"quantity": 1,
"taxable": true,
"taxes": [],
"type": "service",
"unit_cost": 10
}
],
"metadata": {},
"name": null,
"notes": null,
"number": "CN-0016",
"object": "credit_note",
"paid": false,
"pdf_url": "https://dundermifflin.invoiced.com/credit_notes/IZmXbVOPyvfD3GPBmyd6FwXY/pdf",
"status": "open",
"subtotal": 55,
"taxes": [
{
"amount": 3.85,
"id": 20554,
"object": "tax",
"tax_rate": null
}
],
"total": 51.15,
"url": "https://dundermifflin.invoiced.com/credit_notes/IZmXbVOPyvfD3GPBmyd6FwXY"
}
`
so := new(CreditNote)
err := json.Unmarshal([]byte(s), so)
if err != nil {
t.Fatal(err)
}
}