package com.h.pixeldroid.api import com.h.pixeldroid.objects.Application import com.h.pixeldroid.objects.Status import com.h.pixeldroid.objects.Token import retrofit2.Call import retrofit2.Retrofit import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory import retrofit2.converter.gson.GsonConverterFactory import retrofit2.http.FormUrlEncoded import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.Query import retrofit2.http.Field /* Implements the Pixelfed API https://docs.pixelfed.org/technical-documentation/api-v1.html However, since this is mostly based on the Mastodon API, the documentation there will be more useful: https://docs.joinmastodon.org/ */ interface PixelfedAPI { @FormUrlEncoded @POST("/api/v1/apps") fun registerApplication( @Field("client_name") client_name: String, @Field("redirect_uris") redirect_uris: String, @Field("scopes") scopes: String? = null, @Field("website") website: String? = null ): Call @FormUrlEncoded @POST("/oauth/token") fun obtainToken( @Field("client_id") client_id: String, @Field("client_secret") client_secret: String, @Field("redirect_uri") redirect_uri: String, @Field("scope") scope: String? = "read", @Field("code") code: String? = null, @Field("grant_type") grant_type: String? = null ): Call @GET("/api/v1/timelines/public") fun timelinePublic( @Query("local") local: Boolean? = null, @Query("max_id") max_id: String? = null, @Query("since_id") since_id: String? = null, @Query("min_id") min_id: String? = null, @Query("limit") limit: Int? = null ): Call> companion object { fun create(baseUrl: String): PixelfedAPI { return Retrofit.Builder() .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .build().create(PixelfedAPI::class.java) } } }