Added flexible-asset-types
This commit is contained in:
		
							
								
								
									
										54
									
								
								itglue/flexible-asset-types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								itglue/flexible-asset-types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
package itglue
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type FlexibleAssetTypeData 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 FlexibleAssetType struct {
 | 
			
		||||
	Data  struct{ FlexibleAssetTypeData } `json:"data"`
 | 
			
		||||
	Meta  struct{ Metadata }              `json:"metadata"`
 | 
			
		||||
	Links struct{ Links }                 `json:"links"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type FlexibleAssetTypeList struct {
 | 
			
		||||
	Data  []struct{ FlexibleAssetTypeData } `json:"data"`
 | 
			
		||||
	Meta  struct{ Metadata }                `json:"metadata"`
 | 
			
		||||
	Links struct{ Links }                   `json:"links"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (itg *ITGAPI) GetFlexibleAssetTypes() (*FlexibleAssetTypeList, error) {
 | 
			
		||||
	itgurl, err := itg.BuildURL("/flexible_asset_types")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("could not build URL: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	body, err := itg.GetRequest(itgurl)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("request failed: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	flexibleAssetTypes := &FlexibleAssetTypeList{}
 | 
			
		||||
	err = json.Unmarshal(body, flexibleAssetTypes)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("could not get flexible asset types: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return flexibleAssetTypes, nil
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user