2021-07-16 16:06:33 +00:00
|
|
|
module Card exposing (..)
|
|
|
|
|
|
|
|
import Json.Decode
|
|
|
|
import Json.Decode.Pipeline as JDP
|
|
|
|
|
|
|
|
|
|
|
|
type alias Card =
|
|
|
|
{ scryfallId : String
|
|
|
|
, name : String
|
|
|
|
, setCode : String
|
|
|
|
, rarity : String
|
2021-07-17 03:18:06 +00:00
|
|
|
, oracleText : String
|
2021-07-16 16:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
decode : Json.Decode.Decoder Card
|
|
|
|
decode =
|
|
|
|
Json.Decode.succeed Card
|
|
|
|
|> JDP.required "scryfall_id" Json.Decode.string
|
|
|
|
|> JDP.required "name" Json.Decode.string
|
|
|
|
|> JDP.required "set_code" Json.Decode.string
|
|
|
|
|> JDP.required "rarity" Json.Decode.string
|
2021-07-17 03:18:06 +00:00
|
|
|
|> JDP.required "oracle_text"
|
|
|
|
(Json.Decode.nullable Json.Decode.string
|
|
|
|
|> Json.Decode.map (Maybe.withDefault "")
|
|
|
|
)
|