1
0
Fork 0
tooty/src/Mastodon/ApiUrl.elm

172 lines
3.2 KiB
Elm
Raw Normal View History

2017-04-26 15:07:43 +00:00
module Mastodon.ApiUrl
exposing
( apps
, oauthAuthorize
, oauthToken
, userAccount
2017-04-26 15:07:43 +00:00
, account
2017-04-27 20:01:51 +00:00
, accountTimeline
, followers
, following
2017-04-29 07:20:26 +00:00
, status
2017-04-26 15:07:43 +00:00
, homeTimeline
, publicTimeline
, notifications
, relationships
2017-04-26 15:07:43 +00:00
, statuses
, context
2017-04-26 15:07:43 +00:00
, reblog
, unreblog
, favourite
, unfavourite
, follow
, unfollow
2017-04-26 15:07:43 +00:00
, streaming
, searchAccount
2017-04-26 15:07:43 +00:00
)
import Mastodon.Encoder exposing (encodeUrl)
2017-04-26 15:07:43 +00:00
type alias Server =
String
apps : Server -> String
apps server =
server ++ "/api/v1/apps"
oauthAuthorize : Server -> String
oauthAuthorize server =
server ++ "/oauth/authorize"
oauthToken : Server -> String
oauthToken server =
server ++ "/oauth/token"
accounts : String
accounts =
"/api/v1/accounts/"
account : Int -> String
account id =
accounts ++ (toString id)
follow : Server -> Int -> String
follow server id =
server ++ accounts ++ (toString id) ++ "/follow"
unfollow : Server -> Int -> String
unfollow server id =
server ++ accounts ++ (toString id) ++ "/unfollow"
userAccount : Server -> String
userAccount server =
server ++ accounts ++ "verify_credentials"
searchAccount : Server -> String -> Int -> Bool -> String
searchAccount server query limit resolve =
encodeUrl (server ++ accounts ++ "search")
[ ( "q", query )
, ( "limit", toString limit )
, ( "resolve"
, if resolve then
"true"
else
"false"
)
]
relationships : List Int -> String
relationships ids =
encodeUrl (accounts ++ "relationships") <|
List.map (\id -> ( "id[]", toString id )) ids
followers : Int -> String
followers id =
(account id) ++ "/followers"
following : Int -> String
following id =
(account id) ++ "/following"
2017-04-26 15:07:43 +00:00
homeTimeline : String
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
2017-04-27 20:01:51 +00:00
accountTimeline : Int -> String
accountTimeline id =
(account id) ++ "/statuses"
2017-04-26 15:07:43 +00:00
notifications : String
notifications =
"/api/v1/notifications"
statuses : Server -> String
statuses server =
server ++ "/api/v1/statuses"
context : Server -> Int -> String
context server id =
statuses server ++ "/" ++ (toString id) ++ "/context"
2017-04-26 15:07:43 +00:00
reblog : Server -> Int -> String
reblog server id =
statuses server ++ "/" ++ (toString id) ++ "/reblog"
2017-04-26 15:07:43 +00:00
2017-04-29 07:20:26 +00:00
status : Server -> Int -> String
status server id =
statuses server ++ "/" ++ (toString id)
2017-04-26 15:07:43 +00:00
unreblog : Server -> Int -> String
unreblog server id =
statuses server ++ "/" ++ (toString id) ++ "/unreblog"
2017-04-26 15:07:43 +00:00
favourite : Server -> Int -> String
favourite server id =
statuses server ++ "/" ++ (toString id) ++ "/favourite"
2017-04-26 15:07:43 +00:00
unfavourite : Server -> Int -> String
unfavourite server id =
statuses server ++ "/" ++ (toString id) ++ "/unfavourite"
2017-04-26 15:07:43 +00:00
streaming : Server -> String
streaming server =
server ++ "/api/v1/streaming/"