Skip to content

Commit b4e358c

Browse files
authored
Merge pull request #4 from jtx/mail_forwarding
Add get method
2 parents 4cf1404 + 6c7c413 commit b4e358c

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/PleskX/Api/Operator/Mail.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Mail extends \PleskX\Api\Operator
1212
* @param string $forwardAddress
1313
* @return Struct\Info
1414
*/
15-
public function create(string $name, int $siteId, string $forwardAddress)
15+
public function create(string $name, int $siteId, string $forwardAddress): Struct\Info
1616
{
1717
$packet = $this->_client->getPacket();
1818
$info = $packet->addChild($this->_wrapperTag)->addChild('create');
@@ -31,20 +31,37 @@ public function create(string $name, int $siteId, string $forwardAddress)
3131
return new Struct\Info($response->mailname);
3232
}
3333

34+
/**
35+
* @param int $siteId
36+
* @return \PleskX\Api\XmlResponse
37+
*/
38+
public function get(int $siteId)
39+
{
40+
$packet = $this->_client->getPacket();
41+
$info = $packet->addChild($this->_wrapperTag)->addChild('get_info');
42+
$filter = $info->addChild('filter');
43+
$filter->addChild('site_id', $siteId);
44+
$filter->addChild('forwarding', 'true');
45+
46+
$response = $this->_client->request($packet);
47+
48+
return $response;
49+
}
50+
3451
/**
3552
* @param string $field
3653
* @param integer|string $value
3754
* @param integer $siteId
3855
* @return bool
3956
*/
40-
public function delete($field, $value, $siteId)
57+
public function delete($field, $value, $siteId): bool
4158
{
4259
$packet = $this->_client->getPacket();
4360
$filter = $packet->addChild($this->_wrapperTag)->addChild('remove')->addChild('filter');
4461
$filter->addChild('site-id', $siteId);
4562
$filter->addChild($field, $value);
4663
$response = $this->_client->request($packet);
64+
4765
return 'ok' === (string)$response->status;
4866
}
49-
5067
}

0 commit comments

Comments
 (0)