Add GetOrganizationTypes

This commit is contained in:
Steven Polley 2018-07-22 02:11:07 -06:00
parent 9fdb1641d9
commit 9ef552cdea
1 changed files with 8 additions and 21 deletions

View File

@ -16,18 +16,6 @@ type OrganizationTypeData struct {
UpdatedAt time.Time `json:"updated-at"`
Synced bool `json:"synced"`
} `json:"attributes"`
Meta struct {
CurrentPage int `json:"current-page"`
NextPage interface{} `json:"next-page"`
PrevPage interface{} `json:"prev-page"`
TotalPages int `json:"total-pages"`
TotalCount int `json:"total-count"`
Filters struct {
} `json:"filters"`
} `json:"meta"`
Links struct {
} `json:"links"`
}
//OrganizationData contains the schema of an Organization in IT Glue without the "data" wrapper.
@ -73,24 +61,23 @@ type OrganizationTypeList struct {
}
///organization_types
func (itg *ITGAPI) GetOrganizationTypes() error {
func (itg *ITGAPI) GetOrganizationTypes() (*OrganizationTypeList, error) {
itgurl, err := itg.BuildURL("/organization_types")
if err != nil {
return fmt.Errorf("could not build URL: %s", err)
return nil, fmt.Errorf("could not build URL: %s", err)
}
body, err := itg.GetRequest(itgurl)
if err != nil {
return fmt.Errorf("request failed: %s", err)
return nil, fmt.Errorf("request failed: %s", err)
}
fmt.Println(string(body))
/*organization := &Organization{}
err := json.Unmarshal(body, organization)
organizationTypes := &OrganizationTypeList{}
err = json.Unmarshal(body, organizationTypes)
if err != nil {
return nil, fmt.Errorf("could not get organization: %s", err)
return nil, fmt.Errorf("could not get organization types: %s", err)
}
*/
return nil
return organizationTypes, nil
}
//GetOrganizationByID expects an ITG organization ID