/* Copyright 2017 Andrew Dawson * * This file is a part of Tusky. * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. * * Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along with Tusky; if not, * see . */ package com.keylesspalace.tusky; import com.keylesspalace.tusky.entity.AccessToken; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.AppCredentials; import com.keylesspalace.tusky.entity.Media; import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Relationship; import com.keylesspalace.tusky.entity.Status; import com.keylesspalace.tusky.entity.StatusContext; import java.util.List; import okhttp3.MultipartBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.Query; public interface MastodonAPI { String ENDPOINT_AUTHORIZE = "/oauth/authorize"; @GET("api/v1/timelines/home") Call> homeTimeline( @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/timelines/public") Call> publicTimeline( @Query("local") Boolean local, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/timelines/tag/{hashtag}") Call> hashtagTimeline( @Path("hashtag") String hashtag, @Query("local") Boolean local, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/notifications") Call> notifications( @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @POST("api/v1/notifications/clear") Call clearNotifications(); @GET("api/v1/notifications/{id}") Call notification(@Path("id") String notificationId); @Multipart @POST("api/v1/media") Call uploadMedia(@Part MultipartBody.Part file); @FormUrlEncoded @POST("api/v1/statuses") Call createStatus( @Field("status") String text, @Field("in_reply_to_id") String inReplyToId, @Field("spoiler_text") String warningText, @Field("visibility") String visibility, @Field("sensitive") Boolean sensitive, @Field("media_ids[]") List mediaIds); @GET("api/v1/statuses/{id}") Call status(@Path("id") String statusId); @GET("api/v1/statuses/{id}/context") Call statusContext(@Path("id") String statusId); @GET("api/v1/statuses/{id}/reblogged_by") Call> statusRebloggedBy( @Path("id") String statusId, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/statuses/{id}/favourited_by") Call> statusFavouritedBy( @Path("id") String statusId, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @DELETE("api/v1/statuses/{id}") Call deleteStatus(@Path("id") String statusId); @POST("api/v1/statuses/{id}/reblog") Call reblogStatus(@Path("id") String statusId); @POST("api/v1/statuses/{id}/unreblog") Call unreblogStatus(@Path("id") String statusId); @POST("api/v1/statuses/{id}/favourite") Call favouriteStatus(@Path("id") String statusId); @POST("api/v1/statuses/{id}/unfavourite") Call unfavouriteStatus(@Path("id") String statusId); @GET("api/v1/accounts/verify_credentials") Call accountVerifyCredentials(); @GET("api/v1/accounts/search") Call> searchAccounts( @Query("q") String q, @Query("resolve") Boolean resolve, @Query("limit") Integer limit); @GET("api/v1/accounts/{id}") Call account(@Path("id") String accountId); @GET("api/v1/accounts/{id}/statuses") Call> accountStatuses( @Path("id") String accountId, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/accounts/{id}/followers") Call> accountFollowers( @Path("id") String accountId, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/accounts/{id}/following") Call> accountFollowing( @Path("id") String accountId, @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @POST("api/v1/accounts/{id}/follow") Call followAccount(@Path("id") String accountId); @POST("api/v1/accounts/{id}/unfollow") Call unfollowAccount(@Path("id") String accountId); @POST("api/v1/accounts/{id}/block") Call blockAccount(@Path("id") String accountId); @POST("api/v1/accounts/{id}/unblock") Call unblockAccount(@Path("id") String accountId); @POST("api/v1/accounts/{id}/mute") Call muteAccount(@Path("id") String accountId); @POST("api/v1/accounts/{id}/unmute") Call unmuteAccount(@Path("id") String accountId); @GET("api/v1/accounts/relationships") Call> relationships(@Query("id[]") List accountIds); @GET("api/v1/blocks") Call> blocks( @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/mutes") Call> mutes( @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/favourites") Call> favourites( @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @GET("api/v1/follow_requests") Call> followRequests( @Query("max_id") String maxId, @Query("since_id") String sinceId, @Query("limit") Integer limit); @POST("api/v1/follow_requests/{id}/authorize") Call authorizeFollowRequest(@Path("id") String accountId); @POST("api/v1/follow_requests/{id}/reject") Call rejectFollowRequest(@Path("id") String accountId); @FormUrlEncoded @POST("api/v1/reports") Call report(@Field("account_id") String accountId, @Field("status_ids[]") List statusIds, @Field("comment") String comment); @FormUrlEncoded @POST("api/v1/apps") Call authenticateApp( @Field("client_name") String clientName, @Field("redirect_uris") String redirectUris, @Field("scopes") String scopes, @Field("website") String website); @FormUrlEncoded @POST("oauth/token") Call fetchOAuthToken( @Field("client_id") String clientId, @Field("client_secret") String clientSecret, @Field("redirect_uri") String redirectUri, @Field("code") String code, @Field("grant_type") String grantType ); }