use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method muteUserNotifications.
/**
* Sends a mute notification request for the given userId.
*
* <p>The current user will be taken from the user shared preferences.</p>
*
* <p>Note: This is a network method. Run it asynchronously.</p>
*
* @param userId the user id of the user to mute
* @param notificationAfterTime the time (in milliseconds) to mute the user for
* @return the api response, use {@link ApiResponse#isSuccess()} to check for success
*/
@Nullable
public ApiResponse muteUserNotifications(@Nullable String userId, @Nullable Long notificationAfterTime) {
if (userId == null || notificationAfterTime == null) {
return null;
}
JSONObject jsonFromObject = new JSONObject();
try {
String url = getMuteUserUrl() + "?userId=" + userId + "¬ificationAfterTime=" + notificationAfterTime;
String response = httpRequestUtils.postData(url, "application/json", "application/json", jsonFromObject.toString());
Utils.printLog(context, TAG, "Mute user chat response : " + response);
if (!TextUtils.isEmpty(response)) {
return (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method userUnBlock.
// Cleanup: private
/**
* @deprecated This method has been replaced with {@link #userBlock(String, boolean)}. Pass "false" in the second parameter.
*/
@Deprecated
public ApiResponse userUnBlock(String userId) {
String response = "";
ApiResponse apiResponse = null;
try {
if (!TextUtils.isEmpty(userId)) {
response = httpRequestUtils.getResponse(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 logout.
// Cleanup: private
// Cleanup: fromLogin is always false
/**
* Internal. This methods has a un-necessary parameter.
*
* @param fromLogin pass false
* @return logout backend api response, use {@link ApiResponse#isSuccess()} to check for success
*/
public ApiResponse logout(boolean fromLogin) {
Utils.printLog(context, TAG, "Al Logout call !!");
ApiResponse apiResponse = userLogoutResponse();
MobiComUserPreference mobiComUserPreference = MobiComUserPreference.getInstance(context);
final String deviceKeyString = mobiComUserPreference.getDeviceKeyString();
final String userKeyString = mobiComUserPreference.getSuUserKeyString();
String url = mobiComUserPreference.getUrl();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Applozic.Store.setCustomNotificationSound(context, null);
new NotificationChannels(context).deleteAllChannels();
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
mobiComUserPreference.clearAll();
ALSpecificSettings.getInstance(context).clearAll();
MessageDatabaseService.recentlyAddedMessage.clear();
MobiComDatabaseHelper.getInstance(context).delDatabase();
mobiComUserPreference.setUrl(url);
if (!fromLogin) {
ApplozicMqttWorker.enqueueWorkDisconnectPublish(context, deviceKeyString, userKeyString, false);
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserService method updateUserWithResponse.
// Cleanup: private
/**
* Internal. Do not use.
*/
public ApiResponse updateUserWithResponse(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);
}
return response;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserService method updateUserDisplayName.
/**
* Internal. Do not use.
*
* Updates the display name for the given userId (remote and local).
*
* <p>Note: This method has database and network operation. Run it asynchronously.</p>
*
* @param userId the user id of the user
* @param userDisplayName the new display name
* @return api response from the server
*/
public ApiResponse updateUserDisplayName(String userId, String userDisplayName) {
ApiResponse response = userClientService.updateUserDisplayName(userId, userDisplayName);
if (response != null && response.isSuccess()) {
baseContactService.updateMetadataKeyValueForUserId(userId, Contact.AL_DISPLAY_NAME_UPDATED, "true");
Utils.printLog(context, TAG, " Update display name Response :" + response.getStatus());
}
return response;
}
Aggregations