Beispiel #1
0
        private static void ErrorTest()
        {
            var client = new Client("*****@*****.**", "Dynam1cs!");
             ApiAddressBook ab = new ApiAddressBook();
            ab.Name = "API_Addressbook5";
            var result = client.PostAddressBooks(ab);
            if (result.Success)
            {
                Console.WriteLine(String.Format("Created AddressBook {0}", result.Data.Id.ToString()));

                ApiContact c = new ApiContact();
                c.Email = "*****@*****.**";
                ApiContact c1 = new ApiContact();
                c1.Email = "*****@*****.**";
                ApiContact c2 = new ApiContact();
                c2.Email = "*****@*****.**";

                List<ApiContact> contacts = new List<ApiContact>();
                contacts.Add(c);
                contacts.Add(c1);
                contacts.Add(c2);

                string filestring = "Email,FirstName,FullName,Gender,LastName,Postcode" + Environment.NewLine;
                filestring = filestring + "[email protected],John,John Smith,M,Smith,CR0 0XT" + Environment.NewLine;
                filestring = filestring + "[email protected],John,John Smith,M,Smith,CR0 0XT" + Environment.NewLine;
                filestring = filestring + "[email protected],John,John Smith,M,Smith,CR0 0XT" + Environment.NewLine;

                byte[] b = System.Text.Encoding.UTF8.GetBytes(filestring);
                ApiFileMedia afm = new ApiFileMedia();
                afm.Data = b;
                afm.FileName = "contacts.csv";

                var importresult = client.PostAddressBookContactsImportAsync(result.Data.Id, afm);
            }
                else
            {
                Console.WriteLine(result.Message);
            }
            Console.Read();
            //var result = client.DeleteAddressBook(838);
            //result = client.DeleteAddressBookContact(838, 838);
            //result = client.DeleteAddressBookContacts(838);
            //result = client.DeleteCampaignAttachment(838, 838);
            //result = client.GetAddressBookById(838);
            //result = client.GetAddressBookCampaigns(838);
            //result = client.GetAddressBookContacts(838);
            //result = client.GetCampaignActivities(838);
            //result = client.GetContactsImportByImportId(Guid.Empty);
            //result = client.GetContactsImportReport(Guid.Empty);
            //result = client.GetContactsImportReportFaults(Guid.Empty);
            //result = client.GetContactsTransactionalDataImportByImportId(Guid.Empty);
            //result = client.GetContactTransactionalDataByCollectionName("test", 300);
        }
Beispiel #2
0
 public bool send()
 {
     try
     {
         var client = new Client(UserName,Password);
         byte[] b = System.Text.Encoding.UTF8.GetBytes(importfiletext);
         ApiFileMedia afm = new ApiFileMedia();
         afm.Data = b;
         afm.FileName = "contacts.csv";
         CallResult = client.PostAddressBookContactsImport(AddressBookID, afm);
         return true;
     }
     catch (Exception e)
     {
         ErrorText = e.Message;
         return false;
     }
 }
Beispiel #3
0
		/// <summary>
		/// Uploads a new campaign image to the specified folder.
		/// </summary>
		public async Task<ServiceResult<ApiImage>> PostImageFolderImagesAsync(int folderId, ApiFileMedia apiFileMedia)
		{
			var request = new Request(baseAddress, "image-folders/{folderId}/images", 
			new Dictionary<string, object>
			{
				{ "folderId", folderId },
			});
			return await PostAsync<ApiImage, ApiFileMedia>(request, apiFileMedia);
		}
Beispiel #4
0
		/// <summary>
		/// Upload a document to the specified folder.
		/// </summary>
		public async Task<ServiceResult<ApiDocument>> PostDocumentFolderDocumentsAsync(int folderId, ApiFileMedia apiFileMedia)
		{
			var request = new Request(baseAddress, "document-folders/{folderId}/documents", 
			new Dictionary<string, object>
			{
				{ "folderId", folderId },
			});
			return await PostAsync<ApiDocument, ApiFileMedia>(request, apiFileMedia);
		}
Beispiel #5
0
		/// <summary>
		/// Uploads a new campaign image to the specified folder.
		/// </summary>
		public ServiceResult<ApiImage> PostImageFolderImages(int folderId, ApiFileMedia apiFileMedia)
		{
			return PostImageFolderImagesAsync(folderId, apiFileMedia).Result;
		}
Beispiel #6
0
		/// <summary>
		/// Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel. Must include one column called "Email". Any other columns will attempt to map to your custom data fields. The ID of returned object can be used to query import progress.
		/// </summary>
		public async Task<ServiceResult<ApiContactImport>> PostContactsImportAsync(ApiFileMedia apiFileMedia)
		{
			var request = new Request(baseAddress, "contacts/import");
			return await PostAsync<ApiContactImport, ApiFileMedia>(request, apiFileMedia);
		}
Beispiel #7
0
		/// <summary>
		/// Upload a document to the specified folder.
		/// </summary>
		public ServiceResult<ApiDocument> PostDocumentFolderDocuments(int folderId, ApiFileMedia apiFileMedia)
		{
			return PostDocumentFolderDocumentsAsync(folderId, apiFileMedia).Result;
		}
Beispiel #8
0
		/// <summary>
		/// Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel. Must include one column called "Email". Any other columns will attempt to map to your custom data fields. The ID of returned object can be used to query import progress.
		/// </summary>
		public async Task<ServiceResult<ApiContactImport>> PostAddressBookContactsImportAsync(int addressBookId, ApiFileMedia apiFileMedia)
		{
			var request = new Request(baseAddress, "address-books/{addressBookId}/contacts/import", 
			new Dictionary<string, object>
			{
				{ "addressBookId", addressBookId },
			});
			return await PostAsync<ApiContactImport, ApiFileMedia>(request, apiFileMedia);
		}
Beispiel #9
0
		/// <summary>
		/// Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel. Must include one column called "Email". Any other columns will attempt to map to your custom data fields. The ID of returned object can be used to query import progress.
		/// </summary>
		public ServiceResult<ApiContactImport> PostContactsImport(ApiFileMedia apiFileMedia)
		{
			return PostContactsImportAsync(apiFileMedia).Result;
		}
Beispiel #10
0
		/// <summary>
		/// Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel. Must include one column called "Email". Any other columns will attempt to map to your custom data fields. The ID of returned object can be used to query import progress.
		/// </summary>
		public ServiceResult<ApiContactImport> PostAddressBookContactsImport(int addressBookId, ApiFileMedia apiFileMedia)
		{
			return PostAddressBookContactsImportAsync(addressBookId, apiFileMedia).Result;
		}
Beispiel #11
0
 public void Ensure_PostAddressBookContactsImport_Works()
 {
     var client = GetClient();
     var file = new ApiFileMedia();
     AssertResult(() => client.PostAddressBookContactsImport(sampleAddressBookId, file));
 }
Beispiel #12
0
 public void Ensure_PostImageFolderImages_Works()
 {
     var client = GetClient();
     var file = new ApiFileMedia();
     AssertResult(() => client.PostImageFolderImages(sampleImageFolderId, file));
 }
Beispiel #13
0
 public void Ensure_PostDocumentFolderDocuments_Works()
 {
     var client = GetClient();
     var file = new ApiFileMedia();
     AssertResult(() => client.PostDocumentFolderDocuments(sampleDocumentFolderId, file));
 }
Beispiel #14
0
 public void Ensure_PostContactsImport_Works()
 {
     var client = GetClient();
     var file = new ApiFileMedia();
     AssertResult(() => client.PostContactsImport(file));
 }