klicktipp-php-client/src/Entities/Subscription.php

91 lignes
2.2 KiB
PHP
Brut Vue normale Historique

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
*/
2025-01-05 15:20:56 +01:00
declare(strict_types=1);
2024-12-22 13:52:28 +01:00
namespace D3\KlicktippPhpClient\Entities;
use D3\KlicktippPhpClient\Exceptions\BaseException;
2025-01-03 09:33:08 +01:00
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
2024-12-22 13:52:28 +01:00
use Doctrine\Common\Collections\ArrayCollection;
class Subscription extends ArrayCollection
{
private ?SubscriptionProcess $endpoint;
public function __construct(array $elements = [], ?SubscriptionProcess $endpoint = null)
{
$this->endpoint = $endpoint;
parent::__construct($elements);
}
2024-12-22 23:38:41 +01:00
public function getListId(): string
2024-12-22 13:52:28 +01:00
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::LISTID) ?? '';
2024-12-22 23:38:41 +01:00
}
public function getName(): string
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::NAME) ?? '';
2024-12-22 23:38:41 +01:00
}
public function setName(string $name): void
{
$this->set(SubscriptionProcess::NAME, $name);
}
2024-12-22 23:38:41 +01:00
public function getPendingUrl(): string
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::PENDINGURL) ?? '';
2024-12-22 23:38:41 +01:00
}
public function getThankyouUrl(): string
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::THANKYOUURL) ?? '';
2024-12-22 23:38:41 +01:00
}
public function useSingleOptin(): bool
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::USE_SINGLE_OPTIN);
2024-12-22 23:38:41 +01:00
}
public function useDoubleOptin(): bool
{
return !$this->useSingleOptin();
}
public function resendConfirmationEmail(): bool
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::RESEND_CONFIRMATION_EMAIL);
2024-12-22 23:38:41 +01:00
}
public function useChangeEmail(): bool
{
2025-01-03 09:33:08 +01:00
return $this->get(SubscriptionProcess::USE_CHANGE_EMAIL);
2024-12-22 13:52:28 +01:00
}
/**
* @return null|bool
* @throws BaseException
*/
public function persist(): ?bool
{
return $this->endpoint?->update(
$this->getListId(),
$this->getName()
);
}
2024-12-29 00:47:30 +01:00
}