import Set exposing (Set)
import Dict exposing (Dict)
import Json.Decode as Decode exposing (..)
import Json.Decode.Extra exposing ((|:), withDefault)
type Item =
Item
{ name : Maybe String
, description : Maybe String
, price : Maybe Int
, sku : Maybe String
, stockAvailable : Maybe Int
, internationalShipping : Maybe Bool
}
itemDecoder : Decoder Item
itemDecoder =
(Decode.succeed
(\name description price sku stockAvailable internationalShipping ->
Item
{
name = name
,description = description
,price = price
,sku = sku
,stockAvailable = stockAvailable
,internationalShipping = internationalShipping
}
)
)
|: Decode.maybe (field "name" Decode.string)
|: Decode.maybe (field "description" Decode.string)
|: Decode.maybe (field "price" Decode.int)
|: Decode.maybe (field "sku" Decode.string)
|: Decode.maybe (field "stock-available" Decode.int)
|: Decode.maybe (field "international-shipping" Decode.bool)