Package org.motechproject.mots.service
Class IvrService
- java.lang.Object
-
- org.motechproject.mots.service.IvrService
-
@Service public class IvrService extends java.lang.Object
This class is responsible for making requests to IVR system (e.g. managing subscribers, getting call statuses, retrieving informations about phone interactions ).
-
-
Constructor Summary
Constructors Constructor Description IvrService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubscribersToGroup(java.lang.String groupId, java.util.List<java.lang.String> subscriberIds)
Add Subscribers to group.void
addSubscriberToGroups(java.lang.String subscriberId, java.util.List<java.lang.String> groupsIds)
Add Subscriber to groups.void
changeSubscriberGroup(java.lang.String subscriberId, java.lang.String oldGroupId, java.lang.String newGroupId)
java.lang.String
createGroup(java.lang.String groupName)
java.lang.String
createSubscriber(java.lang.String phoneNumber, java.lang.String name, java.lang.String districtIvrId)
Create IVR Subscriber with given phone number.void
manuallySendVotoCallLog(VotoCallLogDto votoCallLogDto)
Manually send Voto call log to Mots, this should be used only when call log is incorrect and must be manually changed before it can be successfully processed in Mots.void
removeSubscriberFromGroups(java.lang.String subscriberId, java.util.List<java.lang.String> groupsIds)
Remove Subscriber from groups.void
saveCallDetailRecordAndUpdateModuleProgress(CallDetailRecord callDetailRecord, java.lang.String configName)
Save IVR Call Detail Record and update module progress.void
sendModuleAssignedMessage(java.util.Set<java.lang.String> subscriberIds)
Send module assignment message to a list of subscribers.]void
updateSubscriber(java.lang.String ivrId, java.lang.String phoneNumber, java.lang.String name)
Update existing IVR subscriber.
-
-
-
Method Detail
-
createSubscriber
public java.lang.String createSubscriber(java.lang.String phoneNumber, java.lang.String name, java.lang.String districtIvrId) throws IvrException
Create IVR Subscriber with given phone number.- Parameters:
phoneNumber
- CHW phone numbername
- CHW namedistrictIvrId
- IVR group id- Returns:
- ivr id of created subscriber
- Throws:
IvrException
- in case of any error
-
updateSubscriber
public void updateSubscriber(java.lang.String ivrId, java.lang.String phoneNumber, java.lang.String name) throws IvrException
Update existing IVR subscriber.- Parameters:
ivrId
- id of existing IVR subscriberphoneNumber
- new CHW phone numbername
- new CHW name- Throws:
IvrException
- if there is an error while creating a subscriber or sending request to IVR service
-
createGroup
public java.lang.String createGroup(java.lang.String groupName) throws IvrException
- Throws:
IvrException
-
changeSubscriberGroup
public void changeSubscriberGroup(java.lang.String subscriberId, java.lang.String oldGroupId, java.lang.String newGroupId) throws IvrException
- Throws:
IvrException
-
addSubscribersToGroup
public void addSubscribersToGroup(java.lang.String groupId, java.util.List<java.lang.String> subscriberIds) throws IvrException
Add Subscribers to group.- Parameters:
groupId
- id of group to add subscribersubscriberIds
- set of subscribers ids- Throws:
IvrException
- if there is an error while sending request to IVR service
-
addSubscriberToGroups
public void addSubscriberToGroups(java.lang.String subscriberId, java.util.List<java.lang.String> groupsIds) throws IvrException
Add Subscriber to groups.- Parameters:
subscriberId
- subscriber idgroupsIds
- ids of groups to add subscriber- Throws:
IvrException
- if there is an error while sending request to IVR service
-
removeSubscriberFromGroups
public void removeSubscriberFromGroups(java.lang.String subscriberId, java.util.List<java.lang.String> groupsIds) throws IvrException
Remove Subscriber from groups.- Parameters:
subscriberId
- subscriber idgroupsIds
- ids of groups to remove subscriber- Throws:
IvrException
- if there is an error while sending request to IVR service
-
saveCallDetailRecordAndUpdateModuleProgress
public void saveCallDetailRecordAndUpdateModuleProgress(CallDetailRecord callDetailRecord, java.lang.String configName)
Save IVR Call Detail Record and update module progress.- Parameters:
callDetailRecord
- callDetailRecord to be savedconfigName
- name of the IVR config
-
manuallySendVotoCallLog
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") public void manuallySendVotoCallLog(VotoCallLogDto votoCallLogDto)
Manually send Voto call log to Mots, this should be used only when call log is incorrect and must be manually changed before it can be successfully processed in Mots.- Parameters:
votoCallLogDto
- it contains information about module progress (which trees were listened by user and what answers were chosen)- Throws:
java.lang.IllegalArgumentException
- if unexpected call status is in a response.
-
sendModuleAssignedMessage
public void sendModuleAssignedMessage(java.util.Set<java.lang.String> subscriberIds) throws IvrException
Send module assignment message to a list of subscribers.]- Parameters:
subscriberIds
- a list of subscribers- Throws:
IvrException
- if there is an error while sending IVR notification
-
-