DiscountCode

Extends \NextEvent\PHPSDK\Model\MutableModel Implements \NextEvent\PHPSDK\Model\Spawnable

Discount code model

Struct for a discount code record assigned to an order/basket item or a DiscountGroup relation.

package

NextEvent\PHPSDK\Model

Methods

Supports getX or hasX Methods for properties which are yet unknown.

__call(string $name, array $args) : mixed
inherited

If the source of your model contains, e.g. a property named 'my_property', you can call getMyProperty() to retrieve it's value.

Arguments

$name

string

$args

array

Response

mixed

Model constructor

__construct(array $source) 
inherited

Parse source data.

Throws
\NextEvent\PHPSDK\Exception\InvalidModelDataException

Arguments

$source

array

The source data as received from the API

Get the value for the given variable.

get(string $var) : mixed
inherited

Should be used, if you expect the model to have custom properties which are not known/covered by the known getters

Arguments

$var

string

Response

mixed

Get the code entered for this discount

getCode() : string

Response

string

Get the display name of this discount code

getDisplayname() : string

This is basically an alias for self::getTitle()

Response

string

Get the unique identifier for this discount code

getId() : integer

Response

integer

Get the title/name of this category

getTitle() : string

Response

string

Get the valid from date

getValidFrom() : \NextEvent\PHPSDK\Model\DateTime|null

Get the valid until date

getValidTo() : \NextEvent\PHPSDK\Model\DateTime|null

Determines whether this spawnable is new or not.

isNew() : boolean
inheritdoc

Response

boolean

Check model state if it is valid

isValid() : boolean
inherited abstract

Response

boolean

String representation of object

serialize() : string
inherited

Implements Serializable interface

Response

string

Sets the DiscountGroup relation

setDiscountGroup(\NextEvent\PHPSDK\Model\DiscountGroup $group) : \NextEvent\PHPSDK\Model\DiscountCode

This operation is only permitted on new discount code models

Throws
\NextEvent\PHPSDK\Model\InvalidModelDataException

Arguments

Response

\NextEvent\PHPSDK\Model\DiscountCode

Sets the source of this model instance.

setSource(array $source) : \NextEvent\PHPSDK\Model\MutableModel
inherited
access

private

Arguments

$source

array

The source data as received from the API.

Response

\NextEvent\PHPSDK\Model\MutableModel

Creates a new discount code instance with the given data

spawn(array $data, \NextEvent\PHPSDK\Model\DiscountGroup $discountGroup) : \NextEvent\PHPSDK\Model\DiscountCode
static

The resulting instance will be marked as a new model which has not been persisted via API.

Throws
\NextEvent\PHPSDK\Model\InvalidModelDataException

Arguments

$data

array

Model data as hash array with the following fields

  • code (string) The unique discount code
  • title (string) Optional title to be displayed (will be inherited from the discount group if omitted)
  • valid_from (DateTime) Begin of the validity period
  • valid_to (DateTime) End of the validity period
  • formdata (array) Hash array (key => value pairs) with form data to be pre-filled into a personalization form when booking.

$discountGroup

\NextEvent\PHPSDK\Model\DiscountGroup

Discount group to assign this code to

Response

\NextEvent\PHPSDK\Model\DiscountCode

Convert model to an Array

toArray() : array
inherited

Response

array

Convert the model for logging

toLogContext() : array
inherited

Implements the LogContextInterface interface

Response

array

Represent the model as string

toString() : string
inherited

Response

string

Constructs the object from a string

unserialize( $serialized) 
inherited

Implements Serializable interface

Arguments

$serialized