Skip to content

Commit

Permalink
20.1.0 MNB-669 fixes errors and adds getFinalShippingChosen query
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Bernard committed Feb 2, 2021
1 parent 8f41633 commit ae7a251
Show file tree
Hide file tree
Showing 10 changed files with 456 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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


4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -18,7 +18,7 @@
}
],
"require": {
"php": "~7.0",
"php": "~7.1",
"zendframework/zend-http": "~2.0",
"netresearch/jsonmapper": "~1.4"
},
Expand Down
21 changes: 21 additions & 0 deletions src/Client/GraphQLClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/Queries/getFinalShippingChosen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Shipper HQ
*
* @category ShipperHQ
* @package ShipperHQ_GraphQL
* @copyright Copyright (c) 2019 Zowta LTD and Zowta LLC (http://www.ShipperHQ.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author ShipperHQ Team sales@shipperhq.com
*/

return <<<'graphql'
query{
getFinalShippingChosen{
externalQuoteId
shipmentId
carrierCode
methodCode
selectedDate
selectedPickupId
selectedTimeSlot
selectedOptions {
code
value
}
}
}
graphql;

?>
46 changes: 46 additions & 0 deletions src/Response/Data/GetFinalShippingChosenData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Shipper HQ
*
* @category ShipperHQ
* @package ShipperHQ_GraphQL
* @copyright Copyright (c) 2019 Zowta LTD and Zowta LLC (http://www.ShipperHQ.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author ShipperHQ Team sales@shipperhq.com
*/

namespace ShipperHQ\GraphQL\Response\Data;

class GetFinalShippingChosenData implements ResponseDataInterface
{
/**
* @var \ShipperHQ\GraphQL\Types\SelectedShippingRates[]|null
*/
private $getFinalShippingChosen;

/**
* @return \ShipperHQ\GraphQL\Types\SelectedShippingRates[]|null
*/
public function getGetFinalShippingChosen(): ?array
{
return $this->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);
}
}
76 changes: 76 additions & 0 deletions src/Response/GetFinalShippingChosen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Shipper HQ
*
* @category ShipperHQ
* @package ShipperHQ_GraphQL
* @copyright Copyright (c) 2019 Zowta LTD and Zowta LLC (http://www.ShipperHQ.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author ShipperHQ Team sales@shipperhq.com
*/

namespace ShipperHQ\GraphQL\Response;

use ShipperHQ\GraphQL\Response\Data\GetFinalShippingChosenData;

class GetFinalShippingChosen implements ResponseInterface
{
/**
* @var GetFinalShippingChosenData
*/
private $data;

/**
* @var Error[]|null
*/
private $errors;

/**
* AbstractResponse constructor.
* @param GetFinalShippingChosenData $data
* @param Error[] $errors
*/
public function __construct(GetFinalShippingChosenData $data, array $errors)
{
$this->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;
}


}
10 changes: 7 additions & 3 deletions src/Response/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

use ShipperHQ\GraphQL\Response\Data\PlaceOrderData;

/**
* Class PlaceOrder
* @package ShipperHQ\GraphQL\Response
*/
class PlaceOrder implements ResponseInterface
{
/**
Expand Down Expand Up @@ -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;
Expand All @@ -74,4 +78,4 @@ public function setErrors(array $errors)
}


}
}
64 changes: 64 additions & 0 deletions src/Types/SelectedRateOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Shipper HQ
*
* @category ShipperHQ
* @package ShipperHQ_GraphQL
* @copyright Copyright (c) 2019 Zowta LTD and Zowta LLC (http://www.ShipperHQ.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author ShipperHQ Team sales@shipperhq.com
*/

namespace ShipperHQ\GraphQL\Types;

/**
* Class RatingCarrier
*/
class SelectedRateOption
{
/**
* @var string
*/
private $code;

/**
* @var string
*/
private $value;

/**
* @return string
*/
public function getCode(): string
{
return $this->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;
}
}
Loading

0 comments on commit ae7a251

Please sign in to comment.