-
Notifications
You must be signed in to change notification settings - Fork 7
/
category_service.go
46 lines (38 loc) · 1010 Bytes
/
category_service.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
package yext
import "net/url"
const categoryPath = "categories"
// Category is a representation of a Category in Yext Location Manager.
// For details see http://developer.yext.com/docs/api-reference/#operation/getBusinessCategories
type Category struct {
Id string `json:"id"`
Name string `json:"name"`
FullName string `json:"fullName"`
Selectable bool `json:"selectable"`
ParentId string `json:"parentId"`
}
type CategoryService struct {
client *Client
}
type CategoryListOptions struct {
Language *string
Country *string
}
func (s *CategoryService) List(opts *CategoryListOptions) ([]*Category, error) {
u, err := url.Parse(categoryPath)
if err != nil {
return nil, err
}
if opts != nil {
q := u.Query()
if opts.Language != nil {
q.Add("language", *opts.Language)
}
if opts.Country != nil {
q.Add("country", *opts.Country)
}
u.RawQuery = q.Encode()
}
v := &[]*Category{}
_, err = s.client.DoRootRequest("GET", u.String(), v)
return *v, err
}