@@ -36,7 +36,7 @@ TRestService = class(TCustomRestService)
3636 // / <remarks>
3737 // / Update an existing pet by Id
3838 // / </remarks>
39- procedure UpdatePet (Body: TPet);
39+ function UpdatePet (Body: TPet): TPet ;
4040 // / <summary>
4141 // / Add a new pet to the store
4242 // / </summary>
@@ -46,7 +46,7 @@ TRestService = class(TCustomRestService)
4646 // / <remarks>
4747 // / Add a new pet to the store
4848 // / </remarks>
49- procedure AddPet (Body: TPet);
49+ function AddPet (Body: TPet): TPet ;
5050 // / <summary>
5151 // / Finds Pets by status
5252 // / </summary>
@@ -56,7 +56,7 @@ TRestService = class(TCustomRestService)
5656 // / <remarks>
5757 // / Multiple status values can be provided with comma separated strings
5858 // / </remarks>
59- procedure FindPetsByStatus (Status: string);
59+ function FindPetsByStatus (Status: string): TPetList ;
6060 // / <summary>
6161 // / Finds Pets by tags
6262 // / </summary>
@@ -66,7 +66,7 @@ TRestService = class(TCustomRestService)
6666 // / <remarks>
6767 // / Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
6868 // / </remarks>
69- procedure FindPetsByTags (Tags: stringArray);
69+ function FindPetsByTags (Tags: stringArray): TPetList ;
7070 // / <summary>
7171 // / Find pet by ID
7272 // / </summary>
@@ -76,7 +76,7 @@ TRestService = class(TCustomRestService)
7676 // / <remarks>
7777 // / Returns a single pet
7878 // / </remarks>
79- procedure GetPetById (PetId: Int64);
79+ function GetPetById (PetId: Int64): TPet ;
8080 // / <summary>
8181 // / Updates a pet in the store with form data
8282 // / </summary>
@@ -104,23 +104,23 @@ TPetService = class(TRestService, IPetService)
104104 // / <param name="Body">
105105 // / Update an existent pet in the store
106106 // / </param>
107- procedure UpdatePet (Body: TPet);
107+ function UpdatePet (Body: TPet): TPet ;
108108 // / <param name="Body">
109109 // / Create a new pet in the store
110110 // / </param>
111- procedure AddPet (Body: TPet);
111+ function AddPet (Body: TPet): TPet ;
112112 // / <param name="Status">
113113 // / Status values that need to be considered for filter
114114 // / </param>
115- procedure FindPetsByStatus (Status: string);
115+ function FindPetsByStatus (Status: string): TPetList ;
116116 // / <param name="Tags">
117117 // / Tags to filter by
118118 // / </param>
119- procedure FindPetsByTags (Tags: stringArray);
119+ function FindPetsByTags (Tags: stringArray): TPetList ;
120120 // / <param name="PetId">
121121 // / ID of pet to return
122122 // / </param>
123- procedure GetPetById (PetId: Int64);
123+ function GetPetById (PetId: Int64): TPet ;
124124 // / <param name="PetId">
125125 // / ID of pet that needs to be updated
126126 // / </param>
@@ -148,14 +148,14 @@ TPetService = class(TRestService, IPetService)
148148 // / <remarks>
149149 // / Returns a map of status codes to quantities
150150 // / </remarks>
151- procedure GetInventory ;
151+ function GetInventory : TGetInventoryOutput ;
152152 // / <summary>
153153 // / Place an order for a pet
154154 // / </summary>
155155 // / <remarks>
156156 // / Place a new order in the store
157157 // / </remarks>
158- procedure PlaceOrder (Body: TOrder);
158+ function PlaceOrder (Body: TOrder): TOrder ;
159159 // / <summary>
160160 // / Find purchase order by ID
161161 // / </summary>
@@ -165,7 +165,7 @@ TPetService = class(TRestService, IPetService)
165165 // / <remarks>
166166 // / For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
167167 // / </remarks>
168- procedure GetOrderById (OrderId: Int64);
168+ function GetOrderById (OrderId: Int64): TOrder ;
169169 // / <summary>
170170 // / Delete purchase order by ID
171171 // / </summary>
@@ -180,12 +180,12 @@ TPetService = class(TRestService, IPetService)
180180
181181 TStoreService = class (TRestService, IStoreService)
182182 public
183- procedure GetInventory ;
184- procedure PlaceOrder (Body: TOrder);
183+ function GetInventory : TGetInventoryOutput ;
184+ function PlaceOrder (Body: TOrder): TOrder ;
185185 // / <param name="OrderId">
186186 // / ID of order that needs to be fetched
187187 // / </param>
188- procedure GetOrderById (OrderId: Int64);
188+ function GetOrderById (OrderId: Int64): TOrder ;
189189 // / <param name="OrderId">
190190 // / ID of the order that needs to be deleted
191191 // / </param>
@@ -206,14 +206,14 @@ TStoreService = class(TRestService, IStoreService)
206206 // / <remarks>
207207 // / This can only be done by the logged in user.
208208 // / </remarks>
209- procedure CreateUser (Body: TUser);
209+ function CreateUser (Body: TUser): TUser ;
210210 // / <summary>
211211 // / Creates list of users with given input array
212212 // / </summary>
213213 // / <remarks>
214214 // / Creates list of users with given input array
215215 // / </remarks>
216- procedure CreateUsersWithListInput (Body: TUserList);
216+ function CreateUsersWithListInput (Body: TUserList): TUser ;
217217 // / <summary>
218218 // / Logs user into the system
219219 // / </summary>
@@ -223,7 +223,7 @@ TStoreService = class(TRestService, IStoreService)
223223 // / <param name="Password">
224224 // / The password for login in clear text
225225 // / </param>
226- procedure LoginUser (Username: string; Password: string);
226+ function LoginUser (Username: string; Password: string): string ;
227227 // / <summary>
228228 // / Logs out current logged in user session
229229 // / </summary>
@@ -234,7 +234,7 @@ TStoreService = class(TRestService, IStoreService)
234234 // / <param name="Username">
235235 // / The name that needs to be fetched. Use user1 for testing.
236236 // / </param>
237- procedure GetUserByName (Username: string);
237+ function GetUserByName (Username: string): TUser ;
238238 // / <summary>
239239 // / Update user
240240 // / </summary>
@@ -265,20 +265,20 @@ TUserService = class(TRestService, IUserService)
265265 // / <param name="Body">
266266 // / Created user object
267267 // / </param>
268- procedure CreateUser (Body: TUser);
269- procedure CreateUsersWithListInput (Body: TUserList);
268+ function CreateUser (Body: TUser): TUser ;
269+ function CreateUsersWithListInput (Body: TUserList): TUser ;
270270 // / <param name="Username">
271271 // / The user name for login
272272 // / </param>
273273 // / <param name="Password">
274274 // / The password for login in clear text
275275 // / </param>
276- procedure LoginUser (Username: string; Password: string);
276+ function LoginUser (Username: string; Password: string): string ;
277277 procedure LogoutUser ;
278278 // / <param name="Username">
279279 // / The name that needs to be fetched. Use user1 for testing.
280280 // / </param>
281- procedure GetUserByName (Username: string);
281+ function GetUserByName (Username: string): TUser ;
282282 // / <param name="Username">
283283 // / name that need to be deleted
284284 // / </param>
@@ -336,7 +336,7 @@ function TRestService.Converter: TJsonConverter;
336336
337337{ TPetService }
338338
339- procedure TPetService.UpdatePet (Body: TPet);
339+ function TPetService.UpdatePet (Body: TPet): TPet ;
340340var
341341 Request: IRestRequest;
342342 Response: IRestResponse;
@@ -345,9 +345,10 @@ procedure TPetService.UpdatePet(Body: TPet);
345345 Request.AddBody(Converter.TPetToJson(Body));
346346 Response := Request.Execute;
347347 CheckError(Response);
348+ Result := Converter.TPetFromJson(Response.ContentAsString);
348349end ;
349350
350- procedure TPetService.AddPet (Body: TPet);
351+ function TPetService.AddPet (Body: TPet): TPet ;
351352var
352353 Request: IRestRequest;
353354 Response: IRestResponse;
@@ -356,9 +357,10 @@ procedure TPetService.AddPet(Body: TPet);
356357 Request.AddBody(Converter.TPetToJson(Body));
357358 Response := Request.Execute;
358359 CheckError(Response);
360+ Result := Converter.TPetFromJson(Response.ContentAsString);
359361end ;
360362
361- procedure TPetService.FindPetsByStatus (Status: string);
363+ function TPetService.FindPetsByStatus (Status: string): TPetList ;
362364var
363365 Request: IRestRequest;
364366 Response: IRestResponse;
@@ -367,9 +369,10 @@ procedure TPetService.FindPetsByStatus(Status: string);
367369 Request.AddQueryParam(' status' , Status);
368370 Response := Request.Execute;
369371 CheckError(Response);
372+ Result := Converter.TPetListFromJson(Response.ContentAsString);
370373end ;
371374
372- procedure TPetService.FindPetsByTags (Tags: stringArray);
375+ function TPetService.FindPetsByTags (Tags: stringArray): TPetList ;
373376var
374377 Request: IRestRequest;
375378 I: Integer;
@@ -380,9 +383,10 @@ procedure TPetService.FindPetsByTags(Tags: stringArray);
380383 Request.AddQueryParam(' tags' , Tags[I]);
381384 Response := Request.Execute;
382385 CheckError(Response);
386+ Result := Converter.TPetListFromJson(Response.ContentAsString);
383387end ;
384388
385- procedure TPetService.GetPetById (PetId: Int64);
389+ function TPetService.GetPetById (PetId: Int64): TPet ;
386390var
387391 Request: IRestRequest;
388392 Response: IRestResponse;
@@ -391,6 +395,7 @@ procedure TPetService.GetPetById(PetId: Int64);
391395 Request.AddUrlParam(' petId' , IntToStr(PetId));
392396 Response := Request.Execute;
393397 CheckError(Response);
398+ Result := Converter.TPetFromJson(Response.ContentAsString);
394399end ;
395400
396401procedure TPetService.UpdatePetWithForm (PetId: Int64; Name : string; Status: string);
@@ -420,17 +425,18 @@ procedure TPetService.DeletePet(ApiKey: string; PetId: Int64);
420425
421426{ TStoreService }
422427
423- procedure TStoreService.GetInventory ;
428+ function TStoreService.GetInventory : TGetInventoryOutput ;
424429var
425430 Request: IRestRequest;
426431 Response: IRestResponse;
427432begin
428433 Request := CreateRequest(' /store/inventory' , ' GET' );
429434 Response := Request.Execute;
430435 CheckError(Response);
436+ Result := Converter.TGetInventoryOutputFromJson(Response.ContentAsString);
431437end ;
432438
433- procedure TStoreService.PlaceOrder (Body: TOrder);
439+ function TStoreService.PlaceOrder (Body: TOrder): TOrder ;
434440var
435441 Request: IRestRequest;
436442 Response: IRestResponse;
@@ -439,9 +445,10 @@ procedure TStoreService.PlaceOrder(Body: TOrder);
439445 Request.AddBody(Converter.TOrderToJson(Body));
440446 Response := Request.Execute;
441447 CheckError(Response);
448+ Result := Converter.TOrderFromJson(Response.ContentAsString);
442449end ;
443450
444- procedure TStoreService.GetOrderById (OrderId: Int64);
451+ function TStoreService.GetOrderById (OrderId: Int64): TOrder ;
445452var
446453 Request: IRestRequest;
447454 Response: IRestResponse;
@@ -450,6 +457,7 @@ procedure TStoreService.GetOrderById(OrderId: Int64);
450457 Request.AddUrlParam(' orderId' , IntToStr(OrderId));
451458 Response := Request.Execute;
452459 CheckError(Response);
460+ Result := Converter.TOrderFromJson(Response.ContentAsString);
453461end ;
454462
455463procedure TStoreService.DeleteOrder (OrderId: Int64);
@@ -465,7 +473,7 @@ procedure TStoreService.DeleteOrder(OrderId: Int64);
465473
466474{ TUserService }
467475
468- procedure TUserService.CreateUser (Body: TUser);
476+ function TUserService.CreateUser (Body: TUser): TUser ;
469477var
470478 Request: IRestRequest;
471479 Response: IRestResponse;
@@ -474,9 +482,10 @@ procedure TUserService.CreateUser(Body: TUser);
474482 Request.AddBody(Converter.TUserToJson(Body));
475483 Response := Request.Execute;
476484 CheckError(Response);
485+ Result := Converter.TUserFromJson(Response.ContentAsString);
477486end ;
478487
479- procedure TUserService.CreateUsersWithListInput (Body: TUserList);
488+ function TUserService.CreateUsersWithListInput (Body: TUserList): TUser ;
480489var
481490 Request: IRestRequest;
482491 Response: IRestResponse;
@@ -485,9 +494,10 @@ procedure TUserService.CreateUsersWithListInput(Body: TUserList);
485494 Request.AddBody(Converter.TUserListToJson(Body));
486495 Response := Request.Execute;
487496 CheckError(Response);
497+ Result := Converter.TUserFromJson(Response.ContentAsString);
488498end ;
489499
490- procedure TUserService.LoginUser (Username: string; Password: string);
500+ function TUserService.LoginUser (Username: string; Password: string): string ;
491501var
492502 Request: IRestRequest;
493503 Response: IRestResponse;
@@ -497,6 +507,7 @@ procedure TUserService.LoginUser(Username: string; Password: string);
497507 Request.AddQueryParam(' password' , Password);
498508 Response := Request.Execute;
499509 CheckError(Response);
510+ Result := Converter.stringFromJson(Response.ContentAsString);
500511end ;
501512
502513procedure TUserService.LogoutUser ;
@@ -509,7 +520,7 @@ procedure TUserService.LogoutUser;
509520 CheckError(Response);
510521end ;
511522
512- procedure TUserService.GetUserByName (Username: string);
523+ function TUserService.GetUserByName (Username: string): TUser ;
513524var
514525 Request: IRestRequest;
515526 Response: IRestResponse;
@@ -518,6 +529,7 @@ procedure TUserService.GetUserByName(Username: string);
518529 Request.AddUrlParam(' username' , Username);
519530 Response := Request.Execute;
520531 CheckError(Response);
532+ Result := Converter.TUserFromJson(Response.ContentAsString);
521533end ;
522534
523535procedure TUserService.UpdateUser (Username: string; Body: TUser);
0 commit comments