8
0

54 Zeilen
1.2 KiB
PHP

2024-12-20 23:46:48 +01:00
<?php
namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Subscriber as SubscriberEntity;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use GuzzleHttp\Exception\GuzzleException;
2024-12-21 19:25:33 +01:00
use GuzzleHttp\RequestOptions;
2024-12-20 23:46:48 +01:00
class Subscriber extends Model
{
/**
* @throws BaseException|GuzzleException
*/
public function index(): array
{
return $this->connection->requestAndParse(
'GET',
2024-12-21 19:25:33 +01:00
'subscriber'
2024-12-20 23:46:48 +01:00
);
}
/**
* @throws BaseException|GuzzleException
*/
public function get(string $subscriberId): SubscriberEntity
{
$data = $this->connection->requestAndParse(
'GET',
2024-12-21 19:25:33 +01:00
'subscriber/'.urlencode(trim($subscriberId))
2024-12-20 23:46:48 +01:00
);
return new SubscriberEntity($data);
}
/**
* @throws BaseException|GuzzleException
*/
public function search(string $mailAddress): string
{
return current(
$this->connection->requestAndParse(
'POST',
'subscriber/search',
[
2024-12-21 19:25:33 +01:00
RequestOptions::FORM_PARAMS => [
2024-12-20 23:46:48 +01:00
'email' => trim($mailAddress)
]
]
)
);
}
}