Show:      

CollabMSGraphClient

Signature
global with sharing class CollabMSGraphClient

CollabMSGraphClient Methods

createFolder(userId, driveId, parentId, name)

Create folder "name" in drive identified by<var>driveId</var> with parent identified by <var>parentId</var>
Signature
global static SaveFileResponse createFolder(String userId, String driveId, String parentId, String name)
Parameters
userId
Type: String
user ID
driveId
Type: String
drive ID
parentId
Type: String
parent ID
name
Type: String
folder name
Returns
created folder

ensurePath(userId, driveId, path)

checks if the path exists on SharePoint
Signature
global static Boolean ensurePath(String userId, String driveId, String path)
Parameters
userId
Type: String
user ID
driveId
Type: String
drive ID
path
Type: String
path to folder, <strong>Without file part</strong>
Returns
true on success

getDrive(userId, siteUrl)

Get drive from URL. You probably do not want to use this. #getSiteDrive()
Signature
global static GetDriveResponse getDrive(String userId, String siteUrl)
Parameters
userId
Type: String
user Id
siteUrl
Type: String
site URL
Returns
corresponding drive
See
CollabMSGraphClient.getSiteDrive()

getDriveItemByPath(userId, driveId, path)

Retrieve drive item in drive <var>driveId</var> at path <var>path</var>
Signature
global static GetDriveResponse getDriveItemByPath(String userId, String driveId, String path)
Parameters
userId
Type: String
User Id
driveId
Type: String
drive ID
path
Type: String
path
Returns
drive item at path <var>path</var>. See: GetDriveResponse
See
CollabMSGraphClient.getDriveItemsByPath to get the children

getDriveItemsById(userId, driveId, childId)

Retrieve drive items(children) in drive <var>driveId</var> identified by <var>childId<var>
Signature
global static GetDriveContentResponse getDriveItemsById(String userId, String driveId, String childId)
Parameters
userId
Type: String
User Id
driveId
Type: String
drive ID
childId
Type: String
child id
Returns
drive item with id <var>childId</var>. See: GetDriveContentResponse
See
CollabMSGraphClient.getDriveItemByPath to get the children

getDriveItemsByPath(userId, driveId, path)

Retrieve drive items (children) in drive <var>driveId</var> at path <var>path</var>
Signature
global static GetDriveContentResponse getDriveItemsByPath(String userId, String driveId, String path)
Parameters
userId
Type: String
User Id
driveId
Type: String
drive ID
path
Type: String
path
Returns
drive items (children) at path <var>path</var>. See: GetDriveContentResponse
See
CollabMSGraphClient.getDriveItemByPath to get the item itself

getFile(userId, url, isLibrary, path)

Gets a SharePoint file
Signature
global static GetFileResponse getFile(String userId, String url, Boolean isLibrary, String path)
Parameters
userId
Type: String
the user of which the SharePoint credentials should be used. Current user: UserInfo.getUserId()
url
Type: String
Site Library Url
isLibrary
Type: Boolean
unless you are using an old version, use "true"
path
Type: String
sharepoint library folder patch
Returns
GetFileResponse object
Example
 cadmus_una.CollabMSGraphClient.getFile(UserInfo.getUserId(), 'https://cloudcrossingautomation.sharepoint.com/sites/Marketing21/Gedeelde documenten', true, 
 '/General/Test Corelus.docx'); => the blob is on “response.data”

getFileAsPDF(userId, url, isLibrary, path)

Converts a SharePoint file into PDF - Remote Site Setting: https://westeurope1-mediap.svc.ms
Signature
global static GetFileResponse getFileAsPDF(String userId, String url, Boolean isLibrary, String path)
Parameters
userId
Type: String
the user of which the SharePoint credentials should be used. Current user: UserInfo.getUserId()
url
Type: String
Site Library Url
isLibrary
Type: Boolean
unless you are using an old version, use "true"
path
Type: String
sharepoint library folder patch
Returns
GetFileResponse object
Example
 cadmus_una.CollabMSGraphClient.getFileAsPDF(UserInfo.getUserId(), 'https://cloudcrossingautomation.sharepoint.com/sites/Marketing21/Gedeelde documenten', true, 
 '/General/Test Corelus.docx'); => the blob is on “response.data”

getRefreshedToken(userId)

Get a refreshed OAuth token. This method will save this token to the user, so afterwards, it will not be possible to callout to SharePoint in the same request
Signature
global static String getRefreshedToken(String userId)
Parameters
userId
Type: String
the user id
Returns
refreshed token

getSiteDrive(userId, libraryUrl)

Get drive from URL, tacking into account sites and libraries.
Signature
global static GetDriveResponse getSiteDrive(String userId, String libraryUrl)
Parameters
userId
Type: String
user Id
libraryUrl
Type: String
site/library URL
Returns
corresponding drive: GetDriveResponse

refreshToken(userId)

Get a refreshed OAuth token. This method will save this token to the user, so afterwards, it will not be possible to callout to SharePoint in the same request
Signature
global static String refreshToken(String userId)
Parameters
userId
Type: String
the user id
Returns
refreshed token

sanitizeFileName(dirtyFilename)

General cleanup of characters SharePoint cannot deal with
Signature
global static String sanitizeFileName(String dirtyFilename)
Parameters
dirtyFilename
Type: String
Url
Returns
clean URL

saveFile(userId, url, isLibrary, path, fileContent)

Save file
Signature
global static SaveFileResponse saveFile(String userId, String url, Boolean isLibrary, String path, Blob fileContent)
Parameters
userId
Type: String
user ID
url
Type: String
drive URL
isLibrary
Type: Boolean
indicate if it is a library
path
Type: String
target path
fileContent
Type: Blob
file content
Returns
saved file

saveFile(userId, driveUrl, path, fileContent)

Save file in a site drive
Signature
global static SaveFileResponse saveFile(String userId, String driveUrl, String path, Blob fileContent)
Parameters
userId
Type: String
user ID
driveUrl
Type: String
drive URL
path
Type: String
target path
fileContent
Type: Blob
file content
Returns
saved file

saveFileById(userId, driveId, parentId, fileName, fileContent)

Save file in a site drive using IDs
Signature
global static SaveFileResponse saveFileById(String userId, String driveId, String parentId, String fileName, Blob fileContent)
Parameters
userId
Type: String
user ID
driveId
Type: String
drive ID
parentId
Type: String
parent ID
fileName
Type: String
file name
fileContent
Type: Blob
file content
Returns
saved file

urlEncodeFilePath(url)

Convenience method for encoding url's.
Signature
global static String urlEncodeFilePath(String url)
Parameters
url
Type: global static String
Url to encode
Returns
url-encoded URL

CollabMSGraphClient.DriveItemResponse

Class to wrap an item, eg File, in a folder
Signature
global class DriveItemResponse

CollabMSGraphClient.DriveItemResponse Properties

Name Signature Description
id
global String id
id of the item
name
global String name
name of the item
size
global Integer size
size of the item
webUrl
global String webUrl
Url to open the item

CollabMSGraphClient.DriveItemResponse Constructors

DriveItemResponse(parser)

Signature
global DriveItemResponse(JSONParser parser)

CollabMSGraphClient.GetDriveContentResponse

Class to wrap the Drive content returned from SharePoint
Signature
global class GetDriveContentResponse

CollabMSGraphClient.GetDriveContentResponse Properties

Name Signature Description
data
global MsGraphContentResponse data
Drive response data: MsGraphContentResponse
error
global GraphErrorResponse error
Error object see: GraphErrorResponse

CollabMSGraphClient.GetDriveContentResponse Methods

isError()

checks if there is an error present
Signature
global Boolean isError()

isError(errorCode)

checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)

CollabMSGraphClient.GetDriveResponse

Class to wrap the Drive information returned from SharePoint
Signature
global class GetDriveResponse

CollabMSGraphClient.GetDriveResponse Properties

Name Signature Description
data
global GetDriveResponseData data
Drive response data: GetDriveResponseData
error
global GraphErrorResponse error
Error object see: GraphErrorResponse

CollabMSGraphClient.GetDriveResponse Methods

isError()

checks if there is an error present
Signature
global Boolean isError()

isError(errorCode)

checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)

CollabMSGraphClient.GetDriveResponseData

Class to wrap the Drive response from SharePoint
Signature
global class GetDriveResponseData

CollabMSGraphClient.GetDriveResponseData Properties

Name Signature Description
downloadUrl
global String downloadUrl
Download Url
id
global String id
Drive id
parentReference
global ParentReference parentReference
Reference to the parent: ParentReference

CollabMSGraphClient.GetDriveResponseData Constructors

GetDriveResponseData(parser)

Signature
global GetDriveResponseData(JSONParser parser)

GetDriveResponseData(id)

Signature
global GetDriveResponseData(String id)

CollabMSGraphClient.GetFileResponse

Class to wrap the File returned from SharePoint
Signature
global class GetFileResponse

CollabMSGraphClient.GetFileResponse Properties

Name Signature Description
data
global Blob data
the return file
error
global GraphErrorResponse error
Error object see: GraphErrorResponse

CollabMSGraphClient.GetFileResponse Methods

isError()

checks if there is an error present
Signature
global Boolean isError()

isError(errorCode)

checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)

CollabMSGraphClient.GraphErrorResponse

Class to wrap the errors
Signature
global class GraphErrorResponse

CollabMSGraphClient.GraphErrorResponse Properties

Name Signature Description
code
global String code
error code
innerError
global GraphErrorResponse innerError
get more lower-level errors
message
global String message
error message

CollabMSGraphClient.GraphErrorResponse Constructors

GraphErrorResponse(parser)

Signature
global GraphErrorResponse(JSONParser parser)

GraphErrorResponse()

Signature
GraphErrorResponse()

CollabMSGraphClient.ParentReference

reference to the parent
Signature
global class ParentReference

CollabMSGraphClient.ParentReference Constructors

ParentReference(parser)

Id of the parent drive
Signature
global ParentReference(JSONParser parser)

CollabMSGraphClient.SaveFileResponse

Response info after saving a File to SharePoint
Signature
global class SaveFileResponse

CollabMSGraphClient.SaveFileResponse Properties

Name Signature Description
data
global DriveItemResponse data
Info on the item saved: DriveItemResponse
error
global GraphErrorResponse error
Error object see: GraphErrorResponse

CollabMSGraphClient.SaveFileResponse Methods

isError()

checks if there is an error present
Signature
global Boolean isError()

isError(errorCode)

checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)