googlefreebase.pp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. unit googlefreebase;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, googleservice, restbase, googlebase;
  6. type
  7. //Top-level schema types
  8. TReconcileCandidate = Class;
  9. TReconcileGet = Class;
  10. TReconcileCandidateArray = Array of TReconcileCandidate;
  11. TReconcileGetArray = Array of TReconcileGet;
  12. //Anonymous types, using auto-generated names
  13. TReconcileCandidateTypenotable = Class;
  14. TReconcileGetTypecosts = Class;
  15. TReconcileGetTypewarningItem = Class;
  16. TReconcileGetTypecandidateArray = Array of TReconcileCandidate;
  17. TReconcileGetTypewarningArray = Array of TReconcileGetTypewarningItem;
  18. { --------------------------------------------------------------------
  19. TReconcileCandidateTypenotable
  20. --------------------------------------------------------------------}
  21. TReconcileCandidateTypenotable = Class(TGoogleBaseObject)
  22. Private
  23. Fid : String;
  24. Fname : String;
  25. Protected
  26. //Property setters
  27. Procedure Setid(AIndex : Integer; const AValue : String); virtual;
  28. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  29. Public
  30. Published
  31. Property id : String Index 0 Read Fid Write Setid;
  32. Property name : String Index 8 Read Fname Write Setname;
  33. end;
  34. TReconcileCandidateTypenotableClass = Class of TReconcileCandidateTypenotable;
  35. { --------------------------------------------------------------------
  36. TReconcileCandidate
  37. --------------------------------------------------------------------}
  38. TReconcileCandidate = Class(TGoogleBaseObject)
  39. Private
  40. Fconfidence : integer;
  41. Flang : String;
  42. Fmid : String;
  43. Fname : String;
  44. Fnotable : TReconcileCandidateTypenotable;
  45. Protected
  46. //Property setters
  47. Procedure Setconfidence(AIndex : Integer; const AValue : integer); virtual;
  48. Procedure Setlang(AIndex : Integer; const AValue : String); virtual;
  49. Procedure Setmid(AIndex : Integer; const AValue : String); virtual;
  50. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  51. Procedure Setnotable(AIndex : Integer; const AValue : TReconcileCandidateTypenotable); virtual;
  52. Public
  53. Published
  54. Property confidence : integer Index 0 Read Fconfidence Write Setconfidence;
  55. Property lang : String Index 8 Read Flang Write Setlang;
  56. Property mid : String Index 16 Read Fmid Write Setmid;
  57. Property name : String Index 24 Read Fname Write Setname;
  58. Property notable : TReconcileCandidateTypenotable Index 32 Read Fnotable Write Setnotable;
  59. end;
  60. TReconcileCandidateClass = Class of TReconcileCandidate;
  61. { --------------------------------------------------------------------
  62. TReconcileGetTypecosts
  63. --------------------------------------------------------------------}
  64. TReconcileGetTypecosts = Class(TGoogleBaseObject)
  65. Private
  66. Fhits : integer;
  67. Fms : integer;
  68. Protected
  69. //Property setters
  70. Procedure Sethits(AIndex : Integer; const AValue : integer); virtual;
  71. Procedure Setms(AIndex : Integer; const AValue : integer); virtual;
  72. Public
  73. Published
  74. Property hits : integer Index 0 Read Fhits Write Sethits;
  75. Property ms : integer Index 8 Read Fms Write Setms;
  76. end;
  77. TReconcileGetTypecostsClass = Class of TReconcileGetTypecosts;
  78. { --------------------------------------------------------------------
  79. TReconcileGetTypewarningItem
  80. --------------------------------------------------------------------}
  81. TReconcileGetTypewarningItem = Class(TGoogleBaseObject)
  82. Private
  83. Flocation : String;
  84. Fmessage : String;
  85. Freason : String;
  86. Protected
  87. //Property setters
  88. Procedure Setlocation(AIndex : Integer; const AValue : String); virtual;
  89. Procedure Setmessage(AIndex : Integer; const AValue : String); virtual;
  90. Procedure Setreason(AIndex : Integer; const AValue : String); virtual;
  91. Public
  92. Published
  93. Property location : String Index 0 Read Flocation Write Setlocation;
  94. Property message : String Index 8 Read Fmessage Write Setmessage;
  95. Property reason : String Index 16 Read Freason Write Setreason;
  96. end;
  97. TReconcileGetTypewarningItemClass = Class of TReconcileGetTypewarningItem;
  98. { --------------------------------------------------------------------
  99. TReconcileGet
  100. --------------------------------------------------------------------}
  101. TReconcileGet = Class(TGoogleBaseObject)
  102. Private
  103. Fcandidate : TReconcileGetTypecandidateArray;
  104. Fcosts : TReconcileGetTypecosts;
  105. Fmatch : TReconcileCandidate;
  106. Fwarning : TReconcileGetTypewarningArray;
  107. Protected
  108. //Property setters
  109. Procedure Setcandidate(AIndex : Integer; const AValue : TReconcileGetTypecandidateArray); virtual;
  110. Procedure Setcosts(AIndex : Integer; const AValue : TReconcileGetTypecosts); virtual;
  111. Procedure Setmatch(AIndex : Integer; const AValue : TReconcileCandidate); virtual;
  112. Procedure Setwarning(AIndex : Integer; const AValue : TReconcileGetTypewarningArray); virtual;
  113. //2.6.4. bug workaround
  114. {$IFDEF VER2_6}
  115. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  116. {$ENDIF VER2_6}
  117. Public
  118. Published
  119. Property candidate : TReconcileGetTypecandidateArray Index 0 Read Fcandidate Write Setcandidate;
  120. Property costs : TReconcileGetTypecosts Index 8 Read Fcosts Write Setcosts;
  121. Property match : TReconcileCandidate Index 16 Read Fmatch Write Setmatch;
  122. Property warning : TReconcileGetTypewarningArray Index 24 Read Fwarning Write Setwarning;
  123. end;
  124. TReconcileGetClass = Class of TReconcileGet;
  125. { --------------------------------------------------------------------
  126. TFreebaseAPI
  127. --------------------------------------------------------------------}
  128. TFreebaseAPI = Class(TGoogleAPI)
  129. Private
  130. Public
  131. //Override class functions with API info
  132. Class Function APIName : String; override;
  133. Class Function APIVersion : String; override;
  134. Class Function APIRevision : String; override;
  135. Class Function APIID : String; override;
  136. Class Function APITitle : String; override;
  137. Class Function APIDescription : String; override;
  138. Class Function APIOwnerDomain : String; override;
  139. Class Function APIOwnerName : String; override;
  140. Class Function APIIcon16 : String; override;
  141. Class Function APIIcon32 : String; override;
  142. Class Function APIdocumentationLink : String; override;
  143. Class Function APIrootUrl : string; override;
  144. Class Function APIbasePath : string;override;
  145. Class Function APIbaseURL : String;override;
  146. Class Function APIProtocol : string;override;
  147. Class Function APIservicePath : string;override;
  148. Class Function APIbatchPath : String;override;
  149. Class Function APIAuthScopes : TScopeInfoArray;override;
  150. Class Function APINeedsAuth : Boolean;override;
  151. Class Procedure RegisterAPIResources; override;
  152. //Add create function for resources
  153. //Add default on-demand instances for resources
  154. end;
  155. implementation
  156. { --------------------------------------------------------------------
  157. TReconcileCandidateTypenotable
  158. --------------------------------------------------------------------}
  159. Procedure TReconcileCandidateTypenotable.Setid(AIndex : Integer; const AValue : String);
  160. begin
  161. If (Fid=AValue) then exit;
  162. Fid:=AValue;
  163. MarkPropertyChanged(AIndex);
  164. end;
  165. Procedure TReconcileCandidateTypenotable.Setname(AIndex : Integer; const AValue : String);
  166. begin
  167. If (Fname=AValue) then exit;
  168. Fname:=AValue;
  169. MarkPropertyChanged(AIndex);
  170. end;
  171. { --------------------------------------------------------------------
  172. TReconcileCandidate
  173. --------------------------------------------------------------------}
  174. Procedure TReconcileCandidate.Setconfidence(AIndex : Integer; const AValue : integer);
  175. begin
  176. If (Fconfidence=AValue) then exit;
  177. Fconfidence:=AValue;
  178. MarkPropertyChanged(AIndex);
  179. end;
  180. Procedure TReconcileCandidate.Setlang(AIndex : Integer; const AValue : String);
  181. begin
  182. If (Flang=AValue) then exit;
  183. Flang:=AValue;
  184. MarkPropertyChanged(AIndex);
  185. end;
  186. Procedure TReconcileCandidate.Setmid(AIndex : Integer; const AValue : String);
  187. begin
  188. If (Fmid=AValue) then exit;
  189. Fmid:=AValue;
  190. MarkPropertyChanged(AIndex);
  191. end;
  192. Procedure TReconcileCandidate.Setname(AIndex : Integer; const AValue : String);
  193. begin
  194. If (Fname=AValue) then exit;
  195. Fname:=AValue;
  196. MarkPropertyChanged(AIndex);
  197. end;
  198. Procedure TReconcileCandidate.Setnotable(AIndex : Integer; const AValue : TReconcileCandidateTypenotable);
  199. begin
  200. If (Fnotable=AValue) then exit;
  201. Fnotable:=AValue;
  202. MarkPropertyChanged(AIndex);
  203. end;
  204. { --------------------------------------------------------------------
  205. TReconcileGetTypecosts
  206. --------------------------------------------------------------------}
  207. Procedure TReconcileGetTypecosts.Sethits(AIndex : Integer; const AValue : integer);
  208. begin
  209. If (Fhits=AValue) then exit;
  210. Fhits:=AValue;
  211. MarkPropertyChanged(AIndex);
  212. end;
  213. Procedure TReconcileGetTypecosts.Setms(AIndex : Integer; const AValue : integer);
  214. begin
  215. If (Fms=AValue) then exit;
  216. Fms:=AValue;
  217. MarkPropertyChanged(AIndex);
  218. end;
  219. { --------------------------------------------------------------------
  220. TReconcileGetTypewarningItem
  221. --------------------------------------------------------------------}
  222. Procedure TReconcileGetTypewarningItem.Setlocation(AIndex : Integer; const AValue : String);
  223. begin
  224. If (Flocation=AValue) then exit;
  225. Flocation:=AValue;
  226. MarkPropertyChanged(AIndex);
  227. end;
  228. Procedure TReconcileGetTypewarningItem.Setmessage(AIndex : Integer; const AValue : String);
  229. begin
  230. If (Fmessage=AValue) then exit;
  231. Fmessage:=AValue;
  232. MarkPropertyChanged(AIndex);
  233. end;
  234. Procedure TReconcileGetTypewarningItem.Setreason(AIndex : Integer; const AValue : String);
  235. begin
  236. If (Freason=AValue) then exit;
  237. Freason:=AValue;
  238. MarkPropertyChanged(AIndex);
  239. end;
  240. { --------------------------------------------------------------------
  241. TReconcileGet
  242. --------------------------------------------------------------------}
  243. Procedure TReconcileGet.Setcandidate(AIndex : Integer; const AValue : TReconcileGetTypecandidateArray);
  244. begin
  245. If (Fcandidate=AValue) then exit;
  246. Fcandidate:=AValue;
  247. MarkPropertyChanged(AIndex);
  248. end;
  249. Procedure TReconcileGet.Setcosts(AIndex : Integer; const AValue : TReconcileGetTypecosts);
  250. begin
  251. If (Fcosts=AValue) then exit;
  252. Fcosts:=AValue;
  253. MarkPropertyChanged(AIndex);
  254. end;
  255. Procedure TReconcileGet.Setmatch(AIndex : Integer; const AValue : TReconcileCandidate);
  256. begin
  257. If (Fmatch=AValue) then exit;
  258. Fmatch:=AValue;
  259. MarkPropertyChanged(AIndex);
  260. end;
  261. Procedure TReconcileGet.Setwarning(AIndex : Integer; const AValue : TReconcileGetTypewarningArray);
  262. begin
  263. If (Fwarning=AValue) then exit;
  264. Fwarning:=AValue;
  265. MarkPropertyChanged(AIndex);
  266. end;
  267. //2.6.4. bug workaround
  268. {$IFDEF VER2_6}
  269. Procedure TReconcileGet.SetArrayLength(Const AName : String; ALength : Longint);
  270. begin
  271. Case AName of
  272. 'candidate' : SetLength(Fcandidate,ALength);
  273. 'warning' : SetLength(Fwarning,ALength);
  274. else
  275. Inherited SetArrayLength(AName,ALength);
  276. end;
  277. end;
  278. {$ENDIF VER2_6}
  279. { --------------------------------------------------------------------
  280. TFreebaseAPI
  281. --------------------------------------------------------------------}
  282. Class Function TFreebaseAPI.APIName : String;
  283. begin
  284. Result:='freebase';
  285. end;
  286. Class Function TFreebaseAPI.APIVersion : String;
  287. begin
  288. Result:='v1';
  289. end;
  290. Class Function TFreebaseAPI.APIRevision : String;
  291. begin
  292. Result:='20150728';
  293. end;
  294. Class Function TFreebaseAPI.APIID : String;
  295. begin
  296. Result:='freebase:v1';
  297. end;
  298. Class Function TFreebaseAPI.APITitle : String;
  299. begin
  300. Result:='Freebase Search';
  301. end;
  302. Class Function TFreebaseAPI.APIDescription : String;
  303. begin
  304. Result:='Find Freebase entities using textual queries and other constraints.';
  305. end;
  306. Class Function TFreebaseAPI.APIOwnerDomain : String;
  307. begin
  308. Result:='google.com';
  309. end;
  310. Class Function TFreebaseAPI.APIOwnerName : String;
  311. begin
  312. Result:='Google';
  313. end;
  314. Class Function TFreebaseAPI.APIIcon16 : String;
  315. begin
  316. Result:='https://www.google.com/images/icons/product/freebase-16.png';
  317. end;
  318. Class Function TFreebaseAPI.APIIcon32 : String;
  319. begin
  320. Result:='https://www.google.com/images/icons/product/freebase-32.png';
  321. end;
  322. Class Function TFreebaseAPI.APIdocumentationLink : String;
  323. begin
  324. Result:='https://developers.google.com/freebase/';
  325. end;
  326. Class Function TFreebaseAPI.APIrootUrl : string;
  327. begin
  328. Result:='https://www.googleapis.com/';
  329. end;
  330. Class Function TFreebaseAPI.APIbasePath : string;
  331. begin
  332. Result:='/freebase/v1/';
  333. end;
  334. Class Function TFreebaseAPI.APIbaseURL : String;
  335. begin
  336. Result:='https://www.googleapis.com/freebase/v1/';
  337. end;
  338. Class Function TFreebaseAPI.APIProtocol : string;
  339. begin
  340. Result:='rest';
  341. end;
  342. Class Function TFreebaseAPI.APIservicePath : string;
  343. begin
  344. Result:='freebase/v1/';
  345. end;
  346. Class Function TFreebaseAPI.APIbatchPath : String;
  347. begin
  348. Result:='batch';
  349. end;
  350. Class Function TFreebaseAPI.APIAuthScopes : TScopeInfoArray;
  351. begin
  352. SetLength(Result,0);
  353. end;
  354. Class Function TFreebaseAPI.APINeedsAuth : Boolean;
  355. begin
  356. Result:=False;
  357. end;
  358. Class Procedure TFreebaseAPI.RegisterAPIResources;
  359. begin
  360. TReconcileCandidateTypenotable.RegisterObject;
  361. TReconcileCandidate.RegisterObject;
  362. TReconcileGetTypecosts.RegisterObject;
  363. TReconcileGetTypewarningItem.RegisterObject;
  364. TReconcileGet.RegisterObject;
  365. end;
  366. initialization
  367. TFreebaseAPI.RegisterAPI;
  368. end.