Skip to content

Commit d60f1be

Browse files
author
infobip-ci
committed
Update to version 4.3.0
1 parent 3ef77a0 commit d60f1be

File tree

161 files changed

+9177
-4259
lines changed

Some content is hidden

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

161 files changed

+9177
-4259
lines changed

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,54 @@ 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+
## [ [4.3.0](https://github.com/infobip/infobip-api-java-client/releases/tag/4.3.0) ] - 2024-03-19
9+
10+
⚠️ **IMPORTANT NOTE:** This release contains compile time breaking changes.
11+
All changes, including breaking changes, are addressed and explained in the list bellow.
12+
If you find out that something was not addressed properly, please submit an issue.
13+
14+
### Added
15+
* Support for [Infobip Messages API](https://www.infobip.com/docs/api/channels/voice/routing).
16+
* Most recent feature set for:
17+
* [Infobip Call Routing API](https://www.infobip.com/docs/api/channels/voice/routing)
18+
* [Infobip Call Link API](https://www.infobip.com/docs/api/channels/webrtc-calls/call-link)
19+
* [Infobip Email API](https://www.infobip.com/docs/api/channels/email)
20+
* [Infobip MMS API](https://www.infobip.com/docs/api/channels/mms)
21+
* [Infobip Voice API](https://www.infobip.com/docs/api/channels/voice)
22+
* [Infobip WebRTC API](https://www.infobip.com/docs/api/channels/webrtc)
23+
* [Infobip Viber API](https://www.infobip.com/docs/api/channels/viber)
24+
* [Infobip WhatsApp API](https://www.infobip.com/docs/api/channels/whatsapp)
25+
26+
### Changed
27+
* **Removed classes and unified structures**
28+
* Removed basic url security configuration classes (`CallsBasicUrlSecurityConfig`, `CallRoutingBasicUrlSecurityConfig`) in favor of a unified class: [BasicSecurityConfig](src/main/java/com/infobip/model/BasicSecurityConfig.java)
29+
* Removed hmac algorithm class (`CallsHmacAlgorithm`) in favor of a unified class: [HmacAlgorithm](src/main/java/com/infobip/model/HmacAlgorithm.java)
30+
* Removed hmac url security configuration classes (`CallRoutingHmacUrlSecurityConfig`, `CallsHmacUrlSecurityConfig`) in favor of a unified class: [HmacSecurityConfig](src/main/java/com/infobip/model/HmacSecurityConfig.java)
31+
* Removed url security configuration classes (`CallRoutingUrlSecurityConfig`, `CallsUrlSecurityConfig`) in favor of a unified class: [SecurityConfig](src/main/java/com/infobip/model/SecurityConfig.java)
32+
* **Fixes and changes**
33+
* 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).
34+
* 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.
35+
* 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.
36+
* 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.
37+
* Removed 'record' field in [CallsClickToCallMessage](src/main/java/com/infobip/model/CallsClickToCallMessage.java) since it is not supported on the API side.
38+
* Removed 'values' field in [ViberOutboundFileContent](src/main/java/com/infobip/model/ViberOutboundFileContent.java) since it is not supported on the API side.
39+
* Removed 'values' field in [ViberOutboundImageContent](src/main/java/com/infobip/model/ViberOutboundImageContent.java) since it is not supported on the API side.
40+
* Removed 'values' field in [ViberOutboundVideoContent](src/main/java/com/infobip/model/ViberOutboundVideoContent.java) since it is not supported on the API side.
41+
* Changed 'reports' field name in [ViberWebhookReportResponse](src/main/java/com/infobip/model/ViberWebhookReportsResponse.java) to 'results'.
42+
* 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.
43+
* Changed [WhatsAppTemplateApiResponse](src/main/java/com/infobip/model/WhatsAppTemplateApiResponse.java) by making it an abstract class, serving as a base for WhatsAppAuthenticationTemplateApiResponse, WhatsAppDefaultMarketingTemplateApiResponse, WhatsAppDefaultUtilityTemplateApiResponse.
44+
* Changed 'results' field in [WhatsAppWebhookInboundContactMessage](src/main/java/com/infobip/model/WhatsAppWebhookInboundContactMessage.java) to be initialized to an empty list rather than null.
45+
* Changed 'results' field in [WhatsAppWebhookInboundMessageResult](src/main/java/com/infobip/model/WhatsAppWebhookInboundMessageResult.java) to be initialized to an empty list rather than null.
46+
* Removed 'contact' field in [WhatsAppWebhookInboundMessageData](src/main/java/com/infobip/model/WhatsAppWebhookInboundMessageData.java) since it didn't correspond to the state of the endpoint.
47+
* 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).
48+
* Changed [WhatsAppWebhookReferralMedia](src/main/java/com/infobip/model/WhatsAppWebhookReferralMedia.java) by making it an abstract class, serving as a base for WhatsAppWebhookReferralMediaImage, WhatsAppWebhookReferralMediaVideo.
49+
* **Documentation**
50+
* Fixed Javadoc.
51+
52+
### Removed
53+
- Models for Receive WhatsApp Deleted Reports webhook since it is no longer part of Infobip's product stack.
54+
- Unused model classes
55+
856
## ~~[ [4.2.0](https://github.com/infobip/infobip-api-java-client/releases/tag/4.2.0) ] - 2024-03-07~~
957

1058
⚠️ **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.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The current version of this library includes this subset of Infobip products:
3030
* [Email](https://www.infobip.com/docs/api/channels/email)
3131
* [WhatsApp](https://www.infobip.com/docs/api/channels/whatsapp)
3232
* [Viber](https://www.infobip.com/docs/api/channels/viber)
33+
* [Messages API](https://www.infobip.com/docs/api/platform/messages-api)
3334

3435
## General Info
3536
For `infobip-api-java-client` versioning we use [Semantic Versioning][semver] scheme.
@@ -46,7 +47,7 @@ Simply add the following in your project's POM file under `dependencies` tag:
4647
<dependency>
4748
<groupId>com.infobip</groupId>
4849
<artifactId>infobip-api-java-client</artifactId>
49-
<version>4.2.0</version>
50+
<version>4.3.0</version>
5051
</dependency>
5152
```
5253

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

204+
#### Messages API
205+
For Messages API quick start guide, view [these examples](messages-api.md).
206+
203207
## Ask for help
204208

205209
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.

messages-api.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Messages API quickstart
2+
3+
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.
4+
5+
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.
6+
7+
The first step is to create an `ApiClient` instance with some configuration.
8+
9+
````java
10+
ApiClient apiClient = ApiClient.forApiKey(ApiKey.from(API_KEY))
11+
.withBaseUrl(BaseUrl.from(BASE_URL))
12+
.build();
13+
````
14+
15+
With that ready, you can now create an instance of `MessagesApi` which allows you to send messages using Messages API.
16+
17+
````java
18+
MessagesApi messagesApi = new MessagesApi(apiClient);
19+
````
20+
21+
## Activate your test senders
22+
23+
Before sending a message using Messages API, you need to activate your sender(s) and connect to our test domain.
24+
25+
Here you can find the example on how to activate and use **WhatsApp and SMS channels**.
26+
27+
To activate the WhatsApp test sender, add the **447860099299** Infobip sender to your WhatsApp contacts and send a message containing your Infobip account username.
28+
29+
To use the SMS test sender, simply send a message by using **InfoSMS** sender.
30+
31+
You are now ready to send your first message.
32+
33+
**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.
34+
35+
## Send your first message
36+
37+
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:
38+
39+
````java
40+
MessagesApiMessage messagesApiMessage = new MessagesApiMessage()
41+
.channel(MessagesApiOutboundMessageChannel.SMS)
42+
.sender("48123234567")
43+
.destinations(
44+
List.of(
45+
new MessagesApiToDestination()
46+
.to("447491163443")
47+
)
48+
)
49+
.content(
50+
new MessagesApiMessageContent()
51+
.body(
52+
new MessagesApiMessageTextBody()
53+
.text("Sent using Infobip's Java client library!")
54+
)
55+
);
56+
57+
MessagesApiRequest messagesApiRequest = new MessagesApiRequest()
58+
.addMessagesItem(messagesApiMessage);
59+
````
60+
61+
Send the message invoking the appropriate send method and store the results in a new variable.
62+
63+
````java
64+
MessagesApiResponse messageInfo = null;
65+
try {
66+
messageInfo = messagesApi
67+
.sendMessagesApiMessage(messagesApiRequest)
68+
.execute();
69+
} catch (ApiException apiException) {
70+
// HANDLE THE EXCEPTION
71+
}
72+
73+
````
74+
75+
Once the invocation finishes, you can inspect the results and print a status description, as shown below.
76+
77+
````java
78+
System.out.println(messageInfo.getMessages().get(0).getStatus().getDescription());
79+
````
80+
81+
## How to receive messages
82+
83+
To receive messages using Messages API you must set up the webhook.
84+
85+
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).
86+
87+
```java
88+
@PostMapping("/incoming-messages")
89+
public void receiveMessages(HttpServletRequest request) throws IOException {
90+
MessagesApiIncomingMessage messages = new JSON().deserialize(request.inputStream(), MessagesApiIncomingMessage.class);
91+
for (MessagesApiInboundEvent messageData : messages.getResults()) {
92+
switch (messageData.getEvent()) {
93+
case MO:
94+
MessagesApiWebhookEvent messagesApiWebhookEvent = ((MessagesApiWebhookEvent) messageData);
95+
// INSERT YOUR PROCESSING LOGIC HERE
96+
break;
97+
case TYPING_STARTED:
98+
MessagesApiInboundTypingStartedEvent messagesApiInboundTypingStartedEvent = ((MessagesApiInboundTypingStartedEvent) messageData);
99+
// INSERT YOUR PROCESSING LOGIC HERE
100+
break;
101+
case TYPING_STOPPED:
102+
MessagesApiInboundTypingStoppedEvent messagesApiInboundTypingStoppedEvent = ((MessagesApiInboundTypingStoppedEvent) messageData);
103+
// INSERT YOUR PROCESSING LOGIC HERE
104+
break;
105+
default:
106+
throw new IllegalArgumentException("Unexpected message type!");
107+
break;
108+
}
109+
}
110+
}
111+
```
112+
113+
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).
114+
115+
## How to receive delivery reports
116+
117+
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`
118+
119+
```java
120+
@PostMapping("/delivery-reports")
121+
public void receiveDeliveryReports(HttpServletRequest request) throws IOException {
122+
MessagesApiDeliveryReport reports = new JSON().deserialize(request.getInputStream(), MessagesApiDeliveryReport.class);
123+
for (MessagesApiDeliveryResult result : reports.getResults()) {
124+
System.out.println(result.getMessageId() + " - " + result.getStatus().getName());
125+
}
126+
}
127+
```
128+
129+
## Use adaptationMode to automatically modify message types
130+
131+
Enhance your Messages API requests by using the `adaptationMode` parameter. It allows you to send messages even if they are unsupported by the channel.
132+
133+
When you set adaptationMode to `true,` Messages API automatically adjusts the message to remove any unsupported elements, ensuring successful delivery.
134+
135+
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.
136+
137+
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.

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>4.2.0</version>
7+
<version>4.3.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/4.2.0";
29+
private static final String USER_AGENT_HEADER_VALUE = "infobip-api-client-java/4.3.0";
3030

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

src/main/java/com/infobip/api/MessagesApi.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.infobip.RequestDefinition;
1818
import com.infobip.model.MessagesApiEventRequest;
1919
import com.infobip.model.MessagesApiRequest;
20-
import com.infobip.model.ResponseEnvelopeMessageResponseMessageResponseDetails;
20+
import com.infobip.model.MessagesApiResponse;
2121
import java.util.Objects;
2222

2323
/**
@@ -60,15 +60,14 @@ private SendMessagesApiEventsRequest(MessagesApiEventRequest messagesApiEventReq
6060
/**
6161
* Executes the sendMessagesApiEvents request.
6262
*
63-
* @return ResponseEnvelopeMessageResponseMessageResponseDetails The deserialized response.
63+
* @return MessagesApiResponse The deserialized response.
6464
* @throws ApiException If the API call fails or an error occurs during the request or response processing.
6565
*/
66-
public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws ApiException {
66+
public MessagesApiResponse execute() throws ApiException {
6767
RequestDefinition sendMessagesApiEventsDefinition =
6868
sendMessagesApiEventsDefinition(messagesApiEventRequest);
6969
return apiClient.execute(
70-
sendMessagesApiEventsDefinition,
71-
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType());
70+
sendMessagesApiEventsDefinition, new TypeReference<MessagesApiResponse>() {}.getType());
7271
}
7372

7473
/**
@@ -77,13 +76,11 @@ public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws Ap
7776
* @param callback The {@link ApiCallback} to be invoked.
7877
* @return The {@link okhttp3.Call} associated with the API request.
7978
*/
80-
public okhttp3.Call executeAsync(ApiCallback<ResponseEnvelopeMessageResponseMessageResponseDetails> callback) {
79+
public okhttp3.Call executeAsync(ApiCallback<MessagesApiResponse> callback) {
8180
RequestDefinition sendMessagesApiEventsDefinition =
8281
sendMessagesApiEventsDefinition(messagesApiEventRequest);
8382
return apiClient.executeAsync(
84-
sendMessagesApiEventsDefinition,
85-
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType(),
86-
callback);
83+
sendMessagesApiEventsDefinition, new TypeReference<MessagesApiResponse>() {}.getType(), callback);
8784
}
8885
}
8986

@@ -125,14 +122,13 @@ private SendMessagesApiMessageRequest(MessagesApiRequest messagesApiRequest) {
125122
/**
126123
* Executes the sendMessagesApiMessage request.
127124
*
128-
* @return ResponseEnvelopeMessageResponseMessageResponseDetails The deserialized response.
125+
* @return MessagesApiResponse The deserialized response.
129126
* @throws ApiException If the API call fails or an error occurs during the request or response processing.
130127
*/
131-
public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws ApiException {
128+
public MessagesApiResponse execute() throws ApiException {
132129
RequestDefinition sendMessagesApiMessageDefinition = sendMessagesApiMessageDefinition(messagesApiRequest);
133130
return apiClient.execute(
134-
sendMessagesApiMessageDefinition,
135-
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType());
131+
sendMessagesApiMessageDefinition, new TypeReference<MessagesApiResponse>() {}.getType());
136132
}
137133

138134
/**
@@ -141,12 +137,10 @@ public ResponseEnvelopeMessageResponseMessageResponseDetails execute() throws Ap
141137
* @param callback The {@link ApiCallback} to be invoked.
142138
* @return The {@link okhttp3.Call} associated with the API request.
143139
*/
144-
public okhttp3.Call executeAsync(ApiCallback<ResponseEnvelopeMessageResponseMessageResponseDetails> callback) {
140+
public okhttp3.Call executeAsync(ApiCallback<MessagesApiResponse> callback) {
145141
RequestDefinition sendMessagesApiMessageDefinition = sendMessagesApiMessageDefinition(messagesApiRequest);
146142
return apiClient.executeAsync(
147-
sendMessagesApiMessageDefinition,
148-
new TypeReference<ResponseEnvelopeMessageResponseMessageResponseDetails>() {}.getType(),
149-
callback);
143+
sendMessagesApiMessageDefinition, new TypeReference<MessagesApiResponse>() {}.getType(), callback);
150144
}
151145
}
152146

0 commit comments

Comments
 (0)