googleyoutubereporting.pp 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. unit googleyoutubereporting;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, googleservice, restbase, googlebase;
  6. type
  7. //Top-level schema types
  8. TMedia = Class;
  9. TListReportTypesResponse = Class;
  10. TReportType = Class;
  11. TJob = Class;
  12. TListJobsResponse = Class;
  13. TEmpty = Class;
  14. TListReportsResponse = Class;
  15. TReport = Class;
  16. TMediaArray = Array of TMedia;
  17. TListReportTypesResponseArray = Array of TListReportTypesResponse;
  18. TReportTypeArray = Array of TReportType;
  19. TJobArray = Array of TJob;
  20. TListJobsResponseArray = Array of TListJobsResponse;
  21. TEmptyArray = Array of TEmpty;
  22. TListReportsResponseArray = Array of TListReportsResponse;
  23. TReportArray = Array of TReport;
  24. //Anonymous types, using auto-generated names
  25. TListReportTypesResponseTypereportTypesArray = Array of TReportType;
  26. TListJobsResponseTypejobsArray = Array of TJob;
  27. TListReportsResponseTypereportsArray = Array of TReport;
  28. { --------------------------------------------------------------------
  29. TMedia
  30. --------------------------------------------------------------------}
  31. TMedia = Class(TGoogleBaseObject)
  32. Private
  33. FresourceName : String;
  34. Protected
  35. //Property setters
  36. Procedure SetresourceName(AIndex : Integer; const AValue : String); virtual;
  37. Public
  38. Published
  39. Property resourceName : String Index 0 Read FresourceName Write SetresourceName;
  40. end;
  41. TMediaClass = Class of TMedia;
  42. { --------------------------------------------------------------------
  43. TListReportTypesResponse
  44. --------------------------------------------------------------------}
  45. TListReportTypesResponse = Class(TGoogleBaseObject)
  46. Private
  47. FreportTypes : TListReportTypesResponseTypereportTypesArray;
  48. FnextPageToken : String;
  49. Protected
  50. //Property setters
  51. Procedure SetreportTypes(AIndex : Integer; const AValue : TListReportTypesResponseTypereportTypesArray); virtual;
  52. Procedure SetnextPageToken(AIndex : Integer; const AValue : String); virtual;
  53. //2.6.4. bug workaround
  54. {$IFDEF VER2_6}
  55. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  56. {$ENDIF VER2_6}
  57. Public
  58. Published
  59. Property reportTypes : TListReportTypesResponseTypereportTypesArray Index 0 Read FreportTypes Write SetreportTypes;
  60. Property nextPageToken : String Index 8 Read FnextPageToken Write SetnextPageToken;
  61. end;
  62. TListReportTypesResponseClass = Class of TListReportTypesResponse;
  63. { --------------------------------------------------------------------
  64. TReportType
  65. --------------------------------------------------------------------}
  66. TReportType = Class(TGoogleBaseObject)
  67. Private
  68. Fid : String;
  69. Fname : String;
  70. FdeprecateTime : String;
  71. FsystemManaged : boolean;
  72. Protected
  73. //Property setters
  74. Procedure Setid(AIndex : Integer; const AValue : String); virtual;
  75. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  76. Procedure SetdeprecateTime(AIndex : Integer; const AValue : String); virtual;
  77. Procedure SetsystemManaged(AIndex : Integer; const AValue : boolean); virtual;
  78. Public
  79. Published
  80. Property id : String Index 0 Read Fid Write Setid;
  81. Property name : String Index 8 Read Fname Write Setname;
  82. Property deprecateTime : String Index 16 Read FdeprecateTime Write SetdeprecateTime;
  83. Property systemManaged : boolean Index 24 Read FsystemManaged Write SetsystemManaged;
  84. end;
  85. TReportTypeClass = Class of TReportType;
  86. { --------------------------------------------------------------------
  87. TJob
  88. --------------------------------------------------------------------}
  89. TJob = Class(TGoogleBaseObject)
  90. Private
  91. Fid : String;
  92. FreportTypeId : String;
  93. Fname : String;
  94. FcreateTime : String;
  95. FexpireTime : String;
  96. FsystemManaged : boolean;
  97. Protected
  98. //Property setters
  99. Procedure Setid(AIndex : Integer; const AValue : String); virtual;
  100. Procedure SetreportTypeId(AIndex : Integer; const AValue : String); virtual;
  101. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  102. Procedure SetcreateTime(AIndex : Integer; const AValue : String); virtual;
  103. Procedure SetexpireTime(AIndex : Integer; const AValue : String); virtual;
  104. Procedure SetsystemManaged(AIndex : Integer; const AValue : boolean); virtual;
  105. Public
  106. Published
  107. Property id : String Index 0 Read Fid Write Setid;
  108. Property reportTypeId : String Index 8 Read FreportTypeId Write SetreportTypeId;
  109. Property name : String Index 16 Read Fname Write Setname;
  110. Property createTime : String Index 24 Read FcreateTime Write SetcreateTime;
  111. Property expireTime : String Index 32 Read FexpireTime Write SetexpireTime;
  112. Property systemManaged : boolean Index 40 Read FsystemManaged Write SetsystemManaged;
  113. end;
  114. TJobClass = Class of TJob;
  115. { --------------------------------------------------------------------
  116. TListJobsResponse
  117. --------------------------------------------------------------------}
  118. TListJobsResponse = Class(TGoogleBaseObject)
  119. Private
  120. Fjobs : TListJobsResponseTypejobsArray;
  121. FnextPageToken : String;
  122. Protected
  123. //Property setters
  124. Procedure Setjobs(AIndex : Integer; const AValue : TListJobsResponseTypejobsArray); virtual;
  125. Procedure SetnextPageToken(AIndex : Integer; const AValue : String); virtual;
  126. //2.6.4. bug workaround
  127. {$IFDEF VER2_6}
  128. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  129. {$ENDIF VER2_6}
  130. Public
  131. Published
  132. Property jobs : TListJobsResponseTypejobsArray Index 0 Read Fjobs Write Setjobs;
  133. Property nextPageToken : String Index 8 Read FnextPageToken Write SetnextPageToken;
  134. end;
  135. TListJobsResponseClass = Class of TListJobsResponse;
  136. { --------------------------------------------------------------------
  137. TEmpty
  138. --------------------------------------------------------------------}
  139. TEmpty = Class(TGoogleBaseObject)
  140. Private
  141. Protected
  142. //Property setters
  143. Public
  144. Published
  145. end;
  146. TEmptyClass = Class of TEmpty;
  147. { --------------------------------------------------------------------
  148. TListReportsResponse
  149. --------------------------------------------------------------------}
  150. TListReportsResponse = Class(TGoogleBaseObject)
  151. Private
  152. Freports : TListReportsResponseTypereportsArray;
  153. FnextPageToken : String;
  154. Protected
  155. //Property setters
  156. Procedure Setreports(AIndex : Integer; const AValue : TListReportsResponseTypereportsArray); virtual;
  157. Procedure SetnextPageToken(AIndex : Integer; const AValue : String); virtual;
  158. //2.6.4. bug workaround
  159. {$IFDEF VER2_6}
  160. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  161. {$ENDIF VER2_6}
  162. Public
  163. Published
  164. Property reports : TListReportsResponseTypereportsArray Index 0 Read Freports Write Setreports;
  165. Property nextPageToken : String Index 8 Read FnextPageToken Write SetnextPageToken;
  166. end;
  167. TListReportsResponseClass = Class of TListReportsResponse;
  168. { --------------------------------------------------------------------
  169. TReport
  170. --------------------------------------------------------------------}
  171. TReport = Class(TGoogleBaseObject)
  172. Private
  173. Fid : String;
  174. FjobId : String;
  175. FjobExpireTime : String;
  176. FstartTime : String;
  177. FendTime : String;
  178. FcreateTime : String;
  179. FdownloadUrl : String;
  180. Protected
  181. //Property setters
  182. Procedure Setid(AIndex : Integer; const AValue : String); virtual;
  183. Procedure SetjobId(AIndex : Integer; const AValue : String); virtual;
  184. Procedure SetjobExpireTime(AIndex : Integer; const AValue : String); virtual;
  185. Procedure SetstartTime(AIndex : Integer; const AValue : String); virtual;
  186. Procedure SetendTime(AIndex : Integer; const AValue : String); virtual;
  187. Procedure SetcreateTime(AIndex : Integer; const AValue : String); virtual;
  188. Procedure SetdownloadUrl(AIndex : Integer; const AValue : String); virtual;
  189. Public
  190. Published
  191. Property id : String Index 0 Read Fid Write Setid;
  192. Property jobId : String Index 8 Read FjobId Write SetjobId;
  193. Property jobExpireTime : String Index 16 Read FjobExpireTime Write SetjobExpireTime;
  194. Property startTime : String Index 24 Read FstartTime Write SetstartTime;
  195. Property endTime : String Index 32 Read FendTime Write SetendTime;
  196. Property createTime : String Index 40 Read FcreateTime Write SetcreateTime;
  197. Property downloadUrl : String Index 48 Read FdownloadUrl Write SetdownloadUrl;
  198. end;
  199. TReportClass = Class of TReport;
  200. { --------------------------------------------------------------------
  201. TMediaResource
  202. --------------------------------------------------------------------}
  203. TMediaResource = Class(TGoogleResource)
  204. Public
  205. Class Function ResourceName : String; override;
  206. Class Function DefaultAPI : TGoogleAPIClass; override;
  207. Function Download(_resourceName: string) : TMedia;
  208. end;
  209. { --------------------------------------------------------------------
  210. TReportTypesResource
  211. --------------------------------------------------------------------}
  212. //Optional query Options for TReportTypesResource, method List
  213. TReportTypesListOptions = Record
  214. onBehalfOfContentOwner : String;
  215. pageSize : integer;
  216. pageToken : String;
  217. includeSystemManaged : boolean;
  218. end;
  219. TReportTypesResource = Class(TGoogleResource)
  220. Public
  221. Class Function ResourceName : String; override;
  222. Class Function DefaultAPI : TGoogleAPIClass; override;
  223. Function List(AQuery : string = '') : TListReportTypesResponse;
  224. Function List(AQuery : TReportTypeslistOptions) : TListReportTypesResponse;
  225. end;
  226. { --------------------------------------------------------------------
  227. TJobsReportsResource
  228. --------------------------------------------------------------------}
  229. //Optional query Options for TJobsReportsResource, method List
  230. TJobsReportsListOptions = Record
  231. onBehalfOfContentOwner : String;
  232. pageSize : integer;
  233. pageToken : String;
  234. createdAfter : String;
  235. startTimeAtOrAfter : String;
  236. startTimeBefore : String;
  237. end;
  238. //Optional query Options for TJobsReportsResource, method Get
  239. TJobsReportsGetOptions = Record
  240. onBehalfOfContentOwner : String;
  241. end;
  242. TJobsReportsResource = Class(TGoogleResource)
  243. Public
  244. Class Function ResourceName : String; override;
  245. Class Function DefaultAPI : TGoogleAPIClass; override;
  246. Function List(jobId: string; AQuery : string = '') : TListReportsResponse;
  247. Function List(jobId: string; AQuery : TJobsReportslistOptions) : TListReportsResponse;
  248. Function Get(jobId: string; reportId: string; AQuery : string = '') : TReport;
  249. Function Get(jobId: string; reportId: string; AQuery : TJobsReportsgetOptions) : TReport;
  250. end;
  251. { --------------------------------------------------------------------
  252. TJobsResource
  253. --------------------------------------------------------------------}
  254. //Optional query Options for TJobsResource, method Create
  255. TJobsCreateOptions = Record
  256. onBehalfOfContentOwner : String;
  257. end;
  258. //Optional query Options for TJobsResource, method List
  259. TJobsListOptions = Record
  260. onBehalfOfContentOwner : String;
  261. pageSize : integer;
  262. pageToken : String;
  263. includeSystemManaged : boolean;
  264. end;
  265. //Optional query Options for TJobsResource, method Get
  266. TJobsGetOptions = Record
  267. onBehalfOfContentOwner : String;
  268. end;
  269. //Optional query Options for TJobsResource, method Delete
  270. TJobsDeleteOptions = Record
  271. onBehalfOfContentOwner : String;
  272. end;
  273. TJobsResource = Class(TGoogleResource)
  274. Private
  275. FReportsInstance : TJobsReportsResource;
  276. Function GetReportsInstance : TJobsReportsResource;virtual;
  277. Public
  278. Class Function ResourceName : String; override;
  279. Class Function DefaultAPI : TGoogleAPIClass; override;
  280. Function Create(aJob : TJob; AQuery : string = '') : TJob;overload;
  281. Function Create(aJob : TJob; AQuery : TJobscreateOptions) : TJob;overload;
  282. Function List(AQuery : string = '') : TListJobsResponse;
  283. Function List(AQuery : TJobslistOptions) : TListJobsResponse;
  284. Function Get(jobId: string; AQuery : string = '') : TJob;
  285. Function Get(jobId: string; AQuery : TJobsgetOptions) : TJob;
  286. Function Delete(jobId: string; AQuery : string = '') : TEmpty;
  287. Function Delete(jobId: string; AQuery : TJobsdeleteOptions) : TEmpty;
  288. Function CreateReportsResource(AOwner : TComponent) : TJobsReportsResource;virtual;overload;
  289. Function CreateReportsResource : TJobsReportsResource;virtual;overload;
  290. Property ReportsResource : TJobsReportsResource Read GetReportsInstance;
  291. end;
  292. { --------------------------------------------------------------------
  293. TYoutubereportingAPI
  294. --------------------------------------------------------------------}
  295. TYoutubereportingAPI = Class(TGoogleAPI)
  296. Private
  297. FMediaInstance : TMediaResource;
  298. FReportTypesInstance : TReportTypesResource;
  299. FJobsReportsInstance : TJobsReportsResource;
  300. FJobsInstance : TJobsResource;
  301. Function GetMediaInstance : TMediaResource;virtual;
  302. Function GetReportTypesInstance : TReportTypesResource;virtual;
  303. Function GetJobsReportsInstance : TJobsReportsResource;virtual;
  304. Function GetJobsInstance : TJobsResource;virtual;
  305. Public
  306. //Override class functions with API info
  307. Class Function APIName : String; override;
  308. Class Function APIVersion : String; override;
  309. Class Function APIRevision : String; override;
  310. Class Function APIID : String; override;
  311. Class Function APITitle : String; override;
  312. Class Function APIDescription : String; override;
  313. Class Function APIOwnerDomain : String; override;
  314. Class Function APIOwnerName : String; override;
  315. Class Function APIIcon16 : String; override;
  316. Class Function APIIcon32 : String; override;
  317. Class Function APIdocumentationLink : String; override;
  318. Class Function APIrootUrl : string; override;
  319. Class Function APIbasePath : string;override;
  320. Class Function APIbaseURL : String;override;
  321. Class Function APIProtocol : string;override;
  322. Class Function APIservicePath : string;override;
  323. Class Function APIbatchPath : String;override;
  324. Class Function APIAuthScopes : TScopeInfoArray;override;
  325. Class Function APINeedsAuth : Boolean;override;
  326. Class Procedure RegisterAPIResources; override;
  327. //Add create function for resources
  328. Function CreateMediaResource(AOwner : TComponent) : TMediaResource;virtual;overload;
  329. Function CreateMediaResource : TMediaResource;virtual;overload;
  330. Function CreateReportTypesResource(AOwner : TComponent) : TReportTypesResource;virtual;overload;
  331. Function CreateReportTypesResource : TReportTypesResource;virtual;overload;
  332. Function CreateJobsReportsResource(AOwner : TComponent) : TJobsReportsResource;virtual;overload;
  333. Function CreateJobsReportsResource : TJobsReportsResource;virtual;overload;
  334. Function CreateJobsResource(AOwner : TComponent) : TJobsResource;virtual;overload;
  335. Function CreateJobsResource : TJobsResource;virtual;overload;
  336. //Add default on-demand instances for resources
  337. Property MediaResource : TMediaResource Read GetMediaInstance;
  338. Property ReportTypesResource : TReportTypesResource Read GetReportTypesInstance;
  339. Property JobsReportsResource : TJobsReportsResource Read GetJobsReportsInstance;
  340. Property JobsResource : TJobsResource Read GetJobsInstance;
  341. end;
  342. implementation
  343. { --------------------------------------------------------------------
  344. TMedia
  345. --------------------------------------------------------------------}
  346. Procedure TMedia.SetresourceName(AIndex : Integer; const AValue : String);
  347. begin
  348. If (FresourceName=AValue) then exit;
  349. FresourceName:=AValue;
  350. MarkPropertyChanged(AIndex);
  351. end;
  352. { --------------------------------------------------------------------
  353. TListReportTypesResponse
  354. --------------------------------------------------------------------}
  355. Procedure TListReportTypesResponse.SetreportTypes(AIndex : Integer; const AValue : TListReportTypesResponseTypereportTypesArray);
  356. begin
  357. If (FreportTypes=AValue) then exit;
  358. FreportTypes:=AValue;
  359. MarkPropertyChanged(AIndex);
  360. end;
  361. Procedure TListReportTypesResponse.SetnextPageToken(AIndex : Integer; const AValue : String);
  362. begin
  363. If (FnextPageToken=AValue) then exit;
  364. FnextPageToken:=AValue;
  365. MarkPropertyChanged(AIndex);
  366. end;
  367. //2.6.4. bug workaround
  368. {$IFDEF VER2_6}
  369. Procedure TListReportTypesResponse.SetArrayLength(Const AName : String; ALength : Longint);
  370. begin
  371. Case AName of
  372. 'reporttypes' : SetLength(FreportTypes,ALength);
  373. else
  374. Inherited SetArrayLength(AName,ALength);
  375. end;
  376. end;
  377. {$ENDIF VER2_6}
  378. { --------------------------------------------------------------------
  379. TReportType
  380. --------------------------------------------------------------------}
  381. Procedure TReportType.Setid(AIndex : Integer; const AValue : String);
  382. begin
  383. If (Fid=AValue) then exit;
  384. Fid:=AValue;
  385. MarkPropertyChanged(AIndex);
  386. end;
  387. Procedure TReportType.Setname(AIndex : Integer; const AValue : String);
  388. begin
  389. If (Fname=AValue) then exit;
  390. Fname:=AValue;
  391. MarkPropertyChanged(AIndex);
  392. end;
  393. Procedure TReportType.SetdeprecateTime(AIndex : Integer; const AValue : String);
  394. begin
  395. If (FdeprecateTime=AValue) then exit;
  396. FdeprecateTime:=AValue;
  397. MarkPropertyChanged(AIndex);
  398. end;
  399. Procedure TReportType.SetsystemManaged(AIndex : Integer; const AValue : boolean);
  400. begin
  401. If (FsystemManaged=AValue) then exit;
  402. FsystemManaged:=AValue;
  403. MarkPropertyChanged(AIndex);
  404. end;
  405. { --------------------------------------------------------------------
  406. TJob
  407. --------------------------------------------------------------------}
  408. Procedure TJob.Setid(AIndex : Integer; const AValue : String);
  409. begin
  410. If (Fid=AValue) then exit;
  411. Fid:=AValue;
  412. MarkPropertyChanged(AIndex);
  413. end;
  414. Procedure TJob.SetreportTypeId(AIndex : Integer; const AValue : String);
  415. begin
  416. If (FreportTypeId=AValue) then exit;
  417. FreportTypeId:=AValue;
  418. MarkPropertyChanged(AIndex);
  419. end;
  420. Procedure TJob.Setname(AIndex : Integer; const AValue : String);
  421. begin
  422. If (Fname=AValue) then exit;
  423. Fname:=AValue;
  424. MarkPropertyChanged(AIndex);
  425. end;
  426. Procedure TJob.SetcreateTime(AIndex : Integer; const AValue : String);
  427. begin
  428. If (FcreateTime=AValue) then exit;
  429. FcreateTime:=AValue;
  430. MarkPropertyChanged(AIndex);
  431. end;
  432. Procedure TJob.SetexpireTime(AIndex : Integer; const AValue : String);
  433. begin
  434. If (FexpireTime=AValue) then exit;
  435. FexpireTime:=AValue;
  436. MarkPropertyChanged(AIndex);
  437. end;
  438. Procedure TJob.SetsystemManaged(AIndex : Integer; const AValue : boolean);
  439. begin
  440. If (FsystemManaged=AValue) then exit;
  441. FsystemManaged:=AValue;
  442. MarkPropertyChanged(AIndex);
  443. end;
  444. { --------------------------------------------------------------------
  445. TListJobsResponse
  446. --------------------------------------------------------------------}
  447. Procedure TListJobsResponse.Setjobs(AIndex : Integer; const AValue : TListJobsResponseTypejobsArray);
  448. begin
  449. If (Fjobs=AValue) then exit;
  450. Fjobs:=AValue;
  451. MarkPropertyChanged(AIndex);
  452. end;
  453. Procedure TListJobsResponse.SetnextPageToken(AIndex : Integer; const AValue : String);
  454. begin
  455. If (FnextPageToken=AValue) then exit;
  456. FnextPageToken:=AValue;
  457. MarkPropertyChanged(AIndex);
  458. end;
  459. //2.6.4. bug workaround
  460. {$IFDEF VER2_6}
  461. Procedure TListJobsResponse.SetArrayLength(Const AName : String; ALength : Longint);
  462. begin
  463. Case AName of
  464. 'jobs' : SetLength(Fjobs,ALength);
  465. else
  466. Inherited SetArrayLength(AName,ALength);
  467. end;
  468. end;
  469. {$ENDIF VER2_6}
  470. { --------------------------------------------------------------------
  471. TEmpty
  472. --------------------------------------------------------------------}
  473. { --------------------------------------------------------------------
  474. TListReportsResponse
  475. --------------------------------------------------------------------}
  476. Procedure TListReportsResponse.Setreports(AIndex : Integer; const AValue : TListReportsResponseTypereportsArray);
  477. begin
  478. If (Freports=AValue) then exit;
  479. Freports:=AValue;
  480. MarkPropertyChanged(AIndex);
  481. end;
  482. Procedure TListReportsResponse.SetnextPageToken(AIndex : Integer; const AValue : String);
  483. begin
  484. If (FnextPageToken=AValue) then exit;
  485. FnextPageToken:=AValue;
  486. MarkPropertyChanged(AIndex);
  487. end;
  488. //2.6.4. bug workaround
  489. {$IFDEF VER2_6}
  490. Procedure TListReportsResponse.SetArrayLength(Const AName : String; ALength : Longint);
  491. begin
  492. Case AName of
  493. 'reports' : SetLength(Freports,ALength);
  494. else
  495. Inherited SetArrayLength(AName,ALength);
  496. end;
  497. end;
  498. {$ENDIF VER2_6}
  499. { --------------------------------------------------------------------
  500. TReport
  501. --------------------------------------------------------------------}
  502. Procedure TReport.Setid(AIndex : Integer; const AValue : String);
  503. begin
  504. If (Fid=AValue) then exit;
  505. Fid:=AValue;
  506. MarkPropertyChanged(AIndex);
  507. end;
  508. Procedure TReport.SetjobId(AIndex : Integer; const AValue : String);
  509. begin
  510. If (FjobId=AValue) then exit;
  511. FjobId:=AValue;
  512. MarkPropertyChanged(AIndex);
  513. end;
  514. Procedure TReport.SetjobExpireTime(AIndex : Integer; const AValue : String);
  515. begin
  516. If (FjobExpireTime=AValue) then exit;
  517. FjobExpireTime:=AValue;
  518. MarkPropertyChanged(AIndex);
  519. end;
  520. Procedure TReport.SetstartTime(AIndex : Integer; const AValue : String);
  521. begin
  522. If (FstartTime=AValue) then exit;
  523. FstartTime:=AValue;
  524. MarkPropertyChanged(AIndex);
  525. end;
  526. Procedure TReport.SetendTime(AIndex : Integer; const AValue : String);
  527. begin
  528. If (FendTime=AValue) then exit;
  529. FendTime:=AValue;
  530. MarkPropertyChanged(AIndex);
  531. end;
  532. Procedure TReport.SetcreateTime(AIndex : Integer; const AValue : String);
  533. begin
  534. If (FcreateTime=AValue) then exit;
  535. FcreateTime:=AValue;
  536. MarkPropertyChanged(AIndex);
  537. end;
  538. Procedure TReport.SetdownloadUrl(AIndex : Integer; const AValue : String);
  539. begin
  540. If (FdownloadUrl=AValue) then exit;
  541. FdownloadUrl:=AValue;
  542. MarkPropertyChanged(AIndex);
  543. end;
  544. { --------------------------------------------------------------------
  545. TMediaResource
  546. --------------------------------------------------------------------}
  547. Class Function TMediaResource.ResourceName : String;
  548. begin
  549. Result:='media';
  550. end;
  551. Class Function TMediaResource.DefaultAPI : TGoogleAPIClass;
  552. begin
  553. Result:=TyoutubereportingAPI;
  554. end;
  555. Function TMediaResource.Download(_resourceName: string) : TMedia;
  556. Const
  557. _HTTPMethod = 'GET';
  558. _Path = 'v1/media/{+resourceName}';
  559. _Methodid = 'youtubereporting.media.download';
  560. Var
  561. _P : String;
  562. begin
  563. _P:=SubstitutePath(_Path,['resourceName',_resourceName]);
  564. Result:=ServiceCall(_HTTPMethod,_P,'',Nil,TMedia) as TMedia;
  565. end;
  566. { --------------------------------------------------------------------
  567. TReportTypesResource
  568. --------------------------------------------------------------------}
  569. Class Function TReportTypesResource.ResourceName : String;
  570. begin
  571. Result:='reportTypes';
  572. end;
  573. Class Function TReportTypesResource.DefaultAPI : TGoogleAPIClass;
  574. begin
  575. Result:=TyoutubereportingAPI;
  576. end;
  577. Function TReportTypesResource.List(AQuery : string = '') : TListReportTypesResponse;
  578. Const
  579. _HTTPMethod = 'GET';
  580. _Path = 'v1/reportTypes';
  581. _Methodid = 'youtubereporting.reportTypes.list';
  582. begin
  583. Result:=ServiceCall(_HTTPMethod,_Path,AQuery,Nil,TListReportTypesResponse) as TListReportTypesResponse;
  584. end;
  585. Function TReportTypesResource.List(AQuery : TReportTypeslistOptions) : TListReportTypesResponse;
  586. Var
  587. _Q : String;
  588. begin
  589. _Q:='';
  590. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  591. AddToQuery(_Q,'pageSize',AQuery.pageSize);
  592. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  593. AddToQuery(_Q,'includeSystemManaged',AQuery.includeSystemManaged);
  594. Result:=List(_Q);
  595. end;
  596. { --------------------------------------------------------------------
  597. TJobsReportsResource
  598. --------------------------------------------------------------------}
  599. Class Function TJobsReportsResource.ResourceName : String;
  600. begin
  601. Result:='reports';
  602. end;
  603. Class Function TJobsReportsResource.DefaultAPI : TGoogleAPIClass;
  604. begin
  605. Result:=TyoutubereportingAPI;
  606. end;
  607. Function TJobsReportsResource.List(jobId: string; AQuery : string = '') : TListReportsResponse;
  608. Const
  609. _HTTPMethod = 'GET';
  610. _Path = 'v1/jobs/{jobId}/reports';
  611. _Methodid = 'youtubereporting.jobs.reports.list';
  612. Var
  613. _P : String;
  614. begin
  615. _P:=SubstitutePath(_Path,['jobId',jobId]);
  616. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TListReportsResponse) as TListReportsResponse;
  617. end;
  618. Function TJobsReportsResource.List(jobId: string; AQuery : TJobsReportslistOptions) : TListReportsResponse;
  619. Var
  620. _Q : String;
  621. begin
  622. _Q:='';
  623. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  624. AddToQuery(_Q,'pageSize',AQuery.pageSize);
  625. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  626. AddToQuery(_Q,'createdAfter',AQuery.createdAfter);
  627. AddToQuery(_Q,'startTimeAtOrAfter',AQuery.startTimeAtOrAfter);
  628. AddToQuery(_Q,'startTimeBefore',AQuery.startTimeBefore);
  629. Result:=List(jobId,_Q);
  630. end;
  631. Function TJobsReportsResource.Get(jobId: string; reportId: string; AQuery : string = '') : TReport;
  632. Const
  633. _HTTPMethod = 'GET';
  634. _Path = 'v1/jobs/{jobId}/reports/{reportId}';
  635. _Methodid = 'youtubereporting.jobs.reports.get';
  636. Var
  637. _P : String;
  638. begin
  639. _P:=SubstitutePath(_Path,['jobId',jobId,'reportId',reportId]);
  640. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TReport) as TReport;
  641. end;
  642. Function TJobsReportsResource.Get(jobId: string; reportId: string; AQuery : TJobsReportsgetOptions) : TReport;
  643. Var
  644. _Q : String;
  645. begin
  646. _Q:='';
  647. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  648. Result:=Get(jobId,reportId,_Q);
  649. end;
  650. { --------------------------------------------------------------------
  651. TJobsResource
  652. --------------------------------------------------------------------}
  653. Class Function TJobsResource.ResourceName : String;
  654. begin
  655. Result:='jobs';
  656. end;
  657. Class Function TJobsResource.DefaultAPI : TGoogleAPIClass;
  658. begin
  659. Result:=TyoutubereportingAPI;
  660. end;
  661. Function TJobsResource.Create(aJob : TJob; AQuery : string = '') : TJob;
  662. Const
  663. _HTTPMethod = 'POST';
  664. _Path = 'v1/jobs';
  665. _Methodid = 'youtubereporting.jobs.create';
  666. begin
  667. Result:=ServiceCall(_HTTPMethod,_Path,AQuery,aJob,TJob) as TJob;
  668. end;
  669. Function TJobsResource.Create(aJob : TJob; AQuery : TJobscreateOptions) : TJob;
  670. Var
  671. _Q : String;
  672. begin
  673. _Q:='';
  674. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  675. Result:=Create(aJob,_Q);
  676. end;
  677. Function TJobsResource.List(AQuery : string = '') : TListJobsResponse;
  678. Const
  679. _HTTPMethod = 'GET';
  680. _Path = 'v1/jobs';
  681. _Methodid = 'youtubereporting.jobs.list';
  682. begin
  683. Result:=ServiceCall(_HTTPMethod,_Path,AQuery,Nil,TListJobsResponse) as TListJobsResponse;
  684. end;
  685. Function TJobsResource.List(AQuery : TJobslistOptions) : TListJobsResponse;
  686. Var
  687. _Q : String;
  688. begin
  689. _Q:='';
  690. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  691. AddToQuery(_Q,'pageSize',AQuery.pageSize);
  692. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  693. AddToQuery(_Q,'includeSystemManaged',AQuery.includeSystemManaged);
  694. Result:=List(_Q);
  695. end;
  696. Function TJobsResource.Get(jobId: string; AQuery : string = '') : TJob;
  697. Const
  698. _HTTPMethod = 'GET';
  699. _Path = 'v1/jobs/{jobId}';
  700. _Methodid = 'youtubereporting.jobs.get';
  701. Var
  702. _P : String;
  703. begin
  704. _P:=SubstitutePath(_Path,['jobId',jobId]);
  705. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TJob) as TJob;
  706. end;
  707. Function TJobsResource.Get(jobId: string; AQuery : TJobsgetOptions) : TJob;
  708. Var
  709. _Q : String;
  710. begin
  711. _Q:='';
  712. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  713. Result:=Get(jobId,_Q);
  714. end;
  715. Function TJobsResource.Delete(jobId: string; AQuery : string = '') : TEmpty;
  716. Const
  717. _HTTPMethod = 'DELETE';
  718. _Path = 'v1/jobs/{jobId}';
  719. _Methodid = 'youtubereporting.jobs.delete';
  720. Var
  721. _P : String;
  722. begin
  723. _P:=SubstitutePath(_Path,['jobId',jobId]);
  724. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TEmpty) as TEmpty;
  725. end;
  726. Function TJobsResource.Delete(jobId: string; AQuery : TJobsdeleteOptions) : TEmpty;
  727. Var
  728. _Q : String;
  729. begin
  730. _Q:='';
  731. AddToQuery(_Q,'onBehalfOfContentOwner',AQuery.onBehalfOfContentOwner);
  732. Result:=Delete(jobId,_Q);
  733. end;
  734. Function TJobsResource.GetReportsInstance : TJobsReportsResource;
  735. begin
  736. if (FReportsInstance=Nil) then
  737. FReportsInstance:=CreateReportsResource;
  738. Result:=FReportsInstance;
  739. end;
  740. Function TJobsResource.CreateReportsResource : TJobsReportsResource;
  741. begin
  742. Result:=CreateReportsResource(Self);
  743. end;
  744. Function TJobsResource.CreateReportsResource(AOwner : TComponent) : TJobsReportsResource;
  745. begin
  746. Result:=TJobsReportsResource.Create(AOwner);
  747. Result.API:=Self.API;
  748. end;
  749. { --------------------------------------------------------------------
  750. TYoutubereportingAPI
  751. --------------------------------------------------------------------}
  752. Class Function TYoutubereportingAPI.APIName : String;
  753. begin
  754. Result:='youtubereporting';
  755. end;
  756. Class Function TYoutubereportingAPI.APIVersion : String;
  757. begin
  758. Result:='v1';
  759. end;
  760. Class Function TYoutubereportingAPI.APIRevision : String;
  761. begin
  762. Result:='20160517';
  763. end;
  764. Class Function TYoutubereportingAPI.APIID : String;
  765. begin
  766. Result:='youtubereporting:v1';
  767. end;
  768. Class Function TYoutubereportingAPI.APITitle : String;
  769. begin
  770. Result:='YouTube Reporting API';
  771. end;
  772. Class Function TYoutubereportingAPI.APIDescription : String;
  773. begin
  774. Result:='Schedules reporting jobs containing your YouTube Analytics data and downloads the resulting bulk data reports in the form of CSV files.';
  775. end;
  776. Class Function TYoutubereportingAPI.APIOwnerDomain : String;
  777. begin
  778. Result:='google.com';
  779. end;
  780. Class Function TYoutubereportingAPI.APIOwnerName : String;
  781. begin
  782. Result:='Google';
  783. end;
  784. Class Function TYoutubereportingAPI.APIIcon16 : String;
  785. begin
  786. Result:='http://www.google.com/images/icons/product/search-16.gif';
  787. end;
  788. Class Function TYoutubereportingAPI.APIIcon32 : String;
  789. begin
  790. Result:='http://www.google.com/images/icons/product/search-32.gif';
  791. end;
  792. Class Function TYoutubereportingAPI.APIdocumentationLink : String;
  793. begin
  794. Result:='https://developers.google.com/youtube/reporting/v1/reports/';
  795. end;
  796. Class Function TYoutubereportingAPI.APIrootUrl : string;
  797. begin
  798. Result:='https://youtubereporting.googleapis.com/';
  799. end;
  800. Class Function TYoutubereportingAPI.APIbasePath : string;
  801. begin
  802. Result:='';
  803. end;
  804. Class Function TYoutubereportingAPI.APIbaseURL : String;
  805. begin
  806. Result:='https://youtubereporting.googleapis.com/';
  807. end;
  808. Class Function TYoutubereportingAPI.APIProtocol : string;
  809. begin
  810. Result:='rest';
  811. end;
  812. Class Function TYoutubereportingAPI.APIservicePath : string;
  813. begin
  814. Result:='';
  815. end;
  816. Class Function TYoutubereportingAPI.APIbatchPath : String;
  817. begin
  818. Result:='batch';
  819. end;
  820. Class Function TYoutubereportingAPI.APIAuthScopes : TScopeInfoArray;
  821. begin
  822. SetLength(Result,2);
  823. Result[0].Name:='https://www.googleapis.com/auth/yt-analytics-monetary.readonly';
  824. Result[0].Description:='View monetary and non-monetary YouTube Analytics reports for your YouTube content';
  825. Result[1].Name:='https://www.googleapis.com/auth/yt-analytics.readonly';
  826. Result[1].Description:='View YouTube Analytics reports for your YouTube content';
  827. end;
  828. Class Function TYoutubereportingAPI.APINeedsAuth : Boolean;
  829. begin
  830. Result:=True;
  831. end;
  832. Class Procedure TYoutubereportingAPI.RegisterAPIResources;
  833. begin
  834. TMedia.RegisterObject;
  835. TListReportTypesResponse.RegisterObject;
  836. TReportType.RegisterObject;
  837. TJob.RegisterObject;
  838. TListJobsResponse.RegisterObject;
  839. TEmpty.RegisterObject;
  840. TListReportsResponse.RegisterObject;
  841. TReport.RegisterObject;
  842. end;
  843. Function TYoutubereportingAPI.GetMediaInstance : TMediaResource;
  844. begin
  845. if (FMediaInstance=Nil) then
  846. FMediaInstance:=CreateMediaResource;
  847. Result:=FMediaInstance;
  848. end;
  849. Function TYoutubereportingAPI.CreateMediaResource : TMediaResource;
  850. begin
  851. Result:=CreateMediaResource(Self);
  852. end;
  853. Function TYoutubereportingAPI.CreateMediaResource(AOwner : TComponent) : TMediaResource;
  854. begin
  855. Result:=TMediaResource.Create(AOwner);
  856. Result.API:=Self.API;
  857. end;
  858. Function TYoutubereportingAPI.GetReportTypesInstance : TReportTypesResource;
  859. begin
  860. if (FReportTypesInstance=Nil) then
  861. FReportTypesInstance:=CreateReportTypesResource;
  862. Result:=FReportTypesInstance;
  863. end;
  864. Function TYoutubereportingAPI.CreateReportTypesResource : TReportTypesResource;
  865. begin
  866. Result:=CreateReportTypesResource(Self);
  867. end;
  868. Function TYoutubereportingAPI.CreateReportTypesResource(AOwner : TComponent) : TReportTypesResource;
  869. begin
  870. Result:=TReportTypesResource.Create(AOwner);
  871. Result.API:=Self.API;
  872. end;
  873. Function TYoutubereportingAPI.GetJobsReportsInstance : TJobsReportsResource;
  874. begin
  875. if (FJobsReportsInstance=Nil) then
  876. FJobsReportsInstance:=CreateJobsReportsResource;
  877. Result:=FJobsReportsInstance;
  878. end;
  879. Function TYoutubereportingAPI.CreateJobsReportsResource : TJobsReportsResource;
  880. begin
  881. Result:=CreateJobsReportsResource(Self);
  882. end;
  883. Function TYoutubereportingAPI.CreateJobsReportsResource(AOwner : TComponent) : TJobsReportsResource;
  884. begin
  885. Result:=TJobsReportsResource.Create(AOwner);
  886. Result.API:=Self.API;
  887. end;
  888. Function TYoutubereportingAPI.GetJobsInstance : TJobsResource;
  889. begin
  890. if (FJobsInstance=Nil) then
  891. FJobsInstance:=CreateJobsResource;
  892. Result:=FJobsInstance;
  893. end;
  894. Function TYoutubereportingAPI.CreateJobsResource : TJobsResource;
  895. begin
  896. Result:=CreateJobsResource(Self);
  897. end;
  898. Function TYoutubereportingAPI.CreateJobsResource(AOwner : TComponent) : TJobsResource;
  899. begin
  900. Result:=TJobsResource.Create(AOwner);
  901. Result.API:=Self.API;
  902. end;
  903. initialization
  904. TYoutubereportingAPI.RegisterAPI;
  905. end.