From ae7a251b6a4144dfb7caeccca26794fa71cf1761 Mon Sep 17 00:00:00 2001 From: Travis Bernard Date: Tue, 2 Feb 2021 10:47:41 -0600 Subject: [PATCH] 20.1.0 MNB-669 fixes errors and adds getFinalShippingChosen query --- CHANGELOG-PUBLIC.md | 4 + CHANGELOG.MD | 4 + composer.json | 4 +- src/Client/GraphQLClient.php | 21 ++ src/Queries/getFinalShippingChosen.php | 30 +++ .../Data/GetFinalShippingChosenData.php | 46 ++++ src/Response/GetFinalShippingChosen.php | 76 +++++++ src/Response/PlaceOrder.php | 10 +- src/Types/SelectedRateOption.php | 64 ++++++ src/Types/SelectedShippingRates.php | 202 ++++++++++++++++++ 10 files changed, 456 insertions(+), 5 deletions(-) create mode 100644 src/Queries/getFinalShippingChosen.php create mode 100644 src/Response/Data/GetFinalShippingChosenData.php create mode 100644 src/Response/GetFinalShippingChosen.php create mode 100644 src/Types/SelectedRateOption.php create mode 100644 src/Types/SelectedShippingRates.php diff --git a/CHANGELOG-PUBLIC.md b/CHANGELOG-PUBLIC.md index 454eab8..941fff2 100644 --- a/CHANGELOG-PUBLIC.md +++ b/CHANGELOG-PUBLIC.md @@ -24,3 +24,7 @@ TGR-66 add recipient to placeOrder request SHQ18-3003 support for GROUPED product types +## 20.1.0 (2021-02-02) +MNB-669 fixes errors and adds getFinalShippingChosen query + + diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 454eab8..941fff2 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -24,3 +24,7 @@ TGR-66 add recipient to placeOrder request SHQ18-3003 support for GROUPED product types +## 20.1.0 (2021-02-02) +MNB-669 fixes errors and adds getFinalShippingChosen query + + diff --git a/composer.json b/composer.json index 6f411ff..7aa7729 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "shipperhq/library-graphql", "description": "ShipperHQ GraphQL Library", "type": "magento2-library", - "version": "20.0.5", + "version": "20.1.0", "license": [ "OSL-3.0", "AFL-3.0" @@ -18,7 +18,7 @@ } ], "require": { - "php": "~7.0", + "php": "~7.1", "zendframework/zend-http": "~2.0", "netresearch/jsonmapper": "~1.4" }, diff --git a/src/Client/GraphQLClient.php b/src/Client/GraphQLClient.php index dcc67b2..18961c5 100644 --- a/src/Client/GraphQLClient.php +++ b/src/Client/GraphQLClient.php @@ -15,6 +15,7 @@ use ShipperHQ\GraphQL\Request\SecureHeaders; use ShipperHQ\GraphQL\Request\Request; use ShipperHQ\GraphQL\Response\CreateSecretToken; +use ShipperHQ\GraphQL\Response\GetFinalShippingChosen; use ShipperHQ\GraphQL\Response\PlaceOrder; use ShipperHQ\GraphQL\Response\RetrieveShippingQuote; use ShipperHQ\GraphQL\Types\Input\RMSRatingInfo; @@ -63,6 +64,26 @@ public function retrieveShippingQuote(RMSRatingInfo $ratingInfo, $endpoint, $tim return $this->sendRequest($serializedRequest, RetrieveShippingQuote::class, $endpoint, $timeout, $headers); } + /** + * @param RMSRatingInfo $ratingInfo + * @param $endpoint + * @param $timeout + * @param SecureHeaders $headers + * @return array + * @throws \ReflectionException + */ + public function getFinalShippingChosen($endpoint, $timeout, SecureHeaders $headers) + { + $request = new Request( + self::getQueryStr('getFinalShippingChosen'), + [] + ); + + $serializedRequest = Serializer::serialize($request, JSON_PRETTY_PRINT); + + return $this->sendRequest($serializedRequest, GetFinalShippingChosen::class, $endpoint, $timeout, $headers); + } + /** * @param $orderNumber * @param $totalCharges diff --git a/src/Queries/getFinalShippingChosen.php b/src/Queries/getFinalShippingChosen.php new file mode 100644 index 0000000..4fd4e6c --- /dev/null +++ b/src/Queries/getFinalShippingChosen.php @@ -0,0 +1,30 @@ + diff --git a/src/Response/Data/GetFinalShippingChosenData.php b/src/Response/Data/GetFinalShippingChosenData.php new file mode 100644 index 0000000..d5480a4 --- /dev/null +++ b/src/Response/Data/GetFinalShippingChosenData.php @@ -0,0 +1,46 @@ +getFinalShippingChosen; + } + + /** + * @param \ShipperHQ\GraphQL\Types\SelectedShippingRates[]|null $getFinalShippingChosen + * @return GetFinalShippingChosenData + */ + public function setGetFinalShippingChosen(?array $getFinalShippingChosen): GetFinalShippingChosenData + { + $this->getFinalShippingChosen = $getFinalShippingChosen; + return $this; + } + + /** + * @return bool + */ + public function isEmpty() + { + return empty($this->getFinalShippingChosen); + } +} diff --git a/src/Response/GetFinalShippingChosen.php b/src/Response/GetFinalShippingChosen.php new file mode 100644 index 0000000..e26453b --- /dev/null +++ b/src/Response/GetFinalShippingChosen.php @@ -0,0 +1,76 @@ +data = $data; + $this->errors = $errors; + } + + /** + * @return GetFinalShippingChosenData + */ + public function getData() + { + return $this->data; + } + + /** + * @param GetFinalShippingChosenData $data + * @return GetFinalShippingChosen + */ + public function setData(GetFinalShippingChosenData $data) + { + $this->data = $data; + return $this; + } + + /** + * @return Error[]|null + */ + public function getErrors() + { + return $this->errors; + } + + /** + * @param Error[]|null $errors + * @return GetFinalShippingChosen + */ + public function setErrors(array $errors) + { + $this->errors = $errors; + return $this; + } + + +} diff --git a/src/Response/PlaceOrder.php b/src/Response/PlaceOrder.php index c2a133f..ee17e77 100644 --- a/src/Response/PlaceOrder.php +++ b/src/Response/PlaceOrder.php @@ -14,6 +14,10 @@ use ShipperHQ\GraphQL\Response\Data\PlaceOrderData; +/** + * Class PlaceOrder + * @package ShipperHQ\GraphQL\Response + */ class PlaceOrder implements ResponseInterface { /** @@ -46,10 +50,10 @@ public function getData() } /** - * @param \ShipperHQ\GraphQL\Response\Data\PlaceOrderData $data + * @param \ShipperHQ\GraphQL\Response\Data\PlaceOrderData|null $data * @return PlaceOrder */ - public function setData(PlaceOrderData $data) + public function setData(?PlaceOrderData $data) { $this->data = $data; return $this; @@ -74,4 +78,4 @@ public function setErrors(array $errors) } -} \ No newline at end of file +} diff --git a/src/Types/SelectedRateOption.php b/src/Types/SelectedRateOption.php new file mode 100644 index 0000000..073f044 --- /dev/null +++ b/src/Types/SelectedRateOption.php @@ -0,0 +1,64 @@ +code; + } + + /** + * @param string $code + * @return SelectedRateOption + */ + public function setCode(string $code): SelectedRateOption + { + $this->code = $code; + return $this; + } + + /** + * @return string + */ + public function getValue(): string + { + return $this->value; + } + + /** + * @param string $value + * @return SelectedRateOption + */ + public function setValue(string $value): SelectedRateOption + { + $this->value = $value; + return $this; + } +} diff --git a/src/Types/SelectedShippingRates.php b/src/Types/SelectedShippingRates.php new file mode 100644 index 0000000..980a269 --- /dev/null +++ b/src/Types/SelectedShippingRates.php @@ -0,0 +1,202 @@ +externalQuoteId; + } + + /** + * @param string $externalQuoteId + * @return SelectedShippingRates + */ + public function setExternalQuoteId(string $externalQuoteId): SelectedShippingRates + { + $this->externalQuoteId = $externalQuoteId; + return $this; + } + + /** + * @return string + */ + public function getShipmentId(): string + { + return $this->shipmentId; + } + + /** + * @param string $shipmentId + * @return SelectedShippingRates + */ + public function setShipmentId(string $shipmentId): SelectedShippingRates + { + $this->shipmentId = $shipmentId; + return $this; + } + + /** + * @return string|null + */ + public function getCarrierCode(): ?string + { + return $this->carrierCode; + } + + /** + * @param string|null $carrierCode + * @return SelectedShippingRates + */ + public function setCarrierCode(?string $carrierCode): SelectedShippingRates + { + $this->carrierCode = $carrierCode; + return $this; + } + + /** + * @return string|null + */ + public function getMethodCode(): ?string + { + return $this->methodCode; + } + + /** + * @param string|null $methodCode + * @return SelectedShippingRates + */ + public function setMethodCode(?string $methodCode): SelectedShippingRates + { + $this->methodCode = $methodCode; + return $this; + } + + /** + * @return string|null + */ + public function getSelectedDate(): ?string + { + return $this->selectedDate; + } + + /** + * @param string|null $selectedDate + * @return SelectedShippingRates + */ + public function setSelectedDate(?string $selectedDate): SelectedShippingRates + { + $this->selectedDate = $selectedDate; + return $this; + } + + /** + * @return string|null + */ + public function getSelectedPickupId(): ?string + { + return $this->selectedPickupId; + } + + /** + * @param string|null $selectedPickupId + * @return SelectedShippingRates + */ + public function setSelectedPickupId(?string $selectedPickupId): SelectedShippingRates + { + $this->selectedPickupId = $selectedPickupId; + return $this; + } + + /** + * @return string|null + */ + public function getSelectedTimeSlot(): ?string + { + return $this->selectedTimeSlot; + } + + /** + * @param string|null $selectedTimeSlot + * @return SelectedShippingRates + */ + public function setSelectedTimeSlot(?string $selectedTimeSlot): SelectedShippingRates + { + $this->selectedTimeSlot = $selectedTimeSlot; + return $this; + } + + /** + * @return SelectedRateOption[]|null + */ + public function getSelectedOptions(): ?array + { + return $this->selectedOptions; + } + + /** + * @param SelectedRateOption[]|null $selectedOptions + * @return SelectedShippingRates + */ + public function setSelectedOptions(?array $selectedOptions): SelectedShippingRates + { + $this->selectedOptions = $selectedOptions; + return $this; + } +}