-
Notifications
You must be signed in to change notification settings - Fork 5
/
ListOrders.go
35 lines (29 loc) · 1.07 KB
/
ListOrders.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
package taxjar
import "encoding/json"
// ListOrdersParams should be passed to `ListOrders` to list existing order IDs․
type ListOrdersParams struct {
TransactionDate string `url:"transaction_date,omitempty"`
FromTransactionDate string `url:"from_transaction_date,omitempty"`
ToTransactionDate string `url:"to_transaction_date,omitempty"`
Provider string `url:"provider,omitempty"`
}
// ListOrdersResponse is the structure returned from `ListOrders`․
//
// Access the order list with `ListOrdersResponse.Orders`․
type ListOrdersResponse struct {
Orders []string `json:"orders"`
}
// ListOrders lists existing order IDs in TaxJar․
//
// See https://developers.taxjar.com/api/reference/?go#get-list-order-transactions for more details․
func (client *Config) ListOrders(params ListOrdersParams) (*ListOrdersResponse, error) {
res, err := client.get("transactions/orders", params)
if err != nil {
return nil, err
}
orders := new(ListOrdersResponse)
if err := json.Unmarshal(res.([]byte), &orders); err != nil {
return nil, err
}
return orders, nil
}