/// <summary>
        /// Delete a specific folder
        /// </summary>
        /// <param name="folder">The MyLibraryFolder</param>
        /// <returns>Returns true if folder was deleted successfully, false otherwise</returns>
        public bool DeleteLibraryFolder(MyLibraryFolder folder)
        {
            if (folder == null)
            {
                throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId);
            }

            return(DeleteLibraryFolder(folder.Id));
        }
Beispiel #2
0
        /// <summary>
        /// Get a folder by Id
        /// </summary>
        /// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="folderId">The id of the folder</param>
        /// <returns>Returns a MyLibraryFolder object.</returns>
        public MyLibraryFolder GetLibraryFolder(string accessToken, string apiKey, string folderId)
        {
            MyLibraryFolder folder   = null;
            string          url      = String.Concat(Config.Endpoints.BaseUrl, String.Format(Config.Endpoints.MyLibraryFolder, folderId));
            CUrlResponse    response = RestClient.Get(url, accessToken, apiKey);

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

            if (response.HasData)
            {
                folder = Component.FromJSON <MyLibraryFolder>(response.Body);
            }

            return(folder);
        }
Beispiel #3
0
        /// <summary>
        /// Add new folder to MyLibrary
        /// </summary>
        /// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="folder">Folder to be added (with name and parent id)</param>
        /// <returns>Returns a MyLibraryFolder object.</returns>
        public MyLibraryFolder AddLibraryFolder(string accessToken, string apiKey, MyLibraryFolder folder)
        {
            MyLibraryFolder newFolder = null;
            string          url       = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.MyLibraryFolders);
            string          json      = folder.ToJSON();
            CUrlResponse    response  = RestClient.Post(url, accessToken, apiKey, json);

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

            if (response.HasData)
            {
                newFolder = Component.FromJSON <MyLibraryFolder>(response.Body);
            }

            return(newFolder);
        }
Beispiel #4
0
        /// <summary>
        /// Update name and parent_id for a specific folder
        /// </summary>
        /// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="folder">Folder to be added (with name and parent id)</param>
        /// <param name="includePayload">Determines if update's folder JSON payload is returned</param>
        /// <returns>Returns a MyLibraryFolder object.</returns>
        public MyLibraryFolder UpdateLibraryFolder(string accessToken, string apiKey, MyLibraryFolder folder, bool?includePayload)
        {
            MyLibraryFolder updatedFolder = null;
            string          url           = String.Concat(Config.Endpoints.BaseUrl, string.Format(Config.Endpoints.MyLibraryFolder, folder.Id), GetQueryParameters(new object[] { "include_payload", includePayload }));
            string          json          = folder.ToJSON();
            CUrlResponse    response      = RestClient.Put(url, accessToken, apiKey, json);

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

            if (response.HasData)
            {
                updatedFolder = Component.FromJSON <MyLibraryFolder>(response.Body);
            }

            return(updatedFolder);
        }
        /// <summary>
        /// Add new folder to MyLibrary
        /// </summary>
        /// <param name="folder">Folder to be added (with name and parent id)</param>
        /// <returns>Returns a MyLibraryFolder object.</returns>
        public MyLibraryFolder AddLibraryFolder(MyLibraryFolder folder)
        {
            if (folder == null)
            {
                throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId);
            }

            string         url      = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.MyLibraryFolders);
            string         json     = folder.ToJSON();
            RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var newFolder = response.Get <MyLibraryFolder>();
                return(newFolder);
            }
            catch (Exception ex)
            {
                throw new ConstantContactClientException(ex.Message, ex);
            }
        }
        /// <summary>
        /// Update name and parent_id for a specific folder
        /// </summary>
        /// <param name="folder">Folder to be added (with name and parent id)</param>
        /// <param name="includePayload">Determines if update's folder JSON payload is returned</param>
        /// <returns>Returns a MyLibraryFolder object.</returns>
        public MyLibraryFolder UpdateLibraryFolder(MyLibraryFolder folder, bool?includePayload)
        {
            if (folder == null)
            {
                throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId);
            }

            string         url      = String.Concat(Settings.Endpoints.Default.BaseUrl, string.Format(Settings.Endpoints.Default.MyLibraryFolder, folder.Id), GetQueryParameters(new object[] { "include_payload", includePayload }));
            string         json     = folder.ToJSON();
            RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var updatedFolder = response.Get <MyLibraryFolder>();
                return(updatedFolder);
            }
            catch (Exception ex)
            {
                throw new ConstantContactClientException(ex.Message, ex);
            }
        }
 /// <summary>
 /// Update name and parent_id for a specific folder
 /// </summary>
 /// <param name="folder">Folder to be added (with name and parent id)</param>
 /// <returns>Returns a MyLibraryFolder object.</returns>
 public MyLibraryFolder UpdateLibraryFolder(MyLibraryFolder folder)
 {
     return(UpdateLibraryFolder(folder, null));
 }