Skip to content

Commit

Permalink
Update to version 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
infobip-ci committed Mar 19, 2024
1 parent 3ef77a0 commit d60f1be
Show file tree
Hide file tree
Showing 161 changed files with 9,177 additions and 4,259 deletions.
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,54 @@ 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.

## [ [4.3.0](https://github.com/infobip/infobip-api-java-client/releases/tag/4.3.0) ] - 2024-03-19

⚠️ **IMPORTANT NOTE:** This release contains compile time breaking changes.
All changes, including breaking changes, are addressed and explained in the list bellow.
If you find out that something was not addressed properly, please submit an issue.

### Added
* Support for [Infobip Messages API](https://www.infobip.com/docs/api/channels/voice/routing).
* Most recent feature set for:
* [Infobip Call Routing API](https://www.infobip.com/docs/api/channels/voice/routing)
* [Infobip Call Link API](https://www.infobip.com/docs/api/channels/webrtc-calls/call-link)
* [Infobip Email API](https://www.infobip.com/docs/api/channels/email)
* [Infobip MMS API](https://www.infobip.com/docs/api/channels/mms)
* [Infobip Voice API](https://www.infobip.com/docs/api/channels/voice)
* [Infobip WebRTC API](https://www.infobip.com/docs/api/channels/webrtc)
* [Infobip Viber API](https://www.infobip.com/docs/api/channels/viber)
* [Infobip WhatsApp API](https://www.infobip.com/docs/api/channels/whatsapp)

### Changed
* **Removed classes and unified structures**
* Removed basic url security configuration classes (`CallsBasicUrlSecurityConfig`, `CallRoutingBasicUrlSecurityConfig`) in favor of a unified class: [BasicSecurityConfig](src/main/java/com/infobip/model/BasicSecurityConfig.java)
* Removed hmac algorithm class (`CallsHmacAlgorithm`) in favor of a unified class: [HmacAlgorithm](src/main/java/com/infobip/model/HmacAlgorithm.java)
* Removed hmac url security configuration classes (`CallRoutingHmacUrlSecurityConfig`, `CallsHmacUrlSecurityConfig`) in favor of a unified class: [HmacSecurityConfig](src/main/java/com/infobip/model/HmacSecurityConfig.java)
* Removed url security configuration classes (`CallRoutingUrlSecurityConfig`, `CallsUrlSecurityConfig`) in favor of a unified class: [SecurityConfig](src/main/java/com/infobip/model/SecurityConfig.java)
* **Fixes and changes**
* Changed [CallRoutingRecording](src/main/java/com/infobip/model/CallRoutingRecording.java) model, previously nested enum 'RecordingTypeEnum' is now extracted to a separate class: [CallRoutingRecordingType](src/main/java/com/infobip/model/RecordingTypeEnum.java).
* Changed 'endpoint' field type in [CallsBulkCall](src/main/java/com/infobip/model/CallsBulkCall.java) from CallEndpoint to CallsBulkEndpoint since it didn't correspond to the state of the endpoint.
* Changed 'endpoint' field type in [CallsBulkCallRequest](src/main/java/com/infobip/model/CallsBulkCallRequest.java) from CallEndpoint to CallsBulkEndpoint since it didn't correspond to the state of the endpoint.
* Fixed some of the enum values in [TfaLanguage](src/main/java/com/infobip/model/TfaLanguage.java) since they didn't correspond to the state of the endpoint.
* Removed 'record' field in [CallsClickToCallMessage](src/main/java/com/infobip/model/CallsClickToCallMessage.java) since it is not supported on the API side.
* Removed 'values' field in [ViberOutboundFileContent](src/main/java/com/infobip/model/ViberOutboundFileContent.java) since it is not supported on the API side.
* Removed 'values' field in [ViberOutboundImageContent](src/main/java/com/infobip/model/ViberOutboundImageContent.java) since it is not supported on the API side.
* Removed 'values' field in [ViberOutboundVideoContent](src/main/java/com/infobip/model/ViberOutboundVideoContent.java) since it is not supported on the API side.
* Changed 'reports' field name in [ViberWebhookReportResponse](src/main/java/com/infobip/model/ViberWebhookReportsResponse.java) to 'results'.
* Changed 'callbackData' field type in [ViberWebhooks](src/main/java/com/infobip/model/ViberWebhooks.java) from Object to String since it didn't correspond to the state of the endpoint.
* Changed [WhatsAppTemplateApiResponse](src/main/java/com/infobip/model/WhatsAppTemplateApiResponse.java) by making it an abstract class, serving as a base for WhatsAppAuthenticationTemplateApiResponse, WhatsAppDefaultMarketingTemplateApiResponse, WhatsAppDefaultUtilityTemplateApiResponse.
* Changed 'results' field in [WhatsAppWebhookInboundContactMessage](src/main/java/com/infobip/model/WhatsAppWebhookInboundContactMessage.java) to be initialized to an empty list rather than null.
* Changed 'results' field in [WhatsAppWebhookInboundMessageResult](src/main/java/com/infobip/model/WhatsAppWebhookInboundMessageResult.java) to be initialized to an empty list rather than null.
* Removed 'contact' field in [WhatsAppWebhookInboundMessageData](src/main/java/com/infobip/model/WhatsAppWebhookInboundMessageData.java) since it didn't correspond to the state of the endpoint.
* Changed [WhatsAppWebhookReferral](src/main/java/com/infobip/model/WhatsAppWebhookReferral.java) model, previously nested enum 'SourceTypeEnum' is now extracted to a separate class: [WhatsAppWebhookReferralSourceType](src/main/java/com/infobip/model/WhatsAppWebhookReferralSourceType.java).
* Changed [WhatsAppWebhookReferralMedia](src/main/java/com/infobip/model/WhatsAppWebhookReferralMedia.java) by making it an abstract class, serving as a base for WhatsAppWebhookReferralMediaImage, WhatsAppWebhookReferralMediaVideo.
* **Documentation**
* Fixed Javadoc.

### Removed
- Models for Receive WhatsApp Deleted Reports webhook since it is no longer part of Infobip's product stack.
- Unused model classes

## ~~[ [4.2.0](https://github.com/infobip/infobip-api-java-client/releases/tag/4.2.0) ] - 2024-03-07~~

⚠️ **IMPORTANT NOTE:** This release contains changes that are not compatible with Infobip HTTP API. Therefore, it is considered broken. We strongly advise to avoid using it. We are working on a new version. In the meantime, please use 4.1.2.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The current version of this library includes this subset of Infobip products:
* [Email](https://www.infobip.com/docs/api/channels/email)
* [WhatsApp](https://www.infobip.com/docs/api/channels/whatsapp)
* [Viber](https://www.infobip.com/docs/api/channels/viber)
* [Messages API](https://www.infobip.com/docs/api/platform/messages-api)

## General Info
For `infobip-api-java-client` versioning we use [Semantic Versioning][semver] scheme.
Expand All @@ -46,7 +47,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>4.2.0</version>
<version>4.3.0</version>
</dependency>
```

Expand Down Expand Up @@ -200,6 +201,9 @@ For Email quick start guide, view [these examples](email.md).
#### WhatsApp
For WhatsApp quick start guide, view [these examples](whatsapp.md).

#### Messages API
For Messages API quick start guide, view [these examples](messages-api.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
137 changes: 137 additions & 0 deletions messages-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Messages API quickstart

This quick guide aims to help you start with [Infobip Messages API](https://www.infobip.com/docs/api/platform/messages-api/sending-message/send-messages-api-message). After reading it, you should know how to use Messages API, send various types of messages, receive incoming messages, and receive delivery reports.

Messages API supports 11 different channels: SMS, MMS, RCS, WhatsApp, Viber Business Messages, Viber Bots, Apple Messages for Business, Google Business Messages, Instagram Direct Messages, Messenger, and LINE Official Notification.

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();
````

With that ready, you can now create an instance of `MessagesApi` which allows you to send messages using Messages API.

````java
MessagesApi messagesApi = new MessagesApi(apiClient);
````

## Activate your test senders

Before sending a message using Messages API, you need to activate your sender(s) and connect to our test domain.

Here you can find the example on how to activate and use **WhatsApp and SMS channels**.

To activate the WhatsApp test sender, add the **447860099299** Infobip sender to your WhatsApp contacts and send a message containing your Infobip account username.

To use the SMS test sender, simply send a message by using **InfoSMS** sender.

You are now ready to send your first message.

**IMPORTANT NOTE:** Keep in mind that for test purposes you can only send messages to a number you registered when you created your Infobip account.

## Send your first message

The easiest way to start with Messages API is to send a text message. First you need to prepare the message you want to send, like on snippet below:

````java
MessagesApiMessage messagesApiMessage = new MessagesApiMessage()
.channel(MessagesApiOutboundMessageChannel.SMS)
.sender("48123234567")
.destinations(
List.of(
new MessagesApiToDestination()
.to("447491163443")
)
)
.content(
new MessagesApiMessageContent()
.body(
new MessagesApiMessageTextBody()
.text("Sent using Infobip's Java client library!")
)
);

MessagesApiRequest messagesApiRequest = new MessagesApiRequest()
.addMessagesItem(messagesApiMessage);
````

Send the message invoking the appropriate send method and store the results in a new variable.

````java
MessagesApiResponse messageInfo = null;
try {
messageInfo = messagesApi
.sendMessagesApiMessage(messagesApiRequest)
.execute();
} catch (ApiException apiException) {
// HANDLE THE EXCEPTION
}

````

Once the invocation finishes, you can inspect the results and print a status description, as shown below.

````java
System.out.println(messageInfo.getMessages().get(0).getStatus().getDescription());
````

## How to receive messages

To receive messages using Messages API you must set up the webhook.

Basically, that is just an endpoint implemented on your side where you will accept the requests when a new message arrives. That endpoint will be called by the Infobip API whenever we receive an incoming message for your registered sender(s).

```java
@PostMapping("/incoming-messages")
public void receiveMessages(HttpServletRequest request) throws IOException {
MessagesApiIncomingMessage messages = new JSON().deserialize(request.inputStream(), MessagesApiIncomingMessage.class);
for (MessagesApiInboundEvent messageData : messages.getResults()) {
switch (messageData.getEvent()) {
case MO:
MessagesApiWebhookEvent messagesApiWebhookEvent = ((MessagesApiWebhookEvent) messageData);
// INSERT YOUR PROCESSING LOGIC HERE
break;
case TYPING_STARTED:
MessagesApiInboundTypingStartedEvent messagesApiInboundTypingStartedEvent = ((MessagesApiInboundTypingStartedEvent) messageData);
// INSERT YOUR PROCESSING LOGIC HERE
break;
case TYPING_STOPPED:
MessagesApiInboundTypingStoppedEvent messagesApiInboundTypingStoppedEvent = ((MessagesApiInboundTypingStoppedEvent) messageData);
// INSERT YOUR PROCESSING LOGIC HERE
break;
default:
throw new IllegalArgumentException("Unexpected message type!");
break;
}
}
}
```

You can find more details about the structure of the message you can expect on your endpoint on [docs page](https://www.infobip.com/docs/api/platform/messages-api/incoming-message/receive-messages-api-incoming-messages).

## How to receive delivery reports

For each message that you send out, you can get a message delivery report in real time. Subscribe for reports by contacting our support team at <[email protected]>. e.g. `https://{yourDomain}/delivery-reports`

```java
@PostMapping("/delivery-reports")
public void receiveDeliveryReports(HttpServletRequest request) throws IOException {
MessagesApiDeliveryReport reports = new JSON().deserialize(request.getInputStream(), MessagesApiDeliveryReport.class);
for (MessagesApiDeliveryResult result : reports.getResults()) {
System.out.println(result.getMessageId() + " - " + result.getStatus().getName());
}
}
```

## Use adaptationMode to automatically modify message types

Enhance your Messages API requests by using the `adaptationMode` parameter. It allows you to send messages even if they are unsupported by the channel.

When you set adaptationMode to `true,` Messages API automatically adjusts the message to remove any unsupported elements, ensuring successful delivery.

For instance, if you'd like to include an image in your WhatsApp and SMS messages, set adaptationMode to 'true'. Messages API will handle the delivery for WhatsApp as a message containing an image, while for SMS will provide a link to the image.

On the other hand, if you set adaptationMode to 'false' and try to send a message with an unsupported element to a channel, an error will occur. Make sure to choose the right setting based on your specific channel and content requirements.
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>4.2.0</version>
<version>4.3.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/4.2.0";
private static final String USER_AGENT_HEADER_VALUE = "infobip-api-client-java/4.3.0";

private final ApiKey apiKey;
private final BaseUrl baseUrl;
Expand Down
28 changes: 11 additions & 17 deletions src/main/java/com/infobip/api/MessagesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.infobip.RequestDefinition;
import com.infobip.model.MessagesApiEventRequest;
import com.infobip.model.MessagesApiRequest;
import com.infobip.model.ResponseEnvelopeMessageResponseMessageResponseDetails;
import com.infobip.model.MessagesApiResponse;
import java.util.Objects;

/**
Expand Down Expand Up @@ -60,15 +60,14 @@ private SendMessagesApiEventsRequest(MessagesApiEventRequest messagesApiEventReq
/**
* Executes the sendMessagesApiEvents request.
*
* @return ResponseEnvelopeMessageResponseMessageResponseDetails The deserialized response.
* @return MessagesApiResponse The deserialized response.
* @throws ApiException If the API call fails or an error occurs during the request or response processing.
*/
public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws ApiException {
public MessagesApiResponse execute() throws ApiException {
RequestDefinition sendMessagesApiEventsDefinition =
sendMessagesApiEventsDefinition(messagesApiEventRequest);
return apiClient.execute(
sendMessagesApiEventsDefinition,
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType());
sendMessagesApiEventsDefinition, new TypeReference<MessagesApiResponse>() {}.getType());
}

/**
Expand All @@ -77,13 +76,11 @@ public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws Ap
* @param callback The {@link ApiCallback} to be invoked.
* @return The {@link okhttp3.Call} associated with the API request.
*/
public okhttp3.Call executeAsync(ApiCallback<ResponseEnvelopeMessageResponseMessageResponseDetails> callback) {
public okhttp3.Call executeAsync(ApiCallback<MessagesApiResponse> callback) {
RequestDefinition sendMessagesApiEventsDefinition =
sendMessagesApiEventsDefinition(messagesApiEventRequest);
return apiClient.executeAsync(
sendMessagesApiEventsDefinition,
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType(),
callback);
sendMessagesApiEventsDefinition, new TypeReference<MessagesApiResponse>() {}.getType(), callback);
}
}

Expand Down Expand Up @@ -125,14 +122,13 @@ private SendMessagesApiMessageRequest(MessagesApiRequest messagesApiRequest) {
/**
* Executes the sendMessagesApiMessage request.
*
* @return ResponseEnvelopeMessageResponseMessageResponseDetails The deserialized response.
* @return MessagesApiResponse The deserialized response.
* @throws ApiException If the API call fails or an error occurs during the request or response processing.
*/
public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws ApiException {
public MessagesApiResponse execute() throws ApiException {
RequestDefinition sendMessagesApiMessageDefinition = sendMessagesApiMessageDefinition(messagesApiRequest);
return apiClient.execute(
sendMessagesApiMessageDefinition,
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType());
sendMessagesApiMessageDefinition, new TypeReference<MessagesApiResponse>() {}.getType());
}

/**
Expand All @@ -141,12 +137,10 @@ public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws Ap
* @param callback The {@link ApiCallback} to be invoked.
* @return The {@link okhttp3.Call} associated with the API request.
*/
public okhttp3.Call executeAsync(ApiCallback<ResponseEnvelopeMessageResponseMessageResponseDetails> callback) {
public okhttp3.Call executeAsync(ApiCallback<MessagesApiResponse> callback) {
RequestDefinition sendMessagesApiMessageDefinition = sendMessagesApiMessageDefinition(messagesApiRequest);
return apiClient.executeAsync(
sendMessagesApiMessageDefinition,
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType(),
callback);
sendMessagesApiMessageDefinition, new TypeReference<MessagesApiResponse>() {}.getType(), callback);
}
}

Expand Down
Loading

0 comments on commit d60f1be

Please sign in to comment.