Skip to content

Commit

Permalink
SDK changes for Import Campaign API (#271)
Browse files Browse the repository at this point in the history
* SDK changes for Import Campaign API

* changelog and updated version

* minor change

* changing importcamp fn name to standard

* changelog date updated

---------

Co-authored-by: Thumpala Vinay Kumar <[email protected]>
Co-authored-by: Sajal Singhal <[email protected]>
Co-authored-by: Sajal Singhal <[email protected]>
  • Loading branch information
4 people authored Mar 13, 2024
1 parent 2ef6452 commit 7ca18df
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [5.39.0](https://github.com/plivo/plivo-java/tree/v5.39.0) (2024-03-13)
**Feature - Import Campaign API**
- Import Campaign API


## [5.38.3](https://github.com/plivo/plivo-java/tree/v5.38.3) (2024-02-28)
**Feature - Log Redaction Enhancement**
Expand Down
6 changes: 3 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.38.0/plivo-java-5.38.0.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.39.0/plivo-java-5.39.0.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.38.3</version>
<version>5.39.0</version>
</dependency>
```

If you are using Gradle, use the following line in your dependencies.
```
compile 'com.plivo:plivo-java:5.38.3'
compile 'com.plivo:plivo-java:5.39.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.38.3
version=5.39.0
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.38.3</version>
<version>5.39.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
4 changes: 4 additions & 0 deletions src/main/java/com/plivo/api/PlivoAPIService.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ Call<CampaignNumbers> campaignNumbersGet(@Path("authId") String authId, @Path("c
Call<CampaignNumbers> unlinkCampaignNumber(@Path("authId") String authId, @Path("campaign_id") String campaignID,
@Path("number") String number, @Query("url") String url, @Query("method") String method);

@POST("Account/{authId}/10dlc/Campaign/Import/")
Call<CampaignImportResponse> importCampaign(@Path("authId") String authId,
@Body CampaignImporter campaignImporter);

@POST("Account/{authId}/Profile/")
Call<ProfileAddResponse> profileAdd(@Path("authId") String authId, @Body ProfileAdder profileAdder);

Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/plivo/api/models/base/Importer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.plivo.api.models.base;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.plivo.api.PlivoClient;
import com.plivo.api.exceptions.PlivoRestException;
import java.io.IOException;
import retrofit2.Call;
import retrofit2.Response;

/**
* Creates an instance of a resource.
*
* @param <ImportResponse> The type of the response.
*/
@JsonInclude(Include.NON_NULL)
public abstract class Importer<ImportResponse extends BaseResponse> extends BaseRequest {

/**
* Actually import an instance of the resource.
*/
public ImportResponse import_campaign() throws IOException, PlivoRestException {
validate();
Response<ImportResponse> response = obtainCall().execute();

handleResponse(response);

return response.body();
}

@Override
public Importer<ImportResponse> client(final PlivoClient plivoClient) {
this.plivoClient = plivoClient;
return this;
}


protected abstract Call<ImportResponse> obtainCall();
}
4 changes: 4 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 @@ -42,6 +42,10 @@ public static CampaignUpdater updater(String campaign_id, String reseller_id, St
return new CampaignUpdater(campaign_id,reseller_id,description,sample1,sample2,message_flow,help_message,optin_keywords,optin_message,optout_keywords,optout_message,help_keywords);
}

public static CampaignImporter importer(String campaign_id, String campaignAlias) {
return new CampaignImporter(campaign_id,campaignAlias);
}

public static CampaignGetter getter(String id) {
return new CampaignGetter(id);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.plivo.api.models.campaign;

import com.plivo.api.models.base.BaseResponse;
import java.util.List;

public class CampaignImportResponse extends BaseResponse{
private String campaignID;
public String getcampaignID(){
return campaignID;
}

}
31 changes: 31 additions & 0 deletions src/main/java/com/plivo/api/models/campaign/CampaignImporter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.plivo.api.models.campaign;

import com.plivo.api.models.base.Importer;
import com.plivo.api.util.Utils;
import retrofit2.Call;

public class CampaignImporter extends Importer<CampaignImportResponse> {
private String campaignID;
private String campaignAlias;

CampaignImporter(String campaignID,String campaignAlias) {

this.campaignID = campaignID;
this.campaignAlias = campaignAlias;
}

public String campaignID(){
return this.campaignID;
}

public String campaignAlias(){
return this.campaignAlias;
}



@Override
protected Call<CampaignImportResponse> obtainCall() {
return client().getApiService().importCampaign(client().getAuthId(), 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.38.3
5.39.0
10 changes: 10 additions & 0 deletions src/test/java/com/plivo/api/CampaignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ public void campaignCreateShouldSucceed() throws Exception {
assertRequest("POST", "10dlc/Campaign/");
}

@Test
public void campaignImportShouldSucceed() throws Exception {
String fixtureName = "campaignImportResponse.json";

expectResponse(fixtureName, 202);
Campaign.importer("CNTQ0OD", "New Contact by vinay for ct").import_campaign();

assertRequest("POST", "10dlc/Campaign/Import/");
}

@Test
public void campaignUpdateShouldSucceed() throws Exception {
String fixtureName = "campaignUpdateResponse.json";
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/com/plivo/api/campaignImportResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"api_id": "2c6c5e16-090a-11ed-bb48-0242ac110004",
"campaign_id": "CNTQ0OD",
"message": "Request to import campaign was received and is being processed."
}

0 comments on commit 7ca18df

Please sign in to comment.