googlescript.pp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. unit googlescript;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, googleservice, restbase, googlebase;
  6. type
  7. //Top-level schema types
  8. TExecutionRequest = Class;
  9. TOperation = Class;
  10. TStatus = Class;
  11. TExecutionError = Class;
  12. TScriptStackTraceElement = Class;
  13. TExecutionResponse = Class;
  14. TExecutionRequestArray = Array of TExecutionRequest;
  15. TOperationArray = Array of TOperation;
  16. TStatusArray = Array of TStatus;
  17. TExecutionErrorArray = Array of TExecutionError;
  18. TScriptStackTraceElementArray = Array of TScriptStackTraceElement;
  19. TExecutionResponseArray = Array of TExecutionResponse;
  20. //Anonymous types, using auto-generated names
  21. TOperationTypemetadata = Class;
  22. TOperationTyperesponse = Class;
  23. TStatusTypedetailsItem = Class;
  24. TStatusTypedetailsArray = Array of TStatusTypedetailsItem;
  25. TExecutionErrorTypescriptStackTraceElementsArray = Array of TScriptStackTraceElement;
  26. { --------------------------------------------------------------------
  27. TExecutionRequest
  28. --------------------------------------------------------------------}
  29. TExecutionRequest = Class(TGoogleBaseObject)
  30. Private
  31. F_function : String;
  32. Fparameters : TTJSONSchemaArray;
  33. FsessionState : String;
  34. FdevMode : boolean;
  35. Protected
  36. Class Function ExportPropertyName(Const AName : String) : string; override;
  37. //Property setters
  38. Procedure Set_function(AIndex : Integer; const AValue : String); virtual;
  39. Procedure Setparameters(AIndex : Integer; const AValue : TTJSONSchemaArray); virtual;
  40. Procedure SetsessionState(AIndex : Integer; const AValue : String); virtual;
  41. Procedure SetdevMode(AIndex : Integer; const AValue : boolean); virtual;
  42. //2.6.4. bug workaround
  43. {$IFDEF VER2_6}
  44. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  45. {$ENDIF VER2_6}
  46. Public
  47. Published
  48. Property _function : String Index 0 Read F_function Write Set_function;
  49. Property parameters : TTJSONSchemaArray Index 8 Read Fparameters Write Setparameters;
  50. Property sessionState : String Index 16 Read FsessionState Write SetsessionState;
  51. Property devMode : boolean Index 24 Read FdevMode Write SetdevMode;
  52. end;
  53. TExecutionRequestClass = Class of TExecutionRequest;
  54. { --------------------------------------------------------------------
  55. TOperationTypemetadata
  56. --------------------------------------------------------------------}
  57. TOperationTypemetadata = Class(TGoogleBaseObject)
  58. Private
  59. Protected
  60. //Property setters
  61. Public
  62. Class Function AllowAdditionalProperties : Boolean; override;
  63. Published
  64. end;
  65. TOperationTypemetadataClass = Class of TOperationTypemetadata;
  66. { --------------------------------------------------------------------
  67. TOperationTyperesponse
  68. --------------------------------------------------------------------}
  69. TOperationTyperesponse = Class(TGoogleBaseObject)
  70. Private
  71. Protected
  72. //Property setters
  73. Public
  74. Class Function AllowAdditionalProperties : Boolean; override;
  75. Published
  76. end;
  77. TOperationTyperesponseClass = Class of TOperationTyperesponse;
  78. { --------------------------------------------------------------------
  79. TOperation
  80. --------------------------------------------------------------------}
  81. TOperation = Class(TGoogleBaseObject)
  82. Private
  83. Fname : String;
  84. Fmetadata : TOperationTypemetadata;
  85. Fdone : boolean;
  86. Ferror : TStatus;
  87. Fresponse : TOperationTyperesponse;
  88. Protected
  89. //Property setters
  90. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  91. Procedure Setmetadata(AIndex : Integer; const AValue : TOperationTypemetadata); virtual;
  92. Procedure Setdone(AIndex : Integer; const AValue : boolean); virtual;
  93. Procedure Seterror(AIndex : Integer; const AValue : TStatus); virtual;
  94. Procedure Setresponse(AIndex : Integer; const AValue : TOperationTyperesponse); virtual;
  95. Public
  96. Published
  97. Property name : String Index 0 Read Fname Write Setname;
  98. Property metadata : TOperationTypemetadata Index 8 Read Fmetadata Write Setmetadata;
  99. Property done : boolean Index 16 Read Fdone Write Setdone;
  100. Property error : TStatus Index 24 Read Ferror Write Seterror;
  101. Property response : TOperationTyperesponse Index 32 Read Fresponse Write Setresponse;
  102. end;
  103. TOperationClass = Class of TOperation;
  104. { --------------------------------------------------------------------
  105. TStatusTypedetailsItem
  106. --------------------------------------------------------------------}
  107. TStatusTypedetailsItem = Class(TGoogleBaseObject)
  108. Private
  109. Protected
  110. //Property setters
  111. Public
  112. Class Function AllowAdditionalProperties : Boolean; override;
  113. Published
  114. end;
  115. TStatusTypedetailsItemClass = Class of TStatusTypedetailsItem;
  116. { --------------------------------------------------------------------
  117. TStatus
  118. --------------------------------------------------------------------}
  119. TStatus = Class(TGoogleBaseObject)
  120. Private
  121. Fcode : integer;
  122. Fmessage : String;
  123. Fdetails : TStatusTypedetailsArray;
  124. Protected
  125. //Property setters
  126. Procedure Setcode(AIndex : Integer; const AValue : integer); virtual;
  127. Procedure Setmessage(AIndex : Integer; const AValue : String); virtual;
  128. Procedure Setdetails(AIndex : Integer; const AValue : TStatusTypedetailsArray); virtual;
  129. //2.6.4. bug workaround
  130. {$IFDEF VER2_6}
  131. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  132. {$ENDIF VER2_6}
  133. Public
  134. Published
  135. Property code : integer Index 0 Read Fcode Write Setcode;
  136. Property message : String Index 8 Read Fmessage Write Setmessage;
  137. Property details : TStatusTypedetailsArray Index 16 Read Fdetails Write Setdetails;
  138. end;
  139. TStatusClass = Class of TStatus;
  140. { --------------------------------------------------------------------
  141. TExecutionError
  142. --------------------------------------------------------------------}
  143. TExecutionError = Class(TGoogleBaseObject)
  144. Private
  145. FscriptStackTraceElements : TExecutionErrorTypescriptStackTraceElementsArray;
  146. FerrorMessage : String;
  147. FerrorType : String;
  148. Protected
  149. //Property setters
  150. Procedure SetscriptStackTraceElements(AIndex : Integer; const AValue : TExecutionErrorTypescriptStackTraceElementsArray); virtual;
  151. Procedure SeterrorMessage(AIndex : Integer; const AValue : String); virtual;
  152. Procedure SeterrorType(AIndex : Integer; const AValue : String); virtual;
  153. //2.6.4. bug workaround
  154. {$IFDEF VER2_6}
  155. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  156. {$ENDIF VER2_6}
  157. Public
  158. Published
  159. Property scriptStackTraceElements : TExecutionErrorTypescriptStackTraceElementsArray Index 0 Read FscriptStackTraceElements Write SetscriptStackTraceElements;
  160. Property errorMessage : String Index 8 Read FerrorMessage Write SeterrorMessage;
  161. Property errorType : String Index 16 Read FerrorType Write SeterrorType;
  162. end;
  163. TExecutionErrorClass = Class of TExecutionError;
  164. { --------------------------------------------------------------------
  165. TScriptStackTraceElement
  166. --------------------------------------------------------------------}
  167. TScriptStackTraceElement = Class(TGoogleBaseObject)
  168. Private
  169. F_function : String;
  170. FlineNumber : integer;
  171. Protected
  172. Class Function ExportPropertyName(Const AName : String) : string; override;
  173. //Property setters
  174. Procedure Set_function(AIndex : Integer; const AValue : String); virtual;
  175. Procedure SetlineNumber(AIndex : Integer; const AValue : integer); virtual;
  176. Public
  177. Published
  178. Property _function : String Index 0 Read F_function Write Set_function;
  179. Property lineNumber : integer Index 8 Read FlineNumber Write SetlineNumber;
  180. end;
  181. TScriptStackTraceElementClass = Class of TScriptStackTraceElement;
  182. { --------------------------------------------------------------------
  183. TExecutionResponse
  184. --------------------------------------------------------------------}
  185. TExecutionResponse = Class(TGoogleBaseObject)
  186. Private
  187. Fresult : TJSONSchema;
  188. Protected
  189. //Property setters
  190. Procedure Setresult(AIndex : Integer; const AValue : TJSONSchema); virtual;
  191. Public
  192. Published
  193. Property result : TJSONSchema Index 0 Read Fresult Write Setresult;
  194. end;
  195. TExecutionResponseClass = Class of TExecutionResponse;
  196. { --------------------------------------------------------------------
  197. TScriptsResource
  198. --------------------------------------------------------------------}
  199. TScriptsResource = Class(TGoogleResource)
  200. Public
  201. Class Function ResourceName : String; override;
  202. Class Function DefaultAPI : TGoogleAPIClass; override;
  203. Function Run(scriptId: string; aExecutionRequest : TExecutionRequest) : TOperation;
  204. end;
  205. { --------------------------------------------------------------------
  206. TScriptAPI
  207. --------------------------------------------------------------------}
  208. TScriptAPI = Class(TGoogleAPI)
  209. Private
  210. FScriptsInstance : TScriptsResource;
  211. Function GetScriptsInstance : TScriptsResource;virtual;
  212. Public
  213. //Override class functions with API info
  214. Class Function APIName : String; override;
  215. Class Function APIVersion : String; override;
  216. Class Function APIRevision : String; override;
  217. Class Function APIID : String; override;
  218. Class Function APITitle : String; override;
  219. Class Function APIDescription : String; override;
  220. Class Function APIOwnerDomain : String; override;
  221. Class Function APIOwnerName : String; override;
  222. Class Function APIIcon16 : String; override;
  223. Class Function APIIcon32 : String; override;
  224. Class Function APIdocumentationLink : String; override;
  225. Class Function APIrootUrl : string; override;
  226. Class Function APIbasePath : string;override;
  227. Class Function APIbaseURL : String;override;
  228. Class Function APIProtocol : string;override;
  229. Class Function APIservicePath : string;override;
  230. Class Function APIbatchPath : String;override;
  231. Class Function APIAuthScopes : TScopeInfoArray;override;
  232. Class Function APINeedsAuth : Boolean;override;
  233. Class Procedure RegisterAPIResources; override;
  234. //Add create function for resources
  235. Function CreateScriptsResource(AOwner : TComponent) : TScriptsResource;virtual;overload;
  236. Function CreateScriptsResource : TScriptsResource;virtual;overload;
  237. //Add default on-demand instances for resources
  238. Property ScriptsResource : TScriptsResource Read GetScriptsInstance;
  239. end;
  240. implementation
  241. { --------------------------------------------------------------------
  242. TExecutionRequest
  243. --------------------------------------------------------------------}
  244. Procedure TExecutionRequest.Set_function(AIndex : Integer; const AValue : String);
  245. begin
  246. If (F_function=AValue) then exit;
  247. F_function:=AValue;
  248. MarkPropertyChanged(AIndex);
  249. end;
  250. Procedure TExecutionRequest.Setparameters(AIndex : Integer; const AValue : TTJSONSchemaArray);
  251. begin
  252. If (Fparameters=AValue) then exit;
  253. Fparameters:=AValue;
  254. MarkPropertyChanged(AIndex);
  255. end;
  256. Procedure TExecutionRequest.SetsessionState(AIndex : Integer; const AValue : String);
  257. begin
  258. If (FsessionState=AValue) then exit;
  259. FsessionState:=AValue;
  260. MarkPropertyChanged(AIndex);
  261. end;
  262. Procedure TExecutionRequest.SetdevMode(AIndex : Integer; const AValue : boolean);
  263. begin
  264. If (FdevMode=AValue) then exit;
  265. FdevMode:=AValue;
  266. MarkPropertyChanged(AIndex);
  267. end;
  268. Class Function TExecutionRequest.ExportPropertyName(Const AName : String) :String;
  269. begin
  270. Case AName of
  271. '_function' : Result:='function';
  272. else
  273. Result:=Inherited ExportPropertyName(AName);
  274. end;
  275. end;
  276. //2.6.4. bug workaround
  277. {$IFDEF VER2_6}
  278. Procedure TExecutionRequest.SetArrayLength(Const AName : String; ALength : Longint);
  279. begin
  280. Case AName of
  281. 'parameters' : SetLength(Fparameters,ALength);
  282. else
  283. Inherited SetArrayLength(AName,ALength);
  284. end;
  285. end;
  286. {$ENDIF VER2_6}
  287. { --------------------------------------------------------------------
  288. TOperationTypemetadata
  289. --------------------------------------------------------------------}
  290. Class Function TOperationTypemetadata.AllowAdditionalProperties : Boolean;
  291. begin
  292. Result:=True;
  293. end;
  294. { --------------------------------------------------------------------
  295. TOperationTyperesponse
  296. --------------------------------------------------------------------}
  297. Class Function TOperationTyperesponse.AllowAdditionalProperties : Boolean;
  298. begin
  299. Result:=True;
  300. end;
  301. { --------------------------------------------------------------------
  302. TOperation
  303. --------------------------------------------------------------------}
  304. Procedure TOperation.Setname(AIndex : Integer; const AValue : String);
  305. begin
  306. If (Fname=AValue) then exit;
  307. Fname:=AValue;
  308. MarkPropertyChanged(AIndex);
  309. end;
  310. Procedure TOperation.Setmetadata(AIndex : Integer; const AValue : TOperationTypemetadata);
  311. begin
  312. If (Fmetadata=AValue) then exit;
  313. Fmetadata:=AValue;
  314. MarkPropertyChanged(AIndex);
  315. end;
  316. Procedure TOperation.Setdone(AIndex : Integer; const AValue : boolean);
  317. begin
  318. If (Fdone=AValue) then exit;
  319. Fdone:=AValue;
  320. MarkPropertyChanged(AIndex);
  321. end;
  322. Procedure TOperation.Seterror(AIndex : Integer; const AValue : TStatus);
  323. begin
  324. If (Ferror=AValue) then exit;
  325. Ferror:=AValue;
  326. MarkPropertyChanged(AIndex);
  327. end;
  328. Procedure TOperation.Setresponse(AIndex : Integer; const AValue : TOperationTyperesponse);
  329. begin
  330. If (Fresponse=AValue) then exit;
  331. Fresponse:=AValue;
  332. MarkPropertyChanged(AIndex);
  333. end;
  334. { --------------------------------------------------------------------
  335. TStatusTypedetailsItem
  336. --------------------------------------------------------------------}
  337. Class Function TStatusTypedetailsItem.AllowAdditionalProperties : Boolean;
  338. begin
  339. Result:=True;
  340. end;
  341. { --------------------------------------------------------------------
  342. TStatus
  343. --------------------------------------------------------------------}
  344. Procedure TStatus.Setcode(AIndex : Integer; const AValue : integer);
  345. begin
  346. If (Fcode=AValue) then exit;
  347. Fcode:=AValue;
  348. MarkPropertyChanged(AIndex);
  349. end;
  350. Procedure TStatus.Setmessage(AIndex : Integer; const AValue : String);
  351. begin
  352. If (Fmessage=AValue) then exit;
  353. Fmessage:=AValue;
  354. MarkPropertyChanged(AIndex);
  355. end;
  356. Procedure TStatus.Setdetails(AIndex : Integer; const AValue : TStatusTypedetailsArray);
  357. begin
  358. If (Fdetails=AValue) then exit;
  359. Fdetails:=AValue;
  360. MarkPropertyChanged(AIndex);
  361. end;
  362. //2.6.4. bug workaround
  363. {$IFDEF VER2_6}
  364. Procedure TStatus.SetArrayLength(Const AName : String; ALength : Longint);
  365. begin
  366. Case AName of
  367. 'details' : SetLength(Fdetails,ALength);
  368. else
  369. Inherited SetArrayLength(AName,ALength);
  370. end;
  371. end;
  372. {$ENDIF VER2_6}
  373. { --------------------------------------------------------------------
  374. TExecutionError
  375. --------------------------------------------------------------------}
  376. Procedure TExecutionError.SetscriptStackTraceElements(AIndex : Integer; const AValue : TExecutionErrorTypescriptStackTraceElementsArray);
  377. begin
  378. If (FscriptStackTraceElements=AValue) then exit;
  379. FscriptStackTraceElements:=AValue;
  380. MarkPropertyChanged(AIndex);
  381. end;
  382. Procedure TExecutionError.SeterrorMessage(AIndex : Integer; const AValue : String);
  383. begin
  384. If (FerrorMessage=AValue) then exit;
  385. FerrorMessage:=AValue;
  386. MarkPropertyChanged(AIndex);
  387. end;
  388. Procedure TExecutionError.SeterrorType(AIndex : Integer; const AValue : String);
  389. begin
  390. If (FerrorType=AValue) then exit;
  391. FerrorType:=AValue;
  392. MarkPropertyChanged(AIndex);
  393. end;
  394. //2.6.4. bug workaround
  395. {$IFDEF VER2_6}
  396. Procedure TExecutionError.SetArrayLength(Const AName : String; ALength : Longint);
  397. begin
  398. Case AName of
  399. 'scriptstacktraceelements' : SetLength(FscriptStackTraceElements,ALength);
  400. else
  401. Inherited SetArrayLength(AName,ALength);
  402. end;
  403. end;
  404. {$ENDIF VER2_6}
  405. { --------------------------------------------------------------------
  406. TScriptStackTraceElement
  407. --------------------------------------------------------------------}
  408. Procedure TScriptStackTraceElement.Set_function(AIndex : Integer; const AValue : String);
  409. begin
  410. If (F_function=AValue) then exit;
  411. F_function:=AValue;
  412. MarkPropertyChanged(AIndex);
  413. end;
  414. Procedure TScriptStackTraceElement.SetlineNumber(AIndex : Integer; const AValue : integer);
  415. begin
  416. If (FlineNumber=AValue) then exit;
  417. FlineNumber:=AValue;
  418. MarkPropertyChanged(AIndex);
  419. end;
  420. Class Function TScriptStackTraceElement.ExportPropertyName(Const AName : String) :String;
  421. begin
  422. Case AName of
  423. '_function' : Result:='function';
  424. else
  425. Result:=Inherited ExportPropertyName(AName);
  426. end;
  427. end;
  428. { --------------------------------------------------------------------
  429. TExecutionResponse
  430. --------------------------------------------------------------------}
  431. Procedure TExecutionResponse.Setresult(AIndex : Integer; const AValue : TJSONSchema);
  432. begin
  433. If (Fresult=AValue) then exit;
  434. Fresult:=AValue;
  435. MarkPropertyChanged(AIndex);
  436. end;
  437. { --------------------------------------------------------------------
  438. TScriptsResource
  439. --------------------------------------------------------------------}
  440. Class Function TScriptsResource.ResourceName : String;
  441. begin
  442. Result:='scripts';
  443. end;
  444. Class Function TScriptsResource.DefaultAPI : TGoogleAPIClass;
  445. begin
  446. Result:=TscriptAPI;
  447. end;
  448. Function TScriptsResource.Run(scriptId: string; aExecutionRequest : TExecutionRequest) : TOperation;
  449. Const
  450. _HTTPMethod = 'POST';
  451. _Path = 'v1/scripts/{scriptId}:run';
  452. _Methodid = 'script.scripts.run';
  453. Var
  454. _P : String;
  455. begin
  456. _P:=SubstitutePath(_Path,['scriptId',scriptId]);
  457. Result:=ServiceCall(_HTTPMethod,_P,'',aExecutionRequest,TOperation) as TOperation;
  458. end;
  459. { --------------------------------------------------------------------
  460. TScriptAPI
  461. --------------------------------------------------------------------}
  462. Class Function TScriptAPI.APIName : String;
  463. begin
  464. Result:='script';
  465. end;
  466. Class Function TScriptAPI.APIVersion : String;
  467. begin
  468. Result:='v1';
  469. end;
  470. Class Function TScriptAPI.APIRevision : String;
  471. begin
  472. Result:='20160426';
  473. end;
  474. Class Function TScriptAPI.APIID : String;
  475. begin
  476. Result:='script:v1';
  477. end;
  478. Class Function TScriptAPI.APITitle : String;
  479. begin
  480. Result:='Google Apps Script Execution API';
  481. end;
  482. Class Function TScriptAPI.APIDescription : String;
  483. begin
  484. Result:='Executes Google Apps Script projects.';
  485. end;
  486. Class Function TScriptAPI.APIOwnerDomain : String;
  487. begin
  488. Result:='google.com';
  489. end;
  490. Class Function TScriptAPI.APIOwnerName : String;
  491. begin
  492. Result:='Google';
  493. end;
  494. Class Function TScriptAPI.APIIcon16 : String;
  495. begin
  496. Result:='http://www.google.com/images/icons/product/search-16.gif';
  497. end;
  498. Class Function TScriptAPI.APIIcon32 : String;
  499. begin
  500. Result:='http://www.google.com/images/icons/product/search-32.gif';
  501. end;
  502. Class Function TScriptAPI.APIdocumentationLink : String;
  503. begin
  504. Result:='https://developers.google.com/apps-script/execution/rest/v1/scripts/run';
  505. end;
  506. Class Function TScriptAPI.APIrootUrl : string;
  507. begin
  508. Result:='https://script.googleapis.com/';
  509. end;
  510. Class Function TScriptAPI.APIbasePath : string;
  511. begin
  512. Result:='';
  513. end;
  514. Class Function TScriptAPI.APIbaseURL : String;
  515. begin
  516. Result:='https://script.googleapis.com/';
  517. end;
  518. Class Function TScriptAPI.APIProtocol : string;
  519. begin
  520. Result:='rest';
  521. end;
  522. Class Function TScriptAPI.APIservicePath : string;
  523. begin
  524. Result:='';
  525. end;
  526. Class Function TScriptAPI.APIbatchPath : String;
  527. begin
  528. Result:='batch';
  529. end;
  530. Class Function TScriptAPI.APIAuthScopes : TScopeInfoArray;
  531. begin
  532. SetLength(Result,11);
  533. Result[0].Name:='https://mail.google.com/';
  534. Result[0].Description:='View and manage your mail';
  535. Result[1].Name:='https://www.google.com/calendar/feeds';
  536. Result[1].Description:='Manage your calendars';
  537. Result[2].Name:='https://www.google.com/m8/feeds';
  538. Result[2].Description:='Manage your contacts';
  539. Result[3].Name:='https://www.googleapis.com/auth/admin.directory.group';
  540. Result[3].Description:='View and manage the provisioning of groups on your domain';
  541. Result[4].Name:='https://www.googleapis.com/auth/admin.directory.user';
  542. Result[4].Description:='View and manage the provisioning of users on your domain';
  543. Result[5].Name:='https://www.googleapis.com/auth/drive';
  544. Result[5].Description:='View and manage the files in your Google Drive';
  545. Result[6].Name:='https://www.googleapis.com/auth/forms';
  546. Result[6].Description:='View and manage your forms in Google Drive';
  547. Result[7].Name:='https://www.googleapis.com/auth/forms.currentonly';
  548. Result[7].Description:='View and manage forms that this application has been installed in';
  549. Result[8].Name:='https://www.googleapis.com/auth/groups';
  550. Result[8].Description:='View and manage your Google Groups';
  551. Result[9].Name:='https://www.googleapis.com/auth/spreadsheets';
  552. Result[9].Description:='View and manage your spreadsheets in Google Drive';
  553. Result[10].Name:='https://www.googleapis.com/auth/userinfo.email';
  554. Result[10].Description:='View your email address';
  555. end;
  556. Class Function TScriptAPI.APINeedsAuth : Boolean;
  557. begin
  558. Result:=True;
  559. end;
  560. Class Procedure TScriptAPI.RegisterAPIResources;
  561. begin
  562. TExecutionRequest.RegisterObject;
  563. TOperationTypemetadata.RegisterObject;
  564. TOperationTyperesponse.RegisterObject;
  565. TOperation.RegisterObject;
  566. TStatusTypedetailsItem.RegisterObject;
  567. TStatus.RegisterObject;
  568. TExecutionError.RegisterObject;
  569. TScriptStackTraceElement.RegisterObject;
  570. TExecutionResponse.RegisterObject;
  571. end;
  572. Function TScriptAPI.GetScriptsInstance : TScriptsResource;
  573. begin
  574. if (FScriptsInstance=Nil) then
  575. FScriptsInstance:=CreateScriptsResource;
  576. Result:=FScriptsInstance;
  577. end;
  578. Function TScriptAPI.CreateScriptsResource : TScriptsResource;
  579. begin
  580. Result:=CreateScriptsResource(Self);
  581. end;
  582. Function TScriptAPI.CreateScriptsResource(AOwner : TComponent) : TScriptsResource;
  583. begin
  584. Result:=TScriptsResource.Create(AOwner);
  585. Result.API:=Self.API;
  586. end;
  587. initialization
  588. TScriptAPI.RegisterAPI;
  589. end.