You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-itg/itglue/flexible-assets.go

47 lines
1.4 KiB

package itglue
import (
"fmt"
"time"
)
type FlexibleAssetData struct {
ID string `json:"id"`
Type string `json:"type"`
Attributes struct {
Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"created-at"`
UpdatedAt time.Time `json:"updated-at"`
Icon string `json:"icon"`
Enabled bool `json:"enabled"`
} `json:"attributes"`
Relationships struct {
} `json:"relationships"`
}
type FlexibleAsset struct {
Data struct{ FlexibleAssetData } `json:"data"`
Meta struct{ Metadata } `json:"metadata"`
Links struct{ Links } `json:"links"`
}
type FlexibleAssetList struct {
Data []struct{ FlexibleAssetData } `json:"data"`
Meta struct{ Metadata } `json:"metadata"`
Links struct{ Links } `json:"links"`
}
//GetFlexibleAssetsJSON is a special function. All flexible assets will return different data depending
//on which fields make up the flexible asset. Because of this, this function simply returns the JSON bytes.
func (itg *ITGAPI) GetFlexibleAssetsJSON(flexibleAssetTypeID int) ([]byte, error) {
req := itg.NewRequest("/flexible_assets", "GET", nil)
req.RawURLValues = fmt.Sprintf("filter[flexible_asset_type_id]=%d", flexibleAssetTypeID)
err := req.Do()
if err != nil {
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
}
return req.Body, nil
}