2024-12-22 13:52:28 +01:00
|
|
|
<?php
|
|
|
|
|
2024-12-29 00:47:30 +01:00
|
|
|
/**
|
|
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view
|
|
|
|
* the LICENSE file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
2024-12-22 13:52:28 +01:00
|
|
|
namespace D3\KlicktippPhpClient\Resources;
|
|
|
|
|
|
|
|
use D3\KlicktippPhpClient\Entities\Subscription as SubscriptionEntity;
|
2024-12-22 23:36:29 +01:00
|
|
|
use D3\KlicktippPhpClient\Entities\SubscriptionList;
|
2024-12-22 13:52:28 +01:00
|
|
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
|
|
|
use GuzzleHttp\RequestOptions;
|
|
|
|
|
|
|
|
class SubscriptionProcess extends Model
|
|
|
|
{
|
|
|
|
/**
|
2024-12-29 23:32:29 +01:00
|
|
|
* @throws BaseException
|
2024-12-22 13:52:28 +01:00
|
|
|
*/
|
2024-12-22 23:36:29 +01:00
|
|
|
public function index(): SubscriptionList
|
2024-12-22 13:52:28 +01:00
|
|
|
{
|
2024-12-22 23:36:29 +01:00
|
|
|
$data = $this->connection->requestAndParse(
|
2024-12-22 13:52:28 +01:00
|
|
|
'GET',
|
2024-12-29 23:32:29 +01:00
|
|
|
'list.json'
|
2024-12-22 13:52:28 +01:00
|
|
|
);
|
2024-12-22 23:36:29 +01:00
|
|
|
|
|
|
|
return new SubscriptionList($data);
|
2024-12-22 13:52:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-12-29 23:32:29 +01:00
|
|
|
* @throws BaseException
|
2024-12-22 13:52:28 +01:00
|
|
|
*/
|
|
|
|
public function get(string $listId): SubscriptionEntity
|
|
|
|
{
|
|
|
|
$data = $this->connection->requestAndParse(
|
|
|
|
'GET',
|
2024-12-29 23:32:29 +01:00
|
|
|
'list/'.urlencode(trim($listId)).'.json'
|
2024-12-22 13:52:28 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return new SubscriptionEntity($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-12-29 23:32:29 +01:00
|
|
|
* @throws BaseException
|
2024-12-22 13:52:28 +01:00
|
|
|
*/
|
|
|
|
public function redirect(string $listId, string $email): string
|
|
|
|
{
|
|
|
|
return current(
|
|
|
|
$this->connection->requestAndParse(
|
|
|
|
'POST',
|
2024-12-29 23:32:29 +01:00
|
|
|
'list/redirect.json',
|
2024-12-22 13:52:28 +01:00
|
|
|
[
|
|
|
|
RequestOptions::FORM_PARAMS => [
|
|
|
|
'listid' => trim($listId),
|
|
|
|
'email' => trim($email),
|
2024-12-29 00:47:30 +01:00
|
|
|
],
|
2024-12-22 13:52:28 +01:00
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|