You are here

protected function FedEx::getRateRequest in Commerce FedEx 8

Gets a rate request object for FedEx.

Parameters

\NicholasCreativeMedia\FedExPHP\Services\RateService $rate_service: The FedEx Rate Service.

\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The shipment.

Return value

\NicholasCreativeMedia\FedExPHP\Structs\RateRequest The rate request object.

1 call to FedEx::getRateRequest()
FedEx::calculateRates in src/Plugin/Commerce/ShippingMethod/FedEx.php
Calculates rates for the given shipment.

File

src/Plugin/Commerce/ShippingMethod/FedEx.php, line 890

Class

FedEx
Provides the FedEx shipping method.

Namespace

Drupal\commerce_fedex\Plugin\Commerce\ShippingMethod

Code

protected function getRateRequest(RateService $rate_service, ShipmentInterface $shipment) {
  $rate_request = $this->fedExRequest
    ->getRateRequest($this->configuration);
  $rate_request
    ->setRequestedShipment($this
    ->getFedExShipment($shipment));
  $rate_request
    ->setVersion($rate_service->version);

  // Allow other modules to alter the rate request before it's submitted.
  $rateRequestEvent = new RateRequestEvent($rate_request, $rate_service, $shipment);
  $this->eventDispatcher
    ->dispatch(CommerceFedExEvents::BEFORE_RATE_REQUEST, $rateRequestEvent);
  return $rate_request;
}