/// <summary> /// Get all bulk activities status filtered by status and/or type. /// </summary> /// <param name="type">Bulk activity type</param> /// <param name="status">Bulk activity status</param> /// <returns>A list of StatusReport</returns> /// <exception cref="CtctException">CtctException.</exception> public IList <StatusReport> GetBulkActivitiesStatus(BulkActivityType type, BulkActivityStatus status) { string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.Activities); var uriBuilder = new UriBuilder(url); var query = HttpUtility.ParseQueryString(uriBuilder.Query); if (type != BulkActivityType.ALL) { query["type"] = Enum.GetName(typeof(BulkActivityType), type); } if (status != BulkActivityStatus.ALL) { query["status"] = Enum.GetName(typeof(BulkActivityStatus), status); } uriBuilder.Query = query.ToString(); url = uriBuilder.ToString(); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var bulkStatusReport = response.Get <List <StatusReport> >(); return(bulkStatusReport); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Retrieve all existing attributes for an item /// </summary> /// <param name="eventId">Event id</param> /// <param name="itemId">EventItem id</param> /// <returns>A list of Attributes</returns> public List <CTCT.Components.EventSpot.Attribute> GetAllEventItemAttributes(string eventId, string itemId) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(itemId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.ItemAttribute), eventId, itemId, null); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var attrib = response.Get <List <CTCT.Components.EventSpot.Attribute> >(); return(attrib); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Update contact details for a specific contact. /// </summary> /// <param name="contact">Contact to be updated.</param> /// <param name="actionByVisitor">Set to true if action by visitor.</param> /// <returns>Returns the updated contact.</returns> public Contact UpdateContact(Contact contact, bool actionByVisitor) { if (contact == null) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.ContactOrId); } if (contact.Id == null) { throw new ConstantContactClientException(ConstantContactClient.Resources.Errors.UpdateId); } string url = String.Concat(Settings.Endpoints.Default.BaseUrl, String.Format(Settings.Endpoints.Default.Contact, contact.Id), actionByVisitor ? String.Format("?action_by={0}", ActionBy.ActionByVisitor) : null); string json = contact.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var updateContact = response.Get <Contact>(); return(updateContact); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Retrieve detailed information for a specific event registrant /// </summary> /// <param name="eventId">Event id</param> /// <param name="registrantId">Redistrant id</param> /// <returns>Registrant details</returns> public Registrant GetRegistrant(string eventId, string registrantId) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(registrantId)) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.InvalidId); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventRegistrant), eventId, registrantId); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var registrant = response.Get <Registrant>(); return(registrant); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Retrieve specific event item /// </summary> /// <param name="eventId">Event id</param> /// <param name="itemId">Eventitem id</param> /// <returns>EventItem object</returns> public EventItem GetEventItem(string eventId, string itemId) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(itemId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventItem), eventId, itemId); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var eventItem = response.Get <EventItem>(); return(eventItem); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Update an event /// </summary> /// <param name="eventId">Event id to be updated</param> /// <param name="eventSpot">The new values for event</param> /// <returns>The updated event</returns> public IndividualEvent PutEventSpot(string eventId, IndividualEvent eventSpot) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (eventSpot == null) { throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull); } string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventSpots, "/", eventId); string json = eventSpot.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var individualEvent = response.Get <IndividualEvent>(); return(individualEvent); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Update a specific email campaign. /// </summary> /// <param name="campaign">Campaign to be updated.</param> /// <returns>Returns a campaign.</returns> public EmailCampaign UpdateCampaign(EmailCampaign campaign) { if (campaign == null) { throw new IllegalArgumentException(CTCT.Resources.Errors.EmailCampaignOrId); } string url = String.Concat(Settings.Endpoints.Default.BaseUrl, String.Format(Settings.Endpoints.Default.Campaign, campaign.Id)); // Invalidate data that are not supported by the update API procedure campaign.CreatedDate = null; campaign.TrackingSummary = null; campaign.ModifiedDate = null; campaign.IsVisibleInUI = null; // Convert to JSON string string json = campaign.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var emailCampaign = response.Get <EmailCampaign>(); return(emailCampaign); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Create a specific event item /// </summary> /// <param name="eventId">Event id</param> /// <param name="eventItem">EventItem id</param> /// <returns>The newly created EventItem</returns> public EventItem PostEventItem(string eventId, EventItem eventItem) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (eventItem == null) { throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventItem), eventId, null); string json = eventItem.ToJSON(); RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var eventIt = response.Get <EventItem>(); return(eventIt); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Move files to a different folder /// </summary> /// <param name="folderId">The id of the folder</param> /// <param name="fileIds">List of file ids</param> /// <returns>Returns a list of FileMoveResult objects.</returns> public IList <FileMoveResult> MoveLibraryFile(string folderId, IList <string> fileIds) { if (string.IsNullOrEmpty(folderId)) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId); } if (fileIds == null || fileIds.Count.Equals(0)) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId); } string url = String.Concat(Settings.Endpoints.Default.BaseUrl, string.Format(Settings.Endpoints.Default.MyLibraryFolderFiles, folderId)); string json = fileIds.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var movedFiles = response.Get <IList <FileMoveResult> >(); return(movedFiles); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Update an individual event fee /// </summary> /// <param name="eventId">Event id</param> /// <param name="feeId">EventFee id</param> /// <param name="eventFee">The new values of EventFee</param> /// <returns>The updated EventFee</returns> public EventFee PutEventFee(string eventId, string feeId, EventFee eventFee) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(feeId)) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.InvalidId); } if (eventFee == null) { throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.ObjectNull); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventFees), eventId, feeId); string json = eventFee.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var evFee = response.Get <EventFee>(); return(evFee); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Update a promo code for an event /// </summary> /// <param name="eventId">Event id</param> /// <param name="promocodeId">Promocode id</param> /// <param name="promocode">The new Promocode values</param> /// <returns>The newly updated Promocode</returns> public Promocode PutPromocode(string eventId, string promocodeId, Promocode promocode) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(promocodeId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (promocode == null) { throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventPromocode), eventId, promocodeId); string json = promocode.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var promoc = response.Get <Promocode>(); return(promoc); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
public ExcludeUnsubscribeResponse ExcludeOrUnscribe(string email, string listId = null) { if (string.IsNullOrEmpty(email)) { throw new IllegalArgumentException(Resources.Errors.GeneralId); } string url = string.Empty; if (listId == null) { url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.ListsExclusions); } else { url = String.Concat(Settings.Endpoints.Default.BaseUrl, string.Format(Settings.Endpoints.Default.ListExclusions, listId)); } RawApiResponse response = RestClient.PostXwwwFormUrlEncoded(url, UserServiceContext.ApiKey, HttpUtility.UrlEncode("email" + "=" + email)); try { ResultSet <ExcludeUnsubscribeResponse> excludeUnsubscribeResponse = response.Get <ResultSet <ExcludeUnsubscribeResponse> >(); return(excludeUnsubscribeResponse.Results.FirstOrDefault()); } catch (Exception ex) { throw new KlaviyoException(ex.ToString()); } }
/// <summary> /// Updates an existing attributes for an item /// </summary> /// <param name="eventId">Event id</param> /// <param name="itemId">EventItem id</param> /// <param name="attributeId">Attribute id</param> /// <param name="attribute">Attribute new values</param> /// <returns>The newly updated attribute</returns> public CTCT.Components.EventSpot.Attribute PutEventItemAttribute(string eventId, string itemId, string attributeId, CTCT.Components.EventSpot.Attribute attribute) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(itemId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (string.IsNullOrWhiteSpace(attributeId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } if (attribute == null) { throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull); } string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.ItemAttribute), eventId, itemId, attributeId); string json = attribute.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var attrib = response.Get <CTCT.Components.EventSpot.Attribute>(); return(attrib); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Publish or cancel an event by changing the status of the event /// </summary> /// <param name="eventId">Event id</param> /// <param name="eventStatus">New status of the event. ACTIVE" and "CANCELLED are allowed</param> /// <returns>The updated event</returns> public IndividualEvent PatchEventSpotStatus(string eventId, EventStatus eventStatus) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventSpots, "/", eventId); var patchRequests = new List <PatchRequest>(); var patchRequest = new PatchRequest("REPLACE", "#/status", eventStatus.ToString()); patchRequests.Add(patchRequest); string json = patchRequests.ToJSON(); RawApiResponse response = RestClient.Patch(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var individualEvent = response.Get <IndividualEvent>(); return(individualEvent); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <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); } }
/// <summary> /// Get ClickActivity at the given url. /// </summary> /// <param name="url">The url from which to retrieve an array of @link ClickActivity.</param> /// <returns>ResultSet containing a results array of @link ClickActivity.</returns> private ResultSet <ClickActivity> GetClicks(string url) { RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var results = response.Get <ResultSet <ClickActivity> >(); 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> /// Get a list of activities. /// </summary> /// <returns>Returns the list of activities.</returns> public IList <Activity> GetActivities() { string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.Activities); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var activities = response.Get <IList <Activity> >(); return(activities); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Get files /// </summary> /// <param name="type">The type of the files to retrieve</param> /// <param name="source">Specifies to retrieve files from a particular source</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> GetLibraryFiles(FileTypes?type, FilesSources?source, int?limit, Pagination pag) { string url = (pag == null) ? String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.MyLibraryFiles, GetQueryParameters(new object[] { "type", type, "source", source, "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); } }
/// <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 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 ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Get lists within an account. /// </summary> /// <param name="modifiedSince">limit contacts retrieved to contacts modified since the supplied date</param> /// <returns>Returns a list of contact lists.</returns> public IList <ContactList> GetLists(DateTime?modifiedSince) { string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.Lists, GetQueryParameters(new object[] { "modified_since", Extensions.ToISO8601String(modifiedSince) })); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var lists = response.Get <IList <ContactList> >(); return(lists); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Get MyLibrary usage information /// </summary> /// <returns>Returns a MyLibraryInfo object</returns> public MyLibraryInfo GetLibraryInfo() { string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.MyLibraryInfo); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var result = response.Get <MyLibraryInfo>(); return(result); } catch (Exception ex) { throw new ConstantContactClientException(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> /// Gets the status report for an activity by ID /// </summary> /// <param name="activityId">The activity ID</param> /// <returns>The StatusReport</returns> public StatusReport GetBulkActivityStatusById(string activityId) { string url = String.Concat(Settings.Endpoints.Default.BaseUrl, String.Format(Settings.Endpoints.Default.Activity, activityId)); RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var bulkStatusReport = response.Get <StatusReport>(); return(bulkStatusReport); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Update a specific schedule for a campaign. /// </summary> /// <param name="campaignId">Campaign id to be scheduled.</param> /// <param name="schedule">Schedule to retrieve.</param> /// <returns>Returns the updated schedule object.</returns> public Schedule UpdateSchedule(string campaignId, Schedule schedule) { string url = String.Concat(Settings.Endpoints.Default.BaseUrl, String.Format(Settings.Endpoints.Default.CampaignSchedule, campaignId, schedule.Id)); string json = schedule.ToJSON(); RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var upd = response.Get <Schedule>(); return(upd); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <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); } }
/// <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 ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Get account summary information /// </summary> /// <returns>An AccountSummaryInformation object</returns> public AccountSummaryInformation GetAccountSummaryInformation() { // Construct access URL string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.AccountSummaryInformation); // Get REST response RawApiResponse response = RestClient.Get(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey); try { var result = response.Get <AccountSummaryInformation>(); return(result); } catch (Exception ex) { throw new ConstantContactClientException(ex.Message, ex); } }
/// <summary> /// Create a Remove Contacts Multipart Activity /// </summary> /// <param name="fileName">The file name to be imported</param> /// <param name="fileContent">The file content to be imported</param> /// <param name="lists">Array of list's id</param> /// <returns>Returns an Activity object.</returns> public Activity RemoveContactsMultipartActivity(string fileName, byte[] fileContent, IList <string> lists) { if (string.IsNullOrEmpty(fileName)) { throw new IllegalArgumentException(CTCT.Resources.Errors.FileNameNull); } var extension = Path.GetExtension(fileName).ToLowerInvariant(); string[] fileTypes = new string[4] { ".txt", ".csv", ".xls", ".xlsx" }; if (!((IList <string>)fileTypes).Contains(extension)) { throw new IllegalArgumentException(CTCT.Resources.Errors.FileTypeInvalid); } if (fileContent == null) { throw new IllegalArgumentException(CTCT.Resources.Errors.FileNull); } 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.RemoveFromListsActivity); byte[] data = MultipartBuilder.CreateMultipartContent(fileName, fileContent, lists); RawApiResponse response = RestClient.PostMultipart(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, data); try { var activity = response.Get <Activity>(); return(activity); } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }