-
Notifications
You must be signed in to change notification settings - Fork 0
/
organization-types.go
48 lines (41 loc) · 1.25 KB
/
organization-types.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
package itglue
import (
"encoding/json"
"fmt"
"time"
)
type OrganizationTypeData struct {
ID string `json:"id"`
Type string `json:"type"`
Attributes struct {
Name string `json:"name"`
CreatedAt time.Time `json:"created-at"`
UpdatedAt time.Time `json:"updated-at"`
Synced bool `json:"synced"`
} `json:"attributes"`
}
type OrganizationType struct {
Data struct{ OrganizationTypeData } `json:"data"`
Meta struct{ Metadata } `json:"meta"`
Links struct{ Links } `json:"links"`
}
type OrganizationTypeList struct {
Data []struct{ OrganizationTypeData } `json:"data"`
Meta struct{ Metadata } `json:"meta"`
Links struct{ Links } `json:"links"`
}
///organization_types
func (itg *ITGAPI) GetOrganizationTypes(pageNumber int) (*OrganizationTypeList, error) {
req := itg.NewRequest("/organization_types", "GET", nil)
req.Page = pageNumber
err := req.Do()
if err != nil {
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
}
organizationTypes := &OrganizationTypeList{}
err = json.Unmarshal(req.Body, organizationTypes)
if err != nil {
return nil, fmt.Errorf("could not get organization types: %s", err)
}
return organizationTypes, nil
}