{-
   Swagger Petstore
   This is a sample server Petstore server.  You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).  For this sample, you can use the api key `special-key` to test the authorization filters.

   OpenAPI spec version: 1.0.0
   Contact: apiteam@swagger.io

   NOTE: This file is auto generated by the swagger code generator program.
   https://github.com/swagger-api/swagger-codegen.git
   Do not edit this file manually.
-}


module Data.ApiResponse exposing (ApiResponse, apiResponseDecoder, apiResponseEncoder)

import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (decode, optional, required)
import Json.Encode as Encode
import Maybe exposing (map, withDefault)


{-
   Describes the result of uploading an image resource
-}


type alias ApiResponse =
    { code : Maybe Int
    , type_ : Maybe String
    , message : Maybe String
    }


apiResponseDecoder : Decoder ApiResponse
apiResponseDecoder =
    decode ApiResponse
        |> optional "code" (Decode.nullable Decode.int) Nothing
        |> optional "type" (Decode.nullable Decode.string) Nothing
        |> optional "message" (Decode.nullable Decode.string) Nothing



apiResponseEncoder : ApiResponse -> Encode.Value
apiResponseEncoder model =
    Encode.object
        [ ( "code", withDefault Encode.null (map Encode.int model.code) )
        , ( "type", withDefault Encode.null (map Encode.string model.type_) )
        , ( "message", withDefault Encode.null (map Encode.string model.message) )
        ]


