1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\DiscountCode; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\CartDiscount\CartDiscountReferenceCollection; |
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
11
|
|
|
use Commercetools\Core\Model\Common\LocalizedString; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @package Commercetools\Core\Model\DiscountCode |
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-discountCodes.html#create-discount-code |
16
|
|
|
* @method LocalizedString getName() |
17
|
|
|
* @method DiscountCodeDraft setName(LocalizedString $name = null) |
18
|
|
|
* @method LocalizedString getDescription() |
19
|
|
|
* @method DiscountCodeDraft setDescription(LocalizedString $description = null) |
20
|
|
|
* @method string getCode() |
21
|
|
|
* @method DiscountCodeDraft setCode(string $code = null) |
22
|
|
|
* @method CartDiscountReferenceCollection getCartDiscounts() |
23
|
|
|
* @method DiscountCodeDraft setCartDiscounts(CartDiscountReferenceCollection $cartDiscounts = null) |
24
|
|
|
* @method string getCartPredicate() |
25
|
|
|
* @method DiscountCodeDraft setCartPredicate(string $cartPredicate = null) |
26
|
|
|
* @method bool getIsActive() |
27
|
|
|
* @method DiscountCodeDraft setIsActive(bool $isActive = null) |
28
|
|
|
* @method int getMaxApplications() |
29
|
|
|
* @method DiscountCodeDraft setMaxApplications(int $maxApplications = null) |
30
|
|
|
* @method int getMaxApplicationsPerCustomer() |
31
|
|
|
* @method DiscountCodeDraft setMaxApplicationsPerCustomer(int $maxApplicationsPerCustomer = null) |
32
|
|
|
*/ |
33
|
|
|
class DiscountCodeDraft extends JsonObject |
34
|
|
|
{ |
35
|
2 |
|
public function fieldDefinitions() |
36
|
|
|
{ |
37
|
|
|
return [ |
38
|
2 |
|
'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], |
39
|
2 |
|
'description' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], |
40
|
2 |
|
'code' => [static::TYPE => 'string'], |
41
|
|
|
'cartDiscounts' => [ |
42
|
2 |
|
static::TYPE => '\Commercetools\Core\Model\CartDiscount\CartDiscountReferenceCollection' |
43
|
2 |
|
], |
44
|
2 |
|
'cartPredicate' => [static::TYPE => 'string'], |
45
|
2 |
|
'isActive' => [static::TYPE => 'bool'], |
46
|
2 |
|
'maxApplications' => [static::TYPE => 'int'], |
47
|
2 |
|
'maxApplicationsPerCustomer' => [static::TYPE => 'int'], |
48
|
2 |
|
]; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $code |
53
|
|
|
* @param CartDiscountReferenceCollection $cartDiscounts |
54
|
|
|
* @param bool $isActive |
55
|
|
|
* @param Context|callable $context |
56
|
|
|
* @return DiscountCodeDraft |
57
|
|
|
*/ |
58
|
2 |
|
public static function ofCodeDiscountsAndActive( |
59
|
|
|
$code, |
60
|
|
|
CartDiscountReferenceCollection $cartDiscounts, |
61
|
|
|
$isActive, |
62
|
|
|
$context = null |
63
|
|
|
) { |
64
|
2 |
|
return static::of($context) |
65
|
2 |
|
->setCode($code) |
66
|
2 |
|
->setCartDiscounts($cartDiscounts) |
67
|
2 |
|
->setIsActive($isActive); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|