mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
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:
parent
c6cb97e199
commit
f9090b0c2c
20 changed files with 535 additions and 524 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue