add constants
Dieser Commit ist enthalten in:
Ursprung
0110a3b7b9
Commit
549078f1b7
@ -145,6 +145,7 @@ class Connection
|
|||||||
$response->getBody()->rewind();
|
$response->getBody()->rewind();
|
||||||
|
|
||||||
$response_body = $response->getBody()->getContents();
|
$response_body = $response->getBody()->getContents();
|
||||||
|
|
||||||
$result_array = json_decode($response_body, true);
|
$result_array = json_decode($response_body, true);
|
||||||
|
|
||||||
if ($response->getStatusCode() === 204) {
|
if ($response->getStatusCode() === 204) {
|
||||||
|
@ -36,17 +36,17 @@ class Subscriber extends ArrayCollection
|
|||||||
|
|
||||||
public function getId(): ?string
|
public function getId(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('id');
|
return $this->get(SubscriberEndpoint::ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getListId(): ?string
|
public function getListId(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('listid');
|
return $this->get(SubscriberEndpoint::LISTID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOptinTime(): ?DateTime
|
public function getOptinTime(): ?DateTime
|
||||||
{
|
{
|
||||||
return $this->getDateTimeFromValue($this->get('optin'));
|
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::OPTIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isOptedIn(): bool
|
public function isOptedIn(): bool
|
||||||
@ -58,24 +58,24 @@ class Subscriber extends ArrayCollection
|
|||||||
|
|
||||||
public function getOptinIp(): ?string
|
public function getOptinIp(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('optin_ip');
|
return $this->get(SubscriberEndpoint::OPTIN_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailAddress(): ?string
|
public function getEmailAddress(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('email');
|
return $this->get(SubscriberEndpoint::EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeEmailAddress(string $emailAddress): void
|
public function changeEmailAddress(string $emailAddress): void
|
||||||
{
|
{
|
||||||
$this->set('email', $emailAddress);
|
$this->set(SubscriberEndpoint::EMAIL, $emailAddress);
|
||||||
|
|
||||||
// use persist method to send to Klicktipp
|
// use persist method to send to Klicktipp
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatus(): ?string
|
public function getStatus(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('status');
|
return $this->get(SubscriberEndpoint::STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSubscribed(): bool
|
public function isSubscribed(): bool
|
||||||
@ -85,7 +85,7 @@ class Subscriber extends ArrayCollection
|
|||||||
|
|
||||||
public function getBounce(): ?string
|
public function getBounce(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('bounce');
|
return $this->get(SubscriberEndpoint::BOUNCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBounced(): bool
|
public function isBounced(): bool
|
||||||
@ -95,64 +95,64 @@ class Subscriber extends ArrayCollection
|
|||||||
|
|
||||||
public function getDate(): ?DateTime
|
public function getDate(): ?DateTime
|
||||||
{
|
{
|
||||||
return $this->getDateTimeFromValue($this->get('date'));
|
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::DATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIp(): ?string
|
public function getIp(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('ip');
|
return $this->get(SubscriberEndpoint::IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnsubscription(): ?DateTime
|
public function getUnsubscription(): ?DateTime
|
||||||
{
|
{
|
||||||
return $this->getDateTimeFromValue($this->get('unsubscription'));
|
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::UNSUBSCRIPTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnsubscriptionIp(): ?string
|
public function getUnsubscriptionIp(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('unsubscription_ip');
|
return $this->get(SubscriberEndpoint::UNSUBSCRIPTION_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReferrer(): ?string
|
public function getReferrer(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('referrer');
|
return $this->get(SubscriberEndpoint::REFERRER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmsPhone(): ?string
|
public function getSmsPhone(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('sms_phone');
|
return $this->get(SubscriberEndpoint::SMS_PHONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSmsPhone(string $smsPhone): void
|
public function setSmsPhone(string $smsPhone): void
|
||||||
{
|
{
|
||||||
$this->set('sms_phone', $smsPhone);
|
$this->set(SubscriberEndpoint::SMS_PHONE, $smsPhone);
|
||||||
|
|
||||||
// use persist method to send to Klicktipp
|
// use persist method to send to Klicktipp
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmsStatus(): ?string
|
public function getSmsStatus(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('sms_status');
|
return $this->get(SubscriberEndpoint::SMS_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmsBounce(): ?string
|
public function getSmsBounce(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('sms_bounce');
|
return $this->get(SubscriberEndpoint::SMS_BOUNCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmsDate(): ?DateTime
|
public function getSmsDate(): ?DateTime
|
||||||
{
|
{
|
||||||
return $this->getDateTimeFromValue($this->get('sms_date'));
|
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::SMS_DATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmsUnsubscription(): ?string
|
public function getSmsUnsubscription(): ?string
|
||||||
{
|
{
|
||||||
return $this->getDateTimeFromValue($this->get('sms_unsubscription'));
|
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::SMS_UNSUBSCRIPTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmsReferrer(): ?string
|
public function getSmsReferrer(): ?string
|
||||||
{
|
{
|
||||||
return $this->get('sms_referrer');
|
return $this->get(SubscriberEndpoint::SMS_REFERRER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFields(): ArrayCollection
|
public function getFields(): ArrayCollection
|
||||||
@ -183,7 +183,7 @@ class Subscriber extends ArrayCollection
|
|||||||
|
|
||||||
public function getTags(): ArrayCollection
|
public function getTags(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('tags') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::TAGS) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTagSet(string $tagId): bool
|
public function isTagSet(string $tagId): bool
|
||||||
@ -195,7 +195,7 @@ class Subscriber extends ArrayCollection
|
|||||||
{
|
{
|
||||||
$tags = $this->getTags();
|
$tags = $this->getTags();
|
||||||
$tags->clear();
|
$tags->clear();
|
||||||
$this->set('tags', $tags->toArray());
|
$this->set(SubscriberEndpoint::TAGS, $tags->toArray());
|
||||||
|
|
||||||
// use persist method to send to Klicktipp
|
// use persist method to send to Klicktipp
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ class Subscriber extends ArrayCollection
|
|||||||
{
|
{
|
||||||
$tags = $this->getTags();
|
$tags = $this->getTags();
|
||||||
$tags->add($tagId);
|
$tags->add($tagId);
|
||||||
$this->set('tags', $tags->toArray());
|
$this->set(SubscriberEndpoint::TAGS, $tags->toArray());
|
||||||
|
|
||||||
// use persist method to send to Klicktipp
|
// use persist method to send to Klicktipp
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ class Subscriber extends ArrayCollection
|
|||||||
{
|
{
|
||||||
$tags = $this->getTags();
|
$tags = $this->getTags();
|
||||||
$tags->removeElement($tagId);
|
$tags->removeElement($tagId);
|
||||||
$this->set('tags', $tags->toArray());
|
$this->set(SubscriberEndpoint::TAGS, $tags->toArray());
|
||||||
|
|
||||||
// use persist method to send to Klicktipp
|
// use persist method to send to Klicktipp
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getManualTags(): ArrayCollection
|
public function getManualTags(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('manual_tags') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::MANUALTAGS) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isManualTagSet(string $tagId): bool
|
public function isManualTagSet(string $tagId): bool
|
||||||
@ -238,7 +238,7 @@ class Subscriber extends ArrayCollection
|
|||||||
|
|
||||||
public function getSmartTags(): ArrayCollection
|
public function getSmartTags(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('smart_tags') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::SMARTTAGS) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSmartTagTime(string $tagId): ?DateTime
|
public function getSmartTagTime(string $tagId): ?DateTime
|
||||||
@ -251,7 +251,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getStartedCampaigns(): ArrayCollection
|
public function getStartedCampaigns(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('campaigns_started') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::CAMPAIGNSSTARTED) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStartedCampaignTime(string $campaignId): ?DateTime
|
public function getStartedCampaignTime(string $campaignId): ?DateTime
|
||||||
@ -264,7 +264,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getFinishedCampaigns(): ArrayCollection
|
public function getFinishedCampaigns(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('campaigns_finished') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::CAMPAIGNSFINISHED) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFinishedCampaignTime(string $campaignId): ?DateTime
|
public function getFinishedCampaignTime(string $campaignId): ?DateTime
|
||||||
@ -277,7 +277,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getSentNotificationEmails(): ArrayCollection
|
public function getSentNotificationEmails(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('notification_emails_sent') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSSENT) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -285,7 +285,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getOpenedNotificationEmails(): ArrayCollection
|
public function getOpenedNotificationEmails(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('notification_emails_opened') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSOPENED) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,7 +293,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getClickedNotificationEmails(): ArrayCollection
|
public function getClickedNotificationEmails(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('notification_emails_clicked') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSCLICKED) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,7 +301,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getViewedNotificationEmails(): ArrayCollection
|
public function getViewedNotificationEmails(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('notification_emails_viewed') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSVIEWED) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -309,7 +309,7 @@ class Subscriber extends ArrayCollection
|
|||||||
*/
|
*/
|
||||||
public function getOutbounds(): ArrayCollection
|
public function getOutbounds(): ArrayCollection
|
||||||
{
|
{
|
||||||
return new ArrayCollection($this->get('outbound') ?? []);
|
return new ArrayCollection($this->get(SubscriberEndpoint::OUTBOUND) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,58 @@ use GuzzleHttp\RequestOptions;
|
|||||||
|
|
||||||
class Subscriber extends Model
|
class Subscriber extends Model
|
||||||
{
|
{
|
||||||
|
public const ID = 'id';
|
||||||
|
public const LISTID = 'listid';
|
||||||
|
public const OPTIN = 'optin';
|
||||||
|
public const OPTIN_IP = 'optin_ip';
|
||||||
|
public const EMAIL = 'email';
|
||||||
|
public const STATUS = 'status';
|
||||||
|
public const BOUNCE = 'bounce';
|
||||||
|
public const IP = 'ip';
|
||||||
|
public const UNSUBSCRIPTION = 'unsubscription';
|
||||||
|
public const UNSUBSCRIPTION_IP = 'unsubscription_ip';
|
||||||
|
public const SMS_PHONE = 'sms_phone';
|
||||||
|
public const SMS_STATUS = 'sms_status';
|
||||||
|
public const SMS_BOUNCE = 'sms_bounce';
|
||||||
|
public const SMS_DATE = 'sms_date';
|
||||||
|
public const SMS_UNSUBSCRIPTION = 'sms_unsubscription';
|
||||||
|
public const SMS_REFERRER = 'sms_referrer';
|
||||||
|
public const REFERRER = 'referrer';
|
||||||
|
public const DATE = 'date';
|
||||||
|
public const FIELD_FIRSTNAME = 'fieldFirstName';
|
||||||
|
public const FIELD_LASTNAME = 'fieldLastName';
|
||||||
|
public const FIELD_COMPANYNAME = 'fieldCompanyName';
|
||||||
|
public const FIELD_STREET1 = 'fieldStreet1';
|
||||||
|
public const FIELD_STREET2 = 'fieldStreet2';
|
||||||
|
public const FIELD_CITY = 'fieldCity';
|
||||||
|
public const FIELD_STATE = 'fieldState';
|
||||||
|
public const FIELD_ZIP = 'fieldZip';
|
||||||
|
public const FIELD_COUNTRY = 'fieldCountry';
|
||||||
|
public const FIELD_PRIVATEPHONE = 'fieldPrivatePhone';
|
||||||
|
public const FIELD_MOBILEPHONE = 'fieldMobilePhone';
|
||||||
|
public const FIELD_PHONE = 'fieldPhone';
|
||||||
|
public const FIELD_FAX = 'fieldFax';
|
||||||
|
public const FIELD_WEBSITE = 'fieldWebsite';
|
||||||
|
public const FIELD_BIRTHDAY = 'fieldBirthday';
|
||||||
|
public const FIELD_LEADVALUE = 'fieldLeadValue';
|
||||||
|
public const TAGS = 'tags';
|
||||||
|
public const MANUALTAGS = 'manual_tags';
|
||||||
|
public const SMARTTAGS = 'smart_tags';
|
||||||
|
public const CAMPAIGNSSTARTED = 'campaigns_started';
|
||||||
|
public const CAMPAIGNSFINISHED = 'campaigns_finished';
|
||||||
|
public const NOTIFICATIONEMAILSSENT = 'notification_emails_sent';
|
||||||
|
public const NOTIFICATIONEMAILSOPENED = 'notification_emails_opened';
|
||||||
|
public const NOTIFICATIONEMAILSCLICKED = 'notification_emails_clicked';
|
||||||
|
public const NOTIFICATIONEMAILSVIEWED = 'notification_emails_viewed';
|
||||||
|
public const OUTBOUND = 'outbound';
|
||||||
|
public const PARAM_TAGID = 'tagid';
|
||||||
|
public const PARAM_TAGIDS = 'tagids';
|
||||||
|
public const PARAM_FIELDS = 'fields';
|
||||||
|
public const PARAM_SMS_NUMBER = 'smsnumber';
|
||||||
|
public const PARAM_NEW_EMAIL = 'newemail';
|
||||||
|
public const PARAM_NEW_SMSNUMBER = 'newsmsnumber';
|
||||||
|
public const PARAM_APIKEY = 'apikey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
@ -59,7 +111,7 @@ class Subscriber extends Model
|
|||||||
'subscriber/search.json',
|
'subscriber/search.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'email' => trim($mailAddress),
|
self::EMAIL => trim($mailAddress),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -83,13 +135,13 @@ class Subscriber extends Model
|
|||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => array_filter(
|
RequestOptions::FORM_PARAMS => array_filter(
|
||||||
[
|
[
|
||||||
'email' => trim($mailAddress),
|
self::EMAIL => trim($mailAddress),
|
||||||
'listid' => trim($listId ?? ''),
|
self::LISTID => trim($listId ?? ''),
|
||||||
'tagid' => trim($tagId ?? ''),
|
self::PARAM_TAGID => trim($tagId ?? ''),
|
||||||
'fields' => array_filter(
|
self::PARAM_FIELDS => array_filter(
|
||||||
array_map('trim', $fields ?? [])
|
array_map('trim', $fields ?? [])
|
||||||
),
|
),
|
||||||
'smsnumber' => trim($smsNumber ?? ''),
|
self::PARAM_SMS_NUMBER => trim($smsNumber ?? ''),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -108,7 +160,7 @@ class Subscriber extends Model
|
|||||||
'subscriber/unsubscribe.json',
|
'subscriber/unsubscribe.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'email' => trim($mailAddress),
|
self::EMAIL => trim($mailAddress),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -128,8 +180,8 @@ class Subscriber extends Model
|
|||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => array_filter(
|
RequestOptions::FORM_PARAMS => array_filter(
|
||||||
[
|
[
|
||||||
'email' => trim($mailAddress),
|
self::EMAIL => trim($mailAddress),
|
||||||
'tagids' => array_filter(
|
self::PARAM_TAGIDS => array_filter(
|
||||||
array_map('trim', $tagIds)
|
array_map('trim', $tagIds)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -151,8 +203,8 @@ class Subscriber extends Model
|
|||||||
'subscriber/untag.json',
|
'subscriber/untag.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'email' => trim($mailAddress),
|
self::EMAIL => trim($mailAddress),
|
||||||
'tagid' => trim($tagId),
|
self::PARAM_TAGID => trim($tagId),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -169,7 +221,7 @@ class Subscriber extends Model
|
|||||||
'subscriber/tagged.json',
|
'subscriber/tagged.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'tagid' => trim($tagId),
|
self::PARAM_TAGID => trim($tagId),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
) ?? [];
|
) ?? [];
|
||||||
@ -191,9 +243,9 @@ class Subscriber extends Model
|
|||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => array_filter(
|
RequestOptions::FORM_PARAMS => array_filter(
|
||||||
[
|
[
|
||||||
'newemail' => trim($newEmail ?? ''),
|
self::PARAM_NEW_EMAIL => trim($newEmail ?? ''),
|
||||||
'newsmsnumber' => trim($newSmsNumber ?? ''),
|
self::PARAM_NEW_SMSNUMBER => trim($newSmsNumber ?? ''),
|
||||||
'fields' => array_filter(
|
self::PARAM_FIELDS => array_filter(
|
||||||
array_map('trim', $fields ?? [])
|
array_map('trim', $fields ?? [])
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -233,10 +285,10 @@ class Subscriber extends Model
|
|||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => array_filter(
|
RequestOptions::FORM_PARAMS => array_filter(
|
||||||
[
|
[
|
||||||
'apikey' => trim($apikey),
|
self::PARAM_APIKEY => trim($apikey),
|
||||||
'email' => trim($emailAddress),
|
self::EMAIL => trim($emailAddress),
|
||||||
'smsnumber' => trim($smsNumber ?? ''),
|
self::PARAM_SMS_NUMBER => trim($smsNumber ?? ''),
|
||||||
'fields' => array_filter(
|
self::PARAM_FIELDS => array_filter(
|
||||||
array_map('trim', $fields ?? [])
|
array_map('trim', $fields ?? [])
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -257,8 +309,8 @@ class Subscriber extends Model
|
|||||||
'subscriber/signout.json',
|
'subscriber/signout.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'apikey' => trim($apikey),
|
self::PARAM_APIKEY => trim($apikey),
|
||||||
'email' => trim($emailAddress),
|
self::EMAIL => trim($emailAddress),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -276,8 +328,8 @@ class Subscriber extends Model
|
|||||||
'subscriber/signoff.json',
|
'subscriber/signoff.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'apikey' => trim($apikey),
|
self::PARAM_APIKEY => trim($apikey),
|
||||||
'email' => trim($emailAddress),
|
self::EMAIL => trim($emailAddress),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -48,6 +48,24 @@ class SubscriptionProcess extends Model
|
|||||||
return new SubscriptionEntity($data);
|
return new SubscriptionEntity($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws BaseException
|
||||||
|
*/
|
||||||
|
public function update(string $listId, ?string $name): bool
|
||||||
|
{
|
||||||
|
return (bool) current(
|
||||||
|
$this->connection->requestAndParse(
|
||||||
|
'PUT',
|
||||||
|
'list/'.urlencode(trim($listId)).'.json',
|
||||||
|
[
|
||||||
|
RequestOptions::FORM_PARAMS => array_filter([
|
||||||
|
'name' => trim($name ?? ''),
|
||||||
|
]),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +22,10 @@ use GuzzleHttp\RequestOptions;
|
|||||||
|
|
||||||
class Tag extends Model
|
class Tag extends Model
|
||||||
{
|
{
|
||||||
|
public const ID = 'tagid';
|
||||||
|
public const NAME = 'name';
|
||||||
|
public const TEXT = 'text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
@ -60,7 +64,7 @@ class Tag extends Model
|
|||||||
'tag.json',
|
'tag.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'name' => trim($name),
|
self::NAME => trim($name),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -78,8 +82,8 @@ class Tag extends Model
|
|||||||
'tag/'.urlencode(trim($tagId)).'.json',
|
'tag/'.urlencode(trim($tagId)).'.json',
|
||||||
[
|
[
|
||||||
RequestOptions::FORM_PARAMS => array_filter([
|
RequestOptions::FORM_PARAMS => array_filter([
|
||||||
'name' => trim($name ?? ''),
|
self::NAME => trim($name ?? ''),
|
||||||
'text' => trim($text ?? ''),
|
self::TEXT => trim($text ?? ''),
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -18,6 +18,7 @@ namespace D3\KlicktippPhpClient\tests\integration\Resources;
|
|||||||
use D3\KlicktippPhpClient\Entities\FieldList;
|
use D3\KlicktippPhpClient\Entities\FieldList;
|
||||||
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
||||||
use D3\KlicktippPhpClient\Resources\Field;
|
use D3\KlicktippPhpClient\Resources\Field;
|
||||||
|
use D3\KlicktippPhpClient\Resources\Subscriber;
|
||||||
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
|
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
|
||||||
use Generator;
|
use Generator;
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
@ -55,39 +56,39 @@ class FieldTest extends IntegrationTestCase
|
|||||||
public static function indexDataProvider(): Generator
|
public static function indexDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield 'success' => [new Response(200, [], '{
|
yield 'success' => [new Response(200, [], '{
|
||||||
"fieldFirstName": "Vorname",
|
"'.Subscriber::FIELD_FIRSTNAME.'": "Vorname",
|
||||||
"fieldLastName": "Nachname",
|
"'.Subscriber::FIELD_LASTNAME.'": "Nachname",
|
||||||
"fieldCompanyName": "Firma",
|
"'.Subscriber::FIELD_COMPANYNAME.'": "Firma",
|
||||||
"fieldStreet1": "Straße 1",
|
"'.Subscriber::FIELD_STREET1.'": "Straße 1",
|
||||||
"fieldStreet2": "Straße 2",
|
"'.Subscriber::FIELD_STREET2.'": "Straße 2",
|
||||||
"fieldCity": "Stadt",
|
"'.Subscriber::FIELD_CITY.'": "Stadt",
|
||||||
"fieldState": "Bundesland",
|
"'.Subscriber::FIELD_STATE.'": "Bundesland",
|
||||||
"fieldZip": "Postleitzahl",
|
"'.Subscriber::FIELD_ZIP.'": "Postleitzahl",
|
||||||
"fieldCountry": "Land",
|
"'.Subscriber::FIELD_COUNTRY.'": "Land",
|
||||||
"fieldPrivatePhone": "Telefon (Privat)",
|
"'.Subscriber::FIELD_PRIVATEPHONE.'": "Telefon (Privat)",
|
||||||
"fieldMobilePhone": "Telefon (Mobil)",
|
"'.Subscriber::FIELD_MOBILEPHONE.'": "Telefon (Mobil)",
|
||||||
"fieldPhone": "Telefon",
|
"'.Subscriber::FIELD_PHONE.'": "Telefon",
|
||||||
"fieldFax": "Fax",
|
"'.Subscriber::FIELD_FAX.'": "Fax",
|
||||||
"fieldWebsite": "Website",
|
"'.Subscriber::FIELD_WEBSITE.'": "Website",
|
||||||
"fieldBirthday": "Geburtstag",
|
"'.Subscriber::FIELD_BIRTHDAY.'": "Geburtstag",
|
||||||
"fieldLeadValue": "LeadValue"
|
"'.Subscriber::FIELD_LEADVALUE.'": "LeadValue"
|
||||||
}'), new FieldList([
|
}'), new FieldList([
|
||||||
"fieldFirstName" => "Vorname",
|
Subscriber::FIELD_FIRSTNAME => "Vorname",
|
||||||
"fieldLastName" => "Nachname",
|
Subscriber::FIELD_LASTNAME => "Nachname",
|
||||||
"fieldCompanyName" => "Firma",
|
Subscriber::FIELD_COMPANYNAME => "Firma",
|
||||||
"fieldStreet1" => "Straße 1",
|
Subscriber::FIELD_STREET1 => "Straße 1",
|
||||||
"fieldStreet2" => "Straße 2",
|
Subscriber::FIELD_STREET2 => "Straße 2",
|
||||||
"fieldCity" => "Stadt",
|
Subscriber::FIELD_CITY => "Stadt",
|
||||||
"fieldState" => "Bundesland",
|
Subscriber::FIELD_STATE => "Bundesland",
|
||||||
"fieldZip" => "Postleitzahl",
|
Subscriber::FIELD_ZIP => "Postleitzahl",
|
||||||
"fieldCountry" => "Land",
|
Subscriber::FIELD_COUNTRY => "Land",
|
||||||
"fieldPrivatePhone" => "Telefon (Privat)",
|
Subscriber::FIELD_PRIVATEPHONE => "Telefon (Privat)",
|
||||||
"fieldMobilePhone" => "Telefon (Mobil)",
|
Subscriber::FIELD_MOBILEPHONE => "Telefon (Mobil)",
|
||||||
"fieldPhone" => "Telefon",
|
Subscriber::FIELD_PHONE => "Telefon",
|
||||||
"fieldFax" => "Fax",
|
Subscriber::FIELD_FAX => "Fax",
|
||||||
"fieldWebsite" => "Website",
|
Subscriber::FIELD_WEBSITE => "Website",
|
||||||
"fieldBirthday" => "Geburtstag",
|
Subscriber::FIELD_BIRTHDAY => "Geburtstag",
|
||||||
"fieldLeadValue" => "LeadValue",
|
Subscriber::FIELD_LEADVALUE => "LeadValue",
|
||||||
])];
|
])];
|
||||||
yield 'wrong request type' => [new Response(406, [], '["Bei der Erstellung des Objekt ist ein Fehler aufgetreten."]'), null, true];
|
yield 'wrong request type' => [new Response(406, [], '["Bei der Erstellung des Objekt ist ein Fehler aufgetreten."]'), null, true];
|
||||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||||
|
@ -116,75 +116,75 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
public static function getDataProvider(): Generator
|
public static function getDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield 'success' => [new Response(200, [], '{
|
yield 'success' => [new Response(200, [], '{
|
||||||
"id": "155988456",
|
"'.Subscriber::ID.'": "155988456",
|
||||||
"listid": "368370",
|
"'.Subscriber::LISTID.'": "368370",
|
||||||
"optin": "28.12.2024 22:52:09",
|
"'.Subscriber::OPTIN.'": "28.12.2024 22:52:09",
|
||||||
"optin_ip": "0.0.0.0 - By API Request",
|
"'.Subscriber::OPTIN_IP.'": "0.0.0.0 - By API Request",
|
||||||
"email": "testsubscriber@mydomain.com",
|
"'.Subscriber::EMAIL.'": "testsubscriber@mydomain.com",
|
||||||
"status": "Opt-In Pending",
|
"'.Subscriber::STATUS.'": "Opt-In Pending",
|
||||||
"bounce": "Not Bounced",
|
"'.Subscriber::BOUNCE.'": "Not Bounced",
|
||||||
"date": "",
|
"'.Subscriber::DATE.'": "",
|
||||||
"ip": "0.0.0.0 - By API Request",
|
"'.Subscriber::IP.'": "0.0.0.0 - By API Request",
|
||||||
"unsubscription": "",
|
"'.Subscriber::UNSUBSCRIPTION.'": "",
|
||||||
"unsubscription_ip": "0.0.0.0",
|
"'.Subscriber::UNSUBSCRIPTION_IP.'": "0.0.0.0",
|
||||||
"referrer": "",
|
"'.Subscriber::REFERRER.'": "",
|
||||||
"sms_phone": null,
|
"'.Subscriber::SMS_PHONE.'": null,
|
||||||
"sms_status": null,
|
"'.Subscriber::SMS_STATUS.'": null,
|
||||||
"sms_bounce": null,
|
"'.Subscriber::SMS_BOUNCE.'": null,
|
||||||
"sms_date": "",
|
"'.Subscriber::SMS_DATE.'": "",
|
||||||
"sms_unsubscription": "",
|
"'.Subscriber::SMS_UNSUBSCRIPTION.'": "",
|
||||||
"sms_referrer": null,
|
"'.Subscriber::SMS_REFERRER.'": null,
|
||||||
"fieldFirstName": "",
|
"'.Subscriber::FIELD_FIRSTNAME.'": "",
|
||||||
"fieldLastName": "",
|
"'.Subscriber::FIELD_LASTNAME.'": "",
|
||||||
"fieldCompanyName": "",
|
"'.Subscriber::FIELD_COMPANYNAME.'": "",
|
||||||
"fieldStreet1": "",
|
"'.Subscriber::FIELD_STREET1.'": "",
|
||||||
"fieldStreet2": "",
|
"'.Subscriber::FIELD_STREET2.'": "",
|
||||||
"fieldCity": "",
|
"'.Subscriber::FIELD_CITY.'": "",
|
||||||
"fieldState": "",
|
"'.Subscriber::FIELD_STATE.'": "",
|
||||||
"fieldZip": "",
|
"'.Subscriber::FIELD_ZIP.'": "",
|
||||||
"fieldCountry": "",
|
"'.Subscriber::FIELD_COUNTRY.'": "",
|
||||||
"fieldPrivatePhone": "",
|
"'.Subscriber::FIELD_PRIVATEPHONE.'": "",
|
||||||
"fieldMobilePhone": "",
|
"'.Subscriber::FIELD_MOBILEPHONE.'": "",
|
||||||
"fieldPhone": "",
|
"'.Subscriber::FIELD_PHONE.'": "",
|
||||||
"fieldFax": "",
|
"'.Subscriber::FIELD_FAX.'": "",
|
||||||
"fieldWebsite": "",
|
"'.Subscriber::FIELD_WEBSITE.'": "",
|
||||||
"fieldBirthday": "",
|
"'.Subscriber::FIELD_BIRTHDAY.'": "",
|
||||||
"fieldLeadValue": ""
|
"'.Subscriber::FIELD_LEADVALUE.'": ""
|
||||||
}'), [
|
}'), [
|
||||||
"id" => "155988456",
|
Subscriber::ID => "155988456",
|
||||||
"listid" => "368370",
|
Subscriber::LISTID => "368370",
|
||||||
"optin" => "28.12.2024 22:52:09",
|
Subscriber::OPTIN => "28.12.2024 22:52:09",
|
||||||
"optin_ip" => "0.0.0.0 - By API Request",
|
Subscriber::OPTIN_IP => "0.0.0.0 - By API Request",
|
||||||
"email" => "testsubscriber@mydomain.com",
|
Subscriber::EMAIL => "testsubscriber@mydomain.com",
|
||||||
"status" => "Opt-In Pending",
|
Subscriber::STATUS => "Opt-In Pending",
|
||||||
"bounce" => "Not Bounced",
|
Subscriber::BOUNCE => "Not Bounced",
|
||||||
"date" => "",
|
Subscriber::DATE => "",
|
||||||
"ip" => "0.0.0.0 - By API Request",
|
Subscriber::IP => "0.0.0.0 - By API Request",
|
||||||
"unsubscription" => "",
|
Subscriber::UNSUBSCRIPTION => "",
|
||||||
"unsubscription_ip" => "0.0.0.0",
|
Subscriber::UNSUBSCRIPTION_IP => "0.0.0.0",
|
||||||
"referrer" => "",
|
Subscriber::REFERRER => "",
|
||||||
"sms_phone" => null,
|
Subscriber::SMS_PHONE => null,
|
||||||
"sms_status" => null,
|
Subscriber::SMS_STATUS => null,
|
||||||
"sms_bounce" => null,
|
Subscriber::SMS_BOUNCE => null,
|
||||||
"sms_date" => "",
|
Subscriber::SMS_DATE => "",
|
||||||
"sms_unsubscription" => "",
|
Subscriber::SMS_UNSUBSCRIPTION => "",
|
||||||
"sms_referrer" => null,
|
Subscriber::SMS_REFERRER => null,
|
||||||
"fieldFirstName" => "",
|
Subscriber::FIELD_FIRSTNAME => "",
|
||||||
"fieldLastName" => "",
|
Subscriber::FIELD_LASTNAME => "",
|
||||||
"fieldCompanyName" => "",
|
Subscriber::FIELD_COMPANYNAME => "",
|
||||||
"fieldStreet1" => "",
|
Subscriber::FIELD_STREET1 => "",
|
||||||
"fieldStreet2" => "",
|
Subscriber::FIELD_STREET2 => "",
|
||||||
"fieldCity" => "",
|
Subscriber::FIELD_CITY => "",
|
||||||
"fieldState" => "",
|
Subscriber::FIELD_STATE => "",
|
||||||
"fieldZip" => "",
|
Subscriber::FIELD_ZIP => "",
|
||||||
"fieldCountry" => "",
|
Subscriber::FIELD_COUNTRY => "",
|
||||||
"fieldPrivatePhone" => "",
|
Subscriber::FIELD_PRIVATEPHONE => "",
|
||||||
"fieldMobilePhone" => "",
|
Subscriber::FIELD_MOBILEPHONE => "",
|
||||||
"fieldPhone" => "",
|
Subscriber::FIELD_PHONE => "",
|
||||||
"fieldFax" => "",
|
Subscriber::FIELD_FAX => "",
|
||||||
"fieldWebsite" => "",
|
Subscriber::FIELD_WEBSITE => "",
|
||||||
"fieldBirthday" => "",
|
Subscriber::FIELD_BIRTHDAY => "",
|
||||||
"fieldLeadValue" => "",
|
Subscriber::FIELD_LEADVALUE => "",
|
||||||
]];
|
]];
|
||||||
yield 'unknown id' => [new Response(404, [], ''), null, true];
|
yield 'unknown id' => [new Response(404, [], ''), null, true];
|
||||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||||
@ -255,40 +255,40 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
public static function subscribeDataProvider(): Generator
|
public static function subscribeDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield 'success' => [new Response(200, [], '{
|
yield 'success' => [new Response(200, [], '{
|
||||||
"id": "155988456",
|
"'.Subscriber::ID.'": "155988456",
|
||||||
"listid": "368370",
|
"'.Subscriber::LISTID.'": "368370",
|
||||||
"optin": "28.12.2024 22:52:09",
|
"'.Subscriber::OPTIN.'": "28.12.2024 22:52:09",
|
||||||
"optin_ip": "0.0.0.0 - By API Request",
|
"'.Subscriber::OPTIN_IP.'": "0.0.0.0 - By API Request",
|
||||||
"email": "testsubscriber@mydomain.com",
|
"'.Subscriber::EMAIL.'": "testsubscriber@mydomain.com",
|
||||||
"status": "Opt-In Pending",
|
"'.Subscriber::STATUS.'": "Opt-In Pending",
|
||||||
"bounce": "Not Bounced",
|
"'.Subscriber::BOUNCE.'": "Not Bounced",
|
||||||
"date": "",
|
"'.Subscriber::DATE.'": "",
|
||||||
"ip": "0.0.0.0 - By API Request",
|
"'.Subscriber::IP.'": "0.0.0.0 - By API Request",
|
||||||
"unsubscription": "",
|
"'.Subscriber::UNSUBSCRIPTION.'": "",
|
||||||
"unsubscription_ip": "0.0.0.0",
|
"'.Subscriber::UNSUBSCRIPTION_IP.'": "0.0.0.0",
|
||||||
"referrer": "",
|
"'.Subscriber::REFERRER.'": "",
|
||||||
"sms_phone": null,
|
"'.Subscriber::SMS_PHONE.'": null,
|
||||||
"sms_status": null,
|
"'.Subscriber::SMS_STATUS.'": null,
|
||||||
"sms_bounce": null,
|
"'.Subscriber::SMS_BOUNCE.'": null,
|
||||||
"sms_date": "",
|
"'.Subscriber::SMS_DATE.'": "",
|
||||||
"sms_unsubscription": "",
|
"'.Subscriber::SMS_UNSUBSCRIPTION.'": "",
|
||||||
"sms_referrer": null,
|
"'.Subscriber::SMS_REFERRER.'": null,
|
||||||
"fieldFirstName": "",
|
"'.Subscriber::FIELD_FIRSTNAME.'": "",
|
||||||
"fieldLastName": "",
|
"'.Subscriber::FIELD_LASTNAME.'": "",
|
||||||
"fieldCompanyName": "",
|
"'.Subscriber::FIELD_COMPANYNAME.'": "",
|
||||||
"fieldStreet1": "",
|
"'.Subscriber::FIELD_STREET1.'": "",
|
||||||
"fieldStreet2": "",
|
"'.Subscriber::FIELD_STREET2.'": "",
|
||||||
"fieldCity": "",
|
"'.Subscriber::FIELD_CITY.'": "",
|
||||||
"fieldState": "",
|
"'.Subscriber::FIELD_STATE.'": "",
|
||||||
"fieldZip": "",
|
"'.Subscriber::FIELD_ZIP.'": "",
|
||||||
"fieldCountry": "",
|
"'.Subscriber::FIELD_COUNTRY.'": "",
|
||||||
"fieldPrivatePhone": "",
|
"'.Subscriber::FIELD_PRIVATEPHONE.'": "",
|
||||||
"fieldMobilePhone": "",
|
"'.Subscriber::FIELD_MOBILEPHONE.'": "",
|
||||||
"fieldPhone": "",
|
"'.Subscriber::FIELD_PHONE.'": "",
|
||||||
"fieldFax": "",
|
"'.Subscriber::FIELD_FAX.'": "",
|
||||||
"fieldWebsite": "",
|
"'.Subscriber::FIELD_WEBSITE.'": "",
|
||||||
"fieldBirthday": "",
|
"'.Subscriber::FIELD_BIRTHDAY.'": "",
|
||||||
"fieldLeadValue": ""
|
"'.Subscriber::FIELD_LEADVALUE.'": ""
|
||||||
}'), '155988456'];
|
}'), '155988456'];
|
||||||
yield 'missing mail' => [new Response(401, [], '{"error": 32}'), null, true];
|
yield 'missing mail' => [new Response(401, [], '{"error": 32}'), null, true];
|
||||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||||
@ -454,7 +454,7 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
$this->callMethod(
|
$this->callMethod(
|
||||||
$sut,
|
$sut,
|
||||||
'update',
|
'update',
|
||||||
['2354758', ['fieldCity' => 'Berlin', 'fieldStreet2' => 'Straße unter den Linden 25'], 'mymail@mydomain.com']
|
['2354758', [Subscriber::FIELD_CITY => 'Berlin', Subscriber::FIELD_STREET2 => 'Straße unter den Linden 25'], 'mymail@mydomain.com']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ use D3\KlicktippPhpClient\Entities\Subscription;
|
|||||||
use D3\KlicktippPhpClient\Entities\SubscriptionList;
|
use D3\KlicktippPhpClient\Entities\SubscriptionList;
|
||||||
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
use D3\KlicktippPhpClient\Exceptions\BaseException;
|
||||||
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
|
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
|
||||||
use D3\KlicktippPhpClient\Resources\Tag;
|
|
||||||
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
|
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
|
||||||
use Generator;
|
use Generator;
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
@ -114,6 +113,37 @@ class SubscriptionProcessTest extends IntegrationTestCase
|
|||||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @throws ReflectionException
|
||||||
|
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::update
|
||||||
|
* @dataProvider updateDataProvider
|
||||||
|
*/
|
||||||
|
public function testUpdate(ResponseInterface $response, ?bool $expected, bool $expectException = false)
|
||||||
|
{
|
||||||
|
$sut = new SubscriptionProcess($this->getConnectionMock($response));
|
||||||
|
|
||||||
|
if ($expectException) {
|
||||||
|
$this->expectException(BaseException::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$this->callMethod(
|
||||||
|
$sut,
|
||||||
|
'update',
|
||||||
|
['470370', 'newName']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function updateDataProvider(): Generator
|
||||||
|
{
|
||||||
|
yield 'success' => [new Response(200, [], '[true]'), true];
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
@ -93,13 +93,13 @@ class TagTest extends IntegrationTestCase
|
|||||||
public static function getDataProvider(): Generator
|
public static function getDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield 'success' => [new Response(200, [], '{
|
yield 'success' => [new Response(200, [], '{
|
||||||
"tagid": "12514414",
|
"'.Tag::ID.'": "12514414",
|
||||||
"name": "tagName2",
|
"'.Tag::NAME.'": "tagName2",
|
||||||
"text": ""
|
"'.Tag::TEXT.'": ""
|
||||||
}'), [
|
}'), [
|
||||||
"tagid" => "12514414",
|
Tag::ID => "12514414",
|
||||||
"name" => "tagName2",
|
Tag::NAME => "tagName2",
|
||||||
"text" => "",
|
Tag::TEXT => "",
|
||||||
]];
|
]];
|
||||||
yield 'unknown id' => [new Response(404, [], '["Kein Tag mit dieser ID."]'), null, true];
|
yield 'unknown id' => [new Response(404, [], '["Kein Tag mit dieser ID."]'), null, true];
|
||||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
namespace D3\KlicktippPhpClient\tests\unit\Entities;
|
namespace D3\KlicktippPhpClient\tests\unit\Entities;
|
||||||
|
|
||||||
use D3\KlicktippPhpClient\Entities\Subscriber;
|
use D3\KlicktippPhpClient\Entities\Subscriber;
|
||||||
|
use D3\KlicktippPhpClient\Resources\Subscriber as SubscriberEndpoint;
|
||||||
use D3\KlicktippPhpClient\tests\TestCase;
|
use D3\KlicktippPhpClient\tests\TestCase;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
@ -33,81 +34,81 @@ class SubscriberTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->entity = new Subscriber(
|
$this->entity = new Subscriber(
|
||||||
[
|
[
|
||||||
"id" => "155988456",
|
SubscriberEndpoint::ID => "155988456",
|
||||||
"listid" => "368370",
|
SubscriberEndpoint::LISTID => "368370",
|
||||||
"optin" => "28.12.2024 22:52:09",
|
SubscriberEndpoint::OPTIN => "28.12.2024 22:52:09",
|
||||||
"optin_ip" => "0.0.0.0 - By API Request",
|
SubscriberEndpoint::OPTIN_IP => "0.0.0.0 - By API Request",
|
||||||
"email" => "testsubscriber@mydomain.com",
|
SubscriberEndpoint::EMAIL => "testsubscriber@mydomain.com",
|
||||||
"status" => "Opt-In Pending",
|
SubscriberEndpoint::STATUS => "Opt-In Pending",
|
||||||
"bounce" => "Not Bounced",
|
SubscriberEndpoint::BOUNCE => "Not Bounced",
|
||||||
"date" => "2024-12-24",
|
SubscriberEndpoint::DATE => "2024-12-24",
|
||||||
"ip" => "0.0.0.0 - By API Request",
|
SubscriberEndpoint::IP => "0.0.0.0 - By API Request",
|
||||||
"unsubscription" => "unsubscription fixture",
|
SubscriberEndpoint::UNSUBSCRIPTION => "unsubscription fixture",
|
||||||
"unsubscription_ip" => "0.0.0.0",
|
SubscriberEndpoint::UNSUBSCRIPTION_IP => "0.0.0.0",
|
||||||
"referrer" => "referrer fixture",
|
SubscriberEndpoint::REFERRER => "referrer fixture",
|
||||||
"sms_phone" => "1234567890",
|
SubscriberEndpoint::SMS_PHONE => "1234567890",
|
||||||
"sms_status" => "sms status fixture",
|
SubscriberEndpoint::SMS_STATUS => "sms status fixture",
|
||||||
"sms_bounce" => "sms bounce fixture",
|
SubscriberEndpoint::SMS_BOUNCE => "sms bounce fixture",
|
||||||
"sms_date" => "2024-12-23",
|
SubscriberEndpoint::SMS_DATE => "2024-12-23",
|
||||||
"sms_unsubscription" => "sms unsubscription fixture",
|
SubscriberEndpoint::SMS_UNSUBSCRIPTION => "sms unsubscription fixture",
|
||||||
"sms_referrer" => "sms referrer fixture",
|
SubscriberEndpoint::SMS_REFERRER => "sms referrer fixture",
|
||||||
"fieldFirstName" => "",
|
SubscriberEndpoint::FIELD_FIRSTNAME => "",
|
||||||
"fieldLastName" => "",
|
SubscriberEndpoint::FIELD_LASTNAME => "",
|
||||||
"fieldCompanyName" => "",
|
SubscriberEndpoint::FIELD_COMPANYNAME => "",
|
||||||
"fieldStreet1" => "",
|
SubscriberEndpoint::FIELD_STREET1 => "",
|
||||||
"fieldStreet2" => "",
|
SubscriberEndpoint::FIELD_STREET2 => "",
|
||||||
"fieldCity" => "",
|
SubscriberEndpoint::FIELD_CITY => "",
|
||||||
"fieldState" => "",
|
SubscriberEndpoint::FIELD_STATE => "",
|
||||||
"fieldZip" => "",
|
SubscriberEndpoint::FIELD_ZIP => "",
|
||||||
"fieldCountry" => "",
|
SubscriberEndpoint::FIELD_COUNTRY => "",
|
||||||
"fieldPrivatePhone" => "",
|
SubscriberEndpoint::FIELD_PRIVATEPHONE => "",
|
||||||
"fieldMobilePhone" => "",
|
SubscriberEndpoint::FIELD_MOBILEPHONE => "",
|
||||||
"fieldPhone" => "",
|
SubscriberEndpoint::FIELD_PHONE => "",
|
||||||
"fieldFax" => "",
|
SubscriberEndpoint::FIELD_FAX => "",
|
||||||
"fieldWebsite" => "",
|
SubscriberEndpoint::FIELD_WEBSITE => "",
|
||||||
"fieldBirthday" => "",
|
SubscriberEndpoint::FIELD_BIRTHDAY => "",
|
||||||
"fieldLeadValue" => "",
|
SubscriberEndpoint::FIELD_LEADVALUE => "",
|
||||||
"tags" => [
|
SubscriberEndpoint::TAGS => [
|
||||||
"12494453",
|
"12494453",
|
||||||
"12494463",
|
"12494463",
|
||||||
],
|
],
|
||||||
"manual_tags" => [
|
SubscriberEndpoint::MANUALTAGS => [
|
||||||
"12594453" => "125959453",
|
"12594453" => "125959453",
|
||||||
"12594454" => "125960453",
|
"12594454" => "125960453",
|
||||||
"12594455" => "125961453",
|
"12594455" => "125961453",
|
||||||
],
|
],
|
||||||
"smart_tags" => [
|
SubscriberEndpoint::SMARTTAGS => [
|
||||||
"12594456" => "125959453",
|
"12594456" => "125959453",
|
||||||
"12594457" => "125960453",
|
"12594457" => "125960453",
|
||||||
"12594458" => "125961453",
|
"12594458" => "125961453",
|
||||||
"12594459" => "125961453",
|
"12594459" => "125961453",
|
||||||
],
|
],
|
||||||
"campaigns_started" => [
|
SubscriberEndpoint::CAMPAIGNSSTARTED => [
|
||||||
"12594456" => "125959453",
|
"12594456" => "125959453",
|
||||||
],
|
],
|
||||||
"campaigns_finished" => [
|
SubscriberEndpoint::CAMPAIGNSFINISHED => [
|
||||||
"12594456" => "125959453",
|
"12594456" => "125959453",
|
||||||
"12594457" => "125959453",
|
"12594457" => "125959453",
|
||||||
],
|
],
|
||||||
"notification_emails_sent" => [
|
SubscriberEndpoint::NOTIFICATIONEMAILSSENT => [
|
||||||
"1570256" => "1730508478",
|
"1570256" => "1730508478",
|
||||||
"1570257" => "1730508479",
|
"1570257" => "1730508479",
|
||||||
"1570258" => "1730508480",
|
"1570258" => "1730508480",
|
||||||
],
|
],
|
||||||
"notification_emails_opened" => [
|
SubscriberEndpoint::NOTIFICATIONEMAILSOPENED => [
|
||||||
"1570256" => "1730508478",
|
"1570256" => "1730508478",
|
||||||
"1570257" => "1730508479",
|
"1570257" => "1730508479",
|
||||||
"1570258" => "1730508480",
|
"1570258" => "1730508480",
|
||||||
"1570259" => "1730508481",
|
"1570259" => "1730508481",
|
||||||
],
|
],
|
||||||
"notification_emails_clicked" => [
|
SubscriberEndpoint::NOTIFICATIONEMAILSCLICKED => [
|
||||||
"1570256" => "1730508478",
|
"1570256" => "1730508478",
|
||||||
"1570257" => "1730508479",
|
"1570257" => "1730508479",
|
||||||
"1570258" => "1730508480",
|
"1570258" => "1730508480",
|
||||||
"1570259" => "1730508481",
|
"1570259" => "1730508481",
|
||||||
"1570260" => "1730508482",
|
"1570260" => "1730508482",
|
||||||
],
|
],
|
||||||
"notification_emails_viewed" => [
|
SubscriberEndpoint::NOTIFICATIONEMAILSVIEWED => [
|
||||||
"1570256" => "1730508478",
|
"1570256" => "1730508478",
|
||||||
"1570257" => "1730508479",
|
"1570257" => "1730508479",
|
||||||
"1570258" => "1730508480",
|
"1570258" => "1730508480",
|
||||||
@ -115,7 +116,7 @@ class SubscriberTest extends TestCase
|
|||||||
"1570260" => "1730508482",
|
"1570260" => "1730508482",
|
||||||
"1570261" => "1730508483",
|
"1570261" => "1730508483",
|
||||||
],
|
],
|
||||||
"outbound" => [
|
SubscriberEndpoint::OUTBOUND => [
|
||||||
"1570256" => "1730508478",
|
"1570256" => "1730508478",
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@ -134,7 +135,7 @@ class SubscriberTest extends TestCase
|
|||||||
'key2' => 'value2',
|
'key2' => 'value2',
|
||||||
];
|
];
|
||||||
|
|
||||||
$endpoint = $this->getMockBuilder(\D3\KlicktippPhpClient\Resources\Subscriber::class)
|
$endpoint = $this->getMockBuilder(SubscriberEndpoint::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
@ -342,7 +343,7 @@ class SubscriberTest extends TestCase
|
|||||||
): void {
|
): void {
|
||||||
$sut = $this->getMockBuilder(Subscriber::class)
|
$sut = $this->getMockBuilder(Subscriber::class)
|
||||||
->onlyMethods(['set'])
|
->onlyMethods(['set'])
|
||||||
->setConstructorArgs([['id' => 'foo']])
|
->setConstructorArgs([[SubscriberEndpoint::ID => 'foo']])
|
||||||
->getMock();
|
->getMock();
|
||||||
$sut->expects($this->once())->method('set')->with(
|
$sut->expects($this->once())->method('set')->with(
|
||||||
$this->identicalTo($fieldName)
|
$this->identicalTo($fieldName)
|
||||||
@ -413,8 +414,8 @@ class SubscriberTest extends TestCase
|
|||||||
|
|
||||||
public static function getFieldDataProvider(): Generator
|
public static function getFieldDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield 'short field name' => ['FirstName', 'fieldFirstName'];
|
yield 'short field name' => ['FirstName', SubscriberEndpoint::FIELD_FIRSTNAME];
|
||||||
yield 'long field name' => ['fieldLastName', 'fieldLastName'];
|
yield 'long field name' => ['fieldLastName', SubscriberEndpoint::FIELD_LASTNAME];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,7 +430,7 @@ class SubscriberTest extends TestCase
|
|||||||
): void {
|
): void {
|
||||||
$sut = $this->getMockBuilder(Subscriber::class)
|
$sut = $this->getMockBuilder(Subscriber::class)
|
||||||
->onlyMethods(['set'])
|
->onlyMethods(['set'])
|
||||||
->setConstructorArgs([['id' => 'foo']])
|
->setConstructorArgs([[SubscriberEndpoint::ID => 'foo']])
|
||||||
->getMock();
|
->getMock();
|
||||||
$sut->expects($this->once())->method('set')->with(
|
$sut->expects($this->once())->method('set')->with(
|
||||||
$this->identicalTo($longFieldName)
|
$this->identicalTo($longFieldName)
|
||||||
@ -444,8 +445,8 @@ class SubscriberTest extends TestCase
|
|||||||
|
|
||||||
public static function setFieldDataProvider(): Generator
|
public static function setFieldDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield 'short field name' => ['FirstName', 'fieldFirstName'];
|
yield 'short field name' => ['FirstName', SubscriberEndpoint::FIELD_FIRSTNAME];
|
||||||
yield 'long field name' => ['fieldLastName', 'fieldLastName'];
|
yield 'long field name' => ['fieldLastName', SubscriberEndpoint::FIELD_LASTNAME];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -587,14 +588,14 @@ class SubscriberTest extends TestCase
|
|||||||
InvokedCount $endpointInvocation,
|
InvokedCount $endpointInvocation,
|
||||||
?bool $expectedReturn
|
?bool $expectedReturn
|
||||||
): void {
|
): void {
|
||||||
$endpointMock = $this->getMockBuilder(\D3\KlicktippPhpClient\Resources\Subscriber::class)
|
$endpointMock = $this->getMockBuilder(SubscriberEndpoint::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->onlyMethods(['update'])
|
->onlyMethods(['update'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$endpointMock->expects($endpointInvocation)->method('update')->willReturn(true);
|
$endpointMock->expects($endpointInvocation)->method('update')->willReturn(true);
|
||||||
|
|
||||||
$sut = $this->getMockBuilder(Subscriber::class)
|
$sut = $this->getMockBuilder(Subscriber::class)
|
||||||
->setConstructorArgs([['id' => 'foo'], $endpointSet ? $endpointMock : null])
|
->setConstructorArgs([[SubscriberEndpoint::ID => 'foo'], $endpointSet ? $endpointMock : null])
|
||||||
->onlyMethods(['persistTags'])
|
->onlyMethods(['persistTags'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$sut->expects($this->once())->method('persistTags');
|
$sut->expects($this->once())->method('persistTags');
|
||||||
@ -636,7 +637,7 @@ class SubscriberTest extends TestCase
|
|||||||
"12494463",
|
"12494463",
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$endpointMock = $this->getMockBuilder(\D3\KlicktippPhpClient\Resources\Subscriber::class)
|
$endpointMock = $this->getMockBuilder(SubscriberEndpoint::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->onlyMethods(['get', 'tag', 'untag'])
|
->onlyMethods(['get', 'tag', 'untag'])
|
||||||
->getMock();
|
->getMock();
|
||||||
@ -644,7 +645,7 @@ class SubscriberTest extends TestCase
|
|||||||
$endpointMock->expects($setTagInvocation)->method('tag')->willReturn(true);
|
$endpointMock->expects($setTagInvocation)->method('tag')->willReturn(true);
|
||||||
$endpointMock->expects($removeTagInvocation)->method('untag')->willReturn(true);
|
$endpointMock->expects($removeTagInvocation)->method('untag')->willReturn(true);
|
||||||
|
|
||||||
$sut = new Subscriber(['id' => 'foo', 'email' => 'mymail@mydomain.tld'], $endpointSet ? $endpointMock : null);
|
$sut = new Subscriber([SubscriberEndpoint::ID => 'foo', SubscriberEndpoint::EMAIL => 'mymail@mydomain.tld'], $endpointSet ? $endpointMock : null);
|
||||||
if ($newTagList) {
|
if ($newTagList) {
|
||||||
$sut->set('tags', $newTagList);
|
$sut->set('tags', $newTagList);
|
||||||
}
|
}
|
||||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren