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 {
|
if err := json.Unmarshal(b, &item); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch v := item.(type) {
|
switch v := item.(type) {
|
||||||
|
case float64:
|
||||||
|
*st = TraitValue(strconv.FormatFloat(v, 'f', 2, 64))
|
||||||
case int:
|
case int:
|
||||||
*st = TraitValue(strconv.Itoa(v))
|
*st = TraitValue(strconv.Itoa(v))
|
||||||
case string:
|
case string:
|
||||||
|
@ -48,8 +51,27 @@ type OpenseaTrait struct {
|
||||||
TraitType string `json:"trait_type"`
|
TraitType string `json:"trait_type"`
|
||||||
Value TraitValue `json:"value"`
|
Value TraitValue `json:"value"`
|
||||||
DisplayType string `json:"display_type"`
|
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 {
|
type OpenseaAsset struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -60,13 +82,22 @@ type OpenseaAsset struct {
|
||||||
Contract OpenseaContract `json:"asset_contract"`
|
Contract OpenseaContract `json:"asset_contract"`
|
||||||
Collection OpenseaAssetCollection `json:"collection"`
|
Collection OpenseaAssetCollection `json:"collection"`
|
||||||
Traits []OpenseaTrait `json:"traits"`
|
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 {
|
type OpenseaCollection struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
ImageURL string `json:"image_url"`
|
ImageURL string `json:"image_url"`
|
||||||
OwnedAssetCount int `json:"owned_asset_count"`
|
OwnedAssetCount int `json:"owned_asset_count"`
|
||||||
|
Traits map[string]OpenseaCollectionTrait `json:"traits"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpenseaClient struct {
|
type OpenseaClient struct {
|
||||||
|
|
Loading…
Reference in New Issue