-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestClient.dpr
More file actions
86 lines (66 loc) · 1.85 KB
/
RestClient.dpr
File metadata and controls
86 lines (66 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
program RestClient;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Generics.Collections,
Spring,
Spring.Container,
Spring.Container.Common,
Spring.Interception,
System.Rtti,
RestClient.Core.Attributes in 'Source\RestClient.Core.Attributes.pas',
RestClient.Core.Interceptor in 'Source\RestClient.Core.Interceptor.pas',
RestClient.Core.RestCaller in 'Source\RestClient.Core.RestCaller.pas',
RestClient.Core in 'Source\RestClient.Core.pas',
RestClient.Core.Exceptions in 'Source\RestClient.Core.Exceptions.pas',
SampleRestAPI in 'Demo\SampleRestAPI.pas',
Sample.Classes in 'Demo\Sample.Classes.pas';
var
todo : TTodo;
todos : TObjectList<TTodo>;
response : TResponse;
sampleRestAPI: ISampleRestClient;
begin
try
try
sampleRestAPI := GlobalRestClient.Resolve<ISampleRestClient>;
todo := sampleRestAPI.GetTodo(1);
Writeln(todo.Title);
todos := sampleRestAPI.GetTodos;
Writeln(todos.ToString);
//PathParam samples
todo := sampleRestAPI.GetTodo(1,'Alex');
Writeln(todo.Title);
//BodyParam samples
todo := TTodo.Create;
todo.id := 1;
todo.title := 'Test TODO';
todo.userId := 1;
todo.completed := false;
response := sampleRestAPI.CreateTodo(todo);
Writeln(response.ToString);
//QueryParam samples
todo := sampleRestAPI.GetPerson(1);
Writeln(todo.Title);
todo := sampleRestAPI.GetPerson(1, 'Alex');
Writeln(todo.Title);
{ try
todo := sampleRestAPI.RaiseException;
Except on E: Exception do begin
Writeln(E.Message);
end;
end; }
Readln;
finally
FreeAndNil(todo);
FreeAndNil(todos);
FreeAndNil(response);
end;
except
on E: Exception do BEGIN
Writeln(E.ClassName, ': ', E.Message);
Readln;
END;
end;
end.