Skip to content

Commit

Permalink
updated examples, adjusted SmsApiTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ib-tjuhasz committed Dec 6, 2024
1 parent c5950f2 commit d48a34c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Example of webhook implementation with Spring Web framework:
@PostMapping("/delivery-reports")
public void receiveDeliveryReports(HttpServletRequest request) throws IOException {
SmsDeliveryResult reports = new JSON().deserialize(request.getInputStream(), SmsDeliveryResult.class);
for (SmsReport report : reports.getResults()) {
for (SmsDeliveryReport report : reports.getResults()) {
System.out.println(report.getMessageId() + " - " + report.getStatus().getName());
}
}
Expand Down
2 changes: 2 additions & 0 deletions email.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ You can use data models from the library and the pre-configured `com.infobip.JSO
Additionally, you can use a `messageId` or a `bulkId` autogenerated in a response for troubleshooting and to fetch reports.

```java
String bulkId = "BULK-ID-123-xyz";
Integer numberOfReportsLimit = 10;

EmailReportsResult deliveryReports = emailApi
.getEmailDeliveryReports()
.bulkId(bulkId)
Expand Down
2 changes: 1 addition & 1 deletion messages-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Basically, that is just an endpoint implemented on your side where you will acce
```java
@PostMapping("/incoming-messages")
public void receiveMessages(HttpServletRequest request) throws IOException {
MessagesApiIncomingMessage messages = new JSON().deserialize(request.inputStream(), MessagesApiIncomingMessage.class);
MessagesApiIncomingMessage messages = new JSON().deserialize(request.getInputStream(), MessagesApiIncomingMessage.class);
for (MessagesApiInboundEvent messageData : messages.getResults()) {
switch (messageData.getEvent()) {
case MO:
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/com/infobip/api/SmsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ void shouldGetSmsLogs() {
String givenCurrencyMessage2 = "HRK";
var givenApplicationId = "applicationId";
var givenEntityId = "entityId";
var givenTextContent = "hello";
var givenContent = new SmsTextContent().text(givenTextContent);

String givenResponse = String.format(
"{" + " \"results\": ["
Expand Down Expand Up @@ -1014,6 +1016,9 @@ void shouldGetSmsLogs() {
+ " \"destination\": \"%s\","
+ " \"sentAt\": \"%s\","
+ " \"doneAt\": \"%s\","
+ " \"content\": {"
+ " \"text\": \"%s\""
+ " },"
+ " \"smsCount\": %d,"
+ " \"price\": {"
+ " \"pricePerMessage\": %g,"
Expand Down Expand Up @@ -1063,6 +1068,7 @@ void shouldGetSmsLogs() {
givenToMessage2,
givenSendAtMessage2,
givenDoneAtMessage2,
givenTextContent,
givenSmsCountMessage2,
givenPricePerMessageMessage2,
givenCurrencyMessage2,
Expand Down Expand Up @@ -1130,7 +1136,7 @@ void shouldGetSmsLogs() {
then(anotherLog.getSentAt()).isEqualTo(expectedSendAtMessage2);
then(anotherLog.getDoneAt()).isEqualTo(expectedDoneAtMessage2);
then(anotherLog.getSender()).isNull();
then(anotherLog.getContent()).isNull();
then(anotherLog.getContent()).isEqualTo(givenContent);
then(anotherLog.getMccMnc()).isNull();
thenPriceIsEqualTo(anotherLog.getPrice(), givenPricePerMessageMessage2, givenCurrencyMessage2);
thenStatusIsDelivered(anotherLog.getStatus());
Expand Down

0 comments on commit d48a34c

Please sign in to comment.