Fix ID datatype. Finish GetOrganizationByID

This commit is contained in:
Steven Polley 2018-06-29 22:19:49 -06:00
parent 7dca48c551
commit 09935e7c69

View File

@ -1,11 +1,14 @@
package itglue
import "fmt"
import (
"encoding/json"
"fmt"
)
//Organization maps JSON data from the ITG Organization resource to Go struct
type Organization struct {
Data struct {
ID int `json:"id"`
ID string `json:"id"`
Type string `json:"type"`
Attributes struct {
Name string `json:"name"`
@ -25,12 +28,15 @@ type Organization struct {
//GetOrganizationByID expects an ITG organization ID
//Returns a pointer to an Organization struct
func (itg *ITGAPI) GetOrganizationByID(organizationID int) {
func (itg *ITGAPI) GetOrganizationByID(organizationID int) *Organization {
itgurl := itg.BuildURL(fmt.Sprintf("/organizations/%d", organizationID))
body := itg.GetRequest(itgurl)
fmt.Print(string(body))
//organization := Organization{}
organization := &Organization{}
err := json.Unmarshal(body, organization)
check(err)
return organization
}