Skip to content

Commit

Permalink
Merge pull request #293 from plivo/SMS-7359
Browse files Browse the repository at this point in the history
SMS-7359 : Adding paramater_name to Java SDK
  • Loading branch information
Vishnukumarpg authored Feb 25, 2025
2 parents 853a189 + 8148d0a commit 9128eb1
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 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.5](https://github.com/plivo/plivo-java/tree/v5.45.5) (2025-02-25)
**Enhancement - Supporting parameter_name in WhatsApp Template .**
- Supporting parameter_name in WhatsApp Template .

## [5.45.4](https://github.com/plivo/plivo-java/tree/v5.45.4)(2025-02-18)
**Feature - Throw GeoPermissionException on synchronous geopermissions error**

Expand Down
42 changes: 39 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.45.4/plivo-java-5.45.4.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.5/plivo-java-5.45.5.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.45.4</version>
<version>5.45.5</version>
</dependency>
```

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

### To Install Beta release
Expand Down Expand Up @@ -569,6 +569,42 @@ class Test
}
```

#### Templated WhatsApp Messages With Named Parameter
This guide shows how to send templated WhatsApp messages with named parameters.

Example:
```java
import java.io.IOException;
import java.net.URL;
import java.util.Collections;

import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.message.Message;
import com.plivo.api.models.message.MessageCreateResponse;
import com.plivo.api.models.message.MessageType;
import com.fasterxml.jackson.databind.ObjectMapper;

class Test
{
public static void main(String [] args)
{
Plivo.init("<auth_id>", "<auth_token>");
try {
String templateJson = "{\"name\":\"template_name\",\"language\":\"en_US\",\"components\":[{\"type\":\"header\",\"parameters\":[{\"type\":\"text\",\"parameter_name\":\"header_title\",\"text\":\"WA-header\"}]},{\"type\":\"body\",\"parameters\":[{\"type\":\"text\",\"parameter_name\":\"user_name\",\"text\":\"Saurabh\"}]}]}";

MessageCreateResponse response = Message.creator("+14156667778","+14156667777").type(MessageType.WHATSAPP).template_json_string(templateJson).create();
ObjectMapper ow = new ObjectMapper();
String json_output = ow.writeValueAsString(response);
System.out.println(json_output);
}
catch (PlivoRestException | IOException e) {
e.printStackTrace();
}
}
}
```

### More examples
More examples are available [here](https://github.com/plivo/plivo-examples-java). Also refer to the [guides for configuring the Java Spring to run various scenarios](https://plivo.com/docs/sms/quickstart/java-spring/) & use it to test out your integration in under 5 minutes.

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.45.4
version=5.45.5
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.45.4</version>
<version>5.45.5</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
9 changes: 9 additions & 0 deletions src/main/java/com/plivo/api/models/message/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public class Parameter {
private Currency currency;
private DateTime date_time;
private Location location;
private String parameter_name;


public Parameter() {
}

Expand Down Expand Up @@ -71,4 +73,11 @@ public void setLocation(Location location) {
this.location = location;
}

public String getParameter_name() {
return parameter_name;
}

public void setParameter_name(String parameter_name) {
this.parameter_name = parameter_name;
}
}
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.45.4
5.45.5

0 comments on commit 9128eb1

Please sign in to comment.