{-
   OpenAPI Petstore
   This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.

   OpenAPI spec version: 1.0.0

   NOTE: This file is auto generated by the openapi-generator.
   https://github.com/openapitools/openapi-generator.git
   Do not edit this file manually.
-}


module Data.User exposing (User, decoder, encode)

import Dict exposing (Dict)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode


{-| A User who is purchasing from the pet store
-}
type alias User =
    { id : Maybe Int
    , username : Maybe String
    , firstName : Maybe String
    , lastName : Maybe String
    , email : Maybe String
    , password : Maybe String
    , phone : Maybe String
    , userStatus : Maybe Int
    }


decoder : Decoder User
decoder =
    Decode.succeed User
        |> optional "id" (Decode.nullable Decode.int) Nothing
        |> optional "username" (Decode.nullable Decode.string) Nothing
        |> optional "firstName" (Decode.nullable Decode.string) Nothing
        |> optional "lastName" (Decode.nullable Decode.string) Nothing
        |> optional "email" (Decode.nullable Decode.string) Nothing
        |> optional "password" (Decode.nullable Decode.string) Nothing
        |> optional "phone" (Decode.nullable Decode.string) Nothing
        |> optional "userStatus" (Decode.nullable Decode.int) Nothing


encode : User -> Encode.Value
encode model =
    Encode.object
        [ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
        , ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
        , ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
        , ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
        , ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
        , ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
        , ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
        , ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
        ]
