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

Commit bd745f7

Browse files
committed
feat(ShippingMethod): support Reference expansion
1 parent 75f654d commit bd745f7

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/Core/Request/ShippingMethods/ShippingMethodByCartIdGetRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Commercetools\Core\Request\ShippingMethods;
77

8+
use Commercetools\Core\Request\ExpandTrait;
89
use Commercetools\Core\Response\ResourceResponse;
910
use Psr\Http\Message\ResponseInterface;
1011
use Commercetools\Core\Client\HttpMethod;
@@ -24,6 +25,8 @@
2425
*/
2526
class ShippingMethodByCartIdGetRequest extends AbstractApiRequest
2627
{
28+
use ExpandTrait;
29+
2730
protected $resultClass = ShippingMethodCollection::class;
2831

2932
/**

src/Core/Request/ShippingMethods/ShippingMethodByLocationGetRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Commercetools\Core\Request\ShippingMethods;
77

8+
use Commercetools\Core\Request\ExpandTrait;
89
use Commercetools\Core\Response\ResourceResponse;
910
use Psr\Http\Message\ResponseInterface;
1011
use Commercetools\Core\Client\HttpMethod;
@@ -24,6 +25,8 @@
2425
*/
2526
class ShippingMethodByLocationGetRequest extends AbstractApiRequest
2627
{
28+
use ExpandTrait;
29+
2730
protected $resultClass = ShippingMethodCollection::class;
2831

2932
/**

tests/integration/ShippingMethod/ShippingMethodQueryRequestTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Commercetools\Core\Model\ShippingMethod\ShippingRateCollection;
1616
use Commercetools\Core\Model\ShippingMethod\ZoneRate;
1717
use Commercetools\Core\Model\ShippingMethod\ZoneRateCollection;
18+
use Commercetools\Core\Model\TaxCategory\TaxCategory;
1819
use Commercetools\Core\Request\ShippingMethods\ShippingMethodByIdGetRequest;
1920
use Commercetools\Core\Request\ShippingMethods\ShippingMethodByLocationGetRequest;
2021
use Commercetools\Core\Request\ShippingMethods\ShippingMethodCreateRequest;
@@ -92,11 +93,13 @@ public function testByLocation()
9293
$shippingMethod = $this->createShippingMethod($draft);
9394

9495
$request = ShippingMethodByLocationGetRequest::ofCountry('DE')->withState($this->getRegion());
96+
$request->expand('taxCategory.id');
9597
$response = $request->executeWithClient($this->getClient(), ['X-Vrap-Disable-Validation' => 'response']);
9698
$result = $request->mapResponse($response);
9799

98100
$this->assertTrue($result->current()->getZoneRates()->current()->getShippingRates()->current()->getIsMatching());
99101
$this->assertInstanceOf(ShippingMethodCollection::class, $result);
100102
$this->assertSame($shippingMethod->getId(), $result->current()->getId());
103+
$this->assertInstanceOf(TaxCategory::class, $result->current()->getTaxCategory()->getObj());
101104
}
102105
}

0 commit comments

Comments
 (0)