2018-07-22 08:19:22 +00:00
|
|
|
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 {
|
2018-07-22 08:24:52 +00:00
|
|
|
Data struct{ OrganizationTypeData } `json:"data"`
|
|
|
|
Meta struct{ Metadata } `json:"metadata"`
|
|
|
|
Links struct{ Links } `json:"links"`
|
2018-07-22 08:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type OrganizationTypeList struct {
|
2018-07-22 08:24:52 +00:00
|
|
|
Data []struct{ OrganizationTypeData } `json:"data"`
|
|
|
|
Meta struct{ Metadata } `json:"metadata"`
|
|
|
|
Links struct{ Links } `json:"links"`
|
2018-07-22 08:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///organization_types
|
|
|
|
func (itg *ITGAPI) GetOrganizationTypes() (*OrganizationTypeList, error) {
|
|
|
|
itgurl, err := itg.BuildURL("/organization_types")
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("could not build URL: %s", err)
|
|
|
|
}
|
|
|
|
body, err := itg.GetRequest(itgurl)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("request failed: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
organizationTypes := &OrganizationTypeList{}
|
|
|
|
err = json.Unmarshal(body, organizationTypes)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("could not get organization types: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return organizationTypes, nil
|
|
|
|
}
|