Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new recording params #236

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ hs_err_pid*

*.iml
/target/
.DS_Store
.DS_Store

# Local test files
java-sdk-test/*
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Change Log

## [5.21.1](https://github.com/plivo/plivo-java/tree/v5.21.1) (2023-04-04)
- Added `monthly_recording_storage_amount`, `recording_storage_rate`, `rounded_recording_duration`, and `recording_storage_duration` parameters to the response for [get single recording API](https://www.plivo.com/docs/voice/api/recording#retrieve-a-recording) and [get all recordings API](https://www.plivo.com/docs/voice/api/recording#list-all-recordings)
- Added `rounded_recording_duration` parameter as a filter option for [get all recordings API](https://www.plivo.com/docs/voice/api/recording#list-all-recordings)

## [5.21.0](https://github.com/plivo/plivo-java/tree/v5.21.0) (2023-17-03)
- Added New Param `created_at` to the response for the [list all profiles API](https://www.plivo.com/docs/sms/api/10dlc/profile#retrieve-all-profiles) and the [get profile API](https://www.plivo.com/docs/sms/api/10dlc/profile#retrieve-a-specific-profile) and the [list all brands API](https://www.plivo.com/docs/sms/api/10dlc/brand#retrieve-all-brands) and the [get brand API](https://www.plivo.com/docs/sms/api/10dlc/brand#retrieve-a-specific-brand)
and the [list all campaigns API](https://www.plivo.com/docs/sms/api/10dlc/campaign#retrieve-all-campaigns) and the [get campaign API](https://www.plivo.com/docs/sms/api/10dlc/campaign#retrieve-a-specific-campaign)

## [5.20.0](https://github.com/plivo/plivo-java/tree/v5.20.0) (2023-02-23)
- Add `isDomestic` to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message)

## [5.19.2](https://github.com/plivo/plivo-java/tree/v5.19.2) (2023-02-23)
**Feature - Enhance MDR filtering capabilities **
- Added new fields on MDR object response
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM openjdk:8-alpine

RUN apk update && apk add git vim bash wget make

WORKDIR /usr/src/app
ENV CLASSPATH ${CLASSPATH}:/etc/jars/*

# Copy setup script
COPY setup_sdk.sh /usr/src/app/
RUN chmod a+x /usr/src/app/setup_sdk.sh

ENTRYPOINT [ "/usr/src/app/setup_sdk.sh" ]
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: build test run

build:
docker-compose up --build --remove-orphans

test:
@[ "${CONTAINER}" ] && \
docker exec -it $$CONTAINER /bin/bash -c "/usr/src/app/gradlew test" || \
/usr/src/app/gradlew test

run:
@[ "${CONTAINER}" ] && \
(docker exec -it $$CONTAINER /bin/bash -c 'cd /usr/src/app/java-sdk-test/ && javac Test.java && java Test') || \
(cd /usr/src/app/java-sdk-test/ && javac Test.java && java Test)
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ 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.19.1/plivo-java-5.19.1.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.21.1/plivo-java-5.21.1.jar).

If you are using Maven, use the following XML to include the Plivo SDK as a dependency.

```xml
<dependency>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.19.2</version>
<version>5.21.1</version>
</dependency>
```

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

### To Install Beta release
Expand Down Expand Up @@ -210,3 +210,28 @@ More examples are available [here](https://github.com/plivo/plivo-examples-java)

## Reporting issues
Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-java/issues).

## Local Development
> Note: Requires latest versions of Docker & Docker-Compose. If you're on MacOS, ensure Docker Desktop is running.
1. Export the following environment variables in your host machine:
```bash
export PLIVO_AUTH_ID=<your_auth_id>
export PLIVO_AUTH_TOKEN=<your_auth_token>
export PLIVO_API_DEV_HOST=<plivoapi_dev_endpoint>
export PLIVO_API_PROD_HOST=<plivoapi_public_endpoint>
```
2. Run `make build`. This will create a docker container in which the sdk will be setup and dependencies will be installed.
> The entrypoint of the docker container will be the `setup_sdk.sh` script. The script will handle all the necessary changes required for local development. It will also package the sdk and reinstall it as a dependecy for the test program.
3. The above command will print the docker container id (and instructions to connect to it) to stdout.
4. The test code can be added to `<sdk_dir_path>/java-sdk-test/Test.java` in host
(or `/usr/src/app/java-sdk-test/Test.java` in container)
5. The sdk directory will be mounted as a volume in the container. So any changes in the sdk code will also be reflected inside the container. However, when any change is made, the dependencies for the test program need to be re-installed. To do that:
* Either restart the docker container
* Or Run the `setup_sdk.sh` script
6. To run test code, run `make run CONTAINER=<cont_id>` in host.
7. To run unit tests, run `make test CONTAINER=<cont_id>` in host.
> `<cont_id>` is the docker container id created in 2.
(The docker container should be running)

> Test code and unit tests can also be run within the container using
`make run` and `make test` respectively. (`CONTAINER` argument should be omitted when running from the container)
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'

services:

javaSDK:
build:
context: .
image: javasdk
container_name: javaSDK
environment:
- PLIVO_AUTH_ID=${PLIVO_AUTH_ID}
- PLIVO_AUTH_TOKEN=${PLIVO_AUTH_TOKEN}
- PLIVO_API_DEV_HOST=${PLIVO_API_DEV_HOST}
- PLIVO_API_PROD_HOST=${PLIVO_API_PROD_HOST}
volumes:
- .:/usr/src/app
stdin_open: true
tty: true
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.19.2
version=5.21.1
groupId=com.plivo
artifactId=plivo-java
2 changes: 1 addition & 1 deletion 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.19.2</version>
<version>5.21.1</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
51 changes: 51 additions & 0 deletions setup_sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -e
testDir="java-sdk-test"
GREEN="\033[0;32m"
NC="\033[0m"

if [ ! $PLIVO_API_PROD_HOST ] || [ ! $PLIVO_API_DEV_HOST ] || [ ! $PLIVO_AUTH_ID ] || [ ! $PLIVO_AUTH_TOKEN ]; then
echo "Environment variables not properly set! Please refer to Local Development section in README!"
exit 126
fi

cd /usr/src/app

echo "Setting plivo-api endpoint to dev..."
find /usr/src/app/src/ -type f -exec sed -i "s/$PLIVO_API_PROD_HOST/$PLIVO_API_DEV_HOST/g" {} \;

if [[ $( grep uploadArchives build.gradle ) ]]; then
echo "Modifying build.gradle..."
sed -i '/uploadArchives/,/artifacts/{//!d}' build.gradle
sed -i '/signing {/,/}/d' build.gradle
echo "dependencies{
compile 'com.fasterxml.jackson.core:jackson-core:2.10.1'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.10.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
}" >> build.gradle
fi
./gradlew fatJar

mkdir -p /etc/jars
mv /usr/src/app/build/libs/*.jar /etc/jars/

if [ ! -d $testDir ]; then
echo "Creating test dir..."
mkdir -p $testDir
fi

echo -e "\n\nSDK setup complete! You can test changes either on host or inside the docker container:"
echo -e "\ta. To test your changes ON HOST:"
echo -e "\t\t1. Add your test code in <path_to_cloned_sdk>/$testDir/Test.java"
echo -e "\t\t2. Run your test file using: $GREEN make run CONTAINER=$HOSTNAME$NC"
echo -e "\t\t3. Run unit tests using: $GREEN make test CONTAINER=$HOSTNAME$NC"
echo
echo -e "\tb. To test your changes INSIDE CONTAINER:"
echo -e "\t\t1. Run a terminal in the container using: $GREEN docker exec -it $HOSTNAME /bin/bash$NC"
echo -e "\t\t2. Add your test code in /usr/src/app/$testDir/Test.java"
echo -e "\t\t3. Run your test file using: $GREEN make run$NC"
echo -e "\t\t4. Run unit tests using: $GREEN make test$NC"

# To keep the container running post setup
/bin/bash
8 changes: 8 additions & 0 deletions src/main/java/com/plivo/api/models/brand/Brand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Brand extends BaseResource {
private Address address;
private AuthorizedContact authorizedContact;
private BrandResponse brand;
private String createdAt;

public static BrandCreator creator(String brandAlias,String profileUUID,String brandType,Boolean secondaryVetting,String url,String method) {
return new BrandCreator(brandAlias,profileUUID,brandType,secondaryVetting,url,method);
Expand Down Expand Up @@ -111,6 +112,13 @@ public AuthorizedContact getAuthorizedContact() {
return authorizedContact;
}

/**
* @return String return the getCreatedAt
*/
public String getCreatedAt() {
return createdAt;
}

public BrandResponse getBrand() {
return brand;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/plivo/api/models/brand/BrandResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class BrandResponse extends BaseResource {
private String registrationStatus;
private String vertical;
private Address address;
private String createdAt;
private AuthorizedContact authorizedContact;

/**
Expand Down Expand Up @@ -76,6 +77,13 @@ public Address getAddress() {
return address;
}

/**
* @return String return the getCreatedAt
*/
public String getCreatedAt() {
return createdAt;
}

/**
* @return String return the getAuthorizedContact
*/
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/plivo/api/models/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Campaign extends BaseResource {
private String sample2;
private String description;
private CampaignAttributes campaignAttributes;
private String createdAt;


public static CampaignCreator creator(String brandID,String campaignAlias,String vertical,String usecase,String[] subUsecases,String description,Boolean embeddedLink,Boolean embeddedPhone,Boolean ageGated,Boolean directLending,Boolean affiliateMarketing,Boolean subscriberOptin,Boolean subscriberOptout,Boolean subscriberHelp,String sample1,String sample2,String url, String method, String messageFlow, String helpMessage, String optoutMessage, String optinKeywords, String optinMessage, String optoutKeywords, String helpKeywords) {
Expand Down Expand Up @@ -150,6 +151,10 @@ public String getDescription() {
return description;
}

public String getCreatedAt() {
return createdAt;
}

@Override
public String getId() {
return this.campaignID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CampaignResponse extends BaseResource{
private String sample1;
private String sample2;
private String description;
private String createdAt;
private CampaignAttributes campaignAttributes;


Expand Down Expand Up @@ -128,6 +129,14 @@ public CampaignAttributes getCampaignAttributes() {
public String getDescription() {
return description;
}

/**
* @return createdAt return the CreatedAt
*/
public String getCreatedAt() {
return createdAt;
}



@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/plivo/api/models/message/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Message extends BaseResource {
private String tendlcRegistrationStatus;
private String destinationCountryIso2;
private String requesterIP;
private Boolean isDomestic;

public static MessageCreator creator(String source, List<String> destination, String text) {
return new MessageCreator(source, destination, text);
Expand Down Expand Up @@ -116,6 +117,10 @@ public Long getUnits() {
return units;
}

public Boolean getIsDomestic() {
return isDomestic;
}

@Override
public String getId() {
return getMessageUuid();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/plivo/api/models/profile/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Profile extends BaseResource {
private String profileType;
private String profileUUID;
private String message;
private String createdAt;
private ProfileResponse profile;


Expand Down Expand Up @@ -119,6 +120,10 @@ public String getMessage(){
return message;
}

public String getCreatedAt(){
return createdAt;
}

public ProfileResponse getProfile() {
return profile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ProfileResponse extends BaseResource{
private String primaryProfile;
private String profileType;
private String profileUUID;
private String createdAt;

public String getProfileAlias(){
return profileAlias;
Expand Down Expand Up @@ -91,6 +92,10 @@ public String getProfileUUID(){
return profileUUID;
}

public String getCreatedAt(){
return createdAt;
}

@Override
public String getId() {
return this.profileUUID;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/plivo/api/models/recording/Recording.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class Recording extends BaseResource {
private String addTime;
private String callUuid;
private String conferenceName;
private String cost;
private String daysOfStorage;
private String recordingDurationMs;
private String recordingEndMs;
private String recordingFormat;
Expand All @@ -15,6 +17,7 @@ public class Recording extends BaseResource {
private String recordingUrl;
private String resourceUri;
private String recordingId;
private String roundedDuration;
private String fromNumber;
private String toNumber;

Expand Down Expand Up @@ -112,6 +115,18 @@ public String getRecordingUrl() {
return recordingUrl;
}

public String getCost() {
return cost;
}

public String getDaysOfStorage() {
return daysOfStorage;
}

public String getRoundedDuration() {
return roundedDuration;
}

public String getResourceUri() {
return resourceUri;
}
Expand Down
Loading