Skip to content

Commit

Permalink
Merge pull request #369 from Vonage/random-number-feature
Browse files Browse the repository at this point in the history
adding random form number feature to VAPI
  • Loading branch information
slorello89 authored May 28, 2021
2 parents 71c5845 + 476b911 commit 437ae7d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [6.4.0]
- Adding Random From Number Feature for the Voice API, if set to `true`, the from number will be randomly selected from the pool of numbers available to the application making the call.
- adjusting operator used to check json payloads
- Adding extra parsing for top level Roaming Status in Advanced Number Insights

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/vonage/client/voice/Call.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Call {
private MachineDetection machineDetection = null;
private Integer lengthTimer = null;
private Integer ringingTimer = null;
private Boolean fromRandomNumber = null;
private Ncco ncco;

public Call() {
Expand Down Expand Up @@ -158,6 +159,16 @@ public void setRingingTimer(Integer ringingTimer) {
this.ringingTimer = ringingTimer;
}

@JsonProperty("from_random_number")
public Boolean getFromRandomNumber(){ return fromRandomNumber; }


/**
* Set to true to use random phone number as from. The number will be selected from the list of the numbers assigned to the current application. random_from_number: true cannot be used together with from.
* @param fromRandomNumber
*/
public void setFromRandomNumber(Boolean fromRandomNumber){ this.fromRandomNumber = fromRandomNumber; }

@JsonProperty("ncco")
public Ncco getNcco() {
return ncco;
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/com/vonage/client/voice/CallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ public void testToJson() throws Exception {
);
}

@Test
public void testToJsonRandomNumber() throws Exception{
Call call = new Call();
call.setTo(new Endpoint[]{new PhoneEndpoint("4477999000")});
call.setFromRandomNumber(true);
call.setAnswerMethod("GET");
call.setAnswerUrl("https://callback.example.com/");

assertEquals("{\"to\":[{\"type\":\"phone\",\"number\":\"4477999000\"}],"
+ "\"answer_url\":[\"https://callback.example.com/\"],\"answer_method\":\"GET\",\"from_random_number\":true}",
call.toJson());
}

@Test
public void testToJsonMachineDetection() throws Exception {
Call call = new Call("4477999000", "44111222333", "https://callback.example.com/");
Expand Down

0 comments on commit 437ae7d

Please sign in to comment.