/**
* @class PromoCodeContent
* @hideconstructor
*/
export default class PromoCodeContent {
constructor () {
this.code = null;
this.startDate = null;
this.endDate = null;
this.properties = {}
this.maxClaims = 0;
}
/**
* Create a Promo Code with a random code.
*
* @memberof PromoCodeContent
* @return {PromoCodeContent} New promo code content instance.
*/
static withRandomCode() {
return new PromoCodeContent();
}
/**
* Create a Promo Code with defined code.
*
* @memberof PromoCodeContent
* @param {string} code - Code to be used as promo code.
* @return {PromoCodeContent} - New promo code content instance.
*/
static withCode(code) {
let obj = new PromoCodeContent();
obj.code = code;
return obj;
}
/**
* Set the time range when this Promo Code is available.
* If not set - will be available from the creation moment and until manually disabled on the Dashboard.
*
* @memberof PromoCodeContent
* @instance
* @param {number} startDate - Date when the Promo Code should become available.
* @param {number} endDate - Date when the Promo Code should not be available anymore.
* @return {PromoCodeContent} Same instance.
*/
setTimeLimit(startDate, endDate) {
this.startDate = startDate;
this.endDate = endDate;
return this;
}
}