Exemple #1
0
		/// <summary>
		/// Get all existing MyLibrary folders
		/// </summary>
		/// <param name="sortBy">Specifies how the list of folders is sorted</param>
		/// <param name="limit">Specifies the number of results per page in the output, from 1 - 50, default = 50.</param>
		/// <param name="pag">Pagination object.</param>
		/// <returns>Returns a collection of MyLibraryFolder objects.</returns>
		public ResultSet<MyLibraryFolder> GetLibraryFolders(FoldersSortBy? sortBy, int? limit, Pagination pag)
		{
            string url = (pag == null) ? String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.MyLibraryFolders, GetQueryParameters(new object[] { "sort_by", sortBy, "limit", limit })) : pag.GetNextUrl();
            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var results = response.Get<ResultSet<MyLibraryFolder>>();
                return results;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            } 
		}
        /// <summary>
        /// Get a result set of bounces for a given campaign.
        /// </summary>
        /// <param name="campaignId">Campaign id.</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
		/// <param name="createdSince">Filter for bounces created since the supplied date in the collection</param>
        /// <param name="pag">Pagination object.</param>
        /// <returns>ResultSet containing a results array of @link BounceActivity.</returns>
        private ResultSet<BounceActivity> GetBounces(string campaignId, int? limit, DateTime? createdSince, Pagination pag)
        {
            string url = (pag == null) ? ConstructUrl(Settings.Endpoints.Default.CampaignTrackingBounces, new object[] { campaignId }, new object[] { "limit", limit, "created_since", Extensions.ToISO8601String(createdSince) }) : pag.GetNextUrl();
            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var results = response.Get<ResultSet<BounceActivity>>();
                return results;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
 /// <summary>
 /// Get a set of campaigns.
 /// </summary>
 /// <param name="status">Returns list of email campaigns with specified status.</param>
 /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
 /// <param name="modifiedSince">limit campaigns to campaigns modified since the supplied date</param>
 /// <param name="pag">Pagination object returned by a previous call to GetCampaigns</param>
 /// <returns>Returns a ResultSet of campaigns.</returns>
 public ResultSet<EmailCampaign> GetCampaigns(CampaignStatus? status, int? limit, DateTime? modifiedSince, Pagination pag)
 {
     string url = (pag == null) ? String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.Campaigns, GetQueryParameters(new object[] { "status", status, "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince) })) : pag.GetNextUrl();
     RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
     try
     {
         var results = response.Get<ResultSet<EmailCampaign>>();
         return results;
     }
     catch (Exception ex)
     {
         throw new CtctException(ex.Message, ex);
     } 
 }
        /// <summary>
        /// View all existing events
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 50</param>
        /// <param name="pag">Pagination object</param>
        /// <returns>ResultSet containing a results array of IndividualEvents</returns>
        public ResultSet<IndividualEvent> GetAllEventSpots(string accessToken, string apiKey, int? limit, Pagination pag)
        {
            string url = (pag == null) ? String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.EventSpots, GetQueryParameters(new object[] { "limit", limit })) : pag.GetNextUrl();

            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);
            if (response.HasData)
            {
                return response.Get<ResultSet<IndividualEvent>>();
            }
            else if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }
            return new ResultSet<IndividualEvent>();
        }
Exemple #5
0
        /// <summary>
        /// View all existing events
        /// </summary>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 50</param>
        /// <param name="pag">Pagination object</param>
        /// <returns>ResultSet containing a results array of IndividualEvents</returns>
        public ResultSet<IndividualEvent> GetAllEventSpots(int? limit, Pagination pag)
        {
            string url = (pag == null) ? String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventSpots, GetQueryParameters(new object[] { "limit", limit })) : pag.GetNextUrl();

            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var individualEventSet = response.Get<ResultSet<IndividualEvent>>();
                return individualEventSet;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
Exemple #6
0
		/// <summary>
        /// Get an array of contacts.
        /// </summary>
        /// <param name="email">Match the exact email address.</param>
        /// <param name="limit">Limit the number of returned values.</param>
        /// <param name="modifiedSince">limit contact to contacts modified since the supplied date</param>
		/// <param name="status">Match the exact contact status.</param>
        /// <param name="pag">Pagination object.</param>
        /// <returns>Returns a list of contacts.</returns>
        private ResultSet<Contact> GetContacts(string email, int? limit, DateTime? modifiedSince, ContactStatus? status, Pagination pag)
        {
            // Construct access URL
            string url = (pag == null) ? ConstructUrl(Settings.Endpoints.Default.Contacts, null, new object[] { "email", email, "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince), "status", status }) : pag.GetNextUrl();
            // Get REST response
            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var results = response.Get<ResultSet<Contact>>();
                return results;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
		/// <summary>
		/// Get all existing MyLibrary folders
		/// </summary>
		/// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
		/// <param name="sortBy">Specifies how the list of folders is sorted</param>
		/// <param name="limit">Specifies the number of results per page in the output, from 1 - 50, default = 50.</param>
		/// <param name="pag">Pagination object.</param>
		/// <returns>Returns a collection of MyLibraryFolder objects.</returns>
		public ResultSet<MyLibraryFolder> GetLibraryFolders(string accessToken, string apiKey, FoldersSortBy? sortBy, int? limit, Pagination pag)
		{
			ResultSet<MyLibraryFolder> results = null;
            string url = (pag == null) ? String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.MyLibraryFolders, GetQueryParameters(new object[] { "sort_by", sortBy, "limit", limit})) : pag.GetNextUrl();
            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                results = response.Get<ResultSet<MyLibraryFolder>>();
            }

            return results;
		}
        /// <summary>
        /// Get a result set of bounces for a given campaign.
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="campaignId">Campaign id.</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
        /// <param name="pag">Pagination object.</param>
        /// <returns>ResultSet containing a results array of @link BounceActivity.</returns>
        private ResultSet<BounceActivity> GetBounces(string accessToken, string apiKey, string campaignId, int? limit, Pagination pag)
        {
            ResultSet<BounceActivity> results = null;
            string url = (pag == null) ? Config.ConstructUrl(Config.Endpoints.CampaignTrackingBounces, new object[] { campaignId }, new object[] { "limit", limit }) : pag.GetNextUrl();
            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                results = Component.FromJSON<ResultSet<BounceActivity>>(response.Body);
            }

            return results;
        }
        /// <summary>
        /// Get a set of campaigns.
        /// </summary>
        /// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="status">Returns list of email campaigns with specified status.</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
        /// <param name="modifiedSince">limit campaigns to campaigns modified since the supplied date</param>
        /// <param name="pag">Pagination object returned by a previous call to GetCampaigns</param>
        /// <returns>Returns a ResultSet of campaigns.</returns>
        public ResultSet<EmailCampaign> GetCampaigns(string accessToken, string apiKey, CampaignStatus? status, int? limit, DateTime? modifiedSince, Pagination pag)
        {
            ResultSet<EmailCampaign> results = null;
            string url = (pag == null) ? String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.Campaigns, GetQueryParameters(new object[] { "status", status, "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince) })) : pag.GetNextUrl();
            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                results = response.Get<ResultSet<EmailCampaign>>();
            }

            return results;
        }
		/// <summary>
		/// Get all activities for a given contact.
		/// </summary>
		/// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="contactId">Contact id.</param>
		/// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
		/// <param name="createdSince">Filter for activities created since the supplied date in the collection</param>	 
		/// <param name="pag">Pagination object.</param>
		/// <returns>ResultSet containing a results array of @link ContactActivity</returns>
		public ResultSet<ContactActivity> GetActivities(string accessToken, string apiKey, string contactId, int? limit, DateTime? createdSince, Pagination pag)
		{
			ResultSet<ContactActivity> results = null;
            string url = (pag == null) ? Config.ConstructUrl(Config.Endpoints.ContactTrackingActivities, new object[] { contactId }, new object[] { "limit", limit, "created_since", Extensions.ToISO8601String(createdSince) }) : pag.GetNextUrl();
            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                results = Component.FromJSON<ResultSet<ContactActivity>>(response.Body);
            }

            return results;
		}
        /// <summary>
        /// Get all activities for a given contact.
        /// </summary>
        /// <param name="contactId">Contact id.</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
        /// <param name="createdSince">Filter for activities created since the supplied date in the collection</param>	 
        /// <param name="pag">Pagination object.</param>
        /// <returns>ResultSet containing a results array of @link ContactActivity</returns>
        public ResultSet<ContactActivity> GetActivities(string contactId, int? limit, DateTime? createdSince, Pagination pag)
        {
            if (string.IsNullOrEmpty(contactId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ContactTrackingOrId);
            }

            string url = (pag == null) ? ConstructUrl(Settings.Endpoints.Default.ContactTrackingActivities, new object[] { contactId }, new object[] { "limit", limit, "created_since", Extensions.ToISO8601String(createdSince) }) : pag.GetNextUrl();
            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var results = response.Get<ResultSet<ContactActivity>>();
                return results;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }    
        }
Exemple #12
0
        /// <summary>
        /// Get an array of contacts.
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="email">Match the exact email address.</param>
        /// <param name="limit">Limit the number of returned values.</param>
        /// <param name="modifiedSince">limit contact to contacts modified since the supplied date</param>
        /// <param name="pag">Pagination object.</param>
        /// <returns>Returns a list of contacts.</returns>
        private ResultSet<Contact> GetContacts(string accessToken, string apiKey, string email, int? limit, DateTime? modifiedSince, Pagination pag)
        {
            ResultSet<Contact> results = null;
            // Construct access URL
            string url = (pag == null) ? Config.ConstructUrl(Config.Endpoints.Contacts, null, new object[] { "email", email, "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince) }) : pag.GetNextUrl();
            // Get REST response
            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);
            
            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                // Convert from JSON
                results = response.Get<ResultSet<Contact>>();
            }

            return results;
        }
 /// <summary>
 /// Get clicks for the provided Pagination page.
 /// </summary>
 /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
 /// <param name="apiKey">The API key for the application</param>
 /// <param name="createdSince">filter for activities created since the supplied date in the collection</param>
 /// <param name="pag">Pagination object.</param>
 /// <returns>ResultSet containing a results array of @link ClickActivity.</returns>
 public ResultSet<ClickActivity> GetClicks(string accessToken, string apiKey, DateTime? createdSince, Pagination pag)
 {
     return GetClicks(accessToken, apiKey, pag.GetNextUrl());
 }
Exemple #14
0
        /// <summary>
        /// Get all contacts from an individual list.
        /// </summary>
        /// <param name="listId">List id to retrieve contacts for.</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
        /// <param name="modifiedSince">limit contacts retrieved to contacts modified since the supplied date</param>
        /// <param name="pag">Pagination object.</param>
        /// <returns>Returns a list of contacts.</returns>
        public ResultSet<Contact> GetContactsFromList(string listId, int? limit, DateTime? modifiedSince, Pagination pag)
        {
            if (string.IsNullOrEmpty(listId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ListOrId);
            }

            string url = (pag == null) ? ConstructUrl(Settings.Endpoints.Default.ListContacts, new object[] { listId }, new object[] { "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince) }) : pag.GetNextUrl();
            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var contacts = response.Get<ResultSet<Contact>>();
                return contacts;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            } 
        }
 /// <summary>
 /// Get bounces for a given contact.
 /// </summary>
 /// <param name="contactId">Contact id.</param>
 /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
 /// <param name="pag">Pagination object.</param>
 /// <returns>ResultSet containing a results array of @link BounceActivity</returns>
 private ResultSet<BounceActivity> GetBounces(string contactId, int? limit, Pagination pag)
 {
     string url = (pag == null) ? ConstructUrl(Settings.Endpoints.Default.ContactTrackingBounces, new object[] { contactId }, new object[] { "limit", limit }) : pag.GetNextUrl();
     RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
     try
     {
         var results = response.Get<ResultSet<BounceActivity>>();
         return results;
     }
     catch (Exception ex)
     {
         throw new CtctException(ex.Message, ex);
     }
 }
 /// <summary>
 /// Get clicks for the provided Pagination page.
 /// </summary>
 /// <param name="pag">Pagination object.</param>
 /// <returns>ResultSet containing a results array of @link ClickActivity.</returns>
 public ResultSet<ClickActivity> GetClicks(Pagination pag)
 {
     return GetClicks(pag.GetNextUrl());
 }
Exemple #17
0
        /// <summary>
        /// Retrieve a list of registrants for the specified event
        /// </summary>
        /// <param name="eventId">Event id</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 50</param>
        /// <param name="pag">Pagination object</param>
        /// <returns>ResultSet containing a results array of Registrant</returns>
        public ResultSet<Registrant> GetAllRegistrants(string eventId, int? limit, Pagination pag)
        {
            if (string.IsNullOrWhiteSpace(eventId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }

            string url = (pag == null) ? String.Concat(String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventRegistrant), eventId, null), GetQueryParameters(new object[] { "limit", limit })) : pag.GetNextUrl();

            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var registrantSet = response.Get<ResultSet<Registrant>>();
                return registrantSet;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
Exemple #18
0
        /// <summary>
        /// Get all contacts from an individual list.
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="listId">List id to retrieve contacts for.</param>
        /// <param name="limit">Specifies the number of results per page in the output, from 1 - 500, default = 500.</param>
        /// <param name="modifiedSince">limit contacts retrieved to contacts modified since the supplied date</param>
        /// <param name="pag">Pagination object.</param>
        /// <returns>Returns a list of contacts.</returns>
        private ResultSet<Contact> GetContactsFromList(string accessToken, string apiKey, string listId, int? limit, DateTime? modifiedSince, Pagination pag)
        {
            var contacts = new ResultSet<Contact>();
            string url = (pag == null) ? Config.ConstructUrl(Config.Endpoints.ListContacts, new object[] { listId }, new object[] { "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince) }) : pag.GetNextUrl();
            CUrlResponse response = RestClient.Get(url, accessToken, apiKey);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                contacts = response.Get<ResultSet<Contact>>();
            }

            return contacts;
        }
Exemple #19
0
		/// <summary>
		/// Get files from a specific folder
		/// </summary>
		/// <param name="folderId">The id of the folder from which to retrieve files</param>
		/// <param name="limit">Specifies the number of results per page in the output, from 1 - 50, default = 50.</param>
		/// <param name="pag">Pagination object.</param>
		/// <returns>Returns a collection of MyLibraryFile objects.</returns>
		public ResultSet<MyLibraryFile> GetLibraryFilesByFolder(string folderId, int? limit, Pagination pag)
		{
            if (string.IsNullOrEmpty(folderId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.MyLibraryOrId);
            }

            string url = (pag == null) ? String.Concat(Settings.Endpoints.Default.BaseUrl, String.Format(Settings.Endpoints.Default.MyLibraryFolderFiles, folderId), GetQueryParameters(new object[] { "limit", limit})) : pag.GetNextUrl();
            RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey);
            try
            {
                var results = response.Get<ResultSet<MyLibraryFile>>();
                return results;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
		}