leverage HttpBuilder.withQueryParams where applicable.
This commit is contained in:
parent
ce27e30297
commit
dc5ad2e670
|
@ -25,8 +25,6 @@ module Mastodon.ApiUrl
|
||||||
, searchAccount
|
, searchAccount
|
||||||
)
|
)
|
||||||
|
|
||||||
import Mastodon.Encoder exposing (encodeUrl)
|
|
||||||
|
|
||||||
|
|
||||||
type alias Server =
|
type alias Server =
|
||||||
String
|
String
|
||||||
|
@ -77,10 +75,9 @@ searchAccount =
|
||||||
accounts ++ "search"
|
accounts ++ "search"
|
||||||
|
|
||||||
|
|
||||||
relationships : List Int -> String
|
relationships : String
|
||||||
relationships ids =
|
relationships =
|
||||||
encodeUrl (accounts ++ "relationships") <|
|
accounts ++ "relationships"
|
||||||
List.map (\id -> ( "id[]", toString id )) ids
|
|
||||||
|
|
||||||
|
|
||||||
followers : Int -> String
|
followers : Int -> String
|
||||||
|
@ -98,18 +95,9 @@ homeTimeline =
|
||||||
"/api/v1/timelines/home"
|
"/api/v1/timelines/home"
|
||||||
|
|
||||||
|
|
||||||
publicTimeline : Maybe String -> String
|
publicTimeline : String
|
||||||
publicTimeline local =
|
publicTimeline =
|
||||||
let
|
"/api/v1/timelines/public"
|
||||||
isLocal =
|
|
||||||
case local of
|
|
||||||
Just local ->
|
|
||||||
"?local=true"
|
|
||||||
|
|
||||||
Nothing ->
|
|
||||||
""
|
|
||||||
in
|
|
||||||
"/api/v1/timelines/public" ++ isLocal
|
|
||||||
|
|
||||||
|
|
||||||
accountTimeline : Int -> String
|
accountTimeline : Int -> String
|
||||||
|
|
|
@ -140,20 +140,19 @@ fetchUserTimeline client =
|
||||||
|
|
||||||
fetchRelationships : Client -> List Int -> Request (List Relationship)
|
fetchRelationships : Client -> List Int -> Request (List Relationship)
|
||||||
fetchRelationships client ids =
|
fetchRelationships client ids =
|
||||||
-- TODO: use withQueryParams
|
fetch client GET ApiUrl.relationships (Decode.list relationshipDecoder)
|
||||||
fetch client GET (ApiUrl.relationships ids) <| Decode.list relationshipDecoder
|
|> Build.withQueryParams (List.map (\id -> ( "id[]", toString id )) ids)
|
||||||
|
|
||||||
|
|
||||||
fetchLocalTimeline : Client -> Request (List Status)
|
fetchLocalTimeline : Client -> Request (List Status)
|
||||||
fetchLocalTimeline client =
|
fetchLocalTimeline client =
|
||||||
-- TODO: use withQueryParams
|
fetch client GET ApiUrl.publicTimeline (Decode.list statusDecoder)
|
||||||
fetch client GET (ApiUrl.publicTimeline (Just "public")) <| Decode.list statusDecoder
|
|> Build.withQueryParams [ ( "local", "true" ) ]
|
||||||
|
|
||||||
|
|
||||||
fetchGlobalTimeline : Client -> Request (List Status)
|
fetchGlobalTimeline : Client -> Request (List Status)
|
||||||
fetchGlobalTimeline client =
|
fetchGlobalTimeline client =
|
||||||
-- TODO: use withQueryParams
|
fetch client GET ApiUrl.publicTimeline <| Decode.list statusDecoder
|
||||||
fetch client GET (ApiUrl.publicTimeline (Nothing)) <| Decode.list statusDecoder
|
|
||||||
|
|
||||||
|
|
||||||
fetchAccountTimeline : Client -> Int -> Request (List Status)
|
fetchAccountTimeline : Client -> Int -> Request (List Status)
|
||||||
|
|
Loading…
Reference in New Issue