Fix Organization structs to work around annoying ITG "data" wrapper JSON object.
This commit is contained in:
parent
09935e7c69
commit
06e73821e0
@ -5,25 +5,34 @@ 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.
|
||||||
|
//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 {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
OrganizationTypeID int `json:"organization-type-id"`
|
||||||
|
OrganizationTypeName string `json:"organization-type-name"`
|
||||||
|
OrganizationStatusID int `json:"organization-status-id"`
|
||||||
|
OrganizationStatusName string `json:"organization-status-name"`
|
||||||
|
Logo string `json:"logo"`
|
||||||
|
QuickNotes string `json:"quick-notes"`
|
||||||
|
ShortName string `json:"short-name"`
|
||||||
|
CreatedAt string `json:"created-at"`
|
||||||
|
UpdatedAt string `json:"updated-at"`
|
||||||
|
} `json:"attributes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Organization contains a single Organization
|
||||||
type Organization struct {
|
type Organization struct {
|
||||||
Data struct {
|
Data struct{ OrganizationInternalData } `json:"data"`
|
||||||
ID string `json:"id"`
|
}
|
||||||
Type string `json:"type"`
|
|
||||||
Attributes struct {
|
//OrganizationList contains a slice of Organizations
|
||||||
Name string `json:"name"`
|
type OrganizationList struct {
|
||||||
Description string `json:"description"`
|
Data []struct{ OrganizationInternalData } `json:"data"`
|
||||||
OrganizationTypeID int `json:"organization-type-id"`
|
|
||||||
OrganizationTypeName string `json:"organization-type-name"`
|
|
||||||
OrganizationStatusID int `json:"organization-status-id"`
|
|
||||||
OrganizationStatusName string `json:"organization-status-name"`
|
|
||||||
Logo string `json:"logo"`
|
|
||||||
QuickNotes string `json:"quick-notes"`
|
|
||||||
ShortName string `json:"short-name"`
|
|
||||||
CreatedAt string `json:"created-at"`
|
|
||||||
UpdatedAt string `json:"updated-at"`
|
|
||||||
} `json:"attributes"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetOrganizationByID expects an ITG organization ID
|
//GetOrganizationByID expects an ITG organization ID
|
||||||
|
Loading…
Reference in New Issue
Block a user