Skip to content

Commit eb638aa

Browse files
authored
Added support for Moments (FlowApi, FormsApi)
1 parent a04615b commit eb638aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+8595
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to the library will be documented in this file.
55
The format of the file is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this library adheres to [Semantic Versioning](http://semver.org/) as mentioned in [README.md][readme] file.
77

8+
## [ [5.1.0](https://github.com/infobip/infobip-api-java-client/releases/tag/5.1.0) ] - 2024-12-16
9+
10+
### Added
11+
* Support for [Infobip Moments](https://www.infobip.com/docs/api/customer-engagement/moments).
12+
13+
814
## [ [5.0.0](https://github.com/infobip/infobip-api-java-client/releases/tag/5.0.0) ] - 2024-12-06
915

1016
🎉 **NEW Major Version of `infobip-api-java-client`.**

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Simply add the following in your project's POM file under `dependencies` tag:
4848
<dependency>
4949
<groupId>com.infobip</groupId>
5050
<artifactId>infobip-api-java-client</artifactId>
51-
<version>5.0.0</version>
51+
<version>5.1.0</version>
5252
</dependency>
5353
```
5454

@@ -205,6 +205,9 @@ For WhatsApp quick start guide, view [these examples](whatsapp.md).
205205
#### Messages API
206206
For Messages API quick start guide, view [these examples](messages-api.md).
207207

208+
#### Moments
209+
For Moments quick start guide, view [these examples](moments.md).
210+
208211
## Ask for help
209212

210213
Feel free to open issues on the repository for any encountered problem or feature request. For pull requests, go to the `CONTRIBUTING` [file][contributing] related to it. This code is auto generated, and we are unable to merge any pull requests form here.

moments.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Moments quickstart
2+
3+
This quick guide aims to help you start with [Infobip Moments API](https://www.infobip.com/docs/api/customer-engagement/moments). After reading it, you should know how to use Moments.
4+
5+
The first step is to create an `ApiClient` instance with some configuration.
6+
7+
```java
8+
ApiClient apiClient = ApiClient.forApiKey(ApiKey.from(API_KEY))
9+
.withBaseUrl(BaseUrl.from(BASE_URL))
10+
.build();
11+
```
12+
13+
## Flow API
14+
15+
You can now create an instance of `FlowApi` which allows you to manage your flows.
16+
17+
````java
18+
FlowApi flowApi = new FlowApi(apiClient);
19+
````
20+
### Add participants to flow
21+
22+
To add participants to a flow, you can use the following code:
23+
24+
````java
25+
Long campaignId = 200000000000001L;
26+
27+
FlowAddFlowParticipantsRequest request = new FlowAddFlowParticipantsRequest()
28+
.addParticipantsItem(new FlowParticipant()
29+
.identifyBy(new FlowPersonUniqueField()
30+
.identifier("[email protected]")
31+
.type(FlowPersonUniqueFieldType.EMAIL)
32+
)
33+
.variables(Map.of("orderNumber", 1167873391)))
34+
.notifyUrl("https://example.com");
35+
36+
flowApi.addFlowParticipants(campaignId, request)
37+
.execute();
38+
````
39+
40+
### Get a report on participants added to flow
41+
42+
To fetch a report to confirm that all persons have been successfully added to the flow, you can use the following code:
43+
44+
````java
45+
String givenOperationId = "03f2d474-0508-46bf-9f3d-d8e2c28adaea";
46+
47+
flowApi.getFlowParticipantsAddedReport(campaignId, givenOperationId)
48+
.execute();
49+
````
50+
51+
### Remove person from flow
52+
53+
To remove a person from a flow, you can use the following code:
54+
55+
````java
56+
String externalId = "8edb24b5-0319-48cd-a1d9-1e8bc5d577ab";
57+
flowApi.removePeopleFromFlow(campaignId)
58+
.externalId(externalId)
59+
.execute();
60+
````
61+
62+
63+
## Forms API
64+
65+
You can now create an instance of `FormsApi` which allows you to manage your forms.
66+
67+
````java
68+
FormsApi formsApi = new FormsApi(apiClient);
69+
````
70+
71+
### Get forms
72+
73+
To get all forms, you can use the following code:
74+
75+
````java
76+
FormsResponse formsResponse = formsApi
77+
.getForms()
78+
.execute();
79+
````
80+
81+
### Get form by ID
82+
83+
To get a specific form by ID, you can use the following code:
84+
85+
````java
86+
String formId = "cec5dfd2-4238-48e0-933b-9acbdb2e6f5f";
87+
88+
FormsResponseContent formResponse = formsApi
89+
.getForm(formId)
90+
.execute();
91+
````
92+
93+
### Increment form view count
94+
95+
To increase the view counter of a specific form, you can use the following code:
96+
97+
````java
98+
FormsStatusResponse status = formsApi
99+
.incrementViewCount(formId)
100+
.execute();
101+
````
102+
103+
### Submit form data
104+
105+
To submit data to a specific form, you can use the following code:
106+
107+
````java
108+
Map<String, Object> formDataRequest = Map.of(
109+
"first_name", "John",
110+
"last_name", "Doe",
111+
"company", "Infobip",
112+
"email", "[email protected]"
113+
);
114+
115+
FormsStatusResponse status = formsApi
116+
.submitFormData(formId, formDataRequest)
117+
.execute();
118+
````

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.infobip</groupId>
66
<artifactId>infobip-api-java-client</artifactId>
7-
<version>5.0.0</version>
7+
<version>5.1.0</version>
88
<packaging>jar</packaging>
99

1010
<name>infobip-api-java-client</name>

src/main/java/com/infobip/RequestFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
final class RequestFactory {
2828

29-
private static final String USER_AGENT_HEADER_VALUE = "infobip-api-client-java/5.0.0";
29+
private static final String USER_AGENT_HEADER_VALUE = "infobip-api-client-java/5.1.0";
3030

3131
private final ApiKey apiKey;
3232
private final BaseUrl baseUrl;

0 commit comments

Comments
 (0)