The service enables you to add a new recipient or update the details of an existing recipient. If the recipient already exists, the recipient will be removed from the previous groups and added to the new ones you send
The value returned by the operation indicates whether the recipient existed before the operation and an update was make, or the recipient is a new one.
Java Code:
//get a reference to the service InwiseWebServices ws = new InwiseWebServices();
InwiseWebServicesSoap inwiseWebServicesSoap = ws.getInwiseWebServicesSoap();
//fill the security header
HeaderHandler hh = new HeaderHandler("myusername", "myPassword");
hh.setHeader(inwiseWebServicesSoap);
//the recipient's email
String email = "email@email.com";
//the groups to subscribe to
inwise.ArrayOfAnyType groups = new ArrayOfAnyType();
groups.anyType = new ArrayList<Object>();
groups.anyType.add(34);
groups.anyType.add(158);
//recipient custom fields
//the custom fields values
inwise.ArrayOfCustomFieldValue fields = new ArrayOfCustomFieldValue();
fields.customFieldValue = new ArrayList<CustomFieldValue>();
CustomFieldValue field1 = new CustomFieldValue();//string field
field1.setLocalName("field1");
field1.setFieldValue("my first name");
fields.customFieldValue.add(field1);
CustomFieldValue field23 = new CustomFieldValue();//date field
field23.setLocalName("field23");
field23.setFieldValue(new Date());
fields.customFieldValue.add(field23);
CustomFieldValue field28 = new CustomFieldValue();//int field
field28.setLocalName("field28");
field28.setFieldValue(30);
fields.customFieldValue.add(field28);
//call the operation
boolean existingRecipient = inwiseWebServicesSoap.recipientsAddOrUpdate(email,groups,fields);
C# Code:
//get a reference to the service
InwiseWebServices.InwiseWebServices ws = new InwiseWebServices.InwiseWebServices();
//fill the security header
InwiseWebServices.SecHeader header = new InwiseWebServices.SecHeader();
header.username = "username";
header.pass = "myPassword";
ws.SecHeaderValue = header;//set credentials
//the recipient's email
string email = "email@email.com";
//the groups to subscribe to
object[] groups = new object[2];
groups[0]=342;
groups[1]=9934;
//recipient custom fields
InwiseWebServices.CustomFieldValue[] fields = new InwiseWebServices.CustomFieldValue[3];
fields[0] = new InwiseWebServices.CustomFieldValue();//string field
fields[0].LocalName = "field1";
fields[0].FieldValue = "tal";
fields[1] = new InwiseWebServices.CustomFieldValue();//integer field
fields[1].LocalName = "field28";
fields[1].FieldValue = 30;
fields[2] = new InwiseWebServices.CustomFieldValue();//date field
fields[2].LocalName = "field22";
fields[2].FieldValue = DateTime.Now.ToString("yyyy-MM-dd");
//call the operation
bool existingRecipient = ws.Recipients_AddOrUpdate(email, groups, fields);
VB Code:
Dim ws As InwiseWebServices.InwiseWebServices = New InwiseWebServices.InwiseWebServices()
'fill the security header
Dim header As InwiseWebServices.SecHeader = New InwiseWebServices.SecHeader()
header.username = "username"
header.pass = "myPassword"
ws.SecHeaderValue = header 'set credentials
'the recipient's email
Dim email As String = "email@email.com"
'the groups to subscribe to
Dim groups() As Object = New Object(2) {}
groups(0) = 342
groups(1) = 9934
'recipient custom fields
Dim fields() As InwiseWebServices.CustomFieldValue = New InwiseWebServices.CustomFieldValue(3) {}
fields(0) = New InwiseWebServices.CustomFieldValue() 'string field
fields(0).LocalName = "field1"
fields(0).FieldValue = "tal"
fields(1) = New InwiseWebServices.CustomFieldValue() 'integer field
fields(1).LocalName = "field28"
fields(1).FieldValue = 30
fields(2) = New InwiseWebServices.CustomFieldValue() 'date field
fields(2).LocalName = "field22"
fields(2).FieldValue = DateTime.Now.ToString("yyyy-MM-dd")
'call the operation
Dim existingRecipient As Boolean = ws.Recipients_AddOrUpdate(email, groups, fields)