forked from plesk/api-php-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCertificate.php
57 lines (41 loc) · 1.63 KB
/
Certificate.php
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
<?php
// Copyright 1999-2022. Plesk International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Certificate as Struct;
class Certificate extends \PleskX\Api\Operator
{
public function generate(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('generate')->addChild('info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
public function install(array $properties, string $request, string $privateKey): bool
{
$packet = $this->client->getPacket();
$installTag = $packet->addChild($this->wrapperTag)->addChild('install');
foreach ($properties as $name => $value) {
$installTag->{$name} = $value;
}
$contentTag = $installTag->addChild('content');
$contentTag->addChild('csr', $request);
$contentTag->addChild('pvt', $privateKey);
$result = $this->client->request($packet);
return 'ok' == (string) $result->status;
}
public function delete(string $name, array $properties): bool
{
$packet = $this->client->getPacket();
$removeTag = $packet->addChild($this->wrapperTag)->addChild('remove');
$removeTag->addChild('filter')->addChild('name', $name);
foreach ($properties as $name => $value) {
$removeTag->{$name} = $value;
}
$result = $this->client->request($packet);
return 'ok' == (string) $result->status;
}
}