Fix ID datatype. Finish GetOrganizationByID

This commit is contained in:
Steven Polley 2018-06-29 22:19:49 -06:00
parent 7dca48c551
commit 09935e7c69
1 changed files with 11 additions and 5 deletions

View File

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