add subscriber endpoint
This commit is contained in:
bovenliggende
7608d39af8
commit
e1e08ee313
19
src/Entities/Subscriber.php
Normal file
19
src/Entities/Subscriber.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\KlicktippPhpClient\Entities;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
class Subscriber extends ArrayCollection
|
||||||
|
{
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return $this->get('id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSubscribed(): bool
|
||||||
|
{
|
||||||
|
// ToDo: adjust request
|
||||||
|
return $this->get('isSubscribed');
|
||||||
|
}
|
||||||
|
}
|
59
src/Resources/Subscriber.php
Normal file
59
src/Resources/Subscriber.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\KlicktippPhpClient\Resources;
|
||||||
|
|
||||||
|
use D3\KlicktippPhpClient\Entities\Subscriber as SubscriberEntity;
|
||||||
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
|
||||||
|
class Subscriber extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws BaseException|GuzzleException
|
||||||
|
*/
|
||||||
|
public function index(): array
|
||||||
|
{
|
||||||
|
return $this->connection->requestAndParse(
|
||||||
|
'GET',
|
||||||
|
'subscriber',
|
||||||
|
[
|
||||||
|
'query' => $this->getQuery()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws BaseException|GuzzleException
|
||||||
|
*/
|
||||||
|
public function get(string $subscriberId): SubscriberEntity
|
||||||
|
{
|
||||||
|
$data = $this->connection->requestAndParse(
|
||||||
|
'GET',
|
||||||
|
'subscriber/'.urlencode(trim($subscriberId)),
|
||||||
|
[
|
||||||
|
'query' => $this->getQuery()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return new SubscriberEntity($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws BaseException|GuzzleException
|
||||||
|
*/
|
||||||
|
public function search(string $mailAddress): string
|
||||||
|
{
|
||||||
|
return current(
|
||||||
|
$this->connection->requestAndParse(
|
||||||
|
'POST',
|
||||||
|
'subscriber/search',
|
||||||
|
[
|
||||||
|
'query' => $this->getQuery(),
|
||||||
|
'form_params' => [
|
||||||
|
'email' => trim($mailAddress)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Laden…
x
Verwijs in nieuw issue
Block a user