-
Notifications
You must be signed in to change notification settings - Fork 5
/
NexusRegions.go
35 lines (29 loc) · 1016 Bytes
/
NexusRegions.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"
// NexusRegion is the structure for a nexus region returned within `NexusRegionsResponse.Regions`․
type NexusRegion struct {
CountryCode string `json:"country_code"`
Country string `json:"country"`
RegionCode string `json:"region_code"`
Region string `json:"region"`
}
// NexusRegionsResponse is the structure returned from `NexusRegions`․
//
// Access the nexus list with `NexusRegionsResponse.Regions`.
type NexusRegionsResponse struct {
Regions []NexusRegion `json:"regions"`
}
// NexusRegions lists existing nexus locations for a TaxJar account․
//
// See https://developers.taxjar.com/api/reference/?go#get-list-nexus-regions for more details․
func (client *Config) NexusRegions() (*NexusRegionsResponse, error) {
res, err := client.get("nexus/regions", nil)
if err != nil {
return nil, err
}
regions := new(NexusRegionsResponse)
if err := json.Unmarshal(res.([]byte), ®ions); err != nil {
return nil, err
}
return regions, nil
}