Skip to content

Commit f47e528

Browse files
committed
Adding Infobip Rest based implementation
1 parent acd036e commit f47e528

11 files changed

+204
-1367
lines changed

build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ dependencies {
4545
compile("org.springframework.boot:spring-boot-starter-web")
4646
compile("org.springframework.boot:spring-boot-starter-actuator")
4747
compile("org.springframework.boot:spring-boot-starter-data-jpa")
48-
compile("org.hsqldb:hsqldb")
4948
compile("org.flywaydb:flyway-core")
5049
compile('org.apache.velocity:velocity:1.7')
5150
compile('com.squareup.okhttp:okhttp:2.0.0')
5251
compile('com.squareup.okhttp:okhttp-urlconnection:2.0.0')
5352
compile('com.squareup.retrofit:retrofit:1.6.1')
5453
compile('com.twilio.sdk:twilio:7.1.0')
5554
compile('org.drizzle.jdbc:drizzle-jdbc:1.3')
56-
compile('org.jsmpp:jsmpp:2.3.0')
55+
compile('com.infobip:infobip-api-java-client:1.1.0')
5756
testCompile("org.springframework.boot:spring-boot-starter-test")
5857

5958
}

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'Mifosx-Message-Gateway'
1+
rootProject.name = 'message-gateway'

src/main/java/org/fineract/messagegateway/sms/data/SmsShortMessage.java

-310
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.fineract.messagegateway.sms.providers.impl.infobip;
20+
21+
import org.fineract.messagegateway.sms.domain.SMSMessage;
22+
import org.fineract.messagegateway.sms.repository.SmsOutboundMessageRepository;
23+
import org.fineract.messagegateway.sms.util.SmsMessageStatusType;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
26+
import org.springframework.beans.factory.annotation.Autowired;
27+
import org.springframework.http.HttpStatus;
28+
import org.springframework.http.ResponseEntity;
29+
import org.springframework.web.bind.annotation.ModelAttribute;
30+
import org.springframework.web.bind.annotation.PathVariable;
31+
import org.springframework.web.bind.annotation.RequestMapping;
32+
import org.springframework.web.bind.annotation.RequestMethod;
33+
import org.springframework.web.bind.annotation.RestController;
34+
35+
import infobip.api.model.sms.mt.reports.SMSReport;
36+
import infobip.api.model.sms.mt.reports.SMSReportResponse;
37+
38+
@RestController
39+
@RequestMapping("/infobip")
40+
public class InfoBipApiResource {
41+
42+
private static final Logger logger = LoggerFactory.getLogger(InfoBipApiResource.class);
43+
44+
private final SmsOutboundMessageRepository smsOutboundMessageRepository ;
45+
46+
@Autowired
47+
public InfoBipApiResource(final SmsOutboundMessageRepository smsOutboundMessageRepository) {
48+
this.smsOutboundMessageRepository = smsOutboundMessageRepository ;
49+
}
50+
51+
@RequestMapping(value = "/report/{messageId}", method = RequestMethod.POST, consumes = {"application/json"}, produces = {"application/json"})
52+
public ResponseEntity<Void> updateDeliveryStatus(@PathVariable("messageId") final Long messageId, @ModelAttribute final SMSReportResponse payload) {
53+
SMSMessage message = this.smsOutboundMessageRepository.findOne(messageId) ;
54+
if(message != null) {
55+
SMSReport report = payload.getResults().get(0) ;
56+
logger.info("Status Callback received from InfoBip for "+messageId+" with status:"+report.getStatus());
57+
logger.info("Status Callback received from InfoBip for "+messageId+" with messageid:"+report.getMessageId());
58+
logger.info("Status Callback received from InfoBip for "+messageId+" with groupname:"+report.getStatus().getGroupName());
59+
logger.info("Status Callback received from InfoBip for "+messageId+" with name:"+report.getStatus().getName());
60+
logger.info("Status Callback received from InfoBip for "+messageId+" with groupname:"+report.getStatus().getAction());
61+
message.setDeliveryStatus(SmsMessageStatusType.DELIVERED.getValue());
62+
this.smsOutboundMessageRepository.save(message) ;
63+
}else {
64+
logger.info("Message with Message id "+messageId+" Not found");
65+
}
66+
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
67+
}
68+
}

0 commit comments

Comments
 (0)