Skip to content

Commit

Permalink
Merge pull request #19 from sendinblue/feature_fix-enum-for-type-array
Browse files Browse the repository at this point in the history
Fix enum for array type in create/update webhook models
  • Loading branch information
ekta-slit authored Oct 12, 2017
2 parents 8bfb4ba + 1633c57 commit 2e5f526
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/Model/CreateWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,47 @@ public static function getters()
return self::$getters;
}

const EVENTS_HARD_BOUNCE = 'hardBounce';
const EVENTS_SOFT_BOUNCE = 'softBounce';
const EVENTS_BLOCKED = 'blocked';
const EVENTS_SPAM = 'spam';
const EVENTS_DELIVERED = 'delivered';
const EVENTS_REQUEST = 'request';
const EVENTS_CLICK = 'click';
const EVENTS_INVALID = 'invalid';
const EVENTS_DEFERRED = 'deferred';
const EVENTS_OPENED = 'opened';
const EVENTS_UNIQUE_OPENED = 'uniqueOpened';
const EVENTS_UNSUBSCRIBED = 'unsubscribed';
const EVENTS_LIST_ADDITION = 'listAddition';
const TYPE_TRANSACTIONAL = 'transactional';
const TYPE_MARKETING = 'marketing';



/**
* Gets allowable values of the enum
* @return string[]
*/
public function getEventsAllowableValues()
{
return [
self::EVENTS_HARD_BOUNCE,
self::EVENTS_SOFT_BOUNCE,
self::EVENTS_BLOCKED,
self::EVENTS_SPAM,
self::EVENTS_DELIVERED,
self::EVENTS_REQUEST,
self::EVENTS_CLICK,
self::EVENTS_INVALID,
self::EVENTS_DEFERRED,
self::EVENTS_OPENED,
self::EVENTS_UNIQUE_OPENED,
self::EVENTS_UNSUBSCRIBED,
self::EVENTS_LIST_ADDITION,
];
}

/**
* Gets allowable values of the enum
* @return string[]
Expand Down Expand Up @@ -268,6 +304,15 @@ public function getEvents()
*/
public function setEvents($events)
{
$allowed_values = $this->getEventsAllowableValues();
if (!is_null($events) && array_diff($events, $allowed_values)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value for 'events', must be one of '%s'",
implode("', '", $allowed_values)
)
);
}
$this->container['events'] = $events;

return $this;
Expand Down
45 changes: 45 additions & 0 deletions lib/Model/UpdateWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,45 @@ public static function getters()
return self::$getters;
}

const EVENTS_HARD_BOUNCE = 'hardBounce';
const EVENTS_SOFT_BOUNCE = 'softBounce';
const EVENTS_BLOCKED = 'blocked';
const EVENTS_SPAM = 'spam';
const EVENTS_DELIVERED = 'delivered';
const EVENTS_REQUEST = 'request';
const EVENTS_CLICK = 'click';
const EVENTS_INVALID = 'invalid';
const EVENTS_DEFERRED = 'deferred';
const EVENTS_OPENED = 'opened';
const EVENTS_UNIQUE_OPENED = 'uniqueOpened';
const EVENTS_UNSUBSCRIBED = 'unsubscribed';
const EVENTS_LIST_ADDITION = 'listAddition';



/**
* Gets allowable values of the enum
* @return string[]
*/
public function getEventsAllowableValues()
{
return [
self::EVENTS_HARD_BOUNCE,
self::EVENTS_SOFT_BOUNCE,
self::EVENTS_BLOCKED,
self::EVENTS_SPAM,
self::EVENTS_DELIVERED,
self::EVENTS_REQUEST,
self::EVENTS_CLICK,
self::EVENTS_INVALID,
self::EVENTS_DEFERRED,
self::EVENTS_OPENED,
self::EVENTS_UNIQUE_OPENED,
self::EVENTS_UNSUBSCRIBED,
self::EVENTS_LIST_ADDITION,
];
}


/**
* Associative array for storing property values
Expand Down Expand Up @@ -230,6 +266,15 @@ public function getEvents()
*/
public function setEvents($events)
{
$allowed_values = $this->getEventsAllowableValues();
if (!is_null($events) && array_diff($events, $allowed_values)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value for 'events', must be one of '%s'",
implode("', '", $allowed_values)
)
);
}
$this->container['events'] = $events;

return $this;
Expand Down

0 comments on commit 2e5f526

Please sign in to comment.