Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit 1193cb6

Browse files
authored
Merge pull request #178 from notificationapi-com/QLhfO3eF/3194-java-sdk-docs
docs(sdk): Add Java SDK documentation
2 parents 82c68d4 + 9b869a6 commit 1193cb6

File tree

3 files changed

+259
-1
lines changed

3 files changed

+259
-1
lines changed

docs/intro.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Intercom('show');
4040
<SupportedEnvironment logo="devicon-php-plain" name="PHP" path="./reference/server" />
4141
<SupportedEnvironment logo="devicon-go-original-wordmark" name="Go" path="./reference/server" />
4242
<SupportedEnvironment logo="devicon-csharp-plain" name="C#" path="./reference/server" />
43+
<SupportedEnvironment logo="devicon-java-plain" name="Java" path="./reference/server" />
4344
<SupportedEnvironment logo="devicon-ruby-plain" name="Ruby" path="./reference/server" />
4445
</div>
4546

docs/quick-start/send-a-notification.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ values={[
3131
{ label: 'PHP', value: 'php' },
3232
{ label: 'Go', value: 'go' },
3333
{ label: 'C#', value: 'csharp' },
34+
{ label: 'Java', value: 'java' },
3435
{ label: 'Ruby', value: 'ruby' }
3536
]}>
3637
<TabItem value="js">
@@ -79,6 +80,34 @@ Install the package:
7980
dotnet add package NotificationAPI --version 0.5.0
8081
```
8182

83+
</TabItem>
84+
<TabItem value="java">
85+
86+
Add the following dependency to your Maven project:
87+
88+
```xml
89+
<dependency>
90+
<groupId>com.notificationapi</groupId>
91+
<artifactId>notificationapi-java-server-sdk</artifactId>
92+
<version>0.2.0</version>
93+
</dependency>
94+
```
95+
96+
For optimal functionality, you'll also need the following dependencies:
97+
98+
```xml
99+
<dependency>
100+
<groupId>org.apache.httpcomponents</groupId>
101+
<artifactId>httpclient</artifactId>
102+
<version>4.5.14</version>
103+
</dependency>
104+
<dependency>
105+
<groupId>com.fasterxml.jackson.core</groupId>
106+
<artifactId>jackson-databind</artifactId>
107+
<version>2.15.2</version>
108+
</dependency>
109+
```
110+
82111
</TabItem>
83112
<TabItem value="ruby">
84113

@@ -194,6 +223,7 @@ values={[
194223
{ label: 'PHP', value: 'php' },
195224
{ label: 'Go', value: 'go' },
196225
{ label: 'C#', value: 'csharp' },
226+
{ label: 'Java', value: 'java' },
197227
{ label: 'Ruby', value: 'ruby' }
198228
]
199229
}>
@@ -369,6 +399,40 @@ await notificationApi.Send(new SendNotificationData("order_tracking", user)
369399
});
370400
```
371401

402+
</TabItem>
403+
<TabItem value="java">
404+
405+
```java
406+
// import
407+
import com.notificationapi.NotificationApi;
408+
import com.notificationapi.model.NotificationRequest;
409+
import com.notificationapi.model.User;
410+
import java.util.HashMap;
411+
import java.util.Map;
412+
413+
// Initialize NotificationAPI (default US region)
414+
// If in the CA region, use the third parameter: "https://api.ca.notificationapi.com"
415+
// If in the EU region, use the third parameter: "https://api.eu.notificationapi.com"
416+
NotificationApi api = new NotificationApi("CLIENT_ID", "CLIENT_SECRET", "https://api.notificationapi.com");
417+
418+
// Create user
419+
User user = new User("spongebob.squarepants")
420+
.setEmail("[email protected]") // required for email notifications
421+
.setNumber("+15005550006"); // optional phone number required to send SMS notifications
422+
423+
// Create merge tags
424+
Map<String, Object> mergeTags = new HashMap<>();
425+
mergeTags.put("item", "Krabby Patty Burger");
426+
mergeTags.put("address", "124 Conch Street");
427+
mergeTags.put("orderId", "1234567890");
428+
429+
// Create and send notification request
430+
NotificationRequest request = new NotificationRequest("order_tracking", user)
431+
.setMergeTags(mergeTags);
432+
433+
String response = api.send(request);
434+
```
435+
372436
</TabItem>
373437
<TabItem value="ruby">
374438

0 commit comments

Comments
 (0)