feat: Add more attributes from opensea (#2354)
* feat: Add more attributes from opensea Add sale / orders information as well as collection traits * feat: add background color to opensea response * feat: Add max value and handle float to opensea response
This commit is contained in:
parent
93497f4644
commit
fb3ef387ac
|
@ -22,7 +22,10 @@ func (st *TraitValue) UnmarshalJSON(b []byte) error {
|
|||
if err := json.Unmarshal(b, &item); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch v := item.(type) {
|
||||
case float64:
|
||||
*st = TraitValue(strconv.FormatFloat(v, 'f', 2, 64))
|
||||
case int:
|
||||
*st = TraitValue(strconv.Itoa(v))
|
||||
case string:
|
||||
|
@ -48,8 +51,27 @@ type OpenseaTrait struct {
|
|||
TraitType string `json:"trait_type"`
|
||||
Value TraitValue `json:"value"`
|
||||
DisplayType string `json:"display_type"`
|
||||
MaxValue string `json:"max_value"`
|
||||
}
|
||||
|
||||
type OpenseaPaymentToken struct {
|
||||
ID int `json:"id"`
|
||||
Symbol string `json:"symbol"`
|
||||
Address string `json:"address"`
|
||||
ImageURL string `json:"image_url"`
|
||||
Name string `json:"name"`
|
||||
Decimals int `json:"decimals"`
|
||||
EthPrice string `json:"eth_price"`
|
||||
UsdPrice string `json:"usd_price"`
|
||||
}
|
||||
|
||||
type OpenseaLastSale struct {
|
||||
PaymentToken OpenseaPaymentToken `json:"payment_token"`
|
||||
}
|
||||
|
||||
type OpenseaSellOrder struct {
|
||||
CurrentPrice string `json:"current_price"`
|
||||
}
|
||||
type OpenseaAsset struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
|
@ -60,13 +82,22 @@ type OpenseaAsset struct {
|
|||
Contract OpenseaContract `json:"asset_contract"`
|
||||
Collection OpenseaAssetCollection `json:"collection"`
|
||||
Traits []OpenseaTrait `json:"traits"`
|
||||
LastSale OpenseaLastSale `json:"last_sale"`
|
||||
SellOrders []OpenseaSellOrder `json:"sell_orders"`
|
||||
BackgroundColor string `json:"background_color"`
|
||||
}
|
||||
|
||||
type OpenseaCollectionTrait struct {
|
||||
Min float64 `json:"min"`
|
||||
Max float64 `json:"max"`
|
||||
}
|
||||
|
||||
type OpenseaCollection struct {
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
ImageURL string `json:"image_url"`
|
||||
OwnedAssetCount int `json:"owned_asset_count"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
ImageURL string `json:"image_url"`
|
||||
OwnedAssetCount int `json:"owned_asset_count"`
|
||||
Traits map[string]OpenseaCollectionTrait `json:"traits"`
|
||||
}
|
||||
|
||||
type OpenseaClient struct {
|
||||
|
|
Loading…
Reference in New Issue