forked from Memnarch/Delphinus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DN.PackageProvider.GitHubRepo.pas
51 lines (42 loc) · 1.11 KB
/
DN.PackageProvider.GitHubRepo.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
unit DN.PackageProvider.GitHubRepo;
interface
uses
DN.PackageProvider.GitHub,
DN.HttpClient.Intf,
DN.JSon;
type
TDNGithubRepoPackageProvider = class(TDNGitHubPackageProvider)
private
FOwner: string;
FRepository: string;
protected
function GetRepoList(out ARepos: TJSONArray): Boolean; override;
public
constructor Create(const AClient: IDNHttpClient; const AOwner, ARepository: string); reintroduce;
end;
implementation
uses
SysUtils;
{ TDNGithubRepoPackageProvider }
constructor TDNGithubRepoPackageProvider.Create(const AClient: IDNHttpClient;
const AOwner, ARepository: string);
begin
inherited Create(AClient);
FOwner := AOwner;
FRepository := ARepository;
end;
function TDNGithubRepoPackageProvider.GetRepoList(
out ARepos: TJSONArray): Boolean;
var
LResponse: string;
const
CRequest = 'https://api.github.com/repos/%s/%s';
begin
Result := FClient.GetText(Format(CRequest, [FOwner, FRepository]), LResponse) = HTTPErrorOk;
if Result then
begin
ARepos := TJSonObject.ParseJSONValue('[' + LResponse + ']') as TJSONArray;
Result := Assigned(ARepos);
end;
end;
end.