Struct SmartsheetApi

Source
pub struct SmartsheetApi<'a> { /* private fields */ }
Expand description

Client implementation for making requests to the Smartsheet API v2

Implementations§

Source§

impl<'a> SmartsheetApi<'a>

Source

pub fn from_token(token: &str) -> Self

Initialize a new SmartsheetApi object from an API access token.

Source

pub fn from_env() -> Result<Self, Box<dyn Error + Send + Sync>>

Initialize a new SmartsheetApi object from an API access token, assuming this is currently set in the environment.

Source

pub fn from_endpoint_and_token(endpoint: &'a str, token: &str) -> Self

Initialize a new SmartsheetApi object from a (custom) base API endpoint, and an access token.

Source

pub async fn list_sheets( &self, ) -> Result<IndexResult<Sheet>, Box<dyn Error + Send + Sync>>

List Sheets - Gets a list of all sheets that the user has access to in alphabetical order by name. The list contains an abbreviated Sheet object for each sheet.

§Docs
  • https://smartsheet-platform.github.io/api-docs/#list-sheets
Source

pub async fn list_sheets_with_params( &self, include: impl Into<Option<Vec<ListSheetIncludeFlags>>>, include_all: impl Into<Option<bool>>, modified_since: impl Into<Option<&'a str>>, ) -> Result<IndexResult<Sheet>, Box<dyn Error + Send + Sync>>

List Sheets - Gets a list of all sheets that the user has access to in alphabetical order by name, with included query parameters. The list contains an abbreviated Sheet object for each sheet.

§Arguments
  • include - A comma-separated list of elements to include in the response.
  • include_all - If true, include all results (i.e. do not paginate).
  • modified_since - Return sheets modified since a provided datetime. Date should be in ISO-8601 format, for example, 2020-01-30T13:25:32-07:00.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#list-sheets
Source

pub async fn get_sheet( &self, sheet_id: u64, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>

Get Sheet - Retrieves the specified sheet. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows and data for.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-sheet
  • https://smartsheet-platform.github.io/api-docs/#row-include-flags
Source

pub async fn get_sheet_with_multi_contact_info( &self, sheet_id: u64, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>

Get Sheet - Retrieves the specified sheet. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.

§Note

This is a convenience method to retrieve a Sheet with the MULTI_CONTACT cell data correctly populated. This is primarily important so that we can retrieve the email addresses for such cells, for example.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows and data for.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-sheet
  • https://smartsheet-platform.github.io/api-docs/#row-include-flags
Source

pub async fn get_sheet_with_params( &self, sheet_id: u64, include: impl Into<Option<Vec<SheetIncludeFlags>>>, exclude: impl Into<Option<Vec<SheetExcludeFlags>>>, row_ids: impl Into<Option<Vec<u64>>>, row_numbers: impl Into<Option<Vec<u64>>>, column_ids: impl Into<Option<Vec<u64>>>, rows_modified_since: impl Into<Option<&'a str>>, level: impl Into<Option<Level>>, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>

Get Sheet - Retrieves the specified sheet, with included query parameters. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows and data for.
  • include - A comma-separated list of elements to include in the response.
  • exclude - A comma-separated list of elements to not include in the response.
  • row_ids - A comma-separated list of Row IDs on which to filter the rows included in the result.
  • row_numbers - A comma-separated list of Row numbers on which to filter the rows included in the result. Non-existent row numbers are ignored.
  • column_ids - A comma-separated comma-separated list of Column IDs. The response will contain only the specified columns in the ‘columns’ array, and individual rows’ ‘cells’ array will only contain cells in the specified columns.
  • rows_modified_since - Return rows modified since a provided datetime. Date should be in ISO-8601 format, for example, 2020-01-30T13:25:32-07:00.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-sheet
  • https://smartsheet-platform.github.io/api-docs/#row-include-flags
Source

pub async fn get_row( &self, sheet_id: u64, row_id: u64, ) -> Result<Row, Box<dyn Error + Send + Sync>>

Get Row - Retrieves the specified row from a sheet.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows from.
  • row_id - The specified row to retrieve.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-row
Source

pub async fn get_row_with_column_data( &self, sheet_id: u64, row_id: u64, ) -> Result<Row, Box<dyn Error + Send + Sync>>

Get Row - Retrieves the specified row from a sheet, with included column data.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows from.
  • row_id - The specified row to retrieve.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-row
Source

pub async fn get_row_with_multi_contact_info( &self, sheet_id: u64, row_id: u64, ) -> Result<Row, Box<dyn Error + Send + Sync>>

Get Row - Retrieves the specified row from a sheet, with included Multi-contact data.

§Note

This is a convenience method to retrieve a Row with the MULTI_CONTACT cell data correctly populated. This is primarily important so that we can retrieve the email addresses for such cells, for example.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows from.
  • row_id - The specified row to retrieve.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-row
Source

pub async fn get_row_with_params( &self, sheet_id: u64, row_id: u64, include: impl Into<Option<Vec<RowIncludeFlags>>>, exclude: impl Into<Option<Vec<RowExcludeFlags>>>, level: impl Into<Option<Level>>, ) -> Result<Row, Box<dyn Error + Send + Sync>>

Get Row - Retrieves the specified row from a sheet, with included query parameters.

§Arguments
  • sheet_id - The Smartsheet to retrieve the rows from.
  • row_id - The specified row to retrieve.
  • include - A comma-separated list of elements to include in the response.
  • exclude - A comma-separated list of elements to not include in the response.
  • level - Specifies whether multi-contact data is returned in a backwards-compatible, text format, or as multi-contact data.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-row
  • https://smartsheet-platform.github.io/api-docs/#row-include-flags
Source

pub async fn add_rows( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>

Add Rows - Inserts one or more rows into the sheet.

If you want to insert the rows in any position but the default, use location-specifier attributes.

§Arguments
  • sheet_id - The Smartsheet to add the rows to.
  • rows - An array (list) of new Rows with the cell values to add.
§Docs
Source

pub async fn add_rows_with_params( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, allow_partial_success: impl Into<Option<bool>>, override_validation: impl Into<Option<bool>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>

Add Rows - Inserts one or more rows into the sheet, with included query parameters.

If you want to insert the rows in any position but the default, use location-specifier attributes.

§Arguments
  • sheet_id - The Smartsheet to add the rows to.
  • rows - An array (list) of new Rows with the cell values to add.
  • allow_partial_success - Default: false. When specified with a value of true, enables partial success for this bulk operation. See Partial Success for more information.
  • override_validation - Default: false. If set to a value of true, allows a cell value outside of the validation limits. You must also specify strict on a per-cell level with a value of false to bypass value type checking.
§Docs
Source

pub async fn update_rows( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>

Update Rows - Updates cell values in the specified rows, expands/collapses the specified rows, and/or modifies the position of specified rows (including indenting/outdenting). For detailed information about changing row positions, see location-specifier attributes.

§Arguments
  • sheet_id - The Smartsheet to update the rows in.
  • rows - An array (list) of Rows with the updated cell values.
§Docs
Source

pub async fn update_rows_with_params( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, allow_partial_success: impl Into<Option<bool>>, override_validation: impl Into<Option<bool>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>

Update Rows - Updates cell values in the specified rows, with included query parameters.

Alternatively, expands/collapses the specified rows, and/or modifies the position of specified rows (including indenting/outdenting). For detailed information about changing row positions, see location-specifier attributes.

§Arguments
  • sheet_id - The Smartsheet to update the rows in.
  • rows - An array (list) of Rows with the updated cell values.
  • allow_partial_success - When specified with a value of true, enables partial success for this bulk operation. See Partial Success for more information.
  • override_validation - If set to a value of true, allows a cell value outside of the validation limits. You must also specify strict on a per-cell level with a value of false to bypass value type checking.
§Docs
Source

pub async fn delete_rows<const N: usize>( &self, sheet_id: u64, row_ids: impl Into<[u64; N]>, ) -> Result<RowResult<u64>, Box<dyn Error + Send + Sync>>

Delete Rows - Deletes one or more specified rows from the sheet.

§Arguments
  • sheet_id - The Smartsheet to delete the rows from.
  • row_ids - An array (list) containing the IDs of the Rows to delete from the smartsheet.
§Docs
Source

pub async fn delete_rows_with_params<const N: usize>( &self, sheet_id: u64, row_ids: impl Into<[u64; N]>, ignore_rows_not_found: impl Into<Option<bool>>, ) -> Result<RowResult<u64>, Box<dyn Error + Send + Sync>>

Delete Rows - Deletes one or more specified rows from the sheet, with included query parameters.

§Arguments
  • sheet_id - The Smartsheet to delete the rows from.
  • row_ids - An array (list) containing the IDs of the Rows to delete from the smartsheet.
  • ignore_rows_not_found - Default: false. If set to false and any of the specified Row IDs are not found, no rows are deleted, and the “not found” error is returned.
§Docs
Source

pub async fn list_columns( &self, sheet_id: u64, ) -> Result<IndexResult<Column>, Box<dyn Error + Send + Sync>>

List Columns - Gets a list of all columns belonging to the specified sheet.

§Docs
  • https://smartsheet-platform.github.io/api-docs/#list-columns
Source

pub async fn list_columns_with_params( &self, sheet_id: u64, level: impl Into<Option<Level>>, include: impl Into<Option<Vec<ColumnIncludeFlags>>>, include_all: impl Into<Option<bool>>, ) -> Result<IndexResult<Column>, Box<dyn Error + Send + Sync>>

List Columns - Gets a list of all columns belonging to the specified sheet, with included query parameters.

§Arguments
  • sheet_id - The Smartsheet to retrieve the columns from.
  • level - Specifies whether multi-contact data is returned in a backwards-compatible, text format, or as multi-contact data.
  • include - A comma-separated list of elements to include in the response.
  • include_all - If true, include all results (i.e. do not paginate).
§Docs
  • https://smartsheet-platform.github.io/api-docs/#list-columns
Source

pub async fn get_column( &self, sheet_id: u64, column_id: u64, ) -> Result<Column, Box<dyn Error + Send + Sync>>

Get Column - Retrieves a column by id from the specified sheet.

§Arguments
  • sheet_id - The Smartsheet to retrieve the column for.
  • column_id - The Column Id to retrieve the data for.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-column
Source

pub async fn get_column_with_params( &self, sheet_id: u64, column_id: u64, level: impl Into<Option<Level>>, include: impl Into<Option<Vec<ColumnIncludeFlags>>>, ) -> Result<Column, Box<dyn Error + Send + Sync>>

Get Column - Retrieves a column by id from the specified sheet, with included query parameters.

§Arguments
  • sheet_id - The Smartsheet to retrieve the column for.
  • column_id - The Column Id to retrieve the data for.
  • level - Specifies whether multi-contact data is returned in a backwards-compatible, text format, or as multi-contact data.
  • include - A comma-separated list of elements to include in the response.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-column
Source

pub async fn list_attachments( &self, sheet_id: u64, ) -> Result<IndexResult<AttachmentMeta>, Box<dyn Error + Send + Sync>>

List Attachments - Gets a list of all attachments that are on the sheet, including sheet, row, and discussion-level attachments.

§Arguments
  • sheet_id - The Smartsheet to retrieve the attachments for.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#list-attachments
Source

pub async fn get_attachment( &self, sheet_id: u64, attachment_id: u64, ) -> Result<Attachment, Box<dyn Error + Send + Sync>>

Get Attachment - Retrieves an attachment by id from the specified sheet.

§Notes

Fetches a temporary URL that allows you to download an attachment. The urlExpiresInMillis attribute tells you how long the URL is valid.

§Arguments
  • sheet_id - The Smartsheet to retrieve the attachments for.
  • attachment_id - The Attachment Id to retrieve the data for.
§Docs
  • https://smartsheet-platform.github.io/api-docs/#get-attachment
Source

pub async fn get_sheet_by_name( &self, sheet_name: &'a str, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>

👎Deprecated since 0.2.0: please cache the sheet id and use get_sheet instead

Get Sheet By Name - Convenience function to retrieve a specified sheet by name. Used for those times when you don’t know the Sheet Id.

This will internally call list_sheets and then filter the response data by the sheet name. It returns the first matching name.

Returns the sheet, including rows, and optionally populated with discussion and attachment objects.

§Arguments
  • sheet_name - The name of the Smartsheet to filter results by.
Source

pub async fn get_column_by_title( &self, sheet_id: u64, column_title: &'a str, ) -> Result<Column, Box<dyn Error + Send + Sync>>

👎Deprecated since 0.2.0: please cache the column id and use get_column instead

Get Column By Title - Convenience function to retrieve a specified column by title (name). Used for those times when you don’t know the Column Id.

This will internally call list_columns and then filter the response data by the column title. It returns the first matching name.

§Arguments
  • sheet_id - The Smartsheet to retrieve the column from.
  • column_title - The name of the column to filter results by.

Auto Trait Implementations§

§

impl<'a> Freeze for SmartsheetApi<'a>

§

impl<'a> !RefUnwindSafe for SmartsheetApi<'a>

§

impl<'a> Send for SmartsheetApi<'a>

§

impl<'a> Sync for SmartsheetApi<'a>

§

impl<'a> Unpin for SmartsheetApi<'a>

§

impl<'a> !UnwindSafe for SmartsheetApi<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more