Skip to content

Commit

Permalink
[ACS][CallAutomation] Update with latest Swagger + adding MicrosoftTe…
Browse files Browse the repository at this point in the history
…amsAppIdentifier (#39695)

* Update with latest Swagger + adding MicrosoftTeamsAppIdentifier

* Fixing hold music and sourceCallerId in AnswerOption to Transfer

* Fixing tests + re-record with proper redaction

* Fixing Style Lint

* Fixing Style Lint 2

* Fixing Style Lint 3

---------

Co-authored-by: Min Woo Lee 🧊 <77083090+minwoolee-ms@users.noreply.github.com>
  • Loading branch information
minwoolee-msft and minwoolee-msft committed Apr 30, 2024
1 parent e47adef commit 726104b
Show file tree
Hide file tree
Showing 25 changed files with 323 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/communication/azure-communication-callautomation",
"Tag": "java/communication/azure-communication-callautomation_bde5640047"
"Tag": "java/communication/azure-communication-callautomation_ea89bbe13c"
}
5 changes: 5 additions & 0 deletions sdk/communication/azure-communication-callautomation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
<scope>test</scope>
<version>0.8.12</version> <!-- {x-version-update;org.jacoco:org.jacoco.agent;external_dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.14.2</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ Mono<Response<AnswerCallResult>> answerCallWithResponseInternal(AnswerCallOption
.setIncomingCallContext(answerCallOptions.getIncomingCallContext())
.setCallbackUri(answerCallOptions.getCallbackUrl())
.setAnsweredBy(sourceIdentity)
.setOperationContext(answerCallOptions.getOperationContext())
.setSourceCallerIdNumber(PhoneNumberIdentifierConverter.convert(answerCallOptions.getSourceCallerIdNumber()));
.setOperationContext(answerCallOptions.getOperationContext());

if (answerCallOptions.getCallIntelligenceOptions() != null && answerCallOptions.getCallIntelligenceOptions().getCognitiveServicesEndpoint() != null) {
CallIntelligenceOptionsInternal callIntelligenceOptionsInternal = new CallIntelligenceOptionsInternal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.azure.communication.callautomation.models.UnmuteParticipantResult;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.common.MicrosoftTeamsAppIdentifier;
import com.azure.communication.common.MicrosoftTeamsUserIdentifier;
import com.azure.communication.common.PhoneNumberIdentifier;
import com.azure.core.annotation.ReturnType;
Expand Down Expand Up @@ -254,6 +255,8 @@ public Mono<TransferCallResult> transferCallToParticipant(CommunicationIdentifie
return transferCallToParticipantWithResponse(new TransferCallToParticipantOptions((PhoneNumberIdentifier) targetParticipant)).flatMap(FluxUtil::toMono);
} else if (targetParticipant instanceof MicrosoftTeamsUserIdentifier) {
return transferCallToParticipantWithResponse(new TransferCallToParticipantOptions((MicrosoftTeamsUserIdentifier) targetParticipant)).flatMap(FluxUtil::toMono);
} else if (targetParticipant instanceof MicrosoftTeamsAppIdentifier) {
return transferCallToParticipantWithResponse(new TransferCallToParticipantOptions((MicrosoftTeamsAppIdentifier) targetParticipant)).flatMap(FluxUtil::toMono);
} else {
throw logger.logExceptionAsError(new IllegalArgumentException("targetParticipant type is invalid."));
}
Expand Down Expand Up @@ -281,7 +284,8 @@ Mono<Response<TransferCallResult>> transferCallToParticipantWithResponseInternal
TransferToParticipantRequestInternal request = new TransferToParticipantRequestInternal()
.setTargetParticipant(CommunicationIdentifierConverter.convert(transferCallToParticipantOptions.getTargetParticipant()))
.setOperationContext(transferCallToParticipantOptions.getOperationContext())
.setOperationCallbackUri(transferCallToParticipantOptions.getOperationCallbackUrl());
.setOperationCallbackUri(transferCallToParticipantOptions.getOperationCallbackUrl())
.setSourceCallerIdNumber(PhoneNumberIdentifierConverter.convert(transferCallToParticipantOptions.getSourceCallerIdNumber()));

if (transferCallToParticipantOptions.getCustomCallingContext().getSipHeaders() != null || transferCallToParticipantOptions.getCustomCallingContext().getVoipHeaders() != null) {
request.setCustomCallingContext(new CustomCallingContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import com.azure.communication.callautomation.implementation.models.CommunicationIdentifierModel;
import com.azure.communication.callautomation.implementation.models.CommunicationIdentifierModelKind;
import com.azure.communication.callautomation.implementation.models.CommunicationUserIdentifierModel;
import com.azure.communication.callautomation.implementation.models.MicrosoftTeamsAppIdentifierModel;
import com.azure.communication.callautomation.implementation.models.MicrosoftTeamsUserIdentifierModel;
import com.azure.communication.callautomation.implementation.models.PhoneNumberIdentifierModel;
import com.azure.communication.common.CommunicationCloudEnvironment;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.common.MicrosoftTeamsAppIdentifier;
import com.azure.communication.common.MicrosoftTeamsUserIdentifier;
import com.azure.communication.common.PhoneNumberIdentifier;
import com.azure.communication.common.UnknownIdentifier;
Expand Down Expand Up @@ -64,6 +66,16 @@ public static CommunicationIdentifier convert(CommunicationIdentifierModel ident
.fromString(teamsUserIdentifierModel.getCloud().toString()));
}

if (kind == CommunicationIdentifierModelKind.MICROSOFT_TEAMS_APP
&& identifier.getMicrosoftTeamsApp() != null) {
MicrosoftTeamsAppIdentifierModel teamsUserIdentifierModel = identifier.getMicrosoftTeamsApp();
Objects.requireNonNull(teamsUserIdentifierModel.getAppId(), "'AppId' of the CommunicationIdentifierModel cannot be null.");
Objects.requireNonNull(teamsUserIdentifierModel.getCloud(), "'Cloud' of the CommunicationIdentifierModel cannot be null.");
Objects.requireNonNull(rawId, "'RawID' of the CommunicationIdentifierModel cannot be null.");
return new MicrosoftTeamsAppIdentifier(teamsUserIdentifierModel.getAppId(),
CommunicationCloudEnvironment.fromString(teamsUserIdentifierModel.getCloud().toString()));
}

Objects.requireNonNull(rawId, "'RawID' of the CommunicationIdentifierModel cannot be null.");
return new UnknownIdentifier(rawId);
}
Expand Down Expand Up @@ -104,6 +116,16 @@ public static CommunicationIdentifierModel convert(CommunicationIdentifier ident
teamsUserIdentifier.getCloudEnvironment().toString())));
}

if (identifier instanceof MicrosoftTeamsAppIdentifier) {
MicrosoftTeamsAppIdentifier teamsAppIdentifier = (MicrosoftTeamsAppIdentifier) identifier;
return new CommunicationIdentifierModel()
.setRawId(teamsAppIdentifier.getRawId())
.setMicrosoftTeamsApp(new MicrosoftTeamsAppIdentifierModel()
.setAppId(teamsAppIdentifier.getAppId())
.setCloud(CommunicationCloudEnvironmentModel.fromString(
teamsAppIdentifier.getCloudEnvironment().toString())));
}

if (identifier instanceof UnknownIdentifier) {
UnknownIdentifier unknownIdentifier = (UnknownIdentifier) identifier;
return new CommunicationIdentifierModel().setRawId(unknownIdentifier.getId());
Expand All @@ -116,6 +138,7 @@ private static void assertSingleType(CommunicationIdentifierModel identifier) {
CommunicationUserIdentifierModel communicationUser = identifier.getCommunicationUser();
PhoneNumberIdentifierModel phoneNumber = identifier.getPhoneNumber();
MicrosoftTeamsUserIdentifierModel microsoftTeamsUser = identifier.getMicrosoftTeamsUser();
MicrosoftTeamsAppIdentifierModel microsoftTeamsApp = identifier.getMicrosoftTeamsApp();

ArrayList<String> presentProperties = new ArrayList<>();
if (communicationUser != null) {
Expand All @@ -127,6 +150,9 @@ private static void assertSingleType(CommunicationIdentifierModel identifier) {
if (microsoftTeamsUser != null) {
presentProperties.add(microsoftTeamsUser.getClass().getName());
}
if (microsoftTeamsApp != null) {
presentProperties.add(microsoftTeamsApp.getClass().getName());
}

if (presentProperties.size() > 1) {
throw new IllegalArgumentException(
Expand All @@ -147,6 +173,9 @@ private static CommunicationIdentifierModelKind extractKind(CommunicationIdentif
if (identifier.getMicrosoftTeamsUser() != null) {
return CommunicationIdentifierModelKind.MICROSOFT_TEAMS_USER;
}
if (identifier.getMicrosoftTeamsApp() != null) {
return CommunicationIdentifierModelKind.MICROSOFT_TEAMS_APP;
}
return CommunicationIdentifierModelKind.UNKNOWN;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ public final class AnswerCallRequestInternal {
@JsonProperty(value = "answeredBy")
private CommunicationUserIdentifierModel answeredBy;

/*
* The source caller Id, a phone number, that's will be used when inviting
* a pstn target.
* Required only when transferring call to PSTN, if this is an incoming
* voip call.
*/
@JsonProperty(value = "sourceCallerIdNumber")
private PhoneNumberIdentifierModel sourceCallerIdNumber;

/**
* Get the incomingCallContext property: The context associated with the call.
*
Expand Down Expand Up @@ -203,26 +194,4 @@ public AnswerCallRequestInternal setAnsweredBy(CommunicationUserIdentifierModel
this.answeredBy = answeredBy;
return this;
}

/**
* Get the sourceCallerIdNumber property: The source caller Id, a phone number, that's will be used when inviting a
* pstn target. Required only when transferring call to PSTN, if this is an incoming voip call.
*
* @return the sourceCallerIdNumber value.
*/
public PhoneNumberIdentifierModel getSourceCallerIdNumber() {
return this.sourceCallerIdNumber;
}

/**
* Set the sourceCallerIdNumber property: The source caller Id, a phone number, that's will be used when inviting a
* pstn target. Required only when transferring call to PSTN, if this is an incoming voip call.
*
* @param sourceCallerIdNumber the sourceCallerIdNumber value to set.
* @return the AnswerCallRequestInternal object itself.
*/
public AnswerCallRequestInternal setSourceCallerIdNumber(PhoneNumberIdentifierModel sourceCallerIdNumber) {
this.sourceCallerIdNumber = sourceCallerIdNumber;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public final class TransferToParticipantRequestInternal {
@JsonProperty(value = "operationCallbackUri")
private String operationCallbackUri;

/*
* The source caller Id, a phone number, that's will be used as the
* transferor's(Contoso) caller id when transfering a call a pstn target.
*/
@JsonProperty(value = "sourceCallerIdNumber")
private PhoneNumberIdentifierModel sourceCallerIdNumber;

/**
* Get the targetParticipant property: The identity of the target where call should be transferred to.
*
Expand Down Expand Up @@ -149,4 +156,27 @@ public TransferToParticipantRequestInternal setOperationCallbackUri(String opera
this.operationCallbackUri = operationCallbackUri;
return this;
}

/**
* Get the sourceCallerIdNumber property: The source caller Id, a phone number, that's will be used as the
* transferor's(Contoso) caller id when transfering a call a pstn target.
*
* @return the sourceCallerIdNumber value.
*/
public PhoneNumberIdentifierModel getSourceCallerIdNumber() {
return this.sourceCallerIdNumber;
}

/**
* Set the sourceCallerIdNumber property: The source caller Id, a phone number, that's will be used as the
* transferor's(Contoso) caller id when transfering a call a pstn target.
*
* @param sourceCallerIdNumber the sourceCallerIdNumber value to set.
* @return the TransferToParticipantRequestInternal object itself.
*/
public TransferToParticipantRequestInternal setSourceCallerIdNumber(
PhoneNumberIdentifierModel sourceCallerIdNumber) {
this.sourceCallerIdNumber = sourceCallerIdNumber;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.azure.communication.callautomation.models;

import com.azure.communication.common.PhoneNumberIdentifier;
import com.azure.core.annotation.Fluent;

/**
Expand Down Expand Up @@ -40,12 +39,6 @@ public final class AnswerCallOptions {
* The operational context
*/
private String operationContext;

/**
* The source caller ID number which is a phone number that will be used when inviting a pstn target.
* Required only when this is an incoming voip call and there will be a transfer call request to a PSTN target.
*/
private PhoneNumberIdentifier sourceCallerIdNumber;

/**
* Constructor
Expand Down Expand Up @@ -94,15 +87,6 @@ public String getOperationContext() {
return operationContext;
}

/**
* Get the sourceCallerIdNumber.
*
* @return the sourceCallerIdNumber
*/
public PhoneNumberIdentifier getSourceCallerIdNumber() {
return sourceCallerIdNumber;
}

/**
* Set the transcription configuration.
*
Expand All @@ -124,18 +108,7 @@ public AnswerCallOptions setOperationContext(String operationContext) {
this.operationContext = operationContext;
return this;
}

/**
* Set the sourceCallerIdNumber.
*
* @param sourceCallerIdNumber the sourceCallerIdNumber to set
* @return the AnswerCallOptions object itself.
*/
public AnswerCallOptions setSourceCallerIdNumber(PhoneNumberIdentifier sourceCallerIdNumber) {
this.sourceCallerIdNumber = sourceCallerIdNumber;
return this;
}


/**
* Get the CallIntelligenceOptions property: AI options for the call such as cognitiveServicesEndpoint
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.common.MicrosoftTeamsAppIdentifier;
import com.azure.communication.common.MicrosoftTeamsUserIdentifier;
import com.azure.communication.common.PhoneNumberIdentifier;
import com.azure.core.annotation.Fluent;
Expand Down Expand Up @@ -53,7 +54,17 @@ public CallInvite(MicrosoftTeamsUserIdentifier targetIdentity) {
this.sourceCallerIdNumber = null;
this.customCallingContext = new CustomCallingContext(null, new HashMap<>());
}


/**
* Create a CallInvite object with MicrosoftTeamsAppIdentifier
* @param targetIdentity Target's MicrosoftTeamsAppIdentifier
*/
public CallInvite(MicrosoftTeamsAppIdentifier targetIdentity) {
this.targetParticipant = targetIdentity;
this.sourceCallerIdNumber = null;
this.customCallingContext = new CustomCallingContext(null, new HashMap<>());
}

/**
* Get target's CommunicationIdentifier
* @return target's CommunicationIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ public class StartHoldMusicOptions {
*/
private final PlaySource playSourceInfo;

/**
* If Audio will loop. Default is true.
*/
private boolean loop;

/**
* Operation context.
*/
Expand All @@ -38,7 +33,6 @@ public class StartHoldMusicOptions {
public StartHoldMusicOptions(CommunicationIdentifier targetParticipant, PlaySource playSourceInfo) {
this.targetParticipant = targetParticipant;
this.playSourceInfo = playSourceInfo;
loop = true;
}

/**
Expand All @@ -57,24 +51,6 @@ public PlaySource getPlaySourceInfo() {
return playSourceInfo;
}

/**
* Get if the music is in loop.
* @return true for loop, false for play once.
*/
public boolean isLoop() {
return loop;
}

/**
* Set the value for loop.
* @param loop - boolean.
* @return The StartHoldMusicOptions object.
*/
public StartHoldMusicOptions setLoop(boolean loop) {
this.loop = loop;
return this;
}

/**
* Get the operation context.
* @return operation context.
Expand Down
Loading

0 comments on commit 726104b

Please sign in to comment.