add subscriber endpoint
Cette révision appartient à :
Parent
7608d39af8
révision
e1e08ee313
19
src/Entities/Subscriber.php
Fichier normal
19
src/Entities/Subscriber.php
Fichier normal
@ -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
Fichier normal
59
src/Resources/Subscriber.php
Fichier normal
@ -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)
|
||||
]
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Chargement…
x
Référencer dans un nouveau ticket
Bloquer un utilisateur