leverage HttpBuilder.withQueryParams where applicable.

This commit is contained in:
Nicolas Perriault 2017-05-02 22:31:15 +02:00
parent ce27e30297
commit dc5ad2e670
No known key found for this signature in database
GPG Key ID: DA5E4C83904F7A2A
2 changed files with 11 additions and 24 deletions

View File

@ -25,8 +25,6 @@ module Mastodon.ApiUrl
, searchAccount
)
import Mastodon.Encoder exposing (encodeUrl)
type alias Server =
String
@ -77,10 +75,9 @@ searchAccount =
accounts ++ "search"
relationships : List Int -> String
relationships ids =
encodeUrl (accounts ++ "relationships") <|
List.map (\id -> ( "id[]", toString id )) ids
relationships : String
relationships =
accounts ++ "relationships"
followers : Int -> String
@ -98,18 +95,9 @@ homeTimeline =
"/api/v1/timelines/home"
publicTimeline : Maybe String -> String
publicTimeline local =
let
isLocal =
case local of
Just local ->
"?local=true"
Nothing ->
""
in
"/api/v1/timelines/public" ++ isLocal
publicTimeline : String
publicTimeline =
"/api/v1/timelines/public"
accountTimeline : Int -> String

View File

@ -140,20 +140,19 @@ fetchUserTimeline client =
fetchRelationships : Client -> List Int -> Request (List Relationship)
fetchRelationships client ids =
-- TODO: use withQueryParams
fetch client GET (ApiUrl.relationships ids) <| Decode.list relationshipDecoder
fetch client GET ApiUrl.relationships (Decode.list relationshipDecoder)
|> Build.withQueryParams (List.map (\id -> ( "id[]", toString id )) ids)
fetchLocalTimeline : Client -> Request (List Status)
fetchLocalTimeline client =
-- TODO: use withQueryParams
fetch client GET (ApiUrl.publicTimeline (Just "public")) <| Decode.list statusDecoder
fetch client GET ApiUrl.publicTimeline (Decode.list statusDecoder)
|> Build.withQueryParams [ ( "local", "true" ) ]
fetchGlobalTimeline : Client -> Request (List Status)
fetchGlobalTimeline client =
-- TODO: use withQueryParams
fetch client GET (ApiUrl.publicTimeline (Nothing)) <| Decode.list statusDecoder
fetch client GET ApiUrl.publicTimeline <| Decode.list statusDecoder
fetchAccountTimeline : Client -> Int -> Request (List Status)