You are here

public function USPSRateRequestInternational::buildRate in Commerce USPS 8

Initialize the rate request object needed for the USPS API.

Overrides USPSRateRequestBase::buildRate

File

src/USPSRateRequestInternational.php, line 73

Class

USPSRateRequestInternational
Class USPSRateRequest.

Namespace

Drupal\commerce_usps

Code

public function buildRate() {

  // Invoke the parent to initialize the uspsRequest.
  parent::buildRate();
  $this->uspsRequest
    ->setInternationalCall(TRUE);
  $this->uspsRequest
    ->addExtraOption('Revision', 2);

  // Add each package to the request.
  // Todo: IntlRateV2 is limited to 25 packages per txn.
  foreach ($this
    ->getPackages() as $package) {
    $this->uspsRequest
      ->addPackage($package);
  }
}