@@ -36,7 +36,7 @@ TRestService = class(TCustomRestService)
36
36
// / <remarks>
37
37
// / Update an existing pet by Id
38
38
// / </remarks>
39
- procedure UpdatePet (Body: TPet);
39
+ function UpdatePet (Body: TPet): TPet ;
40
40
// / <summary>
41
41
// / Add a new pet to the store
42
42
// / </summary>
@@ -46,7 +46,7 @@ TRestService = class(TCustomRestService)
46
46
// / <remarks>
47
47
// / Add a new pet to the store
48
48
// / </remarks>
49
- procedure AddPet (Body: TPet);
49
+ function AddPet (Body: TPet): TPet ;
50
50
// / <summary>
51
51
// / Finds Pets by status
52
52
// / </summary>
@@ -56,7 +56,7 @@ TRestService = class(TCustomRestService)
56
56
// / <remarks>
57
57
// / Multiple status values can be provided with comma separated strings
58
58
// / </remarks>
59
- procedure FindPetsByStatus (Status: string);
59
+ function FindPetsByStatus (Status: string): TPetList ;
60
60
// / <summary>
61
61
// / Finds Pets by tags
62
62
// / </summary>
@@ -66,7 +66,7 @@ TRestService = class(TCustomRestService)
66
66
// / <remarks>
67
67
// / Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
68
68
// / </remarks>
69
- procedure FindPetsByTags (Tags: stringArray);
69
+ function FindPetsByTags (Tags: stringArray): TPetList ;
70
70
// / <summary>
71
71
// / Find pet by ID
72
72
// / </summary>
@@ -76,7 +76,7 @@ TRestService = class(TCustomRestService)
76
76
// / <remarks>
77
77
// / Returns a single pet
78
78
// / </remarks>
79
- procedure GetPetById (PetId: Int64);
79
+ function GetPetById (PetId: Int64): TPet ;
80
80
// / <summary>
81
81
// / Updates a pet in the store with form data
82
82
// / </summary>
@@ -104,23 +104,23 @@ TPetService = class(TRestService, IPetService)
104
104
// / <param name="Body">
105
105
// / Update an existent pet in the store
106
106
// / </param>
107
- procedure UpdatePet (Body: TPet);
107
+ function UpdatePet (Body: TPet): TPet ;
108
108
// / <param name="Body">
109
109
// / Create a new pet in the store
110
110
// / </param>
111
- procedure AddPet (Body: TPet);
111
+ function AddPet (Body: TPet): TPet ;
112
112
// / <param name="Status">
113
113
// / Status values that need to be considered for filter
114
114
// / </param>
115
- procedure FindPetsByStatus (Status: string);
115
+ function FindPetsByStatus (Status: string): TPetList ;
116
116
// / <param name="Tags">
117
117
// / Tags to filter by
118
118
// / </param>
119
- procedure FindPetsByTags (Tags: stringArray);
119
+ function FindPetsByTags (Tags: stringArray): TPetList ;
120
120
// / <param name="PetId">
121
121
// / ID of pet to return
122
122
// / </param>
123
- procedure GetPetById (PetId: Int64);
123
+ function GetPetById (PetId: Int64): TPet ;
124
124
// / <param name="PetId">
125
125
// / ID of pet that needs to be updated
126
126
// / </param>
@@ -148,14 +148,14 @@ TPetService = class(TRestService, IPetService)
148
148
// / <remarks>
149
149
// / Returns a map of status codes to quantities
150
150
// / </remarks>
151
- procedure GetInventory ;
151
+ function GetInventory : TGetInventoryOutput ;
152
152
// / <summary>
153
153
// / Place an order for a pet
154
154
// / </summary>
155
155
// / <remarks>
156
156
// / Place a new order in the store
157
157
// / </remarks>
158
- procedure PlaceOrder (Body: TOrder);
158
+ function PlaceOrder (Body: TOrder): TOrder ;
159
159
// / <summary>
160
160
// / Find purchase order by ID
161
161
// / </summary>
@@ -165,7 +165,7 @@ TPetService = class(TRestService, IPetService)
165
165
// / <remarks>
166
166
// / For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
167
167
// / </remarks>
168
- procedure GetOrderById (OrderId: Int64);
168
+ function GetOrderById (OrderId: Int64): TOrder ;
169
169
// / <summary>
170
170
// / Delete purchase order by ID
171
171
// / </summary>
@@ -180,12 +180,12 @@ TPetService = class(TRestService, IPetService)
180
180
181
181
TStoreService = class (TRestService, IStoreService)
182
182
public
183
- procedure GetInventory ;
184
- procedure PlaceOrder (Body: TOrder);
183
+ function GetInventory : TGetInventoryOutput ;
184
+ function PlaceOrder (Body: TOrder): TOrder ;
185
185
// / <param name="OrderId">
186
186
// / ID of order that needs to be fetched
187
187
// / </param>
188
- procedure GetOrderById (OrderId: Int64);
188
+ function GetOrderById (OrderId: Int64): TOrder ;
189
189
// / <param name="OrderId">
190
190
// / ID of the order that needs to be deleted
191
191
// / </param>
@@ -206,14 +206,14 @@ TStoreService = class(TRestService, IStoreService)
206
206
// / <remarks>
207
207
// / This can only be done by the logged in user.
208
208
// / </remarks>
209
- procedure CreateUser (Body: TUser);
209
+ function CreateUser (Body: TUser): TUser ;
210
210
// / <summary>
211
211
// / Creates list of users with given input array
212
212
// / </summary>
213
213
// / <remarks>
214
214
// / Creates list of users with given input array
215
215
// / </remarks>
216
- procedure CreateUsersWithListInput (Body: TUserList);
216
+ function CreateUsersWithListInput (Body: TUserList): TUser ;
217
217
// / <summary>
218
218
// / Logs user into the system
219
219
// / </summary>
@@ -223,7 +223,7 @@ TStoreService = class(TRestService, IStoreService)
223
223
// / <param name="Password">
224
224
// / The password for login in clear text
225
225
// / </param>
226
- procedure LoginUser (Username: string; Password: string);
226
+ function LoginUser (Username: string; Password: string): string ;
227
227
// / <summary>
228
228
// / Logs out current logged in user session
229
229
// / </summary>
@@ -234,7 +234,7 @@ TStoreService = class(TRestService, IStoreService)
234
234
// / <param name="Username">
235
235
// / The name that needs to be fetched. Use user1 for testing.
236
236
// / </param>
237
- procedure GetUserByName (Username: string);
237
+ function GetUserByName (Username: string): TUser ;
238
238
// / <summary>
239
239
// / Update user
240
240
// / </summary>
@@ -265,20 +265,20 @@ TUserService = class(TRestService, IUserService)
265
265
// / <param name="Body">
266
266
// / Created user object
267
267
// / </param>
268
- procedure CreateUser (Body: TUser);
269
- procedure CreateUsersWithListInput (Body: TUserList);
268
+ function CreateUser (Body: TUser): TUser ;
269
+ function CreateUsersWithListInput (Body: TUserList): TUser ;
270
270
// / <param name="Username">
271
271
// / The user name for login
272
272
// / </param>
273
273
// / <param name="Password">
274
274
// / The password for login in clear text
275
275
// / </param>
276
- procedure LoginUser (Username: string; Password: string);
276
+ function LoginUser (Username: string; Password: string): string ;
277
277
procedure LogoutUser ;
278
278
// / <param name="Username">
279
279
// / The name that needs to be fetched. Use user1 for testing.
280
280
// / </param>
281
- procedure GetUserByName (Username: string);
281
+ function GetUserByName (Username: string): TUser ;
282
282
// / <param name="Username">
283
283
// / name that need to be deleted
284
284
// / </param>
@@ -336,7 +336,7 @@ function TRestService.Converter: TJsonConverter;
336
336
337
337
{ TPetService }
338
338
339
- procedure TPetService.UpdatePet (Body: TPet);
339
+ function TPetService.UpdatePet (Body: TPet): TPet ;
340
340
var
341
341
Request: IRestRequest;
342
342
Response: IRestResponse;
@@ -345,9 +345,10 @@ procedure TPetService.UpdatePet(Body: TPet);
345
345
Request.AddBody(Converter.TPetToJson(Body));
346
346
Response := Request.Execute;
347
347
CheckError(Response);
348
+ Result := Converter.TPetFromJson(Response.ContentAsString);
348
349
end ;
349
350
350
- procedure TPetService.AddPet (Body: TPet);
351
+ function TPetService.AddPet (Body: TPet): TPet ;
351
352
var
352
353
Request: IRestRequest;
353
354
Response: IRestResponse;
@@ -356,9 +357,10 @@ procedure TPetService.AddPet(Body: TPet);
356
357
Request.AddBody(Converter.TPetToJson(Body));
357
358
Response := Request.Execute;
358
359
CheckError(Response);
360
+ Result := Converter.TPetFromJson(Response.ContentAsString);
359
361
end ;
360
362
361
- procedure TPetService.FindPetsByStatus (Status: string);
363
+ function TPetService.FindPetsByStatus (Status: string): TPetList ;
362
364
var
363
365
Request: IRestRequest;
364
366
Response: IRestResponse;
@@ -367,9 +369,10 @@ procedure TPetService.FindPetsByStatus(Status: string);
367
369
Request.AddQueryParam(' status' , Status);
368
370
Response := Request.Execute;
369
371
CheckError(Response);
372
+ Result := Converter.TPetListFromJson(Response.ContentAsString);
370
373
end ;
371
374
372
- procedure TPetService.FindPetsByTags (Tags: stringArray);
375
+ function TPetService.FindPetsByTags (Tags: stringArray): TPetList ;
373
376
var
374
377
Request: IRestRequest;
375
378
I: Integer;
@@ -380,9 +383,10 @@ procedure TPetService.FindPetsByTags(Tags: stringArray);
380
383
Request.AddQueryParam(' tags' , Tags[I]);
381
384
Response := Request.Execute;
382
385
CheckError(Response);
386
+ Result := Converter.TPetListFromJson(Response.ContentAsString);
383
387
end ;
384
388
385
- procedure TPetService.GetPetById (PetId: Int64);
389
+ function TPetService.GetPetById (PetId: Int64): TPet ;
386
390
var
387
391
Request: IRestRequest;
388
392
Response: IRestResponse;
@@ -391,6 +395,7 @@ procedure TPetService.GetPetById(PetId: Int64);
391
395
Request.AddUrlParam(' petId' , IntToStr(PetId));
392
396
Response := Request.Execute;
393
397
CheckError(Response);
398
+ Result := Converter.TPetFromJson(Response.ContentAsString);
394
399
end ;
395
400
396
401
procedure TPetService.UpdatePetWithForm (PetId: Int64; Name : string; Status: string);
@@ -420,17 +425,18 @@ procedure TPetService.DeletePet(ApiKey: string; PetId: Int64);
420
425
421
426
{ TStoreService }
422
427
423
- procedure TStoreService.GetInventory ;
428
+ function TStoreService.GetInventory : TGetInventoryOutput ;
424
429
var
425
430
Request: IRestRequest;
426
431
Response: IRestResponse;
427
432
begin
428
433
Request := CreateRequest(' /store/inventory' , ' GET' );
429
434
Response := Request.Execute;
430
435
CheckError(Response);
436
+ Result := Converter.TGetInventoryOutputFromJson(Response.ContentAsString);
431
437
end ;
432
438
433
- procedure TStoreService.PlaceOrder (Body: TOrder);
439
+ function TStoreService.PlaceOrder (Body: TOrder): TOrder ;
434
440
var
435
441
Request: IRestRequest;
436
442
Response: IRestResponse;
@@ -439,9 +445,10 @@ procedure TStoreService.PlaceOrder(Body: TOrder);
439
445
Request.AddBody(Converter.TOrderToJson(Body));
440
446
Response := Request.Execute;
441
447
CheckError(Response);
448
+ Result := Converter.TOrderFromJson(Response.ContentAsString);
442
449
end ;
443
450
444
- procedure TStoreService.GetOrderById (OrderId: Int64);
451
+ function TStoreService.GetOrderById (OrderId: Int64): TOrder ;
445
452
var
446
453
Request: IRestRequest;
447
454
Response: IRestResponse;
@@ -450,6 +457,7 @@ procedure TStoreService.GetOrderById(OrderId: Int64);
450
457
Request.AddUrlParam(' orderId' , IntToStr(OrderId));
451
458
Response := Request.Execute;
452
459
CheckError(Response);
460
+ Result := Converter.TOrderFromJson(Response.ContentAsString);
453
461
end ;
454
462
455
463
procedure TStoreService.DeleteOrder (OrderId: Int64);
@@ -465,7 +473,7 @@ procedure TStoreService.DeleteOrder(OrderId: Int64);
465
473
466
474
{ TUserService }
467
475
468
- procedure TUserService.CreateUser (Body: TUser);
476
+ function TUserService.CreateUser (Body: TUser): TUser ;
469
477
var
470
478
Request: IRestRequest;
471
479
Response: IRestResponse;
@@ -474,9 +482,10 @@ procedure TUserService.CreateUser(Body: TUser);
474
482
Request.AddBody(Converter.TUserToJson(Body));
475
483
Response := Request.Execute;
476
484
CheckError(Response);
485
+ Result := Converter.TUserFromJson(Response.ContentAsString);
477
486
end ;
478
487
479
- procedure TUserService.CreateUsersWithListInput (Body: TUserList);
488
+ function TUserService.CreateUsersWithListInput (Body: TUserList): TUser ;
480
489
var
481
490
Request: IRestRequest;
482
491
Response: IRestResponse;
@@ -485,9 +494,10 @@ procedure TUserService.CreateUsersWithListInput(Body: TUserList);
485
494
Request.AddBody(Converter.TUserListToJson(Body));
486
495
Response := Request.Execute;
487
496
CheckError(Response);
497
+ Result := Converter.TUserFromJson(Response.ContentAsString);
488
498
end ;
489
499
490
- procedure TUserService.LoginUser (Username: string; Password: string);
500
+ function TUserService.LoginUser (Username: string; Password: string): string ;
491
501
var
492
502
Request: IRestRequest;
493
503
Response: IRestResponse;
@@ -497,6 +507,7 @@ procedure TUserService.LoginUser(Username: string; Password: string);
497
507
Request.AddQueryParam(' password' , Password);
498
508
Response := Request.Execute;
499
509
CheckError(Response);
510
+ Result := Converter.stringFromJson(Response.ContentAsString);
500
511
end ;
501
512
502
513
procedure TUserService.LogoutUser ;
@@ -509,7 +520,7 @@ procedure TUserService.LogoutUser;
509
520
CheckError(Response);
510
521
end ;
511
522
512
- procedure TUserService.GetUserByName (Username: string);
523
+ function TUserService.GetUserByName (Username: string): TUser ;
513
524
var
514
525
Request: IRestRequest;
515
526
Response: IRestResponse;
@@ -518,6 +529,7 @@ procedure TUserService.GetUserByName(Username: string);
518
529
Request.AddUrlParam(' username' , Username);
519
530
Response := Request.Execute;
520
531
CheckError(Response);
532
+ Result := Converter.TUserFromJson(Response.ContentAsString);
521
533
end ;
522
534
523
535
procedure TUserService.UpdateUser (Username: string; Body: TUser);
0 commit comments