Skip to content

Commit

Permalink
Fix hydrate endpoint for swagger (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolenorman authored Jun 20, 2024
1 parent 1e7a798 commit c2ae65a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 3 additions & 4 deletions Api/Order/HydrateOrderFromQuoteInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Bold\Checkout\Api\Order;

use Bold\Checkout\Api\Data\Http\Client\ResultInterface;
use Magento\Quote\Api\Data\CartInterface;

/**
Expand All @@ -13,9 +12,9 @@ interface HydrateOrderFromQuoteInterface
/**
* Hydrate Bold simple order with Magento quote data
*
* @param CartInterface $quote
* @param \Magento\Quote\Api\Data\CartInterface $quote
* @param string $publicOrderId
* @return \Bold\Checkout\Api\Data\Http\Client\ResultInterface
* @return void
*/
public function hydrate(CartInterface $quote, string $publicOrderId): ResultInterface;
public function hydrate(CartInterface $quote, string $publicOrderId): void;
}
10 changes: 7 additions & 3 deletions Model/Order/HydrateOrderFromQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

namespace Bold\Checkout\Model\Order;

use Bold\Checkout\Api\Data\Http\Client\ResultInterface;
use Bold\Checkout\Api\Http\ClientInterface;
use Bold\Checkout\Api\Order\HydrateOrderFromQuoteInterface;
use Bold\Checkout\Model\Order\Address\Converter;
use Bold\Checkout\Model\Quote\GetCartLineItems;
use Magento\Catalog\Model\ProductFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote\Address\ToOrderAddress;

Expand Down Expand Up @@ -75,7 +75,7 @@ public function __construct(
/**
* @inheritDoc
*/
public function hydrate(CartInterface $quote, string $publicOrderId): ResultInterface
public function hydrate(CartInterface $quote, string $publicOrderId): void
{
$websiteId = (int)$quote->getStore()->getWebsiteId();
$billingAddress = $this->quoteToOrderAddressConverter->convert($quote->getBillingAddress());
Expand Down Expand Up @@ -131,7 +131,11 @@ public function hydrate(CartInterface $quote, string $publicOrderId): ResultInte
}

$url = sprintf(self::HYDRATE_ORDER_URL, $publicOrderId);
return $this->client->put($websiteId, $url, $body);
$hydrateResponse = $this->client->put($websiteId, $url, $body);

if ($hydrateResponse->getStatus() !== 201) {
throw new LocalizedException(__('Failed to hydrate order with id="%1"', $publicOrderId));
}
}

/**
Expand Down

0 comments on commit c2ae65a

Please sign in to comment.