Exemplo n.º 1
0
        /// <summary>
        /// Delete a column.
        ///
        /// It mirrors To the following Smartsheet REST API method: DELETE /column/{Id}
        ///
        /// Exceptions:
        ///   InvalidRequestException : if there is any problem with the REST API request
        ///   AuthorizationException : if there is any problem with the REST API authorization(access token)
        ///   ResourceNotFoundException : if the resource can not be found
        ///   ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting)
        ///   SmartsheetRestException : if there is any other REST API related error occurred during the operation
        ///   SmartsheetException : if there is any other error occurred during the operation
        /// </summary>
        /// <param name="id"> the ID of the column </param>
        /// <param name="sheetId"> the ID of the sheet </param>
        /// <exception cref="SmartsheetException"> the Smartsheet exception </exception>
        public virtual void DeleteColumn(long id, long sheetId)
        {
            HttpRequest request = null;

            request = CreateHttpRequest(new Uri(Smartsheet.BaseURI, "column/" + id), HttpMethod.DELETE);

            Column column = new Column();

            column.SheetId = sheetId;

            request.Entity = serializeToEntity <Column>(column);

            HttpResponse response = Smartsheet.HttpClient.Request(request);

            switch (response.StatusCode)
            {
            case HttpStatusCode.OK:
                this.Smartsheet.JsonSerializer.deserializeResult <object>(response.Entity.GetContent());
                break;

            default:
                HandleError(response);
                break;
            }

            this.Smartsheet.HttpClient.ReleaseConnection();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update a column.
        ///
        /// It mirrors To the following Smartsheet REST API method: PUT /column/{Id}
        ///
        /// Exceptions:
        ///   IllegalArgumentException : if any argument is null
        ///   InvalidRequestException : if there is any problem with the REST API request
        ///   AuthorizationException : if there is any problem with the REST API authorization(access token)
        ///   ResourceNotFoundException : if the resource can not be found
        ///   ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting)
        ///   SmartsheetRestException : if there is any other REST API related error occurred during the operation
        ///   SmartsheetException : if there is any other error occurred during the operation
        /// </summary>
        /// <param name="column"> the column To update limited To the following attributes: Index (column's new Index in the sheet),
        /// Title, SheetId, Type, Options (optional), Symbol (optional), SystemColumnType (optional),
        /// AutoNumberFormat (optional) </param>
        /// <returns> the updated sheet (note that if there is no such resource, this method will throw
        /// ResourceNotFoundException rather than returning null). </returns>
        /// <exception cref="SmartsheetException"> the Smartsheet exception </exception>
        public virtual Column UpdateColumn(Column column)
        {
            Utils.ThrowIfNull(column);

            return(this.UpdateResource("column/" + column.ID, typeof(Column), column));
        }
 /// <summary>
 /// <para>Updates properties of the column, moves the column, and/or renames the column.</para>
 /// <para>You cannot change the type of a Primary column.</para>
 /// <para>While dependencies are enabled on a sheet, you can’t change the type of any special calendar/Gantt columns.</para>		
 /// <para>If the column type is changed, all cells in the column will be converted to the new column type.</para>
 /// <para>Type is optional when moving or renaming, but required when changing type or dropdown values.</para>
 /// <para>It mirrors To the following Smartsheet REST API method: GET /sheets/{sheetId}/columns/{columnId}</para>
 /// </summary>
 /// <param name="sheetId"> the sheet Id </param>
 /// <param name="column"> column object to update </param>
 /// <returns> the updated column </returns>
 /// <exception cref="System.InvalidOperationException"> if any argument is null or empty string </exception>
 /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception>
 /// <exception cref="AuthorizationException"> if there is any problem with  the REST API authorization (access token) </exception>
 /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception>
 /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due To rate limiting) </exception>
 /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception>
 public virtual Column UpdateColumn(long sheetId, Column column)
 {
     return this.UpdateResource<Column>("sheets/" + sheetId + "/columns/" + column.Id, typeof(Column), column);
 }