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"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Organization maps JSON data from the ITG Organization resource to Go struct
|
//OrganizationInternalData contains the schema of an Organization in IT Glue without the "data" wrapper.
|
||||||
type Organization struct {
|
//This allows us to reuse the schema when data is either a JSON object or an array, depending on what results are returned
|
||||||
Data struct {
|
type OrganizationInternalData struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Attributes struct {
|
Attributes struct {
|
||||||
@ -23,7 +23,16 @@ type Organization struct {
|
|||||||
CreatedAt string `json:"created-at"`
|
CreatedAt string `json:"created-at"`
|
||||||
UpdatedAt string `json:"updated-at"`
|
UpdatedAt string `json:"updated-at"`
|
||||||
} `json:"attributes"`
|
} `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
|
//GetOrganizationByID expects an ITG organization ID
|
||||||
|
Loading…
Reference in New Issue
Block a user