Ejemplo n.º 1
0
        /// <summary>
        /// Delete a specific file
        /// </summary>
        /// <param name="file">The MyLibraryFile</param>
        /// <returns>Returns true if folder was deleted successfully, false otherwise</returns>
        public bool DeleteLibraryFile(MyLibraryFile file)
        {
            if (file == null)
            {
                throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId);
            }

            return(DeleteLibraryFile(file.Id));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get file after id
        /// </summary>
        /// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="fileId">The id of the file</param>
        /// <returns>Returns a MyLibraryFile object.</returns>
        public MyLibraryFile GetLibraryFile(string accessToken, string apiKey, string fileId)
        {
            MyLibraryFile file     = null;
            string        url      = String.Concat(Config.Endpoints.BaseUrl, String.Format(Config.Endpoints.MyLibraryFile, fileId));
            CUrlResponse  response = RestClient.Get(url, accessToken, apiKey);

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

            if (response.HasData)
            {
                file = Component.FromJSON <MyLibraryFile>(response.Body);
            }

            return(file);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update a specific file
        /// </summary>
        /// <param name="accessToken">Access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="file">File to be updated</param>
        /// <param name="includePayload">Determines if update's folder JSON payload is returned</param>
        /// <returns>Returns a MyLibraryFile object.</returns>
        public MyLibraryFile UpdateLibraryFile(string accessToken, string apiKey, MyLibraryFile file, bool?includePayload)
        {
            MyLibraryFile updatedFile = null;
            string        url         = String.Concat(Config.Endpoints.BaseUrl, string.Format(Config.Endpoints.MyLibraryFile, file.Id), GetQueryParameters(new object[] { "include_payload", includePayload }));
            string        json        = file.ToJSON();
            CUrlResponse  response    = RestClient.Put(url, accessToken, apiKey, json);

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

            if (response.HasData)
            {
                updatedFile = Component.FromJSON <MyLibraryFile>(response.Body);
            }

            return(updatedFile);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update a specific file
        /// </summary>
        /// <param name="file">File to be updated</param>
        /// <param name="includePayload">Determines if update's folder JSON payload is returned</param>
        /// <returns>Returns a MyLibraryFile object.</returns>
        public MyLibraryFile UpdateLibraryFile(MyLibraryFile file, bool?includePayload)
        {
            if (file == null)
            {
                throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.MyLibraryOrId);
            }

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

            try
            {
                var updatedFile = response.Get <MyLibraryFile>();
                return(updatedFile);
            }
            catch (Exception ex)
            {
                throw new ConstantContactClientException(ex.Message, ex);
            }
        }