Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CM-1955] Expose Dynamic online/offline status update method #124

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

AbhijeetRanjan308
Copy link
Contributor

Summary

  • Exposed the code for Update User Status in Android and iOS

Code

 final dynamic updateStatusObject = {
         'assigneID': "<Assignee-ID>",
         'status': "away",
    };

 KommunicateFlutterPlugin.updateUserStatus(updateStatusObject);

Parameters

  • assigneID : "" or "Assignee-ID". (compulsory to pass this as well either empty or with value)
  • status : away, online, offline, default (capital character's are also accepted)

@AbhijeetRanjan308 AbhijeetRanjan308 changed the title Expose Dynamic online/offline status update method [CM-1955] Expose Dynamic online/offline status update method Mar 11, 2024
Comment on lines 113 to 114
final String AssigneeID = updateStatusObjc.get("assigneID").toString();
final String Status = updateStatusObjc.get("status").toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check final naming convention

Comment on lines 120 to 150
if (AssigneeID.isEmpty()) {
switch (Status.toLowerCase()) {
case "online":
Kommunicate.updateAssigneeStatus("", KMAgentStatusHelper.KMAgentStatus.ONLINE);
break;
case "offline":
Kommunicate.updateAssigneeStatus("", KMAgentStatusHelper.KMAgentStatus.OFFLINE);
break;
case "away":
Kommunicate.updateAssigneeStatus("", KMAgentStatusHelper.KMAgentStatus.AWAY);
break;
default:
Kommunicate.updateAssigneeStatus("", KMAgentStatusHelper.KMAgentStatus.DefaultStatus);
break;
}
} else {
switch (Status.toLowerCase()) {
case "online":
Kommunicate.updateAssigneeStatus(AssigneeID, KMAgentStatusHelper.KMAgentStatus.ONLINE);
break;
case "offline":
Kommunicate.updateAssigneeStatus(AssigneeID, KMAgentStatusHelper.KMAgentStatus.OFFLINE);
break;
case "away":
Kommunicate.updateAssigneeStatus(AssigneeID, KMAgentStatusHelper.KMAgentStatus.AWAY);
break;
default:
Kommunicate.updateAssigneeStatus(AssigneeID, KMAgentStatusHelper.KMAgentStatus.DefaultStatus);
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use single switch case without if & else & a variable to handle the nullability of assignee ID

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Comment on lines +139 to +141
if status.isEmpty {
self.sendErrorResult(message: "Status is Empty.")
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use another guard let for status empty check & variable for assigneeid . And then use it in a single switch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required already have a check above this

@AbhijeetRanjan308 AbhijeetRanjan308 merged commit b79181d into master Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants