Fixes: #3278: Add java docs to methods which have it missing (#3351)

* achievements/: add Javadocs

* actions/: add Javadocs

* WikiAccountAuthenticator: add Javadocs

* ReasonBuilder: add Javadocs

* di: Add javadocs to DI files

* bookmarks: add Javadocs to bookmarks files

* di: Added more Javadocs

* file: add Javadocs for file picker

* actions: add proper decription to the classes
This commit is contained in:
Kshitij Bhardwaj 2020-01-29 00:15:15 +05:30 committed by Vivek Maskara
parent 803bed43d7
commit 0affe71745
25 changed files with 269 additions and 5 deletions

View file

@ -5,6 +5,13 @@ import org.wikipedia.dataclient.Service;
import io.reactivex.Observable;
/**
* This class acts as a Client to facilitate wiki page editing
* services to various dependency providing modules such as the Network module, the Review Controller ,etc
*
* The methods provided by this class will post to the Media wiki api
* documented at: https://commons.wikimedia.org/w/api.php?action=help&modules=edit
*/
public class PageEditClient {
private final CsrfTokenClient csrfTokenClient;
@ -19,6 +26,12 @@ public class PageEditClient {
this.service = service;
}
/**
* This method is used when the content of the page is to be replaced by new content received
* @param pagetitle Title of the page to edit
* @param text Holds the page content
* @param summary Edit summary
*/
public Observable<Boolean> edit(String pageTitle, String text, String summary) {
try {
return pageEditInterface.postEdit(pageTitle, summary, text, csrfTokenClient.getTokenBlocking())
@ -28,6 +41,12 @@ public class PageEditClient {
}
}
/**
* This method is used when we need to append something to the end of wiki page content
* @param pagetitle Title of the page to edit
* @param appendText The received page content is added to beginning of the page
* @param summary Edit summary
*/
public Observable<Boolean> appendEdit(String pageTitle, String appendText, String summary) {
try {
return pageEditInterface.postAppendEdit(pageTitle, summary, appendText, csrfTokenClient.getTokenBlocking())
@ -37,6 +56,12 @@ public class PageEditClient {
}
}
/**
* This method is used when we need to add something to the starting of the page
* @param pagetitle Title of the page to edit
* @param prependText The received page content is added to beginning of the page
* @param summary Edit summary
*/
public Observable<Boolean> prependEdit(String pageTitle, String prependText, String summary) {
try {
return pageEditInterface.postPrependEdit(pageTitle, summary, prependText, csrfTokenClient.getTokenBlocking())

View file

@ -12,8 +12,24 @@ import retrofit2.http.POST;
import static org.wikipedia.dataclient.Service.MW_API_PREFIX;
/**
* This interface facilitates wiki commons page editing services to the Networking module
* which provides all network related services used by the app.
*
* This interface posts a form encoded request to the wikimedia API
* with editing action as argument to edit a particular page
*/
public interface PageEditInterface {
/**
* This method posts such that the Content which the page
* has will be completely replaced by the value being passed to the
* "text" field of the encoded form data
* @param title Title of the page to edit. Cannot be used together with pageid.
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
* @param text Holds the page content
* @param token A "csrf" token
*/
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(MW_API_PREFIX + "action=edit")
@ -21,8 +37,18 @@ public interface PageEditInterface {
Observable<Edit> postEdit(@NonNull @Field("title") String title,
@NonNull @Field("summary") String summary,
@NonNull @Field("text") String text,
// NOTE: This csrf shold always be sent as the last field of form data
@NonNull @Field("token") String token);
/**
* This method posts such that the Content which the page
* has will be completely replaced by the value being passed to the
* "text" field of the encoded form data
* @param title Title of the page to edit. Cannot be used together with pageid.
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
* @param text The received page content is added to beginning of the page
* @param token A "csrf" token
*/
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(MW_API_PREFIX + "action=edit")
@ -31,6 +57,15 @@ public interface PageEditInterface {
@NonNull @Field("appendtext") String text,
@NonNull @Field("token") String token);
/**
* This method posts such that the Content which the page
* has will be completely replaced by the value being passed to the
* "text" field of the encoded form data
* @param title Title of the page to edit. Cannot be used together with pageid.
* @param summary Edit summary. Also section title when section=new and sectiontitle is not set
* @param text The received page content is added to beginning of the page
* @param token A "csrf" token
*/
@FormUrlEncoded
@Headers("Cache-Control: no-cache")
@POST(MW_API_PREFIX + "action=edit")

View file

@ -10,6 +10,13 @@ import javax.inject.Singleton;
import fr.free.nrw.commons.CommonsApplication;
import io.reactivex.Observable;
/**
* Facilitates the Wkikimedia Thanks api extention, as described in the
* api documentation: "The Thanks extension includes an API for sending thanks"
*
* In simple terms this class is used by a user to thank someone for adding
* contribution to the commons platform
*/
@Singleton
public class ThanksClient {
@ -23,6 +30,11 @@ public class ThanksClient {
this.service = service;
}
/**
* Handles the Thanking logic
* @param revesionID The revision ID you would like to thank someone for
* @return if thanks was successfully sent to intended recepient, returned as a boolean observable
*/
public Observable<Boolean> thank(long revisionId) {
try {
return service.thank(String.valueOf(revisionId), null,