From 9ef552cdea6661448fc2ed43c775a0b4f93d19dc Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Sun, 22 Jul 2018 02:11:07 -0600 Subject: [PATCH] Add GetOrganizationTypes --- itglue/organizations.go | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/itglue/organizations.go b/itglue/organizations.go index 7b329a9..fd175d4 100644 --- a/itglue/organizations.go +++ b/itglue/organizations.go @@ -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