Search in sources :

Example 1 with IvrConfig

use of org.motechproject.mots.domain.IvrConfig in project mots by motech-implementations.

the class IvrService method sendModuleAssignedMessage.

private void sendModuleAssignedMessage(String subscriberId) throws IvrException {
    IvrConfig ivrConfig = ivrConfigService.getConfig();
    String messageId = ivrConfig.getModuleAssignedMessageId();
    String sendSmsIfVoiceFails = boolToIntAsString(ivrConfig.getSendSmsIfVoiceFails());
    String detectVoiceMailAction = boolToIntAsString(ivrConfig.getDetectVoicemailAction());
    String retryAttemptsShort = Integer.toString(ivrConfig.getRetryAttemptsShort());
    String retryDelayShort = Integer.toString(ivrConfig.getRetryDelayShort());
    String retryAttemptsLong = Integer.toString(ivrConfig.getRetryAttemptsLong());
    String retryDelayLong = Integer.toString(ivrConfig.getRetryDelayLong());
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add(SEND_TO_SUBSCRIBERS, subscriberId);
    params.add(MESSAGE_ID, messageId);
    params.add(SEND_SMS_IF_VOICE_FAILS, sendSmsIfVoiceFails);
    params.add(DETECT_VOICEMAIL_ACTION, detectVoiceMailAction);
    params.add(RETRY_ATTEMPTS_SHORT, retryAttemptsShort);
    params.add(RETRY_DELAY_SHORT, retryDelayShort);
    params.add(RETRY_ATTEMPTS_LONG, retryAttemptsLong);
    params.add(RETRY_DELAY_LONG, retryDelayLong);
    sendVotoRequest(getAbsoluteUrl(SEND_MESSAGE_URL), params, new ParameterizedTypeReference<VotoResponseDto<String>>() {
    }, HttpMethod.POST);
}
Also used : VotoResponseDto(org.motechproject.mots.dto.VotoResponseDto) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) IvrConfig(org.motechproject.mots.domain.IvrConfig)

Example 2 with IvrConfig

use of org.motechproject.mots.domain.IvrConfig in project mots by motech-implementations.

the class IvrService method saveCallDetailRecord.

/**
 * Save IVR Call Detail Record.
 * @param callDetailRecord callDetailRecord to be saved
 * @param configName name of the IVR config
 */
public void saveCallDetailRecord(CallDetailRecord callDetailRecord, String configName) throws IvrException {
    IvrConfig ivrConfig = ivrConfigService.getConfig();
    setConfigFields(callDetailRecord, ivrConfig, configName);
    callDetailRecordRepository.save(callDetailRecord);
    CallStatus callStatus = callDetailRecord.getCallStatus();
    boolean callInterrupted = CallStatus.FINISHED_INCOMPLETE.equals(callStatus);
    if (CallStatus.FINISHED_COMPLETE.equals(callStatus) || callInterrupted) {
        VotoCallLogDto votoCallLogDto = getVotoCallLog(callDetailRecord);
        moduleProgressService.updateModuleProgress(votoCallLogDto, callInterrupted);
    }
}
Also used : VotoCallLogDto(org.motechproject.mots.dto.VotoCallLogDto) CallStatus(org.motechproject.mots.domain.enums.CallStatus) IvrConfig(org.motechproject.mots.domain.IvrConfig)

Example 3 with IvrConfig

use of org.motechproject.mots.domain.IvrConfig in project mots by motech-implementations.

the class IvrService method prepareBasicSubscriberParamsToSend.

private MultiValueMap<String, String> prepareBasicSubscriberParamsToSend(String phoneNumber, String name, Language preferredLanguage) {
    IvrConfig ivrConfig = ivrConfigService.getConfig();
    String preferredLanguageString = ivrConfig.getIvrLanguagesIds().get(preferredLanguage);
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add(PHONE, phoneNumber);
    params.add(PREFERRED_LANGUAGE, preferredLanguageString);
    if (StringUtils.isNotBlank(name)) {
        params.add(NAME_PROPERTY, name);
    }
    return params;
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) IvrConfig(org.motechproject.mots.domain.IvrConfig)

Aggregations

IvrConfig (org.motechproject.mots.domain.IvrConfig)3 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)2 CallStatus (org.motechproject.mots.domain.enums.CallStatus)1 VotoCallLogDto (org.motechproject.mots.dto.VotoCallLogDto)1 VotoResponseDto (org.motechproject.mots.dto.VotoResponseDto)1