Skip to content

Commit

Permalink
Merge branch 'saching/adding_downloadFileAPI' into saching/PrintAndDo…
Browse files Browse the repository at this point in the history
…wnload
  • Loading branch information
Sachin Gupta committed Oct 2, 2018
2 parents 99e4851 + 0e0d5b5 commit 6baf612
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/MicrosoftTeams.ts
Expand Up @@ -849,6 +849,46 @@ namespace microsoftTeams {
sendMessageRequest(parentWindow, "openFilePreview", params);
}

/**
* @private
* Hide from docs.
* ------
* download file.
* @param file The file to download.
*/
export function downloadFile(
fileDownloadParameters: FileDownloadParameters
): void {
ensureInitialized(frameContexts.content);

const params = [
fileDownloadParameters.objectUrl,
fileDownloadParameters.title
];

sendMessageRequest(parentWindow, "downloadFile", params);
}

/**
* @private
* Hide from docs.
* ------
* download file.
* @param file The file to download.
*/
export function showNotification(
showNotificationParameters: ShowNotificationParameters
): void {
ensureInitialized(frameContexts.content);

const params = [
showNotificationParameters.message,
showNotificationParameters.isDownloadComplete
];

sendMessageRequest(parentWindow, "showNotification", params);
}

/**
* @private
* Hide from docs.
Expand Down Expand Up @@ -1848,6 +1888,19 @@ namespace microsoftTeams {
subEntityId?: string;
}

export interface FileDownloadParameters {
/**
* A url to the source of the file, used to open the content in the user's default browser
*/
objectUrl: string;
title: string;
}

export interface ShowNotificationParameters {
message: string;
isDownloadComplete: boolean;
}

function ensureInitialized(...expectedFrameContexts: string[]): void {
if (!initializeCalled) {
throw new Error("The library has not yet been initialized");
Expand Down

0 comments on commit 6baf612

Please sign in to comment.