use of org.sagebionetworks.bridge.models.apps.SmsTemplate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method sendSmsMessageForWorker.
@PostMapping(path = { "/v1/apps/{appId}/participants/{userId}/sendSmsMessage", "/v3/studies/{appId}/participants/{userId}/sendSmsMessage" })
@ResponseStatus(HttpStatus.ACCEPTED)
public StatusMessage sendSmsMessageForWorker(@PathVariable String appId, @PathVariable String userId) {
getAuthenticatedSession(WORKER);
App app = appService.getApp(appId);
SmsTemplate template = parseJson(SmsTemplate.class);
participantService.sendSmsMessage(app, userId, template);
return new StatusMessage("Message sent.");
}
use of org.sagebionetworks.bridge.models.apps.SmsTemplate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantServiceTest method sendSmsMessageThrowsIfPhoneUnverified.
@Test(expectedExceptions = BadRequestException.class)
public void sendSmsMessageThrowsIfPhoneUnverified() {
when(accountService.getAccount(any())).thenReturn(Optional.of(account));
account.setPhone(TestConstants.PHONE);
account.setPhoneVerified(false);
SmsTemplate template = new SmsTemplate("This is a test ${appShortName}");
participantService.sendSmsMessage(APP, ID, template);
}
use of org.sagebionetworks.bridge.models.apps.SmsTemplate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantServiceTest method sendSmsMessageThrowsIfBlankMessage.
@Test(expectedExceptions = BadRequestException.class)
public void sendSmsMessageThrowsIfBlankMessage() {
SmsTemplate template = new SmsTemplate(" ");
participantService.sendSmsMessage(APP, ID, template);
}
use of org.sagebionetworks.bridge.models.apps.SmsTemplate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantServiceTest method sendSmsMessageThrowsIfNoPhone.
@Test(expectedExceptions = BadRequestException.class)
public void sendSmsMessageThrowsIfNoPhone() {
when(accountService.getAccount(any())).thenReturn(Optional.of(account));
SmsTemplate template = new SmsTemplate("This is a test ${appShortName}");
participantService.sendSmsMessage(APP, ID, template);
}
use of org.sagebionetworks.bridge.models.apps.SmsTemplate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantServiceTest method sendSmsMessage.
@Test
public void sendSmsMessage() {
when(accountService.getAccount(any())).thenReturn(Optional.of(account));
account.setHealthCode(HEALTH_CODE);
account.setPhone(TestConstants.PHONE);
account.setPhoneVerified(true);
SmsTemplate template = new SmsTemplate("This is a test ${appShortName}");
participantService.sendSmsMessage(APP, ID, template);
verify(smsService).sendSmsMessage(eq(ID), smsProviderCaptor.capture());
SmsMessageProvider provider = smsProviderCaptor.getValue();
assertEquals(provider.getPhone(), TestConstants.PHONE);
assertEquals(provider.getSmsRequest().getMessage(), "This is a test Bridge");
assertEquals(provider.getSmsType(), "Promotional");
}
Aggregations