Skip to content

Commit

Permalink
Merge pull request #195 from plivo/VT-3664
Browse files Browse the repository at this point in the history
VT-3664 MPC Enhancements for Java SDK
  • Loading branch information
huzaif-plivo authored Nov 25, 2021
2 parents d29be26 + dab099e commit b7b16f2
Show file tree
Hide file tree
Showing 15 changed files with 790 additions and 493 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [5.5.0](https://github.com/plivo/plivo-java/tree/v5.5.0) (2021-11-25)
**Features - Voice: Multiparty calls**
- The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods.
- [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio.

## [5.4.1](https://github.com/plivo/plivo-java/tree/v5.4.1) (2021-11-05)
**Bug Fix**
- [Update Powerpack API](https://www.plivo.com/docs/sms/api/powerpack#update-a-powerpack) response to retrun `number_pool` parameter.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you are using Maven, use the following XML to include the Plivo SDK as a depe
<dependency>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.4.1</version>
<version>5.5.0</version>
</dependency>
```

Expand Down Expand Up @@ -89,7 +89,7 @@ class Example {
## The Basics
The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:

```java
``` java
Resource.creator(parameters).create();
Resource.getter(parameters).get();
Resource.updater(identifier, parameters).update();
Expand Down
2 changes: 1 addition & 1 deletion pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Written manually.

version=5.4.1
version=5.5.0
groupId=com.plivo
artifactId=plivo-java
904 changes: 455 additions & 449 deletions src/main/java/com/plivo/api/PlivoAPIService.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ public void participantKick(String participantId) throws PlivoRestException, IOE
kicker.delete();
}

public static MultiPartyCallStartPlayAudio startPlayAudio(String mpcId, String participantId) {
return new MultiPartyCallStartPlayAudio(mpcId, participantId);
}

public static MultiPartyCallStopPlayAudio stopPlayAudio(String mpcId, String participantId) {
return new MultiPartyCallStopPlayAudio(mpcId,participantId);
}

public String getBilledAmount() {
return billedAmount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ public class MultiPartyCallParticipantAdd extends VoiceUpdater<MultiPartyCallPar
@UrlValues
private String customerHoldMusicUrl;
@OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
private String customerHoldMusicMethod ="GET";
private String customerHoldMusicMethod = "GET";
@UrlValues
private String recordingCallbackUrl;
@OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
private String recordingCallbackMethod ="GET";
private String recordingCallbackMethod = "GET";
@UrlValues
private String statusCallbackUrl;
@OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
private String statusCallbackMethod ="POST";
private String statusCallbackMethod = "POST";
@UrlValues
private String onExitActionUrl;
@OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
private String onExitActionMethod ="POST";
private String onExitActionMethod = "POST";
private Boolean record = false;
@OneOf(message = "should be one of [mp3, wav]", options = {"mp3", "wav"})
private String recordFileFormat ="mp3";
private String recordFileFormat = "mp3";
@JsonSerialize(using = CommaDelimitedListSerializer.class)
@MultiOf(message = "should be among [mpc-state-changes, participant-state-changes, participant-speak-events, participant-digit-input-events, add-participant-api-events]", options = {"mpc-state-changes", "participant-state-changes", "participant-speak-events", "participant-digit-input-events", "add-participant-api-events"})
private List<String> statusCallbackEvents = Arrays.asList("mpc-state-changes", "participant-state-changes");
Expand All @@ -90,6 +90,15 @@ public class MultiPartyCallParticipantAdd extends VoiceUpdater<MultiPartyCallPar
private String exitSound = "beep:2";
@OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
private String exitSoundMethod = "GET";
@UrlValues
private String startRecordingAudio;
@OneOf(message = "should be one of['GET',POST']", options = {"GET", "POST"})
private String startRecordingAudioMethod = "GET";
@UrlValues
private String stopRecordingAudio;
@OneOf(message = "should be one of['GET',POST']", options = {"GET", "POST"})
private String stopRecordingAudioMethod = "GET";


public MultiPartyCallParticipantAdd(String mpcId, String role, String from, List<String> to) throws PlivoValidationException {
super(mpcId);
Expand All @@ -103,7 +112,7 @@ public MultiPartyCallParticipantAdd(String mpcId, String role, String from, List
this.from = from;
this.to = to;
this.callUuid = null;
if(this.callerName==null){
if (this.callerName == null) {
this.callerName = this.from;
}
}
Expand Down Expand Up @@ -132,7 +141,9 @@ public String callUuid() {
return callUuid;
}

public String callerName(){ return callerName;}
public String callerName() {
return callerName;
}

public String callStatusCallbackUrl() {
return callStatusCallbackUrl;
Expand Down Expand Up @@ -166,7 +177,7 @@ public Object ringTimeout() {
return ringTimeout;
}

public Object delayDial() {
public Object delayDial() {
return delayDial;
}

Expand Down Expand Up @@ -282,9 +293,25 @@ public String exitSoundMethod() {
return exitSoundMethod;
}

public MultiPartyCallParticipantAdd callerName( String callerName) throws PlivoValidationException {
public String startRecordingAudio() {
return startRecordingAudio;
}

public String startRecordingAudioMethod() {
return startRecordingAudioMethod;
}

public String stopRecordingAudio() {
return stopRecordingAudio;
}

public String stopRecordingAudioMethod() {
return stopRecordingAudioMethod;
}

public MultiPartyCallParticipantAdd callerName(String callerName) throws PlivoValidationException {
this.callerName = callerName;
if (callerName.length() > 50){
if (callerName.length() > 50) {
throw new PlivoValidationException("CallerName Length must be in range [0,50]");
}
return this;
Expand Down Expand Up @@ -475,6 +502,26 @@ public MultiPartyCallParticipantAdd exitSoundMethod(String exitSoundMethod) {
return this;
}

public MultiPartyCallParticipantAdd startRecordingAudio(String startRecordingAudio) {
this.startRecordingAudio = startRecordingAudio;
return this;
}

public MultiPartyCallParticipantAdd startRecordingAudioMethod(String startRecordingAudioMethod) {
this.startRecordingAudioMethod = startRecordingAudioMethod;
return this;
}

public MultiPartyCallParticipantAdd stopRecordingAudio(String stopRecordingAudio) {
this.stopRecordingAudio= stopRecordingAudio;
return this;
}

public MultiPartyCallParticipantAdd stopRecordingAudioMethod(String stopRecordingAudioMethod) {
this.stopRecordingAudioMethod = stopRecordingAudioMethod;
return this;
}

@Override
protected Call<MultiPartyCallParticipantAddResponse> obtainCall() throws PlivoValidationException {
Validate.check(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.plivo.api.models.multipartycall;

import com.plivo.api.exceptions.PlivoValidationException;
import com.plivo.api.models.base.VoiceUpdater;
import com.plivo.api.validators.UrlValues;
import com.plivo.api.validators.Validate;
import retrofit2.Call;

public class MultiPartyCallStartPlayAudio extends VoiceUpdater<MultiPartyCallStartPlayAudioResponse> {

@UrlValues
private String url;

public MultiPartyCallStartPlayAudio(String mpcId, String secondaryId) {
super(mpcId, secondaryId);
}

@Override
protected Call<MultiPartyCallStartPlayAudioResponse> obtainCall() throws PlivoValidationException {
MultiPartyCallUtils.validMultiPartyCallId(id);
Validate.check(this);
return client().getVoiceApiService().mpcStartPlayAudio(client().getAuthId(), id, secondaryId, this);
}

@Override
protected Call<MultiPartyCallStartPlayAudioResponse> obtainFallback1Call() throws PlivoValidationException {
MultiPartyCallUtils.validMultiPartyCallId(id);
Validate.check(this);
return client().getVoiceFallback1Service().mpcStartPlayAudio(client().getAuthId(), id, secondaryId, this);
}

@Override
protected Call<MultiPartyCallStartPlayAudioResponse> obtainFallback2Call() throws PlivoValidationException {
MultiPartyCallUtils.validMultiPartyCallId(id);
Validate.check(this);
return client().getVoiceFallback1Service().mpcStartPlayAudio(client().getAuthId(), id, secondaryId, this);
}

public String url() {
return url;
}

public MultiPartyCallStartPlayAudio url(String url) {
this.url = url;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.plivo.api.models.multipartycall;

import com.plivo.api.models.base.BaseResponse;

import java.util.List;

public class MultiPartyCallStartPlayAudioResponse extends BaseResponse {

private List<String> mpcMemberId;
private String mpcName;

public List<String> getMpcMemberId() {
return mpcMemberId;
}
public String mpcName() {
return mpcName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.plivo.api.models.multipartycall;

import com.plivo.api.exceptions.PlivoValidationException;
import com.plivo.api.models.base.VoiceDeleter;
import com.plivo.api.validators.Validate;
import okhttp3.ResponseBody;
import retrofit2.Call;

public class MultiPartyCallStopPlayAudio extends VoiceDeleter<MultiPartyCallParticipant> {
public MultiPartyCallStopPlayAudio(String id, String secondaryId) {
super(id, secondaryId);
}

@Override
protected Call<ResponseBody> obtainCall() throws PlivoValidationException {
MultiPartyCallUtils.validMultiPartyCallId(id);
Validate.check(this);
return client().getVoiceApiService().mpcStopPlayAudio(client().getAuthId(), id, secondaryId);
}

@Override
protected Call<ResponseBody> obtainFallback1Call() throws PlivoValidationException {
MultiPartyCallUtils.validMultiPartyCallId(id);
Validate.check(this);
return client().getVoiceFallback1Service().mpcStopPlayAudio(client().getAuthId(), id, secondaryId);
}

@Override
protected Call<ResponseBody> obtainFallback2Call() throws PlivoValidationException {
MultiPartyCallUtils.validMultiPartyCallId(id);
Validate.check(this);
return client().getVoiceFallback2Service().mpcStopPlayAudio(client().getAuthId(), id, secondaryId);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/plivo/api/validators/Validate.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class Validate {


private static final Pattern urlPattern = Pattern.compile("r'(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+|None)'");
private static final Pattern urlPattern = Pattern.compile("(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+|None)");
private static final String COLON = ": ";


Expand Down
53 changes: 53 additions & 0 deletions src/main/java/com/plivo/api/xml/MultiPartyCall.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.plivo.api.xml;

import com.plivo.api.models.multipartycall.MultiPartyCallParticipantAdd;
import com.plivo.api.serializers.DelimitedListXMLSerializer;
import com.plivo.api.validators.InRange;
import com.plivo.api.validators.MultiOf;
Expand Down Expand Up @@ -127,6 +128,22 @@ public class MultiPartyCall extends PlivoXml implements ResponseNestable {
@XmlValue
private String name;

@XmlAttribute
@UrlValues
private String startRecordingAudio;

@XmlAttribute
@OneOf(message = "should be one of['GET',POST']", options = {"GET", "POST"})
private String startRecordingAudioMethod = "GET";

@XmlAttribute
@UrlValues
private String stopRecordingAudio;

@XmlAttribute
@OneOf(message = "should be one of['GET',POST']", options = {"GET", "POST"})
private String stopRecordingAudioMethod = "GET";

private MultiPartyCall() {

}
Expand Down Expand Up @@ -264,6 +281,22 @@ public String name() {
return name;
}

public String startRecordingAudio() {
return startRecordingAudio;
}

public String startRecordingAudioMethod() {
return startRecordingAudioMethod;
}

public String stopRecordingAudio() {
return stopRecordingAudio;
}

public String stopRecordingAudioMethod() {
return stopRecordingAudioMethod;
}

public MultiPartyCall role(String role) {
this.role = role;
return this;
Expand Down Expand Up @@ -413,4 +446,24 @@ public MultiPartyCall name(String name) {
this.name = name;
return this;
}

public MultiPartyCall startRecordingAudio(String startRecordingAudio) {
this.startRecordingAudio = startRecordingAudio;
return this;
}

public MultiPartyCall startRecordingAudioMethod(String startRecordingAudioMethod) {
this.startRecordingAudioMethod = startRecordingAudioMethod;
return this;
}

public MultiPartyCall stopRecordingAudio(String stopRecordingAudio) {
this.stopRecordingAudio= stopRecordingAudio;
return this;
}

public MultiPartyCall stopRecordingAudioMethod(String stopRecordingAudioMethod) {
this.stopRecordingAudioMethod = stopRecordingAudioMethod;
return this;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/com/plivo/api/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.1
5.5.0
Loading

0 comments on commit b7b16f2

Please sign in to comment.