use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method userLogoutResponse.
// Cleanup: rename to something more suitable for a public api
/**
* Simply sends a logout server call for the logged user.
*
* <p>Note: This is a network method. Run it asynchronously.</p>
*
* @return logout backend api response. use {@link ApiResponse#isSuccess()} to check for success
*/
public ApiResponse userLogoutResponse() {
String response = "";
ApiResponse apiResponse = null;
try {
response = httpRequestUtils.postData(getUserLogout(), "application/json", "application/json", null);
if (!TextUtils.isEmpty(response)) {
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
}
} catch (Exception e) {
e.printStackTrace();
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method getUserReadServerCall.
// Cleanup: default
/**
* @deprecated This method is not longer used and will be removed soon.
*/
@Deprecated
public ApiResponse getUserReadServerCall() {
String response = null;
ApiResponse apiResponse = null;
try {
response = httpRequestUtils.getResponse(getUserReadUrl(), null, null);
if (response != null) {
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
}
Utils.printLog(context, TAG, "User read response: " + response);
} catch (Exception e) {
e.printStackTrace();
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method userBlock.
/**
* Sends a server request to block/unblock the given userId for the current(logged) user.
*
* <p>You do not need to pass the current user's user-id, it is taken from the local shared preferences({@link MobiComUserPreference}).</p>
*
* <p>Note: This is a network method. Run it asynchronously.</p>
*
* @param userId the userId of the user to block/unblock
* @param block true for block/false for unblock
* @return api response from the server, use {@link ApiResponse#isSuccess()} to check for success
*/
@Nullable
public ApiResponse userBlock(@Nullable String userId, boolean block) {
String response = "";
ApiResponse apiResponse = null;
try {
if (!TextUtils.isEmpty(userId)) {
response = httpRequestUtils.getResponse((block ? getBlockUserUrl() : getUnBlockUserSyncUrl()) + "?userId=" + URLEncoder.encode(userId, "UTF-8"), "application/json", "application/json");
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
}
} catch (Exception e) {
e.printStackTrace();
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method updateUserPassword.
// Cleanup: default
/**
* @deprecated This method is not longer used and will be removed soon.
*/
@Deprecated
public String updateUserPassword(String oldPassword, String newPassword) {
if (TextUtils.isEmpty(oldPassword) || TextUtils.isEmpty(newPassword)) {
return null;
}
String response = "";
ApiResponse apiResponse = null;
try {
response = httpRequestUtils.getResponse(getUpdateUserPasswordUrl() + "?oldPassword=" + oldPassword + "&newPassword=" + newPassword, "application/json", "application/json");
if (TextUtils.isEmpty(response)) {
return null;
}
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null && apiResponse.isSuccess()) {
return apiResponse.getStatus();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserService method updateDisplayNameORImageLink.
// internal methods >>>
/**
* Internal. Do not use.
*/
// Cleanup: private
public String updateDisplayNameORImageLink(String displayName, String profileImageLink, String localURL, String status, String contactNumber, String emailId, Map<String, String> metadata, String userId) {
ApiResponse response = userClientService.updateDisplayNameORImageLink(displayName, profileImageLink, status, contactNumber, emailId, metadata, userId);
if (response == null) {
return null;
}
if (response.isSuccess()) {
Contact contact = baseContactService.getContactById(!TextUtils.isEmpty(userId) ? userId : MobiComUserPreference.getInstance(context).getUserId());
if (!TextUtils.isEmpty(displayName)) {
contact.setFullName(displayName);
}
if (!TextUtils.isEmpty(profileImageLink)) {
contact.setImageURL(profileImageLink);
}
contact.setLocalImageUrl(localURL);
if (!TextUtils.isEmpty(status)) {
contact.setStatus(status);
}
if (!TextUtils.isEmpty(contactNumber)) {
contact.setContactNumber(contactNumber);
}
if (!TextUtils.isEmpty(emailId)) {
contact.setEmailId(emailId);
}
if (metadata != null && !metadata.isEmpty()) {
Map<String, String> existingMetadata = contact.getMetadata();
if (existingMetadata == null) {
existingMetadata = new HashMap<>();
}
existingMetadata.putAll(metadata);
contact.setMetadata(existingMetadata);
}
baseContactService.upsert(contact);
Contact contact1 = baseContactService.getContactById(!TextUtils.isEmpty(userId) ? userId : MobiComUserPreference.getInstance(context).getUserId());
Utils.printLog(context, TAG, contact1.getImageURL() + ", " + contact1.getDisplayName() + "," + contact1.getStatus() + "," + contact1.getStatus() + "," + contact1.getMetadata() + "," + contact1.getEmailId() + "," + contact1.getContactNumber());
}
return response.getStatus();
}
Aggregations