Client for the Gab.com API, documented at developers.gab.com.
This does NOT do authentication. You'll need to use billstclair/elm-oauth-middleware to get a Token. See the example directory.
The requests all come in two flavors, one which has the decoder built in, and returns an Http.Request, and one for which you provide your own decoder, and returns RequestParts. E.g.:
getTorbaRequest : OAuth.Token -> Http.Request User
getTorbaRequest token =
userProfile token "a"
getTorbaParts : OAuth.Token -> RequestParts Json.Decode.Value
getTorbaParts token =
userProfileParts Json.Decode.value token "a"
getTorbaRequestFromParts : OAuth.Token -> Http.Request Json.Decode.Value
getTorbaRequestFromParts token =
getTorbaParts token
|> requestYou'll usually use these, not the Parts functions below.
Return the logged-in user's profile information as a User record.
Return the logged-in user's followers as a UserList record.
userFollowers token username beforebefore is the number of following users to skip before the listing starts. This enables scrolling through a long list.
Return a list of users following the logged-in user, as a UserList record.
userFollowing token username beforebefore is the number of followers to skip before the listing starts. This enables scrolling through a long list.
Follow or unfollow a user. Return value not interesting.
followUser token username unfollowMute or unmute a user. Return value not interesting.
muteUser token username unmuteThis isn't currently implemented by the API, but I expect that to change.
Return posts in the home feed.
homeFeed token beforeThe posts returned will have dates before before. Pass the empty string to get the beginning of the list.
Return posts for a user feed.
userFeed token user beforeThe posts returned will have dates before before. Pass the empty string to get the beginning of the list.
Return posts for a group feed.
groupFeed token group beforeThe posts returned will have dates before before. Pass the empty string to get the beginning of the list.
This is a guess at what this API command will look like. It doesn't yet exist.
Return the posts in the "popular" feed, as a ActivityLogList.
popularFeed tokenReturn a list of popular users, as a UserList record.
popularUsers tokenReturn notifications for the logged in user.
notifications token beforeFor notifications, the before parameter is a notification ID, not a date.
Get a single post.
getPost token postidUpvote or unupvote a post. Return value not interesting.
upvotePost token postid unupvoteDownvote or undownvote a post. Return value not interesting.
downvotePost token postid undownvoteThis will return an Http BadStatus error if you you're not
authorized to downvote.
Repost or unrepost. Return value not interesting.
repost token postid unrepostPosting uses JSON, which is not in the spec, but is what the web client does.
Posting an image.
The String that comes back is a media ID, to be used in PostForm.media_attachments.
These are mostly for the example, but if you need to get your hands on the raw return Value from the API, use these intead of the auto-decoding versions.
Return the logged-in user's profile information, using a custom decoder.
Return the logged-in user's profile information, using a custom decoder.
Return the logged-in user's followers, using a custom decoder.
userFollowersParts decoder token username beforebefore is the number of following users to skip before the listing starts. This enables scrolling through a long list.
Return a list of users following the logged-in user, using a custom decoder.
userFollowingParts decoder token username beforebefore is the number of followers to skip before the listing starts. This enables scrolling through a long list.
Follow or unfollow a user, with a custom decoder.
followUserParts decoder token username unfollowMute or unmute a user, with a custom decoder.
muteUserParts decoder token username unmuteThis isn't currently implemented by the API, but I expect that to change.
Return posts in the home feed, using a custom encoder.
homeFeedParts decoder token beforeThe posts returned will have dates before before. Pass the empty string to get the beginning of the list.
Return posts for a user feed, using a custom decoder.
userFeedParts decoder user token beforeThe posts returned will have dates before before. Pass the empty string to get the beginning of the list.
Return posts for a group feed, using a custom decoder.
groupFeedParts decoder token groupid beforeThe posts returned will have dates before before. Pass the empty string to get the beginning of the list.
This is a guess at what this API command will look like. It doesn't yet exist.
Return the posts in the "popular" feed, using a custom decoder.
popularFeedParts decoder tokenReturn a list of popular users, using a custom decoder.
popularUserParts decoder tokenReturn notifications, using a custom decoder.
notificationsParts decoder token beforeFor notifications, the before parameter is a notification ID, not a date.
Get a single post, using a custom decoder.
getPostParts decoder token postidUpvote or unupvote a post, with a custom decoder.
upvotePostParts decoder token postid unupvoteDownvote or undownvote a post, with a custom decoder.
downvotePostParts decoder token postid undownvoteRepost or unrepost, with a custom decoder.
repostParts decoder token postid unrepostCreate a new post with a custom decoder.
Post an image with a custom decoder
These are low-level functions used to implement the others. You won't need them unless you need to implement new API functionality that isn't yet in this module.
Shared by doUsersParts and doPostParts
doParts prefix operation decoder token identifier undoprefix can be "users" or "posts".
If undo is True, does a DELETE. Otherwise, does a POST.
Shared by followUserParts and muteUserParts
doUsersParts operation decoder token username undooperation can be "follow" or "mute".
Shared by upvotePostParts, downvotePostParts, repostParts
doPostsParts operation decoder token username undooperation can be "upvote", "downvote" or "repost".
Convert an OAuthMiddleWare.ResponseToken to Gab.Types.SavedToken.
Use Gab.EncodeDecode.savedTokenEncoder and Gab.EncodeDecode.savedTokenDecoder to persist it.
The base URI for GAB API requests. Automatically prepended to path args.
Turn parts into a ready-to-send Http.Request.
Simple HTTP GET request. Empty body, no custom headers.
get token path decoderGeneral-purpose Http.Request constructor.
request method headers token path body decodermethod is the Http method, e.g. "GET".
headers is a list of custom Http.Headers.
token is an OAuth token, often gotten with billstclair/elm-oauth-middleware.
path is the path to the API endpoint, with NO leading slash.
decoder is a JSON decoder for the result.
Debugging function for displaying a request body.
Return the logged-in user's profile information as a User record.