Consistent api interfaces (#5530)

* Converted CategoryInterface to kotlin

* Converted DepictsInterface to kotlin

* Convert the MediaDetailInterface to kotlin

* Convert MediaInterface to kotlin

* Convert ReviewInterface to kotlin

* Convert the UserInterface to kotlin

* Convert the WikiBaseInterface to kotlin

* Convert WikidataInterface to kotlin

* Convert WikidataMediaInterface to kotlin

* Convert UploadInterface to kotlin
This commit is contained in:
Paul Hawke 2024-02-08 22:43:01 -06:00 committed by GitHub
parent c6cb97e199
commit f9090b0c2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 535 additions and 524 deletions

View file

@ -1,36 +0,0 @@
package fr.free.nrw.commons.wikidata;
import androidx.annotation.NonNull;
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResponse;
import fr.free.nrw.commons.wikidata.model.WbCreateClaimResponse;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import static fr.free.nrw.commons.wikidata.WikidataConstants.MW_API_PREFIX;
public interface WikidataInterface {
/**
* Get edit token for wikidata wiki site
*/
@Headers("Cache-Control: no-cache")
@GET(MW_API_PREFIX + "action=query&meta=tokens&type=csrf")
@NonNull
Observable<MwQueryResponse> getCsrfToken();
/**
* Wikidata create claim API. Posts a new claim for the given entity ID
*/
@Headers("Cache-Control: no-cache")
@POST("w/api.php?format=json&action=wbsetclaim")
@FormUrlEncoded
Observable<WbCreateClaimResponse> postSetClaim(@NonNull @Field("claim") String request,
@NonNull @Field("tags") String tags,
@NonNull @Field("token") String token);
}

View file

@ -0,0 +1,31 @@
package fr.free.nrw.commons.wikidata
import fr.free.nrw.commons.wikidata.model.WbCreateClaimResponse
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResponse
import io.reactivex.Observable
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
interface WikidataInterface {
/**
* Get edit token for wikidata wiki site
*/
@Headers("Cache-Control: no-cache")
@GET(WikidataConstants.MW_API_PREFIX + "action=query&meta=tokens&type=csrf")
fun getCsrfToken(): Observable<MwQueryResponse>
/**
* Wikidata create claim API. Posts a new claim for the given entity ID
*/
@Headers("Cache-Control: no-cache")
@POST("w/api.php?format=json&action=wbsetclaim")
@FormUrlEncoded
fun postSetClaim(
@Field("claim") request: String,
@Field("tags") tags: String,
@Field("token") token: String
): Observable<WbCreateClaimResponse>
}