This repository was archived by the owner on Jul 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Example: subscriber source creation
Stefano Varesi edited this page Apr 9, 2015
·
2 revisions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ContactLabAPIClient;
using ContactLabAPIClient.ClabService;
namespace ContactLabApiClientExample
{
public class CreateSubscriberSoruce
{
public static void Main() {
ClabServiceClient ClabServiceClient = null;
SubscriberSource SubscriberSource = null;
SubscriberSourceField Name = null;
SubscriberSourceField Email = null;
SubscriberSourceField Phone = null;
SubscriberSourceField Birth = null;
SubscriberSourceField Gender = null;
SubscriberSourceField Privacy = null;
SubscriberSource = new SubscriberSource();
SubscriberSource.name = "Some users with .NET";
// defining the fields
Name = new SubscriberSourceField();
Name.name = "Name";
Name.type = field.STRING;
Name.emailField = false;
Email = new SubscriberSourceField();
Email.name = "Email";
Email.type = field.STRING;
Email.emailField = true;
Phone = new SubscriberSourceField();
Phone.name = "Phone";
Phone.type = field.STRING;
Phone.phoneField = true;
Birth = new SubscriberSourceField();
Birth.name = "Birth";
Birth.type = field.DATE;
Gender = new SubscriberSourceField();
Gender.name = "Gender";
Gender.type = field.CHAR;
Privacy = new SubscriberSourceField();
Privacy.name = "Privacy";
Privacy.type = field.FLAG;
SubscriberSourceField[] fieldsArray = { Name, Email, Phone, Birth, Gender, Privacy };
SubscriberSource.fields = new SubscriberSourceField[fieldsArray.Length];
for (int i = 0; i < fieldsArray.Length; i++) SubscriberSource.fields[i] = fieldsArray[i];
ClabServiceClient = new ClabServiceClient();
try
{
AuthToken Token = ClabServiceClient.borrowToken(ContactlabApiClientExamples.Properties.Settings.Default.ApiKey, ContactlabApiClientExamples.Properties.Settings.Default.UserKey);
SubscriberSource = ClabServiceClient.addSubscriberSource(Token, SubscriberSource);
ClabServiceClient.invalidateToken(Token);
Console.WriteLine("SubscriberSource " + SubscriberSource.name + " created with id " + SubscriberSource.identifier);
}
catch (Exception e)
{
Console.WriteLine("Exception with message " + e.Message);
}
Console.ReadLine();
}
}
}