Skip to content

Commit a886e81

Browse files
authored
PHEE-295 Generalize message gateway classes for SMS and EMAIL (#69)
1 parent 7a7e278 commit a886e81

22 files changed

+92
-345
lines changed

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dependencies {
6868
implementation 'org.apache.camel:camel-endpointdsl:3.12.0'
6969
implementation 'org.apache.camel:camel-jetty:3.12.0'
7070
implementation 'org.apache.camel:camel-undertow:3.12.0'
71+
implementation 'org.apache.camel:camel-http:3.12.0'
7172
implementation 'io.camunda:zeebe-client-java:8.1.4'
7273
implementation 'org.apache.camel.springboot:camel-spring-boot-starter:3.12.0'
7374
implementation("com.google.code.gson:gson:") {

src/main/java/org/fineract/messagegateway/configuration/MessageGatewayConfiguration.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.fineract.messagegateway.sms.domain.AbstractPersistableCustom;
2222
import org.fineract.messagegateway.sms.domain.SMSBridge;
2323
import org.fineract.messagegateway.sms.domain.SMSBridgeConfig;
24-
import org.fineract.messagegateway.sms.domain.SMSMessage;
24+
import org.fineract.messagegateway.sms.domain.OutboundMessages;
2525
import org.fineract.messagegateway.tenants.domain.Tenant;
2626
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2727
import org.springframework.boot.autoconfigure.domain.EntityScan;
@@ -43,7 +43,7 @@
4343
AbstractPersistableCustom.class,
4444
SMSBridge.class,
4545
SMSBridgeConfig.class,
46-
SMSMessage.class,
46+
OutboundMessages.class,
4747
Tenant.class
4848
})
4949
@ComponentScan(basePackages = {

src/main/java/org/fineract/messagegateway/sms/api/SmsApiResource.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
*/
1919
package org.fineract.messagegateway.sms.api;
2020

21+
2122
import org.fineract.messagegateway.constants.MessageGatewayConstants;
2223
import org.fineract.messagegateway.exception.MessageGatewayException;
2324
import org.fineract.messagegateway.sms.data.DeliveryStatusData;
25+
import org.fineract.messagegateway.sms.domain.OutboundMessages;
2426
import org.fineract.messagegateway.sms.domain.SMSBridge;
25-
import org.fineract.messagegateway.sms.domain.SMSMessage;
2627
import org.fineract.messagegateway.sms.exception.ProviderNotDefinedException;
2728
import org.fineract.messagegateway.sms.exception.SMSBridgeNotFoundException;
28-
import org.fineract.messagegateway.sms.providers.SMSProvider;
29+
import org.fineract.messagegateway.sms.providers.Provider;
2930
import org.fineract.messagegateway.sms.providers.impl.telerivet.TelerivetMessageProvider;
3031
import org.fineract.messagegateway.sms.repository.SMSBridgeRepository;
3132
import org.fineract.messagegateway.sms.repository.SmsOutboundMessageRepository;
@@ -76,7 +77,7 @@ public SmsApiResource(final SMSMessageService smsMessageService) {
7677
@RequestMapping(method = RequestMethod.POST, consumes = {"application/json"}, produces = {"application/json"})
7778
public ResponseEntity<Void> sendShortMessages(@RequestHeader(MessageGatewayConstants.TENANT_IDENTIFIER_HEADER) final String tenantId,
7879
@RequestHeader(MessageGatewayConstants.TENANT_APPKEY_HEADER) final String appKey,
79-
@RequestBody final List<SMSMessage> payload) {
80+
@RequestBody final List<OutboundMessages> payload) {
8081
logger.info("Payload "+ payload.get(0).getMessage());
8182
this.smsMessageService.sendShortMessage(tenantId, appKey, payload);
8283
return new ResponseEntity<>(HttpStatus.ACCEPTED);
@@ -85,7 +86,7 @@ public ResponseEntity<Void> sendShortMessages(@RequestHeader(MessageGatewayConst
8586
public ResponseEntity<Void> sendShortMessagesToProvider(@RequestHeader(MessageGatewayConstants.TENANT_IDENTIFIER_HEADER) final String tenantId,
8687
@RequestHeader(MessageGatewayConstants.TENANT_APPKEY_HEADER) final String appKey,
8788
@RequestHeader(MessageGatewayConstants.X_ORCHESTRATOR) final String orchestrator,
88-
@RequestBody final List<SMSMessage> payload) {
89+
@RequestBody final List<OutboundMessages> payload) {
8990
logger.info("Payload "+ payload.get(0).getMessage());
9091
this.smsMessageService.sendShortMessageToProvider(tenantId, appKey, payload,orchestrator);
9192
return new ResponseEntity<>(HttpStatus.ACCEPTED);
@@ -101,13 +102,13 @@ public ResponseEntity<Collection<DeliveryStatusData>> getDeliveryStatus(@Request
101102
logger.info("Delivery status is still pending, fetching message status manually ");
102103
SMSBridge bridge = smsBridgeRepository.findByIdAndTenantId(deliveryStatusData.getBridgeId(),
103104
deliveryStatusData.getTenantId());
104-
SMSProvider provider = null;
105+
Provider provider = null;
105106
try {
106107
if (bridge == null) {
107108
throw new SMSBridgeNotFoundException(deliveryStatusData.getBridgeId());
108109
}
109110
logger.info("Finding provider for fetching message status....{}", bridge.getProviderKey());
110-
provider = (SMSProvider) this.applicationContext.getBean(bridge.getProviderKey());
111+
provider = (Provider) this.applicationContext.getBean(bridge.getProviderKey());
111112
if (provider == null)
112113
throw new ProviderNotDefinedException();
113114
provider.updateStatusByMessageId(bridge, deliveryStatusData.getExternalId(),orchestrator);
@@ -124,11 +125,11 @@ public ResponseEntity<Collection<DeliveryStatusData>> getDeliveryStatus(@Request
124125

125126
}
126127
@RequestMapping(value = "/details/{internalId}", method = RequestMethod.GET, consumes = {"application/json"}, produces = {"application/json"})
127-
public ResponseEntity<SMSMessage> getMessageDetails(@RequestHeader(MessageGatewayConstants.TENANT_IDENTIFIER_HEADER) final String tenantId,
128-
@RequestHeader(MessageGatewayConstants.TENANT_APPKEY_HEADER) final String appKey,
129-
@PathVariable Long internalId) throws MessageGatewayException {
128+
public ResponseEntity<OutboundMessages> getMessageDetails(@RequestHeader(MessageGatewayConstants.TENANT_IDENTIFIER_HEADER) final String tenantId,
129+
@RequestHeader(MessageGatewayConstants.TENANT_APPKEY_HEADER) final String appKey,
130+
@PathVariable Long internalId) throws MessageGatewayException {
130131

131-
SMSMessage smsMessages = this.smsOutboundMessageRepository.findByInternalId(internalId);
132+
OutboundMessages smsMessages = this.smsOutboundMessageRepository.findByInternalId(internalId);
132133
return new ResponseEntity<>(smsMessages, HttpStatus.OK);
133134
}
134135
}

src/main/java/org/fineract/messagegateway/sms/domain/SMSMessage.java

-213
This file was deleted.

src/main/java/org/fineract/messagegateway/sms/providers/SMSProvider.java

-42
This file was deleted.

0 commit comments

Comments
 (0)