Skip to content

Commit

Permalink
feat(msgr-api): integrate with load callbacks (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincejv authored Nov 3, 2022
1 parent 2e20e7c commit edae46b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ jobs:
SMS_BASE_URI=${{ secrets.SMS_BASE_URI }}
FPI_APP_TO_APP_USERN=${{ secrets.FPI_APP_TO_APP_USERN }}
USER_BASE_URI=${{ secrets.USER_BASE_URI }}
MSGR_API_BASE_URI=${{ secrets.MSGR_API_BASE_URI }}
secrets: |
MONGO_CONN_STRING=vbl_mongo_connection_string:latest
OIDC_SECRET=oidc_secret_keycloak:latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ jobs:
SMS_BASE_URI=${{ secrets.SMS_BASE_URI }}
FPI_APP_TO_APP_USERN=${{ secrets.FPI_APP_TO_APP_USERN }}
USER_BASE_URI=${{ secrets.USER_BASE_URI }}
MSGR_API_BASE_URI=${{ secrets.MSGR_API_BASE_URI }}
secrets: |
MONGO_CONN_STRING=vbl_mongo_connection_string:latest
OIDC_SECRET=oidc_secret_keycloak:latest
Expand Down
5 changes: 5 additions & 0 deletions fpi-load-api-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
<artifactId>fpi-sms-api-lib</artifactId>
</dependency>

<dependency>
<groupId>com.abavilla</groupId>
<artifactId>fpi-msgr-api-lib</artifactId>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import com.abavilla.fpi.load.repo.load.RewardsTransRepo;
import com.abavilla.fpi.load.util.LoadConst;
import com.abavilla.fpi.login.ext.rest.UserApi;
import com.abavilla.fpi.msgr.ext.dto.MsgrMsgReqDto;
import com.abavilla.fpi.msgr.ext.rest.MsgrReqApi;
import com.abavilla.fpi.sms.ext.dto.MsgReqDto;
import com.abavilla.fpi.sms.ext.rest.SmsApi;
import com.abavilla.fpi.telco.ext.entity.enums.ApiStatus;
Expand All @@ -48,11 +50,15 @@
import io.quarkus.logging.Log;
import io.smallrye.mutiny.Uni;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;

@ApplicationScoped
public class RewardsCallbackSvc extends AbsSvc<GLRewardsCallbackDto, RewardsTransStatus> {

@ConfigProperty(name = "fpi.app-to-app.auth.username")
String fpiSystemId;

@Inject
RewardsTransRepo advRepo;

Expand All @@ -74,6 +80,9 @@ public class RewardsCallbackSvc extends AbsSvc<GLRewardsCallbackDto, RewardsTran
@RestClient
SmsApi smsApi;

@RestClient
MsgrReqApi msgrApi;

@Inject
PhoneNumberUtil phoneNumberUtil;

Expand Down Expand Up @@ -223,6 +232,8 @@ private Uni<? extends RewardsTransStatus> sendLoaderAckMsg(RewardsTransStatus re
return userApi.getByMetaId(fpiUser).chain(resp -> {
if (StringUtils.isNotBlank(resp.getResp().getMobile())) {
var msg = new MsgReqDto();
var msgrMsg = new MsgrMsgReqDto();
msgrMsg.setRecipient(resp.getResp().getMetaId());
msg.setMobileNumber(resp.getResp().getMobile());
msg.setContent("""
Loaded %s to %s
Expand All @@ -233,7 +244,12 @@ private Uni<? extends RewardsTransStatus> sendLoaderAckMsg(RewardsTransStatus re
StringUtils.isBlank(rewardsTransStatus.getLoadRequest().getAccountNo()) ?
rewardsTransStatus.getLoadRequest().getMobile() : rewardsTransStatus.getLoadRequest().getAccountNo(),
String.valueOf(status), rewardsTransStatus.getLoadSmsId()));
return smsApi.sendSms(msg);
msgrMsg.setContent(msg.getContent());
return
msgrApi.toggleTyping(resp.getResp().getMetaId(), true)
.chain(() -> msgrApi.sendMsg(msgrMsg, fpiSystemId))
.chain(()-> msgrApi.toggleTyping(resp.getResp().getMetaId(), false))
.chain(() -> smsApi.sendSms(msg));
}
return Uni.createFrom().voidItem();
}).chain(() -> Uni.createFrom().item(rewardsTransStatus));
Expand Down
3 changes: 3 additions & 0 deletions fpi-load-api-core/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ quarkus:
user-api:
url: ${USER_BASE_URI}
scope: javax.inject.Singleton
msgr-api:
url: ${MSGR_API_BASE_URI}
scope: javax.inject.Singleton
oidc:
auth-server-url: ${OIDC_AUTH_URL:https://localhost:8543/realms/quarkus}
client-id: ${OIDC_CLIENT_ID:backend-api}
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<parent>
<groupId>com.abavilla</groupId>
<artifactId>fpi-framework-pom</artifactId>
<version>1.1.33</version>
<version>1.1.35</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -113,6 +113,12 @@
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>com.abavilla</groupId>
<artifactId>fpi-msgr-api-lib</artifactId>
<version>1.1.2</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit edae46b

Please sign in to comment.