-
Notifications
You must be signed in to change notification settings - Fork 5
/
ListRefunds.go
35 lines (29 loc) · 1.09 KB
/
ListRefunds.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"
// ListRefundsParams should be passed to `ListRefunds` to list existing refund IDs․
type ListRefundsParams 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"`
}
// ListRefundsResponse is the structure returned from `ListRefunds`․
//
// Access the refund list with `ListRefundsResponse.Refunds`․
type ListRefundsResponse struct {
Refunds []string `json:"refunds"`
}
// ListRefunds lists existing refund IDs in TaxJar․
//
// See https://developers.taxjar.com/api/reference/?go#get-list-refund-transactions for more details․
func (client *Config) ListRefunds(params ListRefundsParams) (*ListRefundsResponse, error) {
res, err := client.get("transactions/refunds", params)
if err != nil {
return nil, err
}
refunds := new(ListRefundsResponse)
if err := json.Unmarshal(res.([]byte), &refunds); err != nil {
return nil, err
}
return refunds, nil
}