Add part5

This commit is contained in:
Richard Feldman
2018-08-11 14:42:13 -04:00
parent 032194c6be
commit 42f4182e1b
55 changed files with 5997 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
module Profile exposing (Profile, avatar, bio, decoder)
{-| A user's profile - potentially your own!
Contrast with Cred, which is the currently signed-in user.
-}
import Api
import Avatar exposing (Avatar)
import Http
import HttpBuilder exposing (RequestBuilder, withExpect)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (required)
import Username exposing (Username)
import Viewer.Cred as Cred exposing (Cred)
-- TYPES
type Profile
= Profile Internals
type alias Internals =
{ bio : Maybe String
, avatar : Avatar
}
-- INFO
bio : Profile -> Maybe String
bio (Profile info) =
info.bio
avatar : Profile -> Avatar
avatar (Profile info) =
info.avatar
-- SERIALIZATION
decoder : Decoder Profile
decoder =
Decode.succeed Internals
|> required "bio" (Decode.nullable Decode.string)
|> required "image" Avatar.decoder
|> Decode.map Profile