Skip to content

Commit aba7bca

Browse files
committed
AC-9030::Fedex API Upgrade - Resolve Review Comments
1 parent f3e3199 commit aba7bca

File tree

13 files changed

+108
-22962
lines changed

13 files changed

+108
-22962
lines changed

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
use Magento\Framework\App\ObjectManager;
2424
use Magento\Framework\DataObject;
2525
use Magento\Framework\Exception\LocalizedException;
26+
use Magento\Framework\HTTP\Client\CurlFactory;
2627
use Magento\Framework\Measure\Length;
2728
use Magento\Framework\Measure\Weight;
2829
use Magento\Framework\Serialize\Serializer\Json;
30+
use Magento\Framework\Url\DecoderInterface;
2931
use Magento\Framework\Xml\Security;
3032
use Magento\Quote\Model\Quote\Address\RateRequest;
3133
use Magento\Shipping\Model\Carrier\AbstractCarrier;
3234
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
3335
use Magento\Shipping\Model\Rate\Result;
34-
use Magento\Framework\HTTP\Client\CurlFactory;
35-
use Magento\Framework\Url\DecoderInterface;
3636

3737
/**
3838
* Fedex shipping implementation
@@ -100,7 +100,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
100100
public const SHIPMENT_CANCEL_END_POINT = '/ship/v1/shipments/cancel';
101101

102102
/**
103-
* REST end point of Tracking API
103+
* Authentication Grant Type for REST end point
104104
*
105105
* @var string
106106
*/
@@ -164,7 +164,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
164164
* @var string[]
165165
*/
166166
protected $_debugReplacePrivateDataKeys = [
167-
'Key', 'Password', 'MeterNumber',
167+
'client_id', 'client_secret',
168168
];
169169

170170
/**
@@ -390,12 +390,12 @@ public function getResult()
390390
* @param string $purpose
391391
* @return array
392392
*/
393-
protected function _formRateRequest($purpose) : array
393+
protected function _formRateRequest($purpose): array
394394
{
395395
$r = $this->_rawRequest;
396396
$ratesRequest = [
397397
'accountNumber' => [
398-
'value' => $r->getAccount()
398+
'value' => $r->getAccount()
399399
],
400400
'requestedShipment' => [
401401
'pickupType' => $this->getConfigData('pickup_type'),
@@ -472,7 +472,7 @@ protected function _formRateRequest($purpose) : array
472472
* @param string $purpose
473473
* @return mixed
474474
*/
475-
protected function _doRatesRequest($purpose) : mixed
475+
protected function _doRatesRequest($purpose): mixed
476476
{
477477
$response = null;
478478
$accessToken = $this->_getAccessToken();
@@ -531,11 +531,11 @@ protected function _getQuotes()
531531
* @return Result
532532
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
533533
*/
534-
protected function _prepareRateResponse($response) : Result
534+
protected function _prepareRateResponse($response): Result
535535
{
536536
$costArr = [];
537537
$priceArr = [];
538-
$errorTitle = 'For some reason we can\'t retrieve tracking info right now.';
538+
$errorTitle = __('For some reason we can\'t retrieve tracking info right now.');
539539

540540
if (is_array($response)) {
541541
if (!empty($response['errors'])) {
@@ -625,7 +625,7 @@ protected function _getPerorderPrice($cost, $handlingType, $handlingFee)
625625
* @param \stdClass $rate
626626
* @return null|float
627627
*/
628-
protected function _getRateAmountOriginBased($rate) : null|float
628+
protected function _getRateAmountOriginBased($rate): null|float
629629
{
630630
$amount = null;
631631
$currencyCode = '';
@@ -650,7 +650,7 @@ protected function _getRateAmountOriginBased($rate) : null|float
650650
}
651651
}
652652

653-
if ($amount === null) {
653+
if ($amount === null && !empty($rate['ratedShipmentDetails'][0]['totalNetCharge'])) {
654654
$amount = (string)$rate['ratedShipmentDetails'][0]['totalNetCharge'];
655655
}
656656

@@ -712,7 +712,7 @@ protected function _setFreeMethodRequest($freeMethod)
712712
* @return \Magento\Framework\Phrase|array|false
713713
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
714714
*/
715-
public function getCode($type, $code = '') : \Magento\Framework\Phrase|array|false
715+
public function getCode($type, $code = ''): \Magento\Framework\Phrase|array|false
716716
{
717717
$codes = [
718718
'method' => [
@@ -911,7 +911,7 @@ public function getCurrencyCode()
911911
* @param string|string[] $trackings
912912
* @return \Magento\Shipping\Model\Tracking\Result|null
913913
*/
914-
public function getTracking($trackings) : \Magento\Shipping\Model\Tracking\Result | null
914+
public function getTracking($trackings): \Magento\Shipping\Model\Tracking\Result|null
915915
{
916916
if (!is_array($trackings)) {
917917
$trackings = [$trackings];
@@ -930,7 +930,7 @@ public function getTracking($trackings) : \Magento\Shipping\Model\Tracking\Resul
930930
* @param string|null $endpoint
931931
* @return string
932932
*/
933-
protected function _getUrl($endpoint = null) : string
933+
protected function _getUrl($endpoint = null): string
934934
{
935935
$url = $this->getConfigFlag('sandbox_mode') ? $this->getConfigData('sandbox_webservices_url')
936936
: $this->getConfigData('production_webservices_url');
@@ -942,13 +942,13 @@ protected function _getUrl($endpoint = null) : string
942942
*
943943
* @return string|null
944944
*/
945-
protected function _getAccessToken() : string | null
945+
protected function _getAccessToken(): string|null
946946
{
947947
$apiKey = $this->getConfigData('api_key') ?? null;
948948
$secretKey = $this->getConfigData('secret_key') ?? null;
949949

950950
if (!$apiKey || !$secretKey) {
951-
$this->_debug('Authentication keys are missing.');
951+
$this->_debug(__('Authentication keys are missing.'));
952952
return null;
953953
}
954954

@@ -979,7 +979,7 @@ protected function _getAccessToken() : string | null
979979
* @param string|null $accessToken
980980
* @return array|bool
981981
*/
982-
protected function sendRequest($endpoint, $request, $accessToken = null) : array|bool
982+
protected function sendRequest($endpoint, $request, $accessToken = null): array|bool
983983
{
984984
if ($accessToken) {
985985
$headers = [
@@ -1018,7 +1018,7 @@ protected function sendRequest($endpoint, $request, $accessToken = null) : array
10181018
* @param string $tracking
10191019
* @return void
10201020
*/
1021-
protected function _getTrackingInformation($tracking) : void
1021+
protected function _getTrackingInformation($tracking): void
10221022
{
10231023
$accessToken = $this->_getAccessToken();
10241024
if (!empty($accessToken)) {
@@ -1062,7 +1062,7 @@ protected function _getTrackingInformation($tracking) : void
10621062
* @param array $response
10631063
* @return void
10641064
*/
1065-
protected function _parseTrackingResponse($trackingValue, $response) : void
1065+
protected function _parseTrackingResponse($trackingValue, $response): void
10661066
{
10671067
if (!is_array($response) || empty($response['output'])) {
10681068
$this->_debug($response);
@@ -1339,7 +1339,7 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request)
13391339
* @param \Magento\Framework\DataObject $request
13401340
* @return \Magento\Framework\DataObject
13411341
*/
1342-
protected function _doShipmentRequest(\Magento\Framework\DataObject $request) : \Magento\Framework\DataObject
1342+
protected function _doShipmentRequest(\Magento\Framework\DataObject $request): \Magento\Framework\DataObject
13431343
{
13441344
$this->_prepareShipmentRequest($request);
13451345
$result = new \Magento\Framework\DataObject();
@@ -1394,7 +1394,7 @@ protected function _doShipmentRequest(\Magento\Framework\DataObject $request) :
13941394
* @param array $pieceResponses
13951395
* @return string
13961396
*/
1397-
private function getTrackingNumber($pieceResponses) : string
1397+
private function getTrackingNumber($pieceResponses): string
13981398
{
13991399
return reset($pieceResponses)['trackingNumber'];
14001400
}
@@ -1405,7 +1405,7 @@ private function getTrackingNumber($pieceResponses) : string
14051405
* @param array|object $pieceResponses
14061406
* @return string
14071407
*/
1408-
private function getPackagingLabel($pieceResponses) : string
1408+
private function getPackagingLabel($pieceResponses): string
14091409
{
14101410
return reset(reset($pieceResponses)['packageDocuments'])['encodedLabel'];
14111411
}
@@ -1421,7 +1421,7 @@ public function rollBack($data): bool
14211421
{
14221422
$accessToken = $this->_getAccessToken();
14231423
if (empty($accessToken)) {
1424-
$this->_debug('Authorization Error. No Access Token found with given credentials.');
1424+
$this->_debug(__('Authorization Error. No Access Token found with given credentials.'));
14251425
return false;
14261426
}
14271427

@@ -1548,7 +1548,7 @@ protected function filterDebugData($data)
15481548
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
15491549
* @SuppressWarnings(PHPMD.NPathComplexity)
15501550
*/
1551-
private function processTrackingDetails($trackInfo) : array
1551+
private function processTrackingDetails($trackInfo): array
15521552
{
15531553
$result = [
15541554
'shippeddate' => null,
@@ -1637,7 +1637,7 @@ private function processTrackingDetails($trackInfo) : array
16371637
* @param array $trackInfo
16381638
* @return \Datetime|null
16391639
*/
1640-
private function getDeliveryDateTime($trackInfo) : \Datetime | null
1640+
private function getDeliveryDateTime($trackInfo): \Datetime|null
16411641
{
16421642
$timestamp = null;
16431643
if (!empty($trackInfo['dateAndTimes']) && is_array($trackInfo['dateAndTimes'])) {
@@ -1661,7 +1661,7 @@ private function getDeliveryDateTime($trackInfo) : \Datetime | null
16611661
* @param array $address
16621662
* @return \Magento\Framework\Phrase|string
16631663
*/
1664-
private function getDeliveryAddress($address) : \Magento\Framework\Phrase | string
1664+
private function getDeliveryAddress($address): \Magento\Framework\Phrase|string
16651665
{
16661666
$details = [];
16671667

@@ -1688,7 +1688,7 @@ private function getDeliveryAddress($address) : \Magento\Framework\Phrase | stri
16881688
* @param array $events
16891689
* @return array
16901690
*/
1691-
private function processTrackDetailsEvents(array $events) : array
1691+
private function processTrackDetailsEvents(array $events): array
16921692
{
16931693
$result = [];
16941694
foreach ($events as $event) {

app/code/Magento/Fedex/Model/Source/Dropoff.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)