Skip to content

Example: clone and send an existing campaign

Stefano Varesi edited this page Apr 9, 2015 · 1 revision
package com.contactlab.api.ws.examples;

import com.contactlab.api.ws.ClabService;
import com.contactlab.api.ws.ClabService_Service;
import com.contactlab.api.ws.domain.ActivityStatus;
import com.contactlab.api.ws.domain.AuthToken;

public class SendAndCloneDelivery {

    public static void main(String[] args) throws InterruptedException {

        int deliveryID = 747;

        ClabService clabService = new ClabService_Service().getClabServicePort();

        AuthToken token = clabService.borrowToken(Parameters.apiKey, Parameters.userKey);

        int request = clabService.cloneAndSendCampaign(token, deliveryID, null);

        System.out.println("Request is " + request);

        ActivityStatus status = null;

        while (true) {
            status = clabService.getRequestStatus(token, request);
            System.out.println("partial status " + status);
            if (status == ActivityStatus.COMPLETED
             || status == ActivityStatus.FAILED) {
                break;
            }
            Thread.sleep(3000);
        }

        System.out.println("Request status is " + status);
    }

}