mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Renamed APIRequestParameters to APIRequest
This commit is contained in:
parent
5e0ad1c526
commit
4c79e5de9f
@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.asynctasks;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
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;
|
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.
|
* Created by pierre on 10/31/17.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@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
|
* 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
|
* @return JSONObject The result of the request
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected APIResponse doInBackground(APIRequestParameters... params) {
|
protected APIResponse doInBackground(APIRequest... params) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Perform the API request
|
//Perform the API request
|
||||||
|
@ -5,8 +5,7 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.BuildConfig;
|
import org.communiquons.android.comunic.client.BuildConfig;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
import org.communiquons.android.comunic.client.data.models.APIRequest;
|
||||||
import org.communiquons.android.comunic.client.data.models.APIRequestParameters;
|
|
||||||
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
@ -45,7 +44,7 @@ public class APIRequestHelper {
|
|||||||
* @param parameters The parameters to pass to the server
|
* @param parameters The parameters to pass to the server
|
||||||
* @return The result of the request
|
* @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
|
//Add API and login tokens
|
||||||
addAPItokens(parameters);
|
addAPItokens(parameters);
|
||||||
@ -136,7 +135,7 @@ public class APIRequestHelper {
|
|||||||
*
|
*
|
||||||
* @param params The request parametres to update
|
* @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("serviceName", BuildConfig.api_service_name);
|
||||||
params.addString("serviceToken", BuildConfig.api_service_token);
|
params.addString("serviceToken", BuildConfig.api_service_token);
|
||||||
}
|
}
|
||||||
@ -146,7 +145,7 @@ public class APIRequestHelper {
|
|||||||
*
|
*
|
||||||
* @param params The parameters of the request to update
|
* @param params The parameters of the request to update
|
||||||
*/
|
*/
|
||||||
private void addLoginTokens(APIRequestParameters params){
|
private void addLoginTokens(APIRequest params){
|
||||||
|
|
||||||
//Create account object
|
//Create account object
|
||||||
AccountHelper accountHelper = new AccountHelper(params.getContext());
|
AccountHelper accountHelper = new AccountHelper(params.getContext());
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.models.Comment;
|
import org.communiquons.android.comunic.client.data.models.Comment;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -50,7 +50,7 @@ public class CommentsHelper {
|
|||||||
public int send_comment(int postID, String comment){
|
public int send_comment(int postID, String comment){
|
||||||
|
|
||||||
//Create and perform an API request
|
//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.addInt("postID", postID);
|
||||||
params.addString("content", comment);
|
params.addString("content", comment);
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class CommentsHelper {
|
|||||||
public Comment getInfosSingle(int commentID){
|
public Comment getInfosSingle(int commentID){
|
||||||
|
|
||||||
//Prepare API request
|
//Prepare API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "comments/get_single");
|
APIRequest params = new APIRequest(mContext, "comments/get_single");
|
||||||
params.addInt("commentID", commentID);
|
params.addInt("commentID", commentID);
|
||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
@ -112,7 +112,7 @@ public class CommentsHelper {
|
|||||||
public boolean editContent(int commentID, String content){
|
public boolean editContent(int commentID, String content){
|
||||||
|
|
||||||
//Perform a request on the server
|
//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.addInt("commentID", commentID);
|
||||||
params.addString("content", content);
|
params.addString("content", content);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public class CommentsHelper {
|
|||||||
public boolean delete(int commentID){
|
public boolean delete(int commentID){
|
||||||
|
|
||||||
//Prepare an API request
|
//Prepare an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "comments/delete");
|
APIRequest params = new APIRequest(mContext, "comments/delete");
|
||||||
params.addInt("commentID", commentID);
|
params.addInt("commentID", commentID);
|
||||||
|
|
||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
|
import org.communiquons.android.comunic.client.data.models.ConversationMessage;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -88,7 +88,7 @@ public class ConversationMessagesHelper {
|
|||||||
public boolean sendMessage(int convID, String message, @Nullable String image){
|
public boolean sendMessage(int convID, String message, @Nullable String image){
|
||||||
|
|
||||||
//Make an API request
|
//Make an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"conversations/sendMessage");
|
"conversations/sendMessage");
|
||||||
params.addString("conversationID", ""+convID);
|
params.addString("conversationID", ""+convID);
|
||||||
params.addString("message", message);
|
params.addString("message", message);
|
||||||
@ -153,7 +153,7 @@ public class ConversationMessagesHelper {
|
|||||||
private ArrayList<ConversationMessage> downloadNew(int conversationID, int last_message_id){
|
private ArrayList<ConversationMessage> downloadNew(int conversationID, int last_message_id){
|
||||||
|
|
||||||
//Prepare a request on the API
|
//Prepare a request on the API
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"conversations/refresh_single");
|
"conversations/refresh_single");
|
||||||
params.addString("conversationID", ""+conversationID);
|
params.addString("conversationID", ""+conversationID);
|
||||||
params.addString("last_message_id", ""+last_message_id);
|
params.addString("last_message_id", ""+last_message_id);
|
||||||
|
@ -6,7 +6,7 @@ import android.support.annotation.Nullable;
|
|||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
@ -113,7 +113,7 @@ public class ConversationsListHelper {
|
|||||||
public Integer getPrivate(int userID, boolean allowCreate){
|
public Integer getPrivate(int userID, boolean allowCreate){
|
||||||
|
|
||||||
//Prepare an API request
|
//Prepare an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"conversations/getPrivate");
|
"conversations/getPrivate");
|
||||||
params.addInt("otherUser", userID);
|
params.addInt("otherUser", userID);
|
||||||
params.addBoolean("allowCreate", allowCreate);
|
params.addBoolean("allowCreate", allowCreate);
|
||||||
@ -212,7 +212,7 @@ public class ConversationsListHelper {
|
|||||||
public boolean delete(int convID){
|
public boolean delete(int convID){
|
||||||
|
|
||||||
//Delete the conversation on the API
|
//Delete the conversation on the API
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "conversations/delete");
|
APIRequest params = new APIRequest(mContext, "conversations/delete");
|
||||||
params.addString("conversationID", ""+convID);
|
params.addString("conversationID", ""+convID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -243,7 +243,7 @@ public class ConversationsListHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Make an API request
|
//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("name", name.equals("") ? "false" : name);
|
||||||
params.addString("follow", follow ? "true" : "false");
|
params.addString("follow", follow ? "true" : "false");
|
||||||
params.addString("users", members_str);
|
params.addString("users", members_str);
|
||||||
@ -286,7 +286,7 @@ public class ConversationsListHelper {
|
|||||||
@Nullable ArrayList<Integer> members, boolean following){
|
@Nullable ArrayList<Integer> members, boolean following){
|
||||||
|
|
||||||
//Prepare a request on the database
|
//Prepare a request on the database
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"conversations/updateSettings");
|
"conversations/updateSettings");
|
||||||
params.addString("conversationID", ""+convID);
|
params.addString("conversationID", ""+convID);
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ public class ConversationsListHelper {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//Prepare the request on the server
|
//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);
|
APIResponse response = new APIRequestHelper().exec(params);
|
||||||
|
|
||||||
//Check if an error occurred
|
//Check if an error occurred
|
||||||
@ -366,7 +366,7 @@ public class ConversationsListHelper {
|
|||||||
private ConversationsInfo downloadSingle(int convID){
|
private ConversationsInfo downloadSingle(int convID){
|
||||||
|
|
||||||
//Perform an API request
|
//Perform an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"conversations/getInfosOne");
|
"conversations/getInfosOne");
|
||||||
params.addString("conversationID", ""+convID);
|
params.addString("conversationID", ""+convID);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.models.Friend;
|
import org.communiquons.android.comunic.client.data.models.Friend;
|
||||||
import org.communiquons.android.comunic.client.data.models.FriendshipStatus;
|
import org.communiquons.android.comunic.client.data.models.FriendshipStatus;
|
||||||
@ -69,7 +69,7 @@ public class FriendsListHelper {
|
|||||||
public ArrayList<Friend> download(){
|
public ArrayList<Friend> download(){
|
||||||
|
|
||||||
//Prepare the API request
|
//Prepare the API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "friends/getList");
|
APIRequest params = new APIRequest(mContext, "friends/getList");
|
||||||
params.addBoolean("complete", true);
|
params.addBoolean("complete", true);
|
||||||
|
|
||||||
//Prepare the result
|
//Prepare the result
|
||||||
@ -121,7 +121,7 @@ public class FriendsListHelper {
|
|||||||
public void remove(Friend friend){
|
public void remove(Friend friend){
|
||||||
try {
|
try {
|
||||||
//Remove the friend online
|
//Remove the friend online
|
||||||
APIRequestParameters delparams = new APIRequestParameters(mContext, "friends/remove");
|
APIRequest delparams = new APIRequest(mContext, "friends/remove");
|
||||||
delparams.addString("friendID", ""+friend.getId());
|
delparams.addString("friendID", ""+friend.getId());
|
||||||
new APIRequestHelper().exec(delparams);
|
new APIRequestHelper().exec(delparams);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class FriendsListHelper {
|
|||||||
public boolean sendRequest(int friendID){
|
public boolean sendRequest(int friendID){
|
||||||
|
|
||||||
//Prepare the request
|
//Prepare the request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "friends/sendRequest");
|
APIRequest params = new APIRequest(mContext, "friends/sendRequest");
|
||||||
params.addInt("friendID", friendID);
|
params.addInt("friendID", friendID);
|
||||||
|
|
||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
@ -165,7 +165,7 @@ public class FriendsListHelper {
|
|||||||
public boolean cancelRequest(int friendID){
|
public boolean cancelRequest(int friendID){
|
||||||
|
|
||||||
//Prepare the request
|
//Prepare the request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "friends/removeRequest");
|
APIRequest params = new APIRequest(mContext, "friends/removeRequest");
|
||||||
params.addInt("friendID", friendID);
|
params.addInt("friendID", friendID);
|
||||||
|
|
||||||
//Try to perform the request
|
//Try to perform the request
|
||||||
@ -216,7 +216,7 @@ public class FriendsListHelper {
|
|||||||
public boolean respondRequest(int friendID, boolean accept){
|
public boolean respondRequest(int friendID, boolean accept){
|
||||||
|
|
||||||
//Perform a request to update the status online
|
//Perform a request to update the status online
|
||||||
APIRequestParameters reqParams = new APIRequestParameters(mContext,
|
APIRequest reqParams = new APIRequest(mContext,
|
||||||
"friends/respondRequest");
|
"friends/respondRequest");
|
||||||
reqParams.addInt("friendID", friendID);
|
reqParams.addInt("friendID", friendID);
|
||||||
reqParams.addString("accept", accept ? "true" : "false");
|
reqParams.addString("accept", accept ? "true" : "false");
|
||||||
@ -244,7 +244,7 @@ public class FriendsListHelper {
|
|||||||
public FriendshipStatus getFrienshipStatus(int friendID) {
|
public FriendshipStatus getFrienshipStatus(int friendID) {
|
||||||
|
|
||||||
//Perform a request on the API
|
//Perform a request on the API
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "friends/getStatus");
|
APIRequest params = new APIRequest(mContext, "friends/getStatus");
|
||||||
params.addInt("friendID", friendID);
|
params.addInt("friendID", friendID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -6,7 +6,7 @@ import android.support.annotation.Nullable;
|
|||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo;
|
import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
@ -127,7 +127,7 @@ public class GetUsersHelper {
|
|||||||
public AdvancedUserInfo get_advanced_infos(int userID){
|
public AdvancedUserInfo get_advanced_infos(int userID){
|
||||||
|
|
||||||
//Perform an API request
|
//Perform an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"user/getAdvancedUserInfos");
|
"user/getAdvancedUserInfos");
|
||||||
params.setTryContinueOnError(true);
|
params.setTryContinueOnError(true);
|
||||||
params.addInt("userID", userID);
|
params.addInt("userID", userID);
|
||||||
@ -263,7 +263,7 @@ public class GetUsersHelper {
|
|||||||
private ArrayList<Integer> search_users_online(String query, int limit){
|
private ArrayList<Integer> search_users_online(String query, int limit){
|
||||||
|
|
||||||
//Make an API request
|
//Make an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "search/user");
|
APIRequest params = new APIRequest(mContext, "search/user");
|
||||||
params.addString("query", query);
|
params.addString("query", query);
|
||||||
params.addString("searchLimit", ""+limit);
|
params.addString("searchLimit", ""+limit);
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ public class GetUsersHelper {
|
|||||||
|
|
||||||
//Perform a request on the API server
|
//Perform a request on the API server
|
||||||
//Setup the request
|
//Setup the request
|
||||||
APIRequestParameters requestParameters = new APIRequestParameters(mContext,
|
APIRequest requestParameters = new APIRequest(mContext,
|
||||||
"user/getInfosMultiple");
|
"user/getInfosMultiple");
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package org.communiquons.android.comunic.client.data.helpers;
|
|||||||
|
|
||||||
import android.content.Context;
|
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.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.enums.LikesType;
|
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){
|
public boolean update(LikesType type, int id, boolean liking){
|
||||||
|
|
||||||
//Perform an API request
|
//Perform an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "likes/update");
|
APIRequest params = new APIRequest(mContext, "likes/update");
|
||||||
params.addInt("id", id);
|
params.addInt("id", id);
|
||||||
params.addBoolean("like", liking);
|
params.addBoolean("like", liking);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.helpers;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.Nullable;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.models.Notif;
|
import org.communiquons.android.comunic.client.data.models.Notif;
|
||||||
import org.communiquons.android.comunic.client.data.enums.NotifElemType;
|
import org.communiquons.android.comunic.client.data.enums.NotifElemType;
|
||||||
@ -50,7 +50,7 @@ public class NotificationsHelper {
|
|||||||
public NotificationsCount pullCount(){
|
public NotificationsCount pullCount(){
|
||||||
|
|
||||||
//Perform an API request
|
//Perform an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"notifications/count_all_news");
|
"notifications/count_all_news");
|
||||||
|
|
||||||
//Try to perform the request and parse results
|
//Try to perform the request and parse results
|
||||||
@ -80,7 +80,7 @@ public class NotificationsHelper {
|
|||||||
public boolean markSeen(int notifID){
|
public boolean markSeen(int notifID){
|
||||||
|
|
||||||
//Perform a request on the server
|
//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);
|
params.addInt("notifID", notifID);
|
||||||
|
|
||||||
//Try to send the request to the server
|
//Try to send the request to the server
|
||||||
@ -102,7 +102,7 @@ public class NotificationsHelper {
|
|||||||
public boolean deleteAllNotifs(){
|
public boolean deleteAllNotifs(){
|
||||||
|
|
||||||
//Perform a request on the server
|
//Perform a request on the server
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"notifications/delete_all");
|
"notifications/delete_all");
|
||||||
|
|
||||||
//Try to perform the request on the server
|
//Try to perform the request on the server
|
||||||
@ -124,7 +124,7 @@ public class NotificationsHelper {
|
|||||||
public NotifsList getListUnread(){
|
public NotifsList getListUnread(){
|
||||||
|
|
||||||
//Perform a request on the server
|
//Perform a request on the server
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext,
|
APIRequest params = new APIRequest(mContext,
|
||||||
"notifications/get_list_unread");
|
"notifications/get_list_unread");
|
||||||
|
|
||||||
//Try to perform the request on the server
|
//Try to perform the request on the server
|
||||||
|
@ -3,7 +3,7 @@ package org.communiquons.android.comunic.client.data.helpers;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.Nullable;
|
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.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.models.CreatePost;
|
import org.communiquons.android.comunic.client.data.models.CreatePost;
|
||||||
import org.communiquons.android.comunic.client.data.enums.PageType;
|
import org.communiquons.android.comunic.client.data.enums.PageType;
|
||||||
@ -56,7 +56,7 @@ public class PostsHelper {
|
|||||||
public Post getSingle(int id){
|
public Post getSingle(int id){
|
||||||
|
|
||||||
//Perform an API request
|
//Perform an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "posts/get_single");
|
APIRequest params = new APIRequest(mContext, "posts/get_single");
|
||||||
params.addInt("postID", id);
|
params.addInt("postID", id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -87,7 +87,7 @@ public class PostsHelper {
|
|||||||
public PostsList get_user(int userID){
|
public PostsList get_user(int userID){
|
||||||
|
|
||||||
//Perform a request on the API
|
//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);
|
params.addInt("userID", userID);
|
||||||
|
|
||||||
//Perform the request
|
//Perform the request
|
||||||
@ -121,7 +121,7 @@ public class PostsHelper {
|
|||||||
public boolean delete(int postID){
|
public boolean delete(int postID){
|
||||||
|
|
||||||
//Perform the request on the server
|
//Perform the request on the server
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "posts/delete");
|
APIRequest params = new APIRequest(mContext, "posts/delete");
|
||||||
params.addInt("postID", postID);
|
params.addInt("postID", postID);
|
||||||
|
|
||||||
//Intend to perform the request
|
//Intend to perform the request
|
||||||
@ -146,7 +146,7 @@ public class PostsHelper {
|
|||||||
public int create(CreatePost post){
|
public int create(CreatePost post){
|
||||||
|
|
||||||
//Prepare the request on the server
|
//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
|
//Put basic information about the post
|
||||||
params.addString("content", post.getContent());
|
params.addString("content", post.getContent());
|
||||||
@ -224,7 +224,7 @@ public class PostsHelper {
|
|||||||
public boolean update_content(int postId, String content) {
|
public boolean update_content(int postId, String content) {
|
||||||
|
|
||||||
//Perform a request on the API
|
//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.addString("new_content", content);
|
||||||
params.addInt("postID", postId);
|
params.addInt("postID", postId);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import java.util.ArrayList;
|
|||||||
* Created by pierre on 10/31/17.
|
* Created by pierre on 10/31/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class APIRequestParameters {
|
public class APIRequest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The context of the request
|
* The context of the request
|
||||||
@ -39,7 +39,7 @@ public class APIRequestParameters {
|
|||||||
* @param context The context of the request
|
* @param context The context of the request
|
||||||
* @param uri The request URI on the server
|
* @param uri The request URI on the server
|
||||||
*/
|
*/
|
||||||
public APIRequestParameters(Context context, String uri){
|
public APIRequest(Context context, String uri){
|
||||||
|
|
||||||
//Save the context
|
//Save the context
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@ -47,7 +47,7 @@ public class APIRequestParameters {
|
|||||||
//Save request URI
|
//Save request URI
|
||||||
request_uri = uri;
|
request_uri = uri;
|
||||||
|
|
||||||
//Intialize parameters array
|
//Initialize parameters array
|
||||||
parameters = new ArrayList<>();
|
parameters = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ package org.communiquons.android.comunic.client.data.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
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.asynctasks.APIRequestTask;
|
||||||
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
import org.communiquons.android.comunic.client.data.models.APIResponse;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -66,7 +66,7 @@ public class AccountUtils {
|
|||||||
public void refresh_current_user_id(final onceRefreshedUserID callback){
|
public void refresh_current_user_id(final onceRefreshedUserID callback){
|
||||||
|
|
||||||
//Perform an API request
|
//Perform an API request
|
||||||
APIRequestParameters params = new APIRequestParameters(mContext, "user/getCurrentUserID");
|
APIRequest params = new APIRequest(mContext, "user/getCurrentUserID");
|
||||||
new APIRequestTask(){
|
new APIRequestTask(){
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(APIResponse result) {
|
protected void onPostExecute(APIResponse result) {
|
||||||
|
@ -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.asynctasks.APIRequestTask;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
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.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.models.APIResponse;
|
||||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.utils.Utilities;
|
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
|
//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("userMail", ""+login_mail.getText());
|
||||||
params.addString("userPassword", ""+login_password.getText());
|
params.addString("userPassword", ""+login_password.getText());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user