MagicTheGathering / mtg-sdk-go

Magic: The Gathering SDK - Go
MIT License
25 stars 17 forks source link

Cannot unmarshal card #2

Closed mbndr closed 5 years ago

mbndr commented 6 years ago

I'm currently playing around with this SDK (good work btw) and noticed that I have a problem to query the third page of all cards. This is caused by this card: https://api.magicthegathering.io/v1/cards/c7affc1bfd16e3091541d52cad6cfd61c712b0d7

It has a cmc of 0.5 and therefore cannot be unmarshalled to uint32. I can query all other 360 pages without this problem so I assume this is a very special attribute.

I don't know if it makes sense to change the type of Card.CMC to something else only because of this card, however, I wanted to inform you about that issue.

boombuler commented 6 years ago

Changing the API (cmc) could cause errors in other peoples code.

What do the other users think about this?

mbndr commented 6 years ago

If it is not possible to fix this easily, at least it would be a good idea to write about this issue in the README

mbndr commented 6 years ago

Simple code snippet to reproduce:

package main

import (
    "log"
    "github.com/MagicTheGathering/mtg-sdk-go"
)

func main()  {
    cards, _, err := mtg.NewQuery().Page(3)
    if err != nil {
        log.Println(err)
    }

    for _, card := range cards {
        log.Println(card.Name)
    }
}
iuculanop commented 5 years ago

it seems that now the mtg api will respond with a float value for every card's cmc, triggering the error described above. Are someone experiencing this problem?

mbndr commented 5 years ago

Yes you're right, I didn't test the Go sdk but in a raw json response the cmc is now a float value :+1:

mbndr commented 5 years ago

Closing this issue because the problem must be handled here #4