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

Commit bde4473

Browse files
committed
feat(ShippingInfoImportDraft): add ShippingInfoImportDraft representation
closes #449
1 parent f8140eb commit bde4473

File tree

5 files changed

+92
-25
lines changed

5 files changed

+92
-25
lines changed

src/Core/Model/Cart/ShippingInfo.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55

66
namespace Commercetools\Core\Model\Cart;
77

8-
use Commercetools\Core\Model\Common\JsonObject;
98
use Commercetools\Core\Model\Common\Money;
109
use Commercetools\Core\Model\Order\DeliveryCollection;
10+
use Commercetools\Core\Model\Order\ShippingInfoImportDraft;
1111
use Commercetools\Core\Model\ShippingMethod\ShippingMethodReference;
1212
use Commercetools\Core\Model\ShippingMethod\ShippingRate;
13-
use Commercetools\Core\Model\TaxCategory\TaxCategory;
1413
use Commercetools\Core\Model\TaxCategory\TaxRate;
1514
use Commercetools\Core\Model\Common\TaxedItemPrice;
15+
use Commercetools\Core\Model\TaxCategory\TaxCategoryReference;
1616

1717
/**
1818
* @package Commercetools\Core\Model\Cart
1919
* @link https://docs.commercetools.com/http-api-projects-carts.html#shippinginfo
20+
*
2021
* @method string getShippingMethodName()
2122
* @method ShippingInfo setShippingMethodName(string $shippingMethodName = null)
2223
* @method Money getPrice()
@@ -25,37 +26,26 @@
2526
* @method ShippingInfo setShippingRate(ShippingRate $shippingRate = null)
2627
* @method TaxRate getTaxRate()
2728
* @method ShippingInfo setTaxRate(TaxRate $taxRate = null)
28-
* @method TaxCategory getTaxCategory()
29-
* @method ShippingInfo setTaxCategory(TaxCategory $taxCategory = null)
29+
* @method TaxCategoryReference getTaxCategory()
30+
* @method ShippingInfo setTaxCategory(TaxCategoryReference $taxCategory = null)
3031
* @method ShippingMethodReference getShippingMethod()
3132
* @method ShippingInfo setShippingMethod(ShippingMethodReference $shippingMethod = null)
3233
* @method DeliveryCollection getDeliveries()
3334
* @method ShippingInfo setDeliveries(DeliveryCollection $deliveries = null)
34-
* @method TaxedItemPrice getTaxedPrice()
35-
* @method ShippingInfo setTaxedPrice(TaxedItemPrice $taxedPrice = null)
3635
* @method DiscountedLineItemPrice getDiscountedPrice()
3736
* @method ShippingInfo setDiscountedPrice(DiscountedLineItemPrice $discountedPrice = null)
3837
* @method string getShippingMethodState()
3938
* @method ShippingInfo setShippingMethodState(string $shippingMethodState = null)
39+
* @method TaxedItemPrice getTaxedPrice()
40+
* @method ShippingInfo setTaxedPrice(TaxedItemPrice $taxedPrice = null)
4041
*/
41-
class ShippingInfo extends JsonObject
42+
class ShippingInfo extends ShippingInfoImportDraft
4243
{
43-
const SHIPPING_METHOD_MATCH = 'MatchesCart';
44-
const SHIPPING_METHOD_DONT_MATCH = 'DoesNotMatchCart';
45-
4644
public function fieldDefinitions()
4745
{
48-
return [
49-
'shippingMethodName' => [static::TYPE => 'string'],
50-
'price' => [static::TYPE => Money::class],
51-
'shippingRate' => [static::TYPE => ShippingRate::class],
52-
'taxedPrice' => [static::TYPE => TaxedItemPrice::class],
53-
'taxRate' => [static::TYPE => TaxRate::class],
54-
'taxCategory' => [static::TYPE => TaxCategory::class],
55-
'shippingMethod' => [static::TYPE => ShippingMethodReference::class],
56-
'deliveries' => [static::TYPE => DeliveryCollection::class],
57-
'discountedPrice' => [static::TYPE => DiscountedLineItemPrice::class],
58-
'shippingMethodState' => [static::TYPE => 'string']
59-
];
46+
$fields = parent::fieldDefinitions();
47+
$fields['taxedPrice'] = [static::TYPE => TaxedItemPrice::class];
48+
49+
return $fields;
6050
}
6151
}

src/Core/Model/Order/ImportOrder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
* @method ImportOrder setShipmentState(string $shipmentState = null)
5050
* @method string getPaymentState()
5151
* @method ImportOrder setPaymentState(string $paymentState = null)
52-
* @method ShippingInfo getShippingInfo()
53-
* @method ImportOrder setShippingInfo(ShippingInfo $shippingInfo = null)
52+
* @method ShippingInfoImportDraft getShippingInfo()
53+
* @method ImportOrder setShippingInfo(ShippingInfoImportDraft $shippingInfo = null)
5454
* @method DateTimeDecorator getCompletedAt()
5555
* @method ImportOrder setCompletedAt(DateTime $completedAt = null)
5656
* @method CustomFieldObjectDraft getCustom()
@@ -85,7 +85,7 @@ public function fieldDefinitions()
8585
'orderState' => [static::TYPE => 'string'],
8686
'shipmentState' => [static::TYPE => 'string'],
8787
'paymentState' => [static::TYPE => 'string'],
88-
'shippingInfo' => [static::TYPE => ShippingInfo::class],
88+
'shippingInfo' => [static::TYPE => ShippingInfoImportDraft::class],
8989
'completedAt' => [
9090
static::TYPE => DateTime::class,
9191
static::DECORATOR => DateTimeDecorator::class
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Model\Order;
6+
7+
use Commercetools\Core\Model\Cart\DiscountedLineItemPrice;
8+
use Commercetools\Core\Model\Common\JsonObject;
9+
use Commercetools\Core\Model\Common\Money;
10+
use Commercetools\Core\Model\ShippingMethod\ShippingMethodReference;
11+
use Commercetools\Core\Model\ShippingMethod\ShippingRate;
12+
use Commercetools\Core\Model\TaxCategory\TaxCategoryReference;
13+
use Commercetools\Core\Model\TaxCategory\TaxRate;
14+
15+
/**
16+
* @package Commercetools\Core\Model\Order
17+
* @link https://docs.commercetools.com/http-api-projects-orders-import.html#shippinginfoimportdraft
18+
*
19+
* @method string getShippingMethodName()
20+
* @method ShippingInfoImportDraft setShippingMethodName(string $shippingMethodName = null)
21+
* @method Money getPrice()
22+
* @method ShippingInfoImportDraft setPrice(Money $price = null)
23+
* @method ShippingRate getShippingRate()
24+
* @method ShippingInfoImportDraft setShippingRate(ShippingRate $shippingRate = null)
25+
* @method TaxRate getTaxRate()
26+
* @method ShippingInfoImportDraft setTaxRate(TaxRate $taxRate = null)
27+
* @method TaxCategoryReference getTaxCategory()
28+
* @method ShippingInfoImportDraft setTaxCategory(TaxCategoryReference $taxCategory = null)
29+
* @method ShippingMethodReference getShippingMethod()
30+
* @method ShippingInfoImportDraft setShippingMethod(ShippingMethodReference $shippingMethod = null)
31+
* @method DeliveryCollection getDeliveries()
32+
* @method ShippingInfoImportDraft setDeliveries(DeliveryCollection $deliveries = null)
33+
* @method DiscountedLineItemPrice getDiscountedPrice()
34+
* @method ShippingInfoImportDraft setDiscountedPrice(DiscountedLineItemPrice $discountedPrice = null)
35+
* @method string getShippingMethodState()
36+
* @method ShippingInfoImportDraft setShippingMethodState(string $shippingMethodState = null)
37+
*/
38+
class ShippingInfoImportDraft extends JsonObject
39+
{
40+
const SHIPPING_METHOD_MATCH = 'MatchesCart';
41+
const SHIPPING_METHOD_DONT_MATCH = 'DoesNotMatchCart';
42+
43+
public function fieldDefinitions()
44+
{
45+
return [
46+
'shippingMethodName' => [static::TYPE => 'string'],
47+
'price' => [static::TYPE => Money::class],
48+
'shippingRate' => [static::TYPE => ShippingRate::class],
49+
'taxRate' => [static::TYPE => TaxRate::class],
50+
'taxCategory' => [static::TYPE => TaxCategoryReference::class],
51+
'shippingMethod' => [static::TYPE => ShippingMethodReference::class],
52+
'deliveries' => [static::TYPE => DeliveryCollection::class],
53+
'discountedPrice' => [static::TYPE => DiscountedLineItemPrice::class],
54+
'shippingMethodState' => [static::TYPE => 'string'],
55+
];
56+
}
57+
}

src/Core/Model/ShippingMethod/ShippingMethodReference.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ public static function ofId($id, $context = null)
3535
{
3636
return static::ofTypeAndId(static::TYPE_SHIPPING_METHOD, $id, $context);
3737
}
38+
39+
/**
40+
* @param $key
41+
* @param Context|callable $context
42+
* @return ShippingMethodReference
43+
*/
44+
public static function ofKey($key, $context = null)
45+
{
46+
return static::ofTypeAndKey(static::TYPE_SHIPPING_METHOD, $key, $context);
47+
}
3848
}

src/Core/Model/TaxCategory/TaxCategoryReference.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,14 @@ public static function ofId($id, $context = null)
3636
{
3737
return static::ofTypeAndId(static::TYPE_TAX_CATEGORY, $id, $context);
3838
}
39+
40+
/**
41+
* @param $key
42+
* @param Context|callable $context
43+
* @return TaxCategoryReference
44+
*/
45+
public static function ofKey($key, $context = null)
46+
{
47+
return static::ofTypeAndKey(static::TYPE_TAX_CATEGORY, $key, $context);
48+
}
3949
}

0 commit comments

Comments
 (0)