-
Notifications
You must be signed in to change notification settings - Fork 63
/
DN.PackageProvider.GitHub.State.pas
61 lines (51 loc) · 1.38 KB
/
DN.PackageProvider.GitHub.State.pas
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
unit DN.PackageProvider.GitHub.State;
interface
uses
DN.PackageProvider.State,
DN.PackageProvider.State.Intf,
DN.HttpClient.Intf;
type
TDNGithubPackageProviderState = class(TDNPackageProviderState)
private
FClient: IDNHttpClient;
protected
function GetStatisticCount: Integer; override;
function GetStatisticName(const AIndex: Integer): string; override;
function GetStatisticValue(const AIndex: Integer): string; override;
public
constructor Create(const AClient: IDNHttpClient);
end;
implementation
{ TDNGithubPackageProviderState }
constructor TDNGithubPackageProviderState.Create(const AClient: IDNHttpClient);
begin
inherited Create;
FClient := AClient;
end;
function TDNGithubPackageProviderState.GetStatisticCount: Integer;
begin
Result := 3;
end;
function TDNGithubPackageProviderState.GetStatisticName(
const AIndex: Integer): string;
begin
case AIndex of
0: Result := 'Ratelimit';
1: Result := 'RateLimit-Remaining';
2: Result := 'RateLimit-Reset';
else
Result := '';
end;
end;
function TDNGithubPackageProviderState.GetStatisticValue(
const AIndex: Integer): string;
begin
case AIndex of
0: Result := FClient.ResponseHeader['X-RateLimit-Limit'];
1: Result := FClient.ResponseHeader['X-RateLimit-Remaining'];
2: Result := FClient.ResponseHeader['X-RateLimit-Reset'];
else
Result := '';
end;
end;
end.