Exemplo n.º 1
0
        /// <summary>
        /// Create an Export Contacts Activity.
        /// </summary>
        /// <param name="exportContacts">Export contacts object.</param>
        /// <returns>Returns an Activity object.</returns>
        public Activity AddExportContactsActivity(ExportContacts exportContacts)
        {
            if (exportContacts == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ActivityOrId);
            }

            string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.ExportContactsActivity);
            string json = exportContacts.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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create an Export Contacts Activity.
        /// </summary>
        /// <param name="exportContacts">Export contacts object.</param>
        /// <returns>Returns an Activity object.</returns>
        /// <exception cref="IllegalArgumentException">IllegalArgumentException</exception>
        public Activity AddExportContactsActivity(ExportContacts exportContacts)
        {
            if (exportContacts == null)
            {
                throw new IllegalArgumentException(Config.Errors.ActivityOrId);
            }

            return ActivityService.AddExportContactsActivity(AccessToken, APIKey, exportContacts);
        }
Exemplo n.º 3
0
        public void LiveActivityExportContactsTest()
        {
            var cc = new ConstantContactFactory(userServiceContext);
            var activityService = cc.CreateActivityService();

            var lists = new List<string>() { "1" }; 

            ExportContacts export = new ExportContacts();
            export.Lists = lists;

            Activity activity = activityService.AddExportContactsActivity(export);

            Assert.IsNotNull(activity);
            Assert.IsNotNull(activity.Id);
            Assert.AreEqual(activity.Type, "EXPORT_CONTACTS");
        }
Exemplo n.º 4
0
        public void LiveActivityExportContactsTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);
            var lists = new List<string>() { "1" };

            ExportContacts export = new ExportContacts();
            export.Lists = lists;

            Activity activity = cc.AddExportContactsActivity(export);

            Assert.IsNotNull(activity);
            Assert.IsNotNull(activity.Id);
            Assert.AreEqual(activity.Type, "EXPORT_CONTACTS");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create an Export Contacts Activity.
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="exportContacts">Export contacts object.</param>
        /// <returns>Returns an Activity object.</returns>
        public Activity AddExportContactsActivity(string accessToken, string apiKey, ExportContacts exportContacts)
        {
            Activity activity = null;
            string url = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.ExportContactsActivity);
            string json = exportContacts.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;
        }