Fix Organization structs to work around annoying ITG "data" wrapper JSON object.
This commit is contained in:
parent
09935e7c69
commit
06e73821e0
@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
//Organization maps JSON data from the ITG Organization resource to Go struct
|
||||
type Organization struct {
|
||||
Data struct {
|
||||
//OrganizationInternalData contains the schema of an Organization in IT Glue without the "data" wrapper.
|
||||
//This allows us to reuse the schema when data is either a JSON object or an array, depending on what results are returned
|
||||
type OrganizationInternalData struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Attributes struct {
|
||||
@ -23,7 +23,16 @@ type Organization struct {
|
||||
CreatedAt string `json:"created-at"`
|
||||
UpdatedAt string `json:"updated-at"`
|
||||
} `json:"attributes"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
//Organization contains a single Organization
|
||||
type Organization struct {
|
||||
Data struct{ OrganizationInternalData } `json:"data"`
|
||||
}
|
||||
|
||||
//OrganizationList contains a slice of Organizations
|
||||
type OrganizationList struct {
|
||||
Data []struct{ OrganizationInternalData } `json:"data"`
|
||||
}
|
||||
|
||||
//GetOrganizationByID expects an ITG organization ID
|
||||
|
Loading…
Reference in New Issue
Block a user