forked from bcmi-labs/taxjar-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.go
62 lines (56 loc) · 2.26 KB
/
order.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
package taxjar
type Order struct {
orderParams
}
type OrderList struct {
Order Order `json:"order" bson:"order"`
}
type OrderDetails struct {
ID string `json:"transaction_id" bson:"transaction_id"`
Date string `json:"transaction_date" bson:"transaction_date"`
Amount float64 `json:"amount" bson:"amount"`
Shipping float64 `json:"shipping" bson:"shipping"`
SalesTax float64 `json:"sales_tax" bson:"sales_tax"`
LineItems []LineItem `json:"line_items,omitempty" bson:"line_items,omitempty"`
}
type orderParams struct {
ID string `json:"transaction_id" bson:"transaction_id"`
Date string `json:"transaction_date" bson:"transaction_date"`
Amount float64 `json:"amount" bson:"amount"`
Shipping float64 `json:"shipping" bson:"shipping"`
SalesTax float64 `json:"sales_tax" bson:"sales_tax"`
FromCountry string `json:"from_country" bson:"from_country"`
FromZip string `json:"from_zip" bson:"from_zip"`
FromState string `json:"from_state,omitempty" bson:"from_state,omitempty"`
FromCity string `json:"from_city,omitempty" bson:"from_city,omitempty"`
FromStreet string `json:"from_street,omitempty" bson:"from_street,omitempty"`
ToCountry string `json:"to_country,omitempty" bson:"to_country,omitempty"`
ToZip string `json:"to_zip" bson:"to_zip"`
ToState string `json:"to_state" bson:"to_state"`
ToStreet string `json:"to_street,omitempty" bson:"to_street,omitempty"`
ToCity string `json:"to_city,omitempty" bson:"to_city,omitempty"`
LineItems []LineItem `json:"line_items,omitempty" bson:"line_items,omitempty"`
}
type OrderService struct {
Repository OrderRepository
}
func (s *OrderService) Create(details OrderDetails, from, to Address) (Order, error) {
return s.Repository.get(orderParams{
ID: details.ID,
Date: details.Date,
Amount: details.Amount,
Shipping: details.Shipping,
SalesTax: details.SalesTax,
LineItems: details.LineItems,
FromStreet: from.Street,
FromCity: from.City,
FromState: from.State,
FromZip: from.Zip,
FromCountry: from.Country,
ToStreet: to.Street,
ToCity: to.City,
ToState: to.State,
ToZip: to.Zip,
ToCountry: to.Country,
})
}