Skip to content

Commit

Permalink
Allow to set custom attributes for recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhj committed May 28, 2018
1 parent 3aedcbe commit 6335d34
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Model/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function setApiCredentials(ApiCredentials $credentials = null)
*/
public function __set($key, $value)
{
if (!$value) {
if ($value) {
$this->data[$key] = $value;
}

Expand Down Expand Up @@ -191,7 +191,7 @@ abstract public function save();
*
* @return array
*/
public static function getConfigurableFields()
public function getConfigurableFields()
{
return static::$configurableFields;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Model/NewsletterAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
* @method NewsletterAttribute setId($id)
* @method NewsletterAttribute setName($name)
* @method NewsletterAttribute setType($type) One of ['number', 'date', 'boolean', 'text']
* @method NewsletterAttribute setSubType($subType)
* @method NewsletterAttribute setSubType($subType) One of the ['text', 'email', 'color', 'url', 'tel', 'date',
* 'datetime', 'time', 'integer', 'float']
* @method string getId()
* @method string getCompanyId()
* @method string getName()
Expand Down
22 changes: 22 additions & 0 deletions src/Model/NewsletterRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ class NewsletterRecipient extends AbstractModel implements ModelDeletableInterfa
'is_blacklisted',
];

/**
* Get all configurable fields
*
* @return array
*/
public function getConfigurableFields()
{
return array_keys($this->getData());
}

/** @noinspection MoreThanThreeArgumentsInspection
*
* Find recipients by a selected list and group
Expand All @@ -77,6 +87,7 @@ class NewsletterRecipient extends AbstractModel implements ModelDeletableInterfa
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
public static function findByListAndGroup(
$lid,
Expand Down Expand Up @@ -109,6 +120,7 @@ public static function findByListAndGroup(
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
public static function findByList($lid, GetParameters $getParams = null, ApiCredentials $credentials = null)
{
Expand All @@ -132,8 +144,10 @@ public static function findByList($lid, GetParameters $getParams = null, ApiCred
*
* @return void
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
public function addToGroup($gid)
{
Expand All @@ -158,8 +172,10 @@ public function addToGroup($gid)
*
* @return void
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
public function removeFromGroup($gid)
{
Expand All @@ -182,8 +198,10 @@ public function removeFromGroup($gid)
*
* @return self
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
public function save()
{
Expand All @@ -210,8 +228,10 @@ public function save()
*
* @return void
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
public function delete()
{
Expand Down Expand Up @@ -249,8 +269,10 @@ public function delete()
*
* @return self
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
private function update()
{
Expand Down

0 comments on commit 6335d34

Please sign in to comment.