-
Notifications
You must be signed in to change notification settings - Fork 1
Example: subscriber creation
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.AuthToken;
import com.contactlab.api.ws.domain.Subscriber;
import com.contactlab.api.ws.domain.SubscriberAttribute;
public class InsertNewSubscriber {
public static void main(String[] args) {
ClabService clabService = new ClabService_Service().getClabServicePort();
AuthToken token = clabService.borrowToken(Parameters.apiKey, Parameters.userKey);
int subscriberSourceId = 1;
Subscriber subscriber = new Subscriber();
SubscriberAttribute email = new SubscriberAttribute();
email.setKey("EMAIL");
email.setValue("[email protected]");
subscriber.getAttributes().add(email);
SubscriberAttribute firstName = new SubscriberAttribute();
firstName.setKey("FIRSTNAME");
firstName.setValue("lamia");
subscriber.getAttributes().add(firstName);
SubscriberAttribute lastName = new SubscriberAttribute();
lastName.setKey("LASTNAME");
lastName.setValue("mail");
subscriber.getAttributes().add(lastName);
subscriber = clabService.addSubscriber(token, subscriberSourceId, subscriber);
System.out.println("Subscriber added with id " + subscriber.getIdentifier());
clabService.invalidateToken(token);
}
}