-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinventory_locations.go
62 lines (51 loc) · 1.86 KB
/
inventory_locations.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
// Copyright 2023 J&J Ideenschmiede GmbH. All rights reserved.
package goshopify
import (
"encoding/json"
"net/http"
"time"
)
// InventoryLocationsReturn is to decode the json data
type InventoryLocationsReturn struct {
Locations []struct {
Id int `json:"id"`
Name string `json:"name"`
Address1 string `json:"address1"`
Address2 interface{} `json:"address2"`
City string `json:"city"`
Zip string `json:"zip"`
Province interface{} `json:"province"`
Country string `json:"country"`
Phone string `json:"phone"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
ProvinceCode interface{} `json:"province_code"`
Legacy bool `json:"legacy"`
Active bool `json:"active"`
AdminGraphqlApiId string `json:"admin_graphql_api_id"`
LocalizedCountryName string `json:"localized_country_name"`
LocalizedProvinceName interface{} `json:"localized_province_name"`
} `json:"locations"`
}
// InventoryLocations is to get a list of all locations
func InventoryLocations(r Request) (InventoryLocationsReturn, error) {
// Set config for new request
c := Config{"/locations.json", http.MethodGet, nil}
// Send request
response, err := c.Send(r)
if err != nil {
return InventoryLocationsReturn{}, err
}
// Close request
defer response.Body.Close()
// Decode data
var decode InventoryLocationsReturn
err = json.NewDecoder(response.Body).Decode(&decode)
if err != nil {
return InventoryLocationsReturn{}, err
}
// Return data
return decode, err
}