This repository has been archived by the owner on Jul 8, 2022. It is now read-only.
forked from taxjar/taxjar-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowOrder.go
51 lines (43 loc) · 1.81 KB
/
ShowOrder.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
package taxjar
import "encoding/json"
// ShowOrderParams should be passed to `ShowOrder` to show an order․
type ShowOrderParams struct {
Provider string `url:"provider,omitempty"`
}
// ShowOrderResponse is the structure returned from `ShowOrder`․
//
// Access the order with `ShowOrderResponse.Order`․
type ShowOrderResponse struct {
Order Order `json:"order"`
}
// OrderLineItem is the structure for a line item passed within `CreateOrderParams.LineItems` and `UpdateOrderParams.LineItems`․
//
// OrderLineItem is also the structure for a line item returned within `CreateOrderResponse.Order.LineItems`, `UpdateOrderResponse.Order.LineItems`, `ShowOrderResponse.Order.LineItems`, and `DeleteOrderResponse.Order.LineItems`․
type OrderLineItem struct {
ID json.Number `json:"id,omitempty"`
Quantity int `json:"quantity,omitempty"`
ProductIdentifier string `json:"product_identifier,omitempty"`
Description string `json:"description,omitempty"`
ProductTaxCode string `json:"product_tax_code,omitempty"`
UnitPrice float64 `json:"unit_price,omitempty,string"`
Discount float64 `json:"discount,omitempty,string"`
SalesTax float64 `json:"sales_tax,omitempty,string"`
}
// ShowOrder shows an existing order in TaxJar․
//
// See https://developers.taxjar.com/api/reference/?go#get-show-an-order-transaction for more details․
func (client *Config) ShowOrder(transactionID string, params ...ShowOrderParams) (*ShowOrderResponse, error) {
var p interface{}
if len(params) > 0 {
p = params[0]
}
res, err := client.get("transactions/orders/"+transactionID, p)
if err != nil {
return nil, err
}
order := new(ShowOrderResponse)
if err := json.Unmarshal(res.([]byte), &order); err != nil {
return nil, err
}
return order, nil
}