Renamed APIRequestParameters to APIRequest

This commit is contained in:
Pierre 2018-04-21 12:03:46 +02:00
parent 5e0ad1c526
commit 4c79e5de9f
13 changed files with 53 additions and 54 deletions

View File

@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.asynctasks;
import android.os.AsyncTask;
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
/**
@ -18,7 +18,7 @@ import org.communiquons.android.comunic.client.data.models.APIResponse;
* Created by pierre on 10/31/17.
*/
@Deprecated
public abstract class APIRequestTask extends AsyncTask<APIRequestParameters, Void, APIResponse> {
public abstract class APIRequestTask extends AsyncTask<APIRequest, Void, APIResponse> {
/**
* API request in a Background task
@ -29,7 +29,7 @@ public abstract class APIRequestTask extends AsyncTask<APIRequestParameters, Voi
* @return JSONObject The result of the request
*/
@Override
protected APIResponse doInBackground(APIRequestParameters... params) {
protected APIResponse doInBackground(APIRequest... params) {
try {
//Perform the API request

View File

@ -5,8 +5,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import org.communiquons.android.comunic.client.BuildConfig;
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import java.io.BufferedOutputStream;
@ -45,7 +44,7 @@ public class APIRequestHelper {
* @param parameters The parameters to pass to the server
* @return The result of the request
*/
public APIResponse exec(APIRequestParameters parameters) throws Exception {
public APIResponse exec(APIRequest parameters) throws Exception {
//Add API and login tokens
addAPItokens(parameters);
@ -136,7 +135,7 @@ public class APIRequestHelper {
*
* @param params The request parametres to update
*/
private void addAPItokens(APIRequestParameters params){
private void addAPItokens(APIRequest params){
params.addString("serviceName", BuildConfig.api_service_name);
params.addString("serviceToken", BuildConfig.api_service_token);
}
@ -146,7 +145,7 @@ public class APIRequestHelper {
*
* @param params The parameters of the request to update
*/
private void addLoginTokens(APIRequestParameters params){
private void addLoginTokens(APIRequest params){
//Create account object
AccountHelper accountHelper = new AccountHelper(params.getContext());

View File

@ -4,7 +4,7 @@ import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.models.Comment;
import org.json.JSONArray;
@ -50,7 +50,7 @@ public class CommentsHelper {
public int send_comment(int postID, String comment){
//Create and perform an API request
APIRequestParameters params = new APIRequestParameters(mContext, "comments/create");
APIRequest params = new APIRequest(mContext, "comments/create");
params.addInt("postID", postID);
params.addString("content", comment);
@ -79,7 +79,7 @@ public class CommentsHelper {
public Comment getInfosSingle(int commentID){
//Prepare API request
APIRequestParameters params = new APIRequestParameters(mContext, "comments/get_single");
APIRequest params = new APIRequest(mContext, "comments/get_single");
params.addInt("commentID", commentID);
//Perform the request
@ -112,7 +112,7 @@ public class CommentsHelper {
public boolean editContent(int commentID, String content){
//Perform a request on the server
APIRequestParameters params = new APIRequestParameters(mContext, "comments/edit");
APIRequest params = new APIRequest(mContext, "comments/edit");
params.addInt("commentID", commentID);
params.addString("content", content);
@ -136,7 +136,7 @@ public class CommentsHelper {
public boolean delete(int commentID){
//Prepare an API request
APIRequestParameters params = new APIRequestParameters(mContext, "comments/delete");
APIRequest params = new APIRequest(mContext, "comments/delete");
params.addInt("commentID", commentID);
//Try to perform the request

View File

@ -4,7 +4,7 @@ import android.content.Context;
import android.support.annotation.Nullable;
import android.util.Log;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
import org.json.JSONArray;
@ -88,7 +88,7 @@ public class ConversationMessagesHelper {
public boolean sendMessage(int convID, String message, @Nullable String image){
//Make an API request
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"conversations/sendMessage");
params.addString("conversationID", ""+convID);
params.addString("message", message);
@ -153,7 +153,7 @@ public class ConversationMessagesHelper {
private ArrayList<ConversationMessage> downloadNew(int conversationID, int last_message_id){
//Prepare a request on the API
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"conversations/refresh_single");
params.addString("conversationID", ""+conversationID);
params.addString("last_message_id", ""+last_message_id);

View File

@ -6,7 +6,7 @@ import android.support.annotation.Nullable;
import android.util.ArrayMap;
import android.util.Log;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
import org.communiquons.android.comunic.client.data.models.UserInfo;
@ -113,7 +113,7 @@ public class ConversationsListHelper {
public Integer getPrivate(int userID, boolean allowCreate){
//Prepare an API request
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"conversations/getPrivate");
params.addInt("otherUser", userID);
params.addBoolean("allowCreate", allowCreate);
@ -212,7 +212,7 @@ public class ConversationsListHelper {
public boolean delete(int convID){
//Delete the conversation on the API
APIRequestParameters params = new APIRequestParameters(mContext, "conversations/delete");
APIRequest params = new APIRequest(mContext, "conversations/delete");
params.addString("conversationID", ""+convID);
try {
@ -243,7 +243,7 @@ public class ConversationsListHelper {
}
//Make an API request
APIRequestParameters params = new APIRequestParameters(mContext, "conversations/create");
APIRequest params = new APIRequest(mContext, "conversations/create");
params.addString("name", name.equals("") ? "false" : name);
params.addString("follow", follow ? "true" : "false");
params.addString("users", members_str);
@ -286,7 +286,7 @@ public class ConversationsListHelper {
@Nullable ArrayList<Integer> members, boolean following){
//Prepare a request on the database
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"conversations/updateSettings");
params.addString("conversationID", ""+convID);
@ -332,7 +332,7 @@ public class ConversationsListHelper {
try {
//Prepare the request on the server
APIRequestParameters params = new APIRequestParameters(mContext, "conversations/getList");
APIRequest params = new APIRequest(mContext, "conversations/getList");
APIResponse response = new APIRequestHelper().exec(params);
//Check if an error occurred
@ -366,7 +366,7 @@ public class ConversationsListHelper {
private ConversationsInfo downloadSingle(int convID){
//Perform an API request
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"conversations/getInfosOne");
params.addString("conversationID", ""+convID);

View File

@ -4,7 +4,7 @@ import android.content.Context;
import android.support.annotation.Nullable;
import android.util.Log;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.models.Friend;
import org.communiquons.android.comunic.client.data.models.FriendshipStatus;
@ -69,7 +69,7 @@ public class FriendsListHelper {
public ArrayList<Friend> download(){
//Prepare the API request
APIRequestParameters params = new APIRequestParameters(mContext, "friends/getList");
APIRequest params = new APIRequest(mContext, "friends/getList");
params.addBoolean("complete", true);
//Prepare the result
@ -121,7 +121,7 @@ public class FriendsListHelper {
public void remove(Friend friend){
try {
//Remove the friend online
APIRequestParameters delparams = new APIRequestParameters(mContext, "friends/remove");
APIRequest delparams = new APIRequest(mContext, "friends/remove");
delparams.addString("friendID", ""+friend.getId());
new APIRequestHelper().exec(delparams);
@ -143,7 +143,7 @@ public class FriendsListHelper {
public boolean sendRequest(int friendID){
//Prepare the request
APIRequestParameters params = new APIRequestParameters(mContext, "friends/sendRequest");
APIRequest params = new APIRequest(mContext, "friends/sendRequest");
params.addInt("friendID", friendID);
//Try to perform the request
@ -165,7 +165,7 @@ public class FriendsListHelper {
public boolean cancelRequest(int friendID){
//Prepare the request
APIRequestParameters params = new APIRequestParameters(mContext, "friends/removeRequest");
APIRequest params = new APIRequest(mContext, "friends/removeRequest");
params.addInt("friendID", friendID);
//Try to perform the request
@ -216,7 +216,7 @@ public class FriendsListHelper {
public boolean respondRequest(int friendID, boolean accept){
//Perform a request to update the status online
APIRequestParameters reqParams = new APIRequestParameters(mContext,
APIRequest reqParams = new APIRequest(mContext,
"friends/respondRequest");
reqParams.addInt("friendID", friendID);
reqParams.addString("accept", accept ? "true" : "false");
@ -244,7 +244,7 @@ public class FriendsListHelper {
public FriendshipStatus getFrienshipStatus(int friendID) {
//Perform a request on the API
APIRequestParameters params = new APIRequestParameters(mContext, "friends/getStatus");
APIRequest params = new APIRequest(mContext, "friends/getStatus");
params.addInt("friendID", friendID);
try {

View File

@ -6,7 +6,7 @@ import android.support.annotation.Nullable;
import android.util.ArrayMap;
import android.util.Log;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo;
import org.communiquons.android.comunic.client.data.models.UserInfo;
@ -127,7 +127,7 @@ public class GetUsersHelper {
public AdvancedUserInfo get_advanced_infos(int userID){
//Perform an API request
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"user/getAdvancedUserInfos");
params.setTryContinueOnError(true);
params.addInt("userID", userID);
@ -263,7 +263,7 @@ public class GetUsersHelper {
private ArrayList<Integer> search_users_online(String query, int limit){
//Make an API request
APIRequestParameters params = new APIRequestParameters(mContext, "search/user");
APIRequest params = new APIRequest(mContext, "search/user");
params.addString("query", query);
params.addString("searchLimit", ""+limit);
@ -299,7 +299,7 @@ public class GetUsersHelper {
//Perform a request on the API server
//Setup the request
APIRequestParameters requestParameters = new APIRequestParameters(mContext,
APIRequest requestParameters = new APIRequest(mContext,
"user/getInfosMultiple");

View File

@ -2,7 +2,7 @@ package org.communiquons.android.comunic.client.data.helpers;
import android.content.Context;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.enums.LikesType;
@ -43,7 +43,7 @@ public class LikesHelper {
public boolean update(LikesType type, int id, boolean liking){
//Perform an API request
APIRequestParameters params = new APIRequestParameters(mContext, "likes/update");
APIRequest params = new APIRequest(mContext, "likes/update");
params.addInt("id", id);
params.addBoolean("like", liking);

View File

@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.helpers;
import android.content.Context;
import android.support.annotation.Nullable;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.models.Notif;
import org.communiquons.android.comunic.client.data.enums.NotifElemType;
@ -50,7 +50,7 @@ public class NotificationsHelper {
public NotificationsCount pullCount(){
//Perform an API request
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"notifications/count_all_news");
//Try to perform the request and parse results
@ -80,7 +80,7 @@ public class NotificationsHelper {
public boolean markSeen(int notifID){
//Perform a request on the server
APIRequestParameters params = new APIRequestParameters(mContext, "notifications/mark_seen");
APIRequest params = new APIRequest(mContext, "notifications/mark_seen");
params.addInt("notifID", notifID);
//Try to send the request to the server
@ -102,7 +102,7 @@ public class NotificationsHelper {
public boolean deleteAllNotifs(){
//Perform a request on the server
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"notifications/delete_all");
//Try to perform the request on the server
@ -124,7 +124,7 @@ public class NotificationsHelper {
public NotifsList getListUnread(){
//Perform a request on the server
APIRequestParameters params = new APIRequestParameters(mContext,
APIRequest params = new APIRequest(mContext,
"notifications/get_list_unread");
//Try to perform the request on the server

View File

@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.helpers;
import android.content.Context;
import android.support.annotation.Nullable;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.models.CreatePost;
import org.communiquons.android.comunic.client.data.enums.PageType;
@ -56,7 +56,7 @@ public class PostsHelper {
public Post getSingle(int id){
//Perform an API request
APIRequestParameters params = new APIRequestParameters(mContext, "posts/get_single");
APIRequest params = new APIRequest(mContext, "posts/get_single");
params.addInt("postID", id);
try {
@ -87,7 +87,7 @@ public class PostsHelper {
public PostsList get_user(int userID){
//Perform a request on the API
APIRequestParameters params = new APIRequestParameters(mContext, "posts/get_user");
APIRequest params = new APIRequest(mContext, "posts/get_user");
params.addInt("userID", userID);
//Perform the request
@ -121,7 +121,7 @@ public class PostsHelper {
public boolean delete(int postID){
//Perform the request on the server
APIRequestParameters params = new APIRequestParameters(mContext, "posts/delete");
APIRequest params = new APIRequest(mContext, "posts/delete");
params.addInt("postID", postID);
//Intend to perform the request
@ -146,7 +146,7 @@ public class PostsHelper {
public int create(CreatePost post){
//Prepare the request on the server
APIRequestParameters params = new APIRequestParameters(mContext, "posts/create");
APIRequest params = new APIRequest(mContext, "posts/create");
//Put basic information about the post
params.addString("content", post.getContent());
@ -224,7 +224,7 @@ public class PostsHelper {
public boolean update_content(int postId, String content) {
//Perform a request on the API
APIRequestParameters params = new APIRequestParameters(mContext, "posts/update_content");
APIRequest params = new APIRequest(mContext, "posts/update_content");
params.addString("new_content", content);
params.addInt("postID", postId);

View File

@ -11,7 +11,7 @@ import java.util.ArrayList;
* Created by pierre on 10/31/17.
*/
public class APIRequestParameters {
public class APIRequest {
/**
* The context of the request
@ -39,7 +39,7 @@ public class APIRequestParameters {
* @param context The context of the request
* @param uri The request URI on the server
*/
public APIRequestParameters(Context context, String uri){
public APIRequest(Context context, String uri){
//Save the context
this.context = context;
@ -47,7 +47,7 @@ public class APIRequestParameters {
//Save request URI
request_uri = uri;
//Intialize parameters array
//Initialize parameters array
parameters = new ArrayList<>();
}

View File

@ -2,7 +2,7 @@ package org.communiquons.android.comunic.client.data.utils;
import android.content.Context;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.json.JSONObject;
@ -66,7 +66,7 @@ public class AccountUtils {
public void refresh_current_user_id(final onceRefreshedUserID callback){
//Perform an API request
APIRequestParameters params = new APIRequestParameters(mContext, "user/getCurrentUserID");
APIRequest params = new APIRequest(mContext, "user/getCurrentUserID");
new APIRequestTask(){
@Override
protected void onPostExecute(APIResponse result) {

View File

@ -14,7 +14,7 @@ import org.communiquons.android.comunic.client.R;
import org.communiquons.android.comunic.client.data.asynctasks.APIRequestTask;
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
import org.communiquons.android.comunic.client.data.models.APIRequest;
import org.communiquons.android.comunic.client.data.models.APIResponse;
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
import org.communiquons.android.comunic.client.data.utils.Utilities;
@ -120,7 +120,7 @@ public class LoginActivity extends AppCompatActivity {
//Perform a request on the API to check user credentials and get login tokens
APIRequestParameters params = new APIRequestParameters(this, "user/connectUSER");
APIRequest params = new APIRequest(this, "user/connectUSER");
params.addString("userMail", ""+login_mail.getText());
params.addString("userPassword", ""+login_password.getText());