msgraph@0.7.7
- create(resource, data, callback)
- get(path, query, callback)
- getDrive(specifier, name, [callback])
- getFile(pathOrId, options, [callback])
- getFolder(pathOrId, options, [callback])
- uploadFile(resource, data, callback)
This adaptor exports the following namespaced functions:
This adaptor exports the following from common:
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- lastReferenceValue()
- merge()
- parseCsv()
- sourceValue()
Functions
create
create(resource, data, callback) ⇒ Operation
Create some resource in msgraph
Param | Type | Description |
---|---|---|
resource | string | The type of entity that will be created |
data | object | The data to create the new resource |
callback | function | An optional callback function |
Example
create("applications", {"displayName": "My App"})
get
get(path, query, callback) ⇒ Operation
Make a GET request to msgraph resource
Param | Type | Description |
---|---|---|
path | string | Path to resource |
query | object | Query, Headers and Authentication parameters |
callback | function | (Optional) Callback function |
Example
get('sites/root/lists')
getDrive
getDrive(specifier, name, [callback]) ⇒ Operation
Get a Drive or SharePoint document library. The drive metadata will be written to state.drives, where it can be used by other adaptor functions. Pass { id } to get a drive by id or { id, owner } to get default drive for some parent resource, like a group
Param | Type | Default | Description |
---|---|---|---|
specifier | Object | A definition of the drive to retrieve - id {string} - The ID of the resource or owner. - owner {string} - The type of drive owner (e.g. sites, groups). | |
name | string | The local name of the drive used to write to state.drives, ie, state.drives[name] | |
[callback] | function | s => s | (Optional) Callback function |
Example: Get a drive by ID
getDrive({ id: "YXzpkoLwR06bxC8tNdg71m" })
Example: Get the default drive for a site
getDrive({ id: "openfn.sharepoint.com", owner: "sites" })
getFile
getFile(pathOrId, options, [callback]) ⇒ Operation
Get file metadata or file content.
Param | Type | Default | Description |
---|---|---|---|
pathOrId | string | A path to a file or file id | |
options | object | (Optional) Query parameters | |
[callback] | function | s => s | (Optional) Callback function |
Example: Get a file by ID
getFile('01LUM6XOGRONYNTZ26DBBJPTN5IFTQPBIW')
Example: Get a file for a named drive by id
getFile("01LUM6XOGRONYNTZ26DBBJPTN5IFTQPBIW",{ driveName: "mydrive"})
getFolder
getFolder(pathOrId, options, [callback]) ⇒ Operation
Get the contents or metadata of a folder.
Param | Type | Default | Description |
---|---|---|---|
pathOrId | string | A path to a folder or folder id | |
options | object | (Optional) Query parameters | |
[callback] | function | s => s | (Optional) Callback function |
Example: Get a folder by ID
getFolder('01LUM6XOCKDTZKQC7AVZF2VMHE2I3O6OY3')
Example: Get a folder for a named drive by id
getFolder("01LUM6XOCKDTZKQC7AVZF2VMHE2I3O6OY3",{ driveName: "mydrive"})
uploadFile
uploadFile(resource, data, callback) ⇒ Operation
Upload a file to a drive
Param | Type | Description |
---|---|---|
resource | Object | Resource Object |
[resource.driveId] | String | Drive Id |
[resource.driveId] | String | Site Id |
[resource.folderId] | String | Parent folder id |
[resource.contentType] | String | Resource content-type |
[resource.onConflict] | String | Specify conflict behavior if file with the same name exists. Can be "rename |
data | Object | A buffer containing the file. |
callback | function | Optional callback function |
Example: Upload Excel file to a drive using driveId
and parantItemId
uploadFile(
state => ({
driveId: state.driveId,
folderId: state.folderId,
fileName: `Tracker.xlsx`,
}),
state => state.buffer
);
Example: Upload Excel file to a SharePoint drive using siteId
and parantItemId
uploadFile(
state => ({
siteId: state.siteId,
folderId: state.folderId,
fileName: `Report.xlsx`,
}),
state => state.buffer
);
Utils
These functions belong to the Utils namespace.
Utils.sheetToBuffer
sheetToBuffer(rows, options) ⇒
The function sheetToBuffer
takes in rows, options and optional callback, It creates a workbook
and worksheet using the rows, appends the worksheet to the workbook, and returns the workbook as a
buffer.
Returns: a buffer containing the Excel file in state.buffer
.
Param | Type | Description |
---|---|---|
rows | The rows parameter is an array of objects representing the data to be written to the Excel sheet. Each object in the array represents a row in the sheet, and the keys of the object represent the column headers. The values of the object represent the data in each cell of the row. | |
options | The options parameter is an object that contains additional configuration options | |
[options.wsName] | String | Worksheet name i.e 32 Characters |
[options.bookType] | String | File format of the exported file, Default is 'xlsx'. See here for the function. It can have the following properties: |
Example: Create a buffer containing excel file with xlsx
output format
sheetToBuffer('$.data[*]', {
wsName: 'Invalid Grant Codes',
bookType: 'xlsx',
});