tosunthex / CoinGecko

CoinGecko .Net Standard api wrapper
111 stars 46 forks source link

Problem with GetCoinMarkets - should be IReadOnlyList? #5

Closed GonzoKK closed 5 years ago

GonzoKK commented 5 years ago

I get the exception: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'CoinGecko.Entities.Response.Coins.CoinMarkets' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

I think it should be public async Task<IReadOnlyList> GetCoinMarkets...

https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=50&page=1&sparkline=false&price_change_percentage=1h%2C24h%2C7d%2C14d%2C30d%2C200d%2C1y

The implications could be wide ranging, for example

    [JsonProperty("current_price")]
    public Dictionary<string,double> CurrentPrice { get; set; }

should be double (not Dictionary)

etc, etc

GonzoKK commented 5 years ago

"current_price" can be double OR Dictionary<string, double>

image

Also note null on "roi" and "total_supply"

tosunthex commented 5 years ago

Hi @GonzoKK

I changes some property and add test for that. I chaecked Roi agains and i didnt see any error. Thanks for your feedback

GonzoKK commented 5 years ago

Thanks @tosunthex I'll test properly tomorrow.

I dont think you're handling "price_change_percentage"

image

Also I don't see properties for: "price_change_percentage_14d_in_currency": 6.58975894468818, "price_change_percentage_1h_in_currency": -0.0482369285285664, "price_change_percentage_1y_in_currency": -63.019853096321, "price_change_percentage_200d_in_currency": -39.4434110238681, "price_change_percentage_24h_in_currency": -0.0905622039465634, "price_change_percentage_30d_in_currency": 12.0946672847526, "price_change_percentage_7d_in_currency": -2.76002154041415

[JsonProperty("price_change_percentage_14d_in_currency", NullValueHandling = NullValueHandling.Ignore)]
public double PriceChangePercentage14dInCurrency { get; set; }

ps They all require null handling

tosunthex commented 5 years ago

Hi @GonzoKK

I fixed the problem. Thanks for your fast reply