forked from TimmyGuy/bigcommerce-api-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomer_groups.go
43 lines (38 loc) · 1.05 KB
/
customer_groups.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
package bigcommerce
import (
"encoding/json"
"net/http"
)
type CustomerGroup struct {
ID int64 `json:"id"`
Name string `json:"name"`
IsDefault bool `json:"is_default"`
CategoryAccess CategoryAccess `json:"category_access"`
DiscountRules []DiscountRule `json:"discount_rules"`
IsGroupForGuests bool `json:"is_group_for_guests"`
}
type CategoryAccess struct {
Type string `json:"type"`
Categories []int64 `json:"categories"`
}
type DiscountRule struct {
Type string `json:"type"`
Method string `json:"method"`
Amount string `json:"amount"`
PriceListID int64 `json:"price_list_id"`
}
func (bc *Client) GetCustomerGroups() ([]CustomerGroup, error) {
req := bc.getAPIRequest(http.MethodGet, "/v2/customer_groups", nil)
res, err := bc.HTTPClient.Do(req)
if err != nil {
return nil, err
}
defer res.Body.Close()
body, err := processBody(res)
if err != nil {
return nil, err
}
var ret []CustomerGroup
err = json.Unmarshal(body, &ret)
return ret, err
}