Search in sources :

Example 1 with OutboundMessage

use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.

the class BulkSmsGateway method buildCsvUrl.

private String buildCsvUrl(List<OutboundMessage> smsBatch) {
    String csvData = "msisdn,message\n";
    for (OutboundMessage sms : smsBatch) {
        csvData += getRecipients(sms.getRecipients());
        csvData += "," + sms.getText() + "\n";
    }
    return csvData;
}
Also used : OutboundMessage(org.hisp.dhis.outboundmessage.OutboundMessage)

Example 2 with OutboundMessage

use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.

the class SmsMessageSenderTest method setUp.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private void setUp() {
    okStatus = new OutboundMessageResponse();
    okStatus.setResponseObject(GatewayResponse.RESULT_CODE_0);
    failedStatus = new OutboundMessageResponse();
    failedStatus.setResponseObject(GatewayResponse.FAILED);
    smsGatewayConfig = new BulkSmsGatewayConfig();
    smsGatewayConfig.setUrlTemplate("");
    smsGatewayConfig.setName(gateway);
    smsGatewayConfig.setUsername(" ");
    smsGatewayConfig.setPassword("");
    smsGatewayConfig.setUrlTemplate("");
    smsGatewayConfig.setDefault(true);
    OutboundMessage outboundMessageA = new OutboundMessage(subject, text, recipientsNormalized);
    OutboundMessage outboundMessageB = new OutboundMessage(subject, text, recipientsNonNormalized);
    OutboundMessage outboundMessageC = new OutboundMessage(subject, text, recipientsNormalized);
    OutboundMessage outboundMessageD = new OutboundMessage(subject, text, recipientsNonNormalized);
    outboundMessages = Arrays.asList(outboundMessageA, outboundMessageB, outboundMessageC, outboundMessageD);
    User userA = new User();
    userA.setPhoneNumber("47401111111");
    User userB = new User();
    userB.setPhoneNumber("47402222222");
    User userC = new User();
    userC.setPhoneNumber("47403333333");
    User userD = new User();
    userD.setPhoneNumber("47404444444");
    users = Sets.newHashSet(userA, userB, userC, userD);
    sender = new User();
    sender.setPhoneNumber("4740555555");
}
Also used : User(org.hisp.dhis.user.User) OutboundMessage(org.hisp.dhis.outboundmessage.OutboundMessage) OutboundMessageResponse(org.hisp.dhis.outboundmessage.OutboundMessageResponse) BulkSmsGatewayConfig(org.hisp.dhis.sms.config.BulkSmsGatewayConfig)

Example 3 with OutboundMessage

use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.

the class SmsMessageSenderTest method createOutBoundMessagesWithOutMaxRecipients.

private void createOutBoundMessagesWithOutMaxRecipients() {
    OutboundMessage outboundMessageA = new OutboundMessage(subject, text, recipientsNormalized);
    OutboundMessage outboundMessageB = new OutboundMessage(subject, text, recipientsNonNormalized);
    OutboundMessage outboundMessageC = new OutboundMessage(subject, text, recipientsNormalized);
    OutboundMessage outboundMessageD = new OutboundMessage(subject, text, recipientsNonNormalized);
    outboundMessages = Arrays.asList(outboundMessageA, outboundMessageB, outboundMessageC, outboundMessageD);
}
Also used : OutboundMessage(org.hisp.dhis.outboundmessage.OutboundMessage)

Example 4 with OutboundMessage

use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.

the class SmsMessageSenderTest method createOutBoundMessagesWithMaxRecipients.

private void createOutBoundMessagesWithMaxRecipients() {
    generateRecipients(500);
    OutboundMessage outboundMessageA = new OutboundMessage(subject, text, generatedRecipients);
    OutboundMessage outboundMessageB = new OutboundMessage(subject, text, recipientsNonNormalized);
    OutboundMessage outboundMessageC = new OutboundMessage(subject, text, recipientsNormalized);
    OutboundMessage outboundMessageD = new OutboundMessage(subject, text, recipientsNonNormalized);
    outboundMessages = Arrays.asList(outboundMessageA, outboundMessageB, outboundMessageC, outboundMessageD);
}
Also used : OutboundMessage(org.hisp.dhis.outboundmessage.OutboundMessage)

Example 5 with OutboundMessage

use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.

the class SMPPClient method sendBatch.

public List<OutboundMessageResponse> sendBatch(OutboundMessageBatch batch, SMPPGatewayConfig config) {
    SMPPSession session = start(config);
    if (session == null) {
        return Collections.emptyList();
    }
    List<OutboundMessageResponse> responses = new ArrayList<>();
    for (OutboundMessage message : batch.getMessages()) {
        OutboundMessageResponse response = send(session, message.getText(), message.getRecipients(), config);
        responses.add(response);
    }
    stop(session);
    return responses;
}
Also used : OutboundMessage(org.hisp.dhis.outboundmessage.OutboundMessage) SMPPSession(org.jsmpp.session.SMPPSession) OutboundMessageResponse(org.hisp.dhis.outboundmessage.OutboundMessageResponse)

Aggregations

OutboundMessage (org.hisp.dhis.outboundmessage.OutboundMessage)10 OutboundMessageResponse (org.hisp.dhis.outboundmessage.OutboundMessageResponse)4 OutboundMessageBatch (org.hisp.dhis.outboundmessage.OutboundMessageBatch)3 ArrayList (java.util.ArrayList)2 OutboundMessageResponseSummary (org.hisp.dhis.outboundmessage.OutboundMessageResponseSummary)2 BulkSmsGatewayConfig (org.hisp.dhis.sms.config.BulkSmsGatewayConfig)2 User (org.hisp.dhis.user.User)2 Test (org.junit.jupiter.api.Test)2 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singleton (java.util.Collections.singleton)1 Collections.unmodifiableList (java.util.Collections.unmodifiableList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Future (java.util.concurrent.Future)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 DhisSpringTest (org.hisp.dhis.DhisSpringTest)1 EmailResponse (org.hisp.dhis.email.EmailResponse)1