2024-12-20 23:45:55 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace D3\KlicktippPhpClient;
|
|
|
|
|
|
|
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
|
|
|
use D3\KlicktippPhpClient\Resources\Account;
|
2024-12-22 23:30:47 +01:00
|
|
|
use D3\KlicktippPhpClient\Resources\Field;
|
2024-12-20 23:45:55 +01:00
|
|
|
use D3\KlicktippPhpClient\Resources\Subscriber;
|
2024-12-22 13:52:28 +01:00
|
|
|
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
|
2024-12-20 23:45:55 +01:00
|
|
|
use D3\KlicktippPhpClient\Resources\Tag;
|
|
|
|
use GuzzleHttp\ClientInterface;
|
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
|
|
|
|
|
|
class Klicktipp
|
|
|
|
{
|
|
|
|
protected string $client_key;
|
|
|
|
|
|
|
|
protected string $secret_key;
|
|
|
|
|
|
|
|
protected ?Connection $connection = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws BaseException
|
|
|
|
* @throws GuzzleException
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
string $client_key,
|
|
|
|
string $secret_key,
|
|
|
|
ClientInterface $client = null
|
|
|
|
){
|
|
|
|
$this->client_key = $client_key;
|
|
|
|
$this->secret_key = $secret_key;
|
|
|
|
|
|
|
|
if ($client) {
|
|
|
|
$this->getConnection()->setClient($client);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->account()->login();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getConnection(): Connection
|
|
|
|
{
|
|
|
|
if (!$this->connection) {
|
|
|
|
$this->connection = new Connection($this->client_key, $this->secret_key);
|
|
|
|
}
|
|
|
|
return $this->connection;
|
|
|
|
}
|
|
|
|
|
2024-12-22 13:52:28 +01:00
|
|
|
public function subscription(): SubscriptionProcess
|
|
|
|
{
|
|
|
|
return new SubscriptionProcess($this->getConnection());
|
|
|
|
}
|
|
|
|
|
2024-12-20 23:45:55 +01:00
|
|
|
public function account(): Account
|
|
|
|
{
|
|
|
|
return new Account($this->getConnection());
|
|
|
|
}
|
|
|
|
|
2024-12-22 23:30:47 +01:00
|
|
|
public function field(): Field
|
|
|
|
{
|
|
|
|
return new Field($this->getConnection());
|
|
|
|
}
|
|
|
|
|
2024-12-20 23:45:55 +01:00
|
|
|
public function subscriber(): Subscriber
|
|
|
|
{
|
|
|
|
return new Subscriber($this->getConnection());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tag(): Tag
|
|
|
|
{
|
|
|
|
return new Tag($this->getConnection());
|
|
|
|
}
|
|
|
|
}
|