示例#1
0
        /// <summary>
        /// Create a Clear Lists Activity.
        /// </summary>
        /// <param name="lists">Array of list id's to be cleared.</param>
        /// <returns>Returns an Activity object.</returns>
        public Activity AddClearListsActivity(IList <string> lists)
        {
            if (lists == null || lists.Count.Equals(0))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ActivityOrId);
            }

            string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.ClearListsActivity);

            ClearContactList clearContact = new ClearContactList()
            {
                Lists = lists
            };
            string         json     = clearContact.ToJSON();
            RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var activity = response.Get <Activity>();
                return(activity);
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
示例#2
0
        /// <summary>
        /// Clears all contacts from one or more contact lists.
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="lists">Array of list id's to be cleared.</param>
        /// <returns>Returns an Activity object.</returns>
        public Activity ClearLists(string accessToken, string apiKey, IList <string> lists)
        {
            Activity activity = null;
            string   url      = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.ClearListsActivity);

            ClearContactList clearContact = new ClearContactList()
            {
                Lists = lists
            };
            string       json     = clearContact.ToJSON();
            CUrlResponse response = RestClient.Post(url, accessToken, apiKey, json);

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

            if (response.HasData)
            {
                activity = response.Get <Activity>();
            }

            return(activity);
        }