Skip to content

Commit

Permalink
Merge pull request #285 from plivo/VT-8165
Browse files Browse the repository at this point in the history
Added changes for masking session.
  • Loading branch information
manjunath-plivo authored Sep 30, 2024
2 parents 429dea1 + bef5577 commit 3d259ac
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 47 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [5.45.0](https://github.com/plivo/plivo-java/tree/v5.45.0) (2024-09-30)
**Feature - Adding new param support for Number Masking session with single party **
- Added `create_session_with_single_party`, `virtual_number_cooloff_period` and `force_pin_authentication` attributes in Masking Session

## [5.44.3](https://github.com/plivo/plivo-java/tree/v5.44.3) (2024-09-06)
**Feature - Adding more attribute on mdr object**
- Added `message_sent_time`, `message_updated_time` and `error-message` on get and list Message API
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Plivo Java SDK makes it simpler to integrate communications into your Java a

### To Install Stable release

You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.44.3/plivo-java-5.44.3.jar).
You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.45.0/plivo-java-5.45.0.jar).


If you are using Maven, use the following XML to include the Plivo SDK as a dependency.
Expand All @@ -19,13 +19,13 @@ 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.44.3</version>
<version>5.45.0</version>
</dependency>
```

If you are using Gradle, use the following line in your dependencies.
```
compile 'com.plivo:plivo-java:5.44.3'
compile 'com.plivo:plivo-java:5.45.0'
```

### To Install Beta release
Expand Down
2 changes: 1 addition & 1 deletion pom.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Written manually.

version=5.44.3
version=5.45.0
groupId=com.plivo
artifactId=plivo-java

3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.43.3</version>
<version>5.45.0</version>
<name>plivo-java</name>
<description>A Java SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</description>
<licenses>
Expand Down Expand Up @@ -76,7 +76,6 @@
<version>2.7.5</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ public class MaskingSessionCreator extends VoiceCreator<MaskingSessionCreateResp
private boolean generatePin;
private boolean record;
private int ringTimeout;
private int generatePinLength;
private int pinRetry;
private int pinRetryWait;
private Integer generatePinLength;
private Integer pinRetry;
private Integer pinRetryWait;
private int sessionExpiry;
private int callTimeLimit;
private boolean createSessionWithSingleParty;
private boolean forcePinAuthentication;
private int virtualNumberCooloffPeriod;

public MaskingSessionCreator(String firstParty, String secondParty) {
this.firstParty = firstParty;
Expand Down Expand Up @@ -179,24 +182,24 @@ public MaskingSessionCreator ringTimeout(final int ringTimeout) {
this.ringTimeout = ringTimeout;
return this;
}
public int generatePinLength() {
public Integer generatePinLength() {
return this.generatePinLength;
}
public MaskingSessionCreator generatePinLength(final int generatePinLength) {
public MaskingSessionCreator generatePinLength(final Integer generatePinLength) {
this.generatePinLength = generatePinLength;
return this;
}
public int pinRetry() {
public Integer pinRetry() {
return this.pinRetry;
}
public MaskingSessionCreator pinRetry(final int pinRetry) {
public MaskingSessionCreator pinRetry(final Integer pinRetry) {
this.pinRetry = pinRetry;
return this;
}
public int pinRetryWait() {
public Integer pinRetryWait() {
return this.pinRetryWait;
}
public MaskingSessionCreator pinRetryWait(final int pinRetryWait) {
public MaskingSessionCreator pinRetryWait(final Integer pinRetryWait) {
this.pinRetryWait = pinRetryWait;
return this;
}
Expand All @@ -214,4 +217,25 @@ public MaskingSessionCreator geomatch(final boolean geomatch) {
this.geomatch = geomatch;
return this;
}
public boolean createSessionWithSingleParty() {
return this.createSessionWithSingleParty;
}
public MaskingSessionCreator createSessionWithSingleParty(final boolean createSessionWithSingleParty) {
this.createSessionWithSingleParty = createSessionWithSingleParty;
return this;
}
public boolean forcePinAuthentication() {
return this.forcePinAuthentication;
}
public MaskingSessionCreator forcePinAuthentication(final boolean forcePinAuthentication) {
this.forcePinAuthentication = forcePinAuthentication;
return this;
}
public int virtualNumberCooloffPeriod() {
return this.virtualNumberCooloffPeriod;
}
public MaskingSessionCreator virtualNumberCooloffPeriod(final int virtualNumberCooloffPeriod) {
this.virtualNumberCooloffPeriod = virtualNumberCooloffPeriod;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import retrofit2.Call;

public class MaskingSessionUpdater extends VoiceUpdater<MaskingSessionUpdateResponse> {

private String firstParty;
private String secondParty;
private int sessionExpiry;
private int callTimeLimit;
private int ringTimeout;
Expand All @@ -19,7 +20,7 @@ public class MaskingSessionUpdater extends VoiceUpdater<MaskingSessionUpdateResp
private String recordFileFormat;
private Boolean geomatch = null;
private boolean record;

private boolean createSessionWithSingleParty;
public MaskingSessionUpdater(String id) {
super(id);
}
Expand All @@ -36,6 +37,20 @@ protected Call<MaskingSessionUpdateResponse> obtainFallback2Call() throws PlivoV
return client().getVoiceFallback2Service().maskingSessionUpdate(client().getAuthId(), id, this);
}

public String firstParty() {
return this.firstParty;
}
public MaskingSessionUpdater firstParty(final String firstParty){
this.firstParty = firstParty;
return this;
}
public String secondParty() {
return this.secondParty;
}
public MaskingSessionUpdater secondParty(final String secondParty){
this.secondParty = secondParty;
return this;
}
public int callTimeLimit() {
return this.callTimeLimit;
}
Expand Down Expand Up @@ -127,5 +142,12 @@ public MaskingSessionUpdater sessionExpiry(final int sessionExpiry) {
this.sessionExpiry = sessionExpiry;
return this;
}
public boolean createSessionWithSingleParty() {
return this.createSessionWithSingleParty;
}
public MaskingSessionUpdater createSessionWithSingleParty(final boolean record){
this.createSessionWithSingleParty = createSessionWithSingleParty;
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.44.3
5.45.0
27 changes: 27 additions & 0 deletions src/test/java/com/plivo/api/MaskingSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@ public void maskingSessionCreate() throws Exception {
assertRequest("POST", "Masking/Session/");
}

@Test
public void maskingSessionCreate_createSessionWithSingleParty() throws Exception {
expectResponse("maskingSessionCreateResponse.json", 201);

MaskingSession.creator("916303955746","").createSessionWithSingleParty(true).create();

assertRequest("POST", "Masking/Session/");
}

@Test
public void maskingSessionCreate_forcePinAuthentication() throws Exception {
expectResponse("maskingSessionCreateResponse.json", 201);

MaskingSession.creator("916303955746", "916303955747").isPinAuthenticationRequired(true).generatePin(true).generatePinLength(4).firstPartyPin("1234").secondPartyPin("2345").pinRetry(2).pinRetryWait(6).pinPromptPlay("https://plivobin-prod-usw.plivops.com/api/v1/speak.mp3").unknownCallerPlay("https://plivobin-prod-usw.plivops.com/api/v1/speak.mp3").incorrectPinPlay("https://plivobin-prod-usw.plivops.com/api/v1/speak.mp3").forcePinAuthentication(true).create();

assertRequest("POST", "Masking/Session/");
}

@Test
public void maskingSessionCreate_virtualNumberCooloffPeriod() throws Exception {
expectResponse("maskingSessionCreateResponse.json", 201);

MaskingSession.creator("916303955746", "916303955747").virtualNumberCooloffPeriod(2500).create();

assertRequest("POST", "Masking/Session/");
}

@Test
public void maskingSessionCreateWithClient() throws Exception {
expectResponse("maskingSessionCreateResponse.json", 201);
Expand Down
61 changes: 32 additions & 29 deletions src/test/resources/com/plivo/api/maskingSessionCreateResponse.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
{
"api_id": "f2a246e0-d585-4d55-bff5-4a6688b8a34a",
"session_uuid": "2d265b0a-32a1-4450-a36c-f5e09144598e",
"virtual_number": "+919790969500",
"api_id": "e0218e45-53f5-435b-83d2-936010e40acc",
"session_uuid": "1091db69-2290-4633-9222-c9473c4815b6",
"virtual_number": "+919988776676",
"message": "Session created",
"session": {
"first_party": "917708772011",
"second_party": "918220568648",
"virtual_number": "919790969500",
"first_party": "916303955747",
"second_party": "916384780853",
"virtual_number": "919988776676",
"status": "active",
"initiate_call_to_first_party": true,
"session_uuid": "2d265b0a-32a1-4450-a36c-f5e09144598e",
"callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1",
"callback_method": "GET",
"created_time": "2024-05-29 04:47:18 +0000 UTC",
"modified_time": "2024-05-29 04:47:18 +0000 UTC",
"expiry_time": "2024-05-29 06:27:18 +0000 UTC",
"duration": 6000,
"initiate_call_to_first_party": false,
"session_uuid": "1091db69-2290-4633-9222-c9473c4815b6",
"callback_url": "",
"callback_method": "POST",
"created_time": "2024-09-05 06:43:26 +0000 UTC",
"modified_time": "2024-09-05 06:43:26 +0000 UTC",
"expiry_time": "2024-09-05 06:46:46 +0000 UTC",
"duration": 200,
"amount": 0,
"call_time_limit": 14400,
"ring_timeout": 120,
"first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml",
"second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml",
"ring_timeout": 45,
"first_party_play_url": "",
"second_party_play_url": "",
"record": false,
"record_file_format": "mp3",
"recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml",
"recording_callback_method": "GET",
"recording_callback_url": "",
"recording_callback_method": "POST",
"interaction": null,
"total_call_amount": 0,
"total_call_count": 0,
"total_call_billed_duration": 0,
"total_session_amount": 0,
"last_interaction_time": "",
"unknown_caller_play": "https://vinodhan-test.s3.amazonaws.com/Number+masking+audio/2024-02-13-201825_178983233.mp3",
"is_pin_authentication_required": false,
"generate_pin": null,
"generate_pin_length": null,
"first_party_pin": null,
"second_party_pin": null,
"pin_prompt_play": null,
"pin_retry": null,
"pin_retry_wait": null,
"incorrect_pin_play": null
"unknown_caller_play": "https://file-examples.com/storage/fefda3519566d3360a0efb3/2017/11/file_example_MP3_700KB.mp3",
"is_pin_authentication_required": true,
"generate_pin": false,
"generate_pin_length": 4,
"first_party_pin": "1234",
"second_party_pin": "4321",
"pin_prompt_play": "https://file-examples.com/storage/fefda3519566d3360a0efb3/2017/11/file_example_MP3_700KB.mp3",
"pin_retry": 2,
"pin_retry_wait": 7,
"incorrect_pin_play": "https://file-examples.com/storage/fefda3519566d3360a0efb3/2017/11/file_example_MP3_700KB.mp3",
"create_session_with_single_party": null,
"virtual_number_cooloff_period": 3500,
"force_pin_authentication": true
}
}

0 comments on commit 3d259ac

Please sign in to comment.