2018-07-23 00:51:25 +00:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2018-07-23 04:39:46 +00:00
|
|
|
//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) {
|
2018-07-23 01:35:10 +00:00
|
|
|
req := itg.NewRequest("/flexible_assets", "GET", nil)
|
2018-07-23 02:06:08 +00:00
|
|
|
req.RawURLValues = fmt.Sprintf("filter[flexible_asset_type_id]=%d", flexibleAssetTypeID)
|
|
|
|
|
2018-07-23 01:35:10 +00:00
|
|
|
err := req.Do()
|
2018-07-23 00:51:25 +00:00
|
|
|
if err != nil {
|
2018-07-23 04:39:46 +00:00
|
|
|
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
|
2018-07-23 00:51:25 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 04:39:46 +00:00
|
|
|
return req.Body, nil
|
2018-07-23 00:51:25 +00:00
|
|
|
}
|