* @author Christoph Aßmann * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link https://www.temando.com/ */ class GuestCartCollectionPointManagement implements GuestCartCollectionPointManagementInterface { /** * @var CheckoutGuestCartCollectionPointManagement */ private $guestCartCollectionPointManagement; /** * @var GuestShippingAddressManagementInterface */ private $addressManagement; /** * @var CollectionPointManagement */ private $collectionPointManagement; /** * GuestCartCollectionPointManagement constructor. * * @param CheckoutGuestCartCollectionPointManagement $guestCartCollectionPointManagement * @param GuestShippingAddressManagementInterface $addressManagement * @param CollectionPointManagement $collectionPointManagement */ public function __construct( CheckoutGuestCartCollectionPointManagement $guestCartCollectionPointManagement, GuestShippingAddressManagementInterface $addressManagement, CollectionPointManagement $collectionPointManagement ) { $this->guestCartCollectionPointManagement = $guestCartCollectionPointManagement; $this->addressManagement = $addressManagement; $this->collectionPointManagement = $collectionPointManagement; } /** * @param string $cartId * @param string $countryId * @param string $postcode * @return CollectionPointSearchRequestInterface * @throws CouldNotSaveException */ public function saveSearchRequest($cartId, $countryId, $postcode) { return $this->guestCartCollectionPointManagement->saveSearchRequest($cartId, $countryId, $postcode); } /** * @param string $cartId * @return bool * @throws CouldNotDeleteException */ public function deleteSearchRequest($cartId) { return $this->guestCartCollectionPointManagement->deleteSearchRequest($cartId); } /** * @param string $cartId * @return \Temando\Shipping\Api\Data\Delivery\QuoteCollectionPointInterface[] */ public function getCollectionPoints($cartId) { return $this->guestCartCollectionPointManagement->getCollectionPoints($cartId); } /** * @param string $cartId * @param int $entityId * @return bool * @throws CouldNotSaveException */ public function selectCollectionPoint($cartId, $entityId) { try { $shippingAddress = $this->addressManagement->get($cartId); } catch (NoSuchEntityException $exception) { throw new CouldNotSaveException(__('Unable to load shipping address for specified quote.')); } return $this->collectionPointManagement->selectCollectionPoint($shippingAddress->getId(), $entityId); } }