/// <summary> /// Exports contacts from the specified contact list to a CSV file. /// </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 ExportContacts(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); }
/// <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); } }