use constants for subscriptions
Dieser Commit ist enthalten in:
Ursprung
395d6c3b2e
Commit
cc3814bbcd
@ -15,33 +15,34 @@
|
||||
|
||||
namespace D3\KlicktippPhpClient\Entities;
|
||||
|
||||
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class Subscription extends ArrayCollection
|
||||
{
|
||||
public function getListId(): string
|
||||
{
|
||||
return $this->get('listid') ?? '';
|
||||
return $this->get(SubscriptionProcess::LISTID) ?? '';
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->get('name') ?? '';
|
||||
return $this->get(SubscriptionProcess::NAME) ?? '';
|
||||
}
|
||||
|
||||
public function getPendingUrl(): string
|
||||
{
|
||||
return $this->get('pendingurl') ?? '';
|
||||
return $this->get(SubscriptionProcess::PENDINGURL) ?? '';
|
||||
}
|
||||
|
||||
public function getThankyouUrl(): string
|
||||
{
|
||||
return $this->get('thankyouurl') ?? '';
|
||||
return $this->get(SubscriptionProcess::THANKYOUURL) ?? '';
|
||||
}
|
||||
|
||||
public function useSingleOptin(): bool
|
||||
{
|
||||
return $this->get('usesingleoptin');
|
||||
return $this->get(SubscriptionProcess::USE_SINGLE_OPTIN);
|
||||
}
|
||||
|
||||
public function useDoubleOptin(): bool
|
||||
@ -51,11 +52,11 @@ class Subscription extends ArrayCollection
|
||||
|
||||
public function resendConfirmationEmail(): bool
|
||||
{
|
||||
return $this->get('resendconfirmationemail');
|
||||
return $this->get(SubscriptionProcess::RESEND_CONFIRMATION_EMAIL);
|
||||
}
|
||||
|
||||
public function useChangeEmail(): bool
|
||||
{
|
||||
return $this->get('usechangeemail');
|
||||
return $this->get(SubscriptionProcess::USE_CHANGE_EMAIL);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,15 @@ use GuzzleHttp\RequestOptions;
|
||||
|
||||
class SubscriptionProcess extends Model
|
||||
{
|
||||
public const LISTID = 'listid';
|
||||
public const NAME = 'name';
|
||||
public const PENDINGURL = 'pendingurl';
|
||||
public const THANKYOUURL = 'thankyouurl';
|
||||
public const USE_SINGLE_OPTIN = 'usesingleoptin';
|
||||
public const RESEND_CONFIRMATION_EMAIL = 'resendconfirmationemail';
|
||||
public const USE_CHANGE_EMAIL = 'usechangeemail';
|
||||
public const PARAM_EMAIL = 'email';
|
||||
|
||||
/**
|
||||
* @throws BaseException
|
||||
*/
|
||||
@ -58,7 +67,7 @@ class SubscriptionProcess extends Model
|
||||
'list.json',
|
||||
[
|
||||
RequestOptions::FORM_PARAMS => array_filter([
|
||||
'name' => trim($name ?? ''),
|
||||
self::NAME => trim($name ?? ''),
|
||||
]),
|
||||
]
|
||||
);
|
||||
@ -77,7 +86,7 @@ class SubscriptionProcess extends Model
|
||||
'list/'.urlencode(trim($listId)).'.json',
|
||||
[
|
||||
RequestOptions::FORM_PARAMS => array_filter([
|
||||
'name' => trim($name ?? ''),
|
||||
self::NAME => trim($name ?? ''),
|
||||
]),
|
||||
]
|
||||
)
|
||||
@ -95,8 +104,8 @@ class SubscriptionProcess extends Model
|
||||
'list/redirect.json',
|
||||
[
|
||||
RequestOptions::FORM_PARAMS => [
|
||||
'listid' => trim($listId),
|
||||
'email' => trim($email),
|
||||
self::LISTID => trim($listId),
|
||||
self::PARAM_EMAIL => trim($email),
|
||||
],
|
||||
]
|
||||
)
|
||||
|
@ -93,21 +93,21 @@ class SubscriptionProcessTest extends IntegrationTestCase
|
||||
public static function getDataProvider(): Generator
|
||||
{
|
||||
yield 'success' => [new Response(200, [], '{
|
||||
"listid": "470370",
|
||||
"name": "name 1",
|
||||
"pendingurl": "",
|
||||
"thankyouurl": "",
|
||||
"usesingleoptin": false,
|
||||
"resendconfirmationemail": false,
|
||||
"usechangeemail": false
|
||||
"'.SubscriptionProcess::LISTID.'": "470370",
|
||||
"'.SubscriptionProcess::NAME.'": "name 1",
|
||||
"'.SubscriptionProcess::PENDINGURL.'": "",
|
||||
"'.SubscriptionProcess::THANKYOUURL.'": "",
|
||||
"'.SubscriptionProcess::USE_SINGLE_OPTIN.'": false,
|
||||
"'.SubscriptionProcess::RESEND_CONFIRMATION_EMAIL.'": false,
|
||||
"'.SubscriptionProcess::USE_CHANGE_EMAIL.'": false
|
||||
}'), new Subscription([
|
||||
"listid" => "470370",
|
||||
"name" => "name 1",
|
||||
"pendingurl" => "",
|
||||
"thankyouurl" => "",
|
||||
"usesingleoptin" => false,
|
||||
"resendconfirmationemail" => false,
|
||||
"usechangeemail" => false,
|
||||
SubscriptionProcess::LISTID => "470370",
|
||||
SubscriptionProcess::NAME => "name 1",
|
||||
SubscriptionProcess::PENDINGURL => "",
|
||||
SubscriptionProcess::THANKYOUURL => "",
|
||||
SubscriptionProcess::USE_SINGLE_OPTIN => false,
|
||||
SubscriptionProcess::RESEND_CONFIRMATION_EMAIL => false,
|
||||
SubscriptionProcess::USE_CHANGE_EMAIL => false,
|
||||
])];
|
||||
yield 'unknown id' => [new Response(404, [], '["Kein Opt-In-Prozess mit dieser ID."]'), null, true];
|
||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren