add subscription process endpoint
This commit is contained in:
bovenliggende
b080b1a64c
commit
2e5dbcbea0
13
src/Entities/Subscription.php
Normal file
13
src/Entities/Subscription.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\KlicktippPhpClient\Entities;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
class Subscription extends ArrayCollection
|
||||||
|
{
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return $this->get('id');
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ namespace D3\KlicktippPhpClient;
|
|||||||
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
||||||
use D3\KlicktippPhpClient\Resources\Account;
|
use D3\KlicktippPhpClient\Resources\Account;
|
||||||
use D3\KlicktippPhpClient\Resources\Subscriber;
|
use D3\KlicktippPhpClient\Resources\Subscriber;
|
||||||
|
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
|
||||||
use D3\KlicktippPhpClient\Resources\Tag;
|
use D3\KlicktippPhpClient\Resources\Tag;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
@ -57,6 +58,11 @@ class Klicktipp
|
|||||||
return $this->connection;
|
return $this->connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subscription(): SubscriptionProcess
|
||||||
|
{
|
||||||
|
return new SubscriptionProcess($this->getConnection());
|
||||||
|
}
|
||||||
|
|
||||||
public function account(): Account
|
public function account(): Account
|
||||||
{
|
{
|
||||||
return new Account($this->getConnection());
|
return new Account($this->getConnection());
|
||||||
|
54
src/Resources/SubscriptionProcess.php
Normal file
54
src/Resources/SubscriptionProcess.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\KlicktippPhpClient\Resources;
|
||||||
|
|
||||||
|
use D3\KlicktippPhpClient\Entities\Subscription as SubscriptionEntity;
|
||||||
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use GuzzleHttp\RequestOptions;
|
||||||
|
|
||||||
|
class SubscriptionProcess extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws BaseException|GuzzleException
|
||||||
|
*/
|
||||||
|
public function index(): array
|
||||||
|
{
|
||||||
|
return $this->connection->requestAndParse(
|
||||||
|
'GET',
|
||||||
|
'list'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws BaseException|GuzzleException
|
||||||
|
*/
|
||||||
|
public function get(string $listId): SubscriptionEntity
|
||||||
|
{
|
||||||
|
$data = $this->connection->requestAndParse(
|
||||||
|
'GET',
|
||||||
|
'list/'.urlencode(trim($listId))
|
||||||
|
);
|
||||||
|
|
||||||
|
return new SubscriptionEntity($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws BaseException|GuzzleException
|
||||||
|
*/
|
||||||
|
public function redirect(string $listId, string $email): string
|
||||||
|
{
|
||||||
|
return current(
|
||||||
|
$this->connection->requestAndParse(
|
||||||
|
'POST',
|
||||||
|
'list/redirect',
|
||||||
|
[
|
||||||
|
RequestOptions::FORM_PARAMS => [
|
||||||
|
'listid' => trim($listId),
|
||||||
|
'email' => trim($email),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Laden…
x
Verwijs in nieuw issue
Block a user