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

Moments support #50

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to the library will be documented in this file.
The format of the file is based on [Keep a Changelog](http://keepachangelog.com/)
and this library adheres to [Semantic Versioning](http://semver.org/) as mentioned in [README.md][readme] file.

## [ [5.1.0](https://github.com/infobip/infobip-api-java-client/releases/tag/5.1.0) ] - 2024-12-16

### Added
* Support for [Infobip Moments](https://www.infobip.com/docs/api/customer-engagement/moments).

## [ [5.0.0](https://github.com/infobip/infobip-api-java-client/releases/tag/5.0.0) ] - 2024-12-06

🎉 **NEW Major Version of `infobip-api-java-client`.**
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Simply add the following in your project's POM file under `dependencies` tag:
<dependency>
<groupId>com.infobip</groupId>
<artifactId>infobip-api-java-client</artifactId>
<version>5.0.0</version>
<version>5.1.0</version>
</dependency>
```

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

#### Moments
For Moments quick start guide, view [these examples](moments.md).

## Ask for help

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.
Expand Down
118 changes: 118 additions & 0 deletions moments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Moments quickstart

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.

The first step is to create an `ApiClient` instance with some configuration.

```java
ApiClient apiClient = ApiClient.forApiKey(ApiKey.from(API_KEY))
.withBaseUrl(BaseUrl.from(BASE_URL))
.build();
```

## Flow API

You can now create an instance of `FlowApi` which allows you to manage your flows.

````java
FlowApi flowApi = new FlowApi(apiClient);
````
### Add participants to flow

To add participants to a flow, you can use the following code:

````java
Long campaignId = 200000000000001L;

FlowAddFlowParticipantsRequest request = new FlowAddFlowParticipantsRequest()
.addParticipantsItem(new FlowParticipant()
.identifyBy(new FlowPersonUniqueField()
.identifier("[email protected]")
.type(FlowPersonUniqueFieldType.EMAIL)
)
.variables(Map.of("orderNumber", 1167873391)))
.notifyUrl("https://example.com");

flowApi.addFlowParticipants(campaignId, request)
.execute();
````

### Get a report on participants added to flow

To fetch a report to confirm that all persons have been successfully added to the flow, you can use the following code:

````java
String givenOperationId = "03f2d474-0508-46bf-9f3d-d8e2c28adaea";

flowApi.getFlowParticipantsAddedReport(campaignId, givenOperationId)
.execute();
````

### Remove person from flow

To remove a person from a flow, you can use the following code:

````java
String externalId = "8edb24b5-0319-48cd-a1d9-1e8bc5d577ab";
flowApi.removePeopleFromFlow(campaignId)
.externalId(externalId)
.execute();
````


## Forms API

You can now create an instance of `FormsApi` which allows you to manage your forms.

````java
FormsApi formsApi = new FormsApi(apiClient);
````

### Get forms

To get all forms, you can use the following code:

````java
FormsResponse formsResponse = formsApi
.getForms()
.execute();
````

### Get form by ID

To get a specific form by ID, you can use the following code:

````java
String formId = "cec5dfd2-4238-48e0-933b-9acbdb2e6f5f";

FormsResponseContent formResponse = formsApi
.getForm(formId)
.execute();
````

### Increment form view count

To increase the view counter of a specific form, you can use the following code:

````java
FormsStatusResponse status = formsApi
.incrementViewCount(formId)
.execute();
````

### Submit form data

To submit data to a specific form, you can use the following code:

````java
Map<String, Object> formDataRequest = Map.of(
"first_name", "John",
"last_name", "Doe",
"company", "Infobip",
"email", "[email protected]"
);

FormsStatusResponse status = formsApi
.submitFormData(formId, formDataRequest)
.execute();
````
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.infobip</groupId>
<artifactId>infobip-api-java-client</artifactId>
<version>5.0.0</version>
<version>5.1.0</version>
<packaging>jar</packaging>

<name>infobip-api-java-client</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/infobip/RequestFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
final class RequestFactory {

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

private final ApiKey apiKey;
private final BaseUrl baseUrl;
Expand Down
Loading
Loading