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

			return this.DeleteLibraryFile(file.Id);
		}
Exemple #2
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(Config.Errors.MyLibraryOrId);
			}
						
			return MyLibraryService.UpdateLibraryFile(this.AccessToken, this.APIKey, file, includePayload);
		}
Exemple #3
0
		/// <summary>
		/// Update a specific file
		/// </summary>
		/// <param name="file">File to be updated</param>
		/// <returns>Returns a MyLibraryFile object.</returns>
		public MyLibraryFile UpdateLibraryFile(MyLibraryFile file)
		{
			return this.UpdateLibraryFile(file, null);
		}
		/// <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;
		}
Exemple #5
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(CTCT.Resources.Errors.MyLibraryOrId);
            }

            return DeleteLibraryFile(file.Id);
        }
Exemple #6
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(CTCT.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 CtctException(ex.Message, ex);
            }
		}