Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344module Sources.Services.Dropbox.Parser exposing (parseErrorResponse, parseTreeResponse)
import Json.Decode exposing (..)import Sources.Processing exposing (Marker(..), TreeAnswer)
-- TREE
parseTreeResponse : String -> Marker -> TreeAnswer MarkerparseTreeResponse response _ = let hasMore = decodeString (field "has_more" bool) response
cursor = decodeString (field "cursor" string) response
paths = decodeString (field "entries" <| list <| field "path_display" string) response in { filePaths = Result.withDefault [] paths , marker = if Result.withDefault False hasMore then InProgress (Result.withDefault "" cursor)
else TheEnd }
-- Error
parseErrorResponse : String -> Maybe StringparseErrorResponse response = response |> decodeString (field "error_summary" string) |> Result.toMaybe