kenken999's picture
df
3d979b2
raw
history blame
1.4 kB
class PlantUML {
generateFlowDiagram() {
var flowDiagram = '@startuml\n';
flowDiagram += 'participant Line as "Line"\n';
flowDiagram += 'participant Script as "Google Apps Script"\n';
flowDiagram += 'participant Drive as "Google Drive"\n';
flowDiagram += 'participant S3 as "Amazon S3"\n';
flowDiagram += 'Line->>Script: doPost\n';
flowDiagram += 'Script->>Drive: save image\n';
flowDiagram += 'Script->>S3: upload image\n';
flowDiagram += '@enduml';
var plantUMLService = getPlantUMLService();
var diagramUrl = plantUMLService.getDiagramUrl(flowDiagram);
var diagramImage = UrlFetchApp.fetch(diagramUrl).getBlob();
var driveFile = DriveApp.createFile(diagramImage);
}
getPlantUMLService() {
var service = OAuth2.createService('plantuml')
.setAuthorizationBaseUrl('https://plantuml.com/')
.setTokenUrl('https://plantuml.com/')
.setClientId('your_client_id')
.setClientSecret('your_client_secret')
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties());
return service;
}
authCallback(request) {
var service = getService();
var authorized = service.handleCallback(request);
if (authorized) {
return HtmlService.createHtmlOutput('Authorized');
} else {
return HtmlService.createHtmlOutput('Access denied');
}
}
}