use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.
the class NotificationUtilsTest method canParsePhoneNumberRawId.
@Test
public void canParsePhoneNumberRawId() {
final String phoneNumber = "+1234567890";
final String phoneNumberRawId = "4:" + phoneNumber;
CommunicationIdentifier communicationIdentifier = NotificationUtils.getCommunicationIdentifier(phoneNumberRawId);
assertNotNull(communicationIdentifier);
assertTrue(communicationIdentifier instanceof PhoneNumberIdentifier);
PhoneNumberIdentifier phoneNumberIdentifier = (PhoneNumberIdentifier) communicationIdentifier;
assertEquals(phoneNumber, phoneNumberIdentifier.getPhoneNumber());
assertEquals(phoneNumberRawId, phoneNumberIdentifier.getRawId());
}
use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.
the class NotificationUtilsTest method canParseTeamsVisitorUserRawId.
@Test
public void canParseTeamsVisitorUserRawId() {
final String teamsVisitorUserRawId = "8:teamsvisitor:" + USER_ID;
CommunicationIdentifier communicationIdentifier = NotificationUtils.getCommunicationIdentifier(teamsVisitorUserRawId);
assertNotNull(communicationIdentifier);
assertTrue(communicationIdentifier instanceof MicrosoftTeamsUserIdentifier);
MicrosoftTeamsUserIdentifier microsoftTeamsUserIdentifier = (MicrosoftTeamsUserIdentifier) communicationIdentifier;
assertEquals(CommunicationCloudEnvironment.PUBLIC, microsoftTeamsUserIdentifier.getCloudEnvironment());
assertTrue(microsoftTeamsUserIdentifier.isAnonymous());
assertEquals(USER_ID, microsoftTeamsUserIdentifier.getUserId());
assertEquals(teamsVisitorUserRawId, microsoftTeamsUserIdentifier.getRawId());
}
use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.
the class ChatThreadCreatedEvent method setParticipants.
/**
* Sets the participants of the thread.
*/
ChatThreadCreatedEvent setParticipants() {
this.participants = new ArrayList<>();
try {
JSONArray participantsJsonArray = new JSONArray(this.participantsJsonString);
for (int i = 0; i < participantsJsonArray.length(); i++) {
JSONObject participant = participantsJsonArray.getJSONObject(i);
CommunicationIdentifier communicationUser = NotificationUtils.getCommunicationIdentifier(participant.getString("participantId"));
ChatParticipant chatParticipant = new ChatParticipant();
chatParticipant.setCommunicationIdentifier(communicationUser);
chatParticipant.setDisplayName(participant.getString("displayName"));
this.participants.add(chatParticipant);
}
} catch (JSONException e) {
return this;
}
return this;
}
use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.
the class ChatThreadDeletedEvent method setDeletedBy.
/**
* Sets the deletedBy of the thread.
*/
ChatThreadDeletedEvent setDeletedBy() {
this.deletedBy = new ChatParticipant();
try {
JSONObject deletedByJsonObject = new JSONObject(this.deletedByJsonString);
CommunicationIdentifier deletedByCommunicationIdentifier = NotificationUtils.getCommunicationIdentifier(deletedByJsonObject.getString("participantId"));
this.deletedBy.setCommunicationIdentifier(deletedByCommunicationIdentifier).setDisplayName(deletedByJsonObject.getString("displayName"));
} catch (JSONException e) {
return this;
}
return this;
}
use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.
the class ChatThreadPropertiesUpdatedEvent method setUpdatedBy.
/**
* Sets the updatedBy of the thread.
*/
ChatThreadPropertiesUpdatedEvent setUpdatedBy() {
this.updatedBy = new ChatParticipant();
try {
JSONObject updatedByJsonObject = new JSONObject(this.updatedByJsonString);
CommunicationIdentifier updatedByCommunicationIdentifier = NotificationUtils.getCommunicationIdentifier(updatedByJsonObject.getString("participantId"));
this.updatedBy.setCommunicationIdentifier(updatedByCommunicationIdentifier).setDisplayName(updatedByJsonObject.getString("displayName"));
} catch (JSONException e) {
return this;
}
return this;
}
Aggregations