Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 9012d5d

Browse files
committed
feat(Error): add error codes for BadRequest
1 parent 7ba30dd commit 9012d5d

File tree

5 files changed

+170
-1
lines changed

5 files changed

+170
-1
lines changed

src/Core/Error/DiscountCodeNonApplicableError.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
namespace Commercetools\Core\Error;
77

8-
use Commercetools\Core\Model\Common\Attribute;
8+
use Commercetools\Core\Model\Common\DateTimeDecorator;
9+
use DateTime;
910

1011
/**
1112
* @package Commercetools\Core\Error
@@ -14,8 +15,42 @@
1415
* @method DiscountCodeNonApplicableError setCode(string $code = null)
1516
* @method string getMessage()
1617
* @method DiscountCodeNonApplicableError setMessage(string $message = null)
18+
* @method string getDiscountCode()
19+
* @method DiscountCodeNonApplicableError setDiscountCode(string $discountCode = null)
20+
* @method string getReason()
21+
* @method DiscountCodeNonApplicableError setReason(string $reason = null)
22+
* @method string getDicountCodeId()
23+
* @method DiscountCodeNonApplicableError setDicountCodeId(string $dicountCodeId = null)
24+
* @method DateTimeDecorator getValidFrom()
25+
* @method DiscountCodeNonApplicableError setValidFrom(DateTime $validFrom = null)
26+
* @method DateTimeDecorator getValidUntil()
27+
* @method DiscountCodeNonApplicableError setValidUntil(DateTime $validUntil = null)
28+
* @method DateTimeDecorator getValidityCheckTime()
29+
* @method DiscountCodeNonApplicableError setValidityCheckTime(DateTime $validityCheckTime = null)
1730
*/
1831
class DiscountCodeNonApplicableError extends ApiError
1932
{
2033
const CODE = 'DiscountCodeNonApplicable';
34+
35+
public function fieldDefinitions()
36+
{
37+
$definitions = parent::fieldDefinitions();
38+
$definitions['discountCode'] = [static::TYPE => 'string'];
39+
$definitions['reason'] = [static::TYPE => 'string'];
40+
$definitions['dicountCodeId'] = [static::TYPE => 'string'];
41+
$definitions['validFrom'] = [
42+
static::TYPE => DateTime::class,
43+
static::DECORATOR => DateTimeDecorator::class
44+
];
45+
$definitions['validUntil'] = [
46+
static::TYPE => DateTime::class,
47+
static::DECORATOR => DateTimeDecorator::class
48+
];
49+
$definitions['validityCheckTime'] = [
50+
static::TYPE => DateTime::class,
51+
static::DECORATOR => DateTimeDecorator::class
52+
];
53+
54+
return $definitions;
55+
}
2156
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Error;
6+
7+
use Commercetools\Core\Model\Common\Reference;
8+
9+
/**
10+
* @package Commercetools\Core\Error
11+
*
12+
* @method string getCode()
13+
* @method DuplicateFieldWithConflictingResourceError setCode(string $code = null)
14+
* @method string getMessage()
15+
* @method DuplicateFieldWithConflictingResourceError setMessage(string $message = null)
16+
* @method string getField()
17+
* @method DuplicateFieldWithConflictingResourceError setField(string $field = null)
18+
* @method mixed getDuplicateValue()
19+
* @method DuplicateFieldWithConflictingResourceError setDuplicateValue($duplicateValue = null)
20+
* @method Reference getConflictingResource()
21+
* @method DuplicateFieldWithConflictingResourceError setConflictingResource(Reference $conflictingResource = null)
22+
*/
23+
class DuplicateFieldWithConflictingResourceError extends ApiError
24+
{
25+
const CODE = 'DuplicateFieldWithConflictingResource';
26+
27+
public function fieldDefinitions()
28+
{
29+
$definitions = parent::fieldDefinitions();
30+
$definitions['field'] = [static::TYPE => 'string'];
31+
$definitions['duplicateValue'] = [static::TYPE => null];
32+
$definitions['conflictingResource'] = [static::TYPE => Reference::class];
33+
34+
return $definitions;
35+
}
36+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Error;
6+
7+
/**
8+
* @package Commercetools\Core\Error
9+
*
10+
* @method string getCode()
11+
* @method EnumValueIsUsedError setCode(string $code = null)
12+
* @method string getMessage()
13+
* @method EnumValueIsUsedError setMessage(string $message = null)
14+
*/
15+
class EnumValueIsUsedError extends ApiError
16+
{
17+
const CODE = 'EnumValueIsUsed';
18+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Error;
6+
7+
use Commercetools\Core\Model\Channel\ChannelReference;
8+
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference;
9+
10+
/**
11+
* @package Commercetools\Core\Error
12+
*
13+
* @method string getCode()
14+
* @method MatchingPriceNotFoundError setCode(string $code = null)
15+
* @method string getMessage()
16+
* @method MatchingPriceNotFoundError setMessage(string $message = null)
17+
* @method string getProductId()
18+
* @method MatchingPriceNotFoundError setProductId(string $productId = null)
19+
* @method string getVariantId()
20+
* @method MatchingPriceNotFoundError setVariantId(string $variantId = null)
21+
* @method string getCurrency()
22+
* @method MatchingPriceNotFoundError setCurrency(string $currency = null)
23+
* @method string getCountry()
24+
* @method MatchingPriceNotFoundError setCountry(string $country = null)
25+
* @method CustomerGroupReference getCustomerGroup()
26+
* @method MatchingPriceNotFoundError setCustomerGroup(CustomerGroupReference $customerGroup = null)
27+
* @method ChannelReference getChannel()
28+
* @method MatchingPriceNotFoundError setChannel(ChannelReference $channel = null)
29+
*/
30+
class MatchingPriceNotFoundError extends ApiError
31+
{
32+
const CODE = 'MatchingPriceNotFound';
33+
34+
public function fieldDefinitions()
35+
{
36+
$definitions = parent::fieldDefinitions();
37+
$definitions['productId'] = [static::TYPE => 'string'];
38+
$definitions['variantId'] = [static::TYPE => 'string'];
39+
$definitions['currency'] = [static::TYPE => 'string'];
40+
$definitions['country'] = [static::TYPE => 'string'];
41+
$definitions['customerGroup'] = [static::TYPE => CustomerGroupReference::class];
42+
$definitions['channel'] = [static::TYPE => ChannelReference::class];
43+
44+
return $definitions;
45+
}
46+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Error;
6+
7+
/**
8+
* @package Commercetools\Core\Error
9+
*
10+
* @method string getCode()
11+
* @method MissingTaxRateForCountryError setCode(string $code = null)
12+
* @method string getMessage()
13+
* @method MissingTaxRateForCountryError setMessage(string $message = null)
14+
* @method string getTaxCategoryId()
15+
* @method MissingTaxRateForCountryError setTaxCategoryId(string $taxCategoryId = null)
16+
* @method string getCountry()
17+
* @method MissingTaxRateForCountryError setCountry(string $country = null)
18+
* @method string getState()
19+
* @method MissingTaxRateForCountryError setState(string $state = null)
20+
*/
21+
class MissingTaxRateForCountryError extends ApiError
22+
{
23+
const CODE = 'MissingTaxRateForCountry';
24+
25+
public function fieldDefinitions()
26+
{
27+
$definitions = parent::fieldDefinitions();
28+
$definitions['taxCategoryId'] = [static::TYPE => 'string'];
29+
$definitions['country'] = [static::TYPE => 'string'];
30+
$definitions['state'] = [static::TYPE => 'string'];
31+
32+
return $definitions;
33+
}
34+
}

0 commit comments

Comments
 (0)