1unit googlefreebase; 2{$MODE objfpc} 3{$H+} 4 5interface 6 7uses sysutils, classes, googleservice, restbase, googlebase; 8 9type 10 11 //Top-level schema types 12 TReconcileCandidate = Class; 13 TReconcileGet = Class; 14 TReconcileCandidateArray = Array of TReconcileCandidate; 15 TReconcileGetArray = Array of TReconcileGet; 16 //Anonymous types, using auto-generated names 17 TReconcileCandidateTypenotable = Class; 18 TReconcileGetTypecosts = Class; 19 TReconcileGetTypewarningItem = Class; 20 TReconcileGetTypecandidateArray = Array of TReconcileCandidate; 21 TReconcileGetTypewarningArray = Array of TReconcileGetTypewarningItem; 22 23 { -------------------------------------------------------------------- 24 TReconcileCandidateTypenotable 25 --------------------------------------------------------------------} 26 27 TReconcileCandidateTypenotable = Class(TGoogleBaseObject) 28 Private 29 Fid : String; 30 Fname : String; 31 Protected 32 //Property setters 33 Procedure Setid(AIndex : Integer; const AValue : String); virtual; 34 Procedure Setname(AIndex : Integer; const AValue : String); virtual; 35 Public 36 Published 37 Property id : String Index 0 Read Fid Write Setid; 38 Property name : String Index 8 Read Fname Write Setname; 39 end; 40 TReconcileCandidateTypenotableClass = Class of TReconcileCandidateTypenotable; 41 42 { -------------------------------------------------------------------- 43 TReconcileCandidate 44 --------------------------------------------------------------------} 45 46 TReconcileCandidate = Class(TGoogleBaseObject) 47 Private 48 Fconfidence : integer; 49 Flang : String; 50 Fmid : String; 51 Fname : String; 52 Fnotable : TReconcileCandidateTypenotable; 53 Protected 54 //Property setters 55 Procedure Setconfidence(AIndex : Integer; const AValue : integer); virtual; 56 Procedure Setlang(AIndex : Integer; const AValue : String); virtual; 57 Procedure Setmid(AIndex : Integer; const AValue : String); virtual; 58 Procedure Setname(AIndex : Integer; const AValue : String); virtual; 59 Procedure Setnotable(AIndex : Integer; const AValue : TReconcileCandidateTypenotable); virtual; 60 Public 61 Published 62 Property confidence : integer Index 0 Read Fconfidence Write Setconfidence; 63 Property lang : String Index 8 Read Flang Write Setlang; 64 Property mid : String Index 16 Read Fmid Write Setmid; 65 Property name : String Index 24 Read Fname Write Setname; 66 Property notable : TReconcileCandidateTypenotable Index 32 Read Fnotable Write Setnotable; 67 end; 68 TReconcileCandidateClass = Class of TReconcileCandidate; 69 70 { -------------------------------------------------------------------- 71 TReconcileGetTypecosts 72 --------------------------------------------------------------------} 73 74 TReconcileGetTypecosts = Class(TGoogleBaseObject) 75 Private 76 Fhits : integer; 77 Fms : integer; 78 Protected 79 //Property setters 80 Procedure Sethits(AIndex : Integer; const AValue : integer); virtual; 81 Procedure Setms(AIndex : Integer; const AValue : integer); virtual; 82 Public 83 Published 84 Property hits : integer Index 0 Read Fhits Write Sethits; 85 Property ms : integer Index 8 Read Fms Write Setms; 86 end; 87 TReconcileGetTypecostsClass = Class of TReconcileGetTypecosts; 88 89 { -------------------------------------------------------------------- 90 TReconcileGetTypewarningItem 91 --------------------------------------------------------------------} 92 93 TReconcileGetTypewarningItem = Class(TGoogleBaseObject) 94 Private 95 Flocation : String; 96 Fmessage : String; 97 Freason : String; 98 Protected 99 //Property setters 100 Procedure Setlocation(AIndex : Integer; const AValue : String); virtual; 101 Procedure Setmessage(AIndex : Integer; const AValue : String); virtual; 102 Procedure Setreason(AIndex : Integer; const AValue : String); virtual; 103 Public 104 Published 105 Property location : String Index 0 Read Flocation Write Setlocation; 106 Property message : String Index 8 Read Fmessage Write Setmessage; 107 Property reason : String Index 16 Read Freason Write Setreason; 108 end; 109 TReconcileGetTypewarningItemClass = Class of TReconcileGetTypewarningItem; 110 111 { -------------------------------------------------------------------- 112 TReconcileGet 113 --------------------------------------------------------------------} 114 115 TReconcileGet = Class(TGoogleBaseObject) 116 Private 117 Fcandidate : TReconcileGetTypecandidateArray; 118 Fcosts : TReconcileGetTypecosts; 119 Fmatch : TReconcileCandidate; 120 Fwarning : TReconcileGetTypewarningArray; 121 Protected 122 //Property setters 123 Procedure Setcandidate(AIndex : Integer; const AValue : TReconcileGetTypecandidateArray); virtual; 124 Procedure Setcosts(AIndex : Integer; const AValue : TReconcileGetTypecosts); virtual; 125 Procedure Setmatch(AIndex : Integer; const AValue : TReconcileCandidate); virtual; 126 Procedure Setwarning(AIndex : Integer; const AValue : TReconcileGetTypewarningArray); virtual; 127 //2.6.4. bug workaround 128 {$IFDEF VER2_6} 129 Procedure SetArrayLength(Const AName : String; ALength : Longint); override; 130 {$ENDIF VER2_6} 131 Public 132 Published 133 Property candidate : TReconcileGetTypecandidateArray Index 0 Read Fcandidate Write Setcandidate; 134 Property costs : TReconcileGetTypecosts Index 8 Read Fcosts Write Setcosts; 135 Property match : TReconcileCandidate Index 16 Read Fmatch Write Setmatch; 136 Property warning : TReconcileGetTypewarningArray Index 24 Read Fwarning Write Setwarning; 137 end; 138 TReconcileGetClass = Class of TReconcileGet; 139 140 { -------------------------------------------------------------------- 141 TFreebaseAPI 142 --------------------------------------------------------------------} 143 144 TFreebaseAPI = Class(TGoogleAPI) 145 Private 146 Public 147 //Override class functions with API info 148 Class Function APIName : String; override; 149 Class Function APIVersion : String; override; 150 Class Function APIRevision : String; override; 151 Class Function APIID : String; override; 152 Class Function APITitle : String; override; 153 Class Function APIDescription : String; override; 154 Class Function APIOwnerDomain : String; override; 155 Class Function APIOwnerName : String; override; 156 Class Function APIIcon16 : String; override; 157 Class Function APIIcon32 : String; override; 158 Class Function APIdocumentationLink : String; override; 159 Class Function APIrootUrl : string; override; 160 Class Function APIbasePath : string;override; 161 Class Function APIbaseURL : String;override; 162 Class Function APIProtocol : string;override; 163 Class Function APIservicePath : string;override; 164 Class Function APIbatchPath : String;override; 165 Class Function APIAuthScopes : TScopeInfoArray;override; 166 Class Function APINeedsAuth : Boolean;override; 167 Class Procedure RegisterAPIResources; override; 168 //Add create function for resources 169 //Add default on-demand instances for resources 170 end; 171 172implementation 173 174 175{ -------------------------------------------------------------------- 176 TReconcileCandidateTypenotable 177 --------------------------------------------------------------------} 178 179 180Procedure TReconcileCandidateTypenotable.Setid(AIndex : Integer; const AValue : String); 181 182begin 183 If (Fid=AValue) then exit; 184 Fid:=AValue; 185 MarkPropertyChanged(AIndex); 186end; 187 188 189 190Procedure TReconcileCandidateTypenotable.Setname(AIndex : Integer; const AValue : String); 191 192begin 193 If (Fname=AValue) then exit; 194 Fname:=AValue; 195 MarkPropertyChanged(AIndex); 196end; 197 198 199 200 201 202{ -------------------------------------------------------------------- 203 TReconcileCandidate 204 --------------------------------------------------------------------} 205 206 207Procedure TReconcileCandidate.Setconfidence(AIndex : Integer; const AValue : integer); 208 209begin 210 If (Fconfidence=AValue) then exit; 211 Fconfidence:=AValue; 212 MarkPropertyChanged(AIndex); 213end; 214 215 216 217Procedure TReconcileCandidate.Setlang(AIndex : Integer; const AValue : String); 218 219begin 220 If (Flang=AValue) then exit; 221 Flang:=AValue; 222 MarkPropertyChanged(AIndex); 223end; 224 225 226 227Procedure TReconcileCandidate.Setmid(AIndex : Integer; const AValue : String); 228 229begin 230 If (Fmid=AValue) then exit; 231 Fmid:=AValue; 232 MarkPropertyChanged(AIndex); 233end; 234 235 236 237Procedure TReconcileCandidate.Setname(AIndex : Integer; const AValue : String); 238 239begin 240 If (Fname=AValue) then exit; 241 Fname:=AValue; 242 MarkPropertyChanged(AIndex); 243end; 244 245 246 247Procedure TReconcileCandidate.Setnotable(AIndex : Integer; const AValue : TReconcileCandidateTypenotable); 248 249begin 250 If (Fnotable=AValue) then exit; 251 Fnotable:=AValue; 252 MarkPropertyChanged(AIndex); 253end; 254 255 256 257 258 259{ -------------------------------------------------------------------- 260 TReconcileGetTypecosts 261 --------------------------------------------------------------------} 262 263 264Procedure TReconcileGetTypecosts.Sethits(AIndex : Integer; const AValue : integer); 265 266begin 267 If (Fhits=AValue) then exit; 268 Fhits:=AValue; 269 MarkPropertyChanged(AIndex); 270end; 271 272 273 274Procedure TReconcileGetTypecosts.Setms(AIndex : Integer; const AValue : integer); 275 276begin 277 If (Fms=AValue) then exit; 278 Fms:=AValue; 279 MarkPropertyChanged(AIndex); 280end; 281 282 283 284 285 286{ -------------------------------------------------------------------- 287 TReconcileGetTypewarningItem 288 --------------------------------------------------------------------} 289 290 291Procedure TReconcileGetTypewarningItem.Setlocation(AIndex : Integer; const AValue : String); 292 293begin 294 If (Flocation=AValue) then exit; 295 Flocation:=AValue; 296 MarkPropertyChanged(AIndex); 297end; 298 299 300 301Procedure TReconcileGetTypewarningItem.Setmessage(AIndex : Integer; const AValue : String); 302 303begin 304 If (Fmessage=AValue) then exit; 305 Fmessage:=AValue; 306 MarkPropertyChanged(AIndex); 307end; 308 309 310 311Procedure TReconcileGetTypewarningItem.Setreason(AIndex : Integer; const AValue : String); 312 313begin 314 If (Freason=AValue) then exit; 315 Freason:=AValue; 316 MarkPropertyChanged(AIndex); 317end; 318 319 320 321 322 323{ -------------------------------------------------------------------- 324 TReconcileGet 325 --------------------------------------------------------------------} 326 327 328Procedure TReconcileGet.Setcandidate(AIndex : Integer; const AValue : TReconcileGetTypecandidateArray); 329 330begin 331 If (Fcandidate=AValue) then exit; 332 Fcandidate:=AValue; 333 MarkPropertyChanged(AIndex); 334end; 335 336 337 338Procedure TReconcileGet.Setcosts(AIndex : Integer; const AValue : TReconcileGetTypecosts); 339 340begin 341 If (Fcosts=AValue) then exit; 342 Fcosts:=AValue; 343 MarkPropertyChanged(AIndex); 344end; 345 346 347 348Procedure TReconcileGet.Setmatch(AIndex : Integer; const AValue : TReconcileCandidate); 349 350begin 351 If (Fmatch=AValue) then exit; 352 Fmatch:=AValue; 353 MarkPropertyChanged(AIndex); 354end; 355 356 357 358Procedure TReconcileGet.Setwarning(AIndex : Integer; const AValue : TReconcileGetTypewarningArray); 359 360begin 361 If (Fwarning=AValue) then exit; 362 Fwarning:=AValue; 363 MarkPropertyChanged(AIndex); 364end; 365 366 367//2.6.4. bug workaround 368{$IFDEF VER2_6} 369Procedure TReconcileGet.SetArrayLength(Const AName : String; ALength : Longint); 370 371begin 372 Case AName of 373 'candidate' : SetLength(Fcandidate,ALength); 374 'warning' : SetLength(Fwarning,ALength); 375 else 376 Inherited SetArrayLength(AName,ALength); 377 end; 378end; 379{$ENDIF VER2_6} 380 381 382 383 384{ -------------------------------------------------------------------- 385 TFreebaseAPI 386 --------------------------------------------------------------------} 387 388Class Function TFreebaseAPI.APIName : String; 389 390begin 391 Result:='freebase'; 392end; 393 394Class Function TFreebaseAPI.APIVersion : String; 395 396begin 397 Result:='v1'; 398end; 399 400Class Function TFreebaseAPI.APIRevision : String; 401 402begin 403 Result:='20150728'; 404end; 405 406Class Function TFreebaseAPI.APIID : String; 407 408begin 409 Result:='freebase:v1'; 410end; 411 412Class Function TFreebaseAPI.APITitle : String; 413 414begin 415 Result:='Freebase Search'; 416end; 417 418Class Function TFreebaseAPI.APIDescription : String; 419 420begin 421 Result:='Find Freebase entities using textual queries and other constraints.'; 422end; 423 424Class Function TFreebaseAPI.APIOwnerDomain : String; 425 426begin 427 Result:='google.com'; 428end; 429 430Class Function TFreebaseAPI.APIOwnerName : String; 431 432begin 433 Result:='Google'; 434end; 435 436Class Function TFreebaseAPI.APIIcon16 : String; 437 438begin 439 Result:='https://www.google.com/images/icons/product/freebase-16.png'; 440end; 441 442Class Function TFreebaseAPI.APIIcon32 : String; 443 444begin 445 Result:='https://www.google.com/images/icons/product/freebase-32.png'; 446end; 447 448Class Function TFreebaseAPI.APIdocumentationLink : String; 449 450begin 451 Result:='https://developers.google.com/freebase/'; 452end; 453 454Class Function TFreebaseAPI.APIrootUrl : string; 455 456begin 457 Result:='https://www.googleapis.com/'; 458end; 459 460Class Function TFreebaseAPI.APIbasePath : string; 461 462begin 463 Result:='/freebase/v1/'; 464end; 465 466Class Function TFreebaseAPI.APIbaseURL : String; 467 468begin 469 Result:='https://www.googleapis.com/freebase/v1/'; 470end; 471 472Class Function TFreebaseAPI.APIProtocol : string; 473 474begin 475 Result:='rest'; 476end; 477 478Class Function TFreebaseAPI.APIservicePath : string; 479 480begin 481 Result:='freebase/v1/'; 482end; 483 484Class Function TFreebaseAPI.APIbatchPath : String; 485 486begin 487 Result:='batch'; 488end; 489 490Class Function TFreebaseAPI.APIAuthScopes : TScopeInfoArray; 491 492begin 493 SetLength(Result,0); 494 495end; 496 497Class Function TFreebaseAPI.APINeedsAuth : Boolean; 498 499begin 500 Result:=False; 501end; 502 503Class Procedure TFreebaseAPI.RegisterAPIResources; 504 505begin 506 TReconcileCandidateTypenotable.RegisterObject; 507 TReconcileCandidate.RegisterObject; 508 TReconcileGetTypecosts.RegisterObject; 509 TReconcileGetTypewarningItem.RegisterObject; 510 TReconcileGet.RegisterObject; 511end; 512 513 514initialization 515 TFreebaseAPI.RegisterAPI; 516end. 517