OfficeDev / Office-Add-in-samples

Code samples for Office Add-in development on the Microsoft 365 platform.
MIT License
672 stars 758 forks source link

Some more improvements #730

Closed akrantz closed 3 months ago

akrantz commented 3 months ago

I changed the PowerPoint code to use addTextBox().

I structured the graph helper code to have makeGraphRequest() which takes path and query params and validates that they start with slash and question mark, respectively, and throws if they don't.

The getFileNames() function is essentially the specific Graph API to get the file names from the root. I made the count an optional parameter which defaults to 10 just to show how it could compose the actual path and query params, and added type info for the response so the parsing to extract the file names is a bit simpler. The getUserFiles() function for the button handler calls to get the file names and then writes the file names to the document.

The ssoGetToken() function had a lot of duplication where it just gets the userAccount and then returns the token for it, so this was simplified.