reshuffle-smartsheet-connector
v0.0.1
Published
Reshuffle connectors for Smartsheet
Downloads
2
Maintainers
Readme
SmartSheet Connector
This package contains a Resshufle connector to access to online spreadsheets at smartsheet.com.
All actions throw in case of an error.
Actions:
deleteRow Delete one row
getImage Get image from a sheet cell
getSheetById Get sheet data by sheet id
getSheetIdByName Find sheet id by its name
getSheetByName Get sheet data by sheet name
getSimpleSheetById Get a simple sheet object by ID
getSimpleSheetByName Get a simple sheet object by name
getRow Get row information
listSheets List all sheets
listRows List rows in a sheet
update Update a sheet
SDK:
sdk Get direct SDK access
Construction
const app = new Reshuffle()
const smartsheetConnector = new SmaetsheetConnector(app, {
apiKey: process.env.SMARTSHEET_API_KEY,
})
Action Details
Delete Row action
Definition:
(
sheetId: number | string,
rowId: number | string,
) => void
Usage:
await smartsheetConnector.deleteRow(4583173393803140, 1234567890123456)
Delete a single row from the specified sheet.
Get Image action
Definition:
(
sheetId: number | string,
rowId: number | string,
columnIdOrIndex: number | string,
width?: number, // optional
height?: number, // optional
) => object
Usage:
const img = await smartsheetConnector.getImage(
4583173393803140,
000000000000000,
3,
)
console.log(img.id, img.text, img.url)
Get an image stored in a sheet cell. sheetId
and rowId
specify the
specific row to query. columnIdOrIndex
is treated as an index if it is
a number smaller than 1024, otherwise it is treated as a column id.
The returned image include a unique ID, the alternative text (uaully the original file name) and a download URL. The URL is valid for half an hour.
Use the optional width
and height
arguments to get a link to a resized
image.
Get Sheet By ID action
Definition:
(
sheetId: number | string,
) => object
Usage:
const sheetData = await smartsheetConnector.getSheetById(4583173393803140)
Get full
sheet data
for the sheet with the specified id
.
Get Sheet ID By Name action
Definition:
(
name: string,
) => number
Usage:
const sheetId = await smartsheetConnector.getSheetIdByName('My Sheet')
Get a sheet ID number for the sheet with the specified name. If a sheet with that name is not found then an Error is thrown.
Get Sheet By Name action
Definition:
(
name: string,
) => object
Usage:
const sheetData = await smartsheetConnector.getSheetByName('My Sheet')
Get full
sheet data
for the sheet with the specified name
. If a sheet with that name is not
found then an Error is thrown.
Get Simple Sheet By ID action
Definition:
(
sheetId: number | string,
) => object
Usage:
const sheet = await smartsheetConnector.getSimpleSheetById(4583173393803140)
const updater = sheet.getUpdater()
updater.addUpdate('My Column', 000000000000000, 'New Value')
await smartsheetConnector.update(updater.getSheetId(), updater.getUpdates())
Get a SimpleSheet
object to representing the sheet with the specified
id
. This object provides the following methods:
getColumnIdByTitle(
columnTitle: string,
): number // Get column ID by column title
getUpdater(): object // Create an updater object
pivot(
pivotColumn: string,
property: string,
matchColumns: string[],
includeRowIDs?: boolean,
): object // Build a pivot table
toSCV(): string // Create a CSV representation
An updater object provides the following methods:
addUpdate(
columnTitle: string,
rowId: number | string,
value: string,
) // Add a cell value to be updated
getSheetId(): number // Get the sheet ID
getUpdates(): object // Get the updates for using with the update action
Get Simple Sheet By Name action
Definition:
(
name: string,
) => object
Get a SimpleSheet
object representing the sheet the the specified
name
. See getSimpleSheetById for details.
Get Row action
Definition:
(
sheetId: number | string,
rowId: number | string,
) => object
Usage:
const row = await smartsheetConnector.getRow(
4583173393803140,
1234567890123456,
)
Get information about the specified row in the specified sheet. Row information is detailed here.
List Rows action
Definition:
(
sheetId: number | string,
) => number[]
Usage:
const rowIds = await smartsheetConnector.listRows(4583173393803140)
Get a list of row IDs in the specified sheet.
List Sheets action
Definition:
() => object[]
Usage:
const sheets = await smartsheetConnector.listSheets()
Get a list of all sheets in the connected Smartsheet account. For each sheet, the following information is returned:
- id - Sheet ID
- name - Sheet name
- accessLevel - Usually 'OWNER'
- permalink - Link to sheet online page
- createdAt - Cretion time stamp
- modifiedAt - Modification time stamp
Update action
Definition:
(
sheetId: number | string,
rows: object[],
) => void
Usage:
await smartsheetConnector.update(
4583173393803140,
[
{
id: '0000000000000000',
cells: [
{
columnId: '0000000000000000',
value: 'My Value',
},
],
},
],
)
Update the data in a sheet. The update object uses the format defined here . You can use the Simple Sheet objet to create an updater object that will construct the rows array.
SDK Details
SDK action
Definition:
() => object
Usage:
const client = await smartsheetConnector.sdk()
Get the underlying SDK object.