You are here

public function TestRateService::getRates in Commerce FedEx 8

Function getRates simulate a fedex rate request.

Parameters

\NicholasCreativeMedia\FedExPHP\Structs\RateRequest $rateRequest: A rate Request object.

Return value

mixed|string A simulated response based on the request.

File

tests/modules/commerce_fedex_test/src/TestRateService.php, line 23

Class

TestRateService
A class to simulate a FedEx Rate Request.

Namespace

Drupal\commerce_fedex_test

Code

public function getRates(RateRequest $rateRequest) {
  $authenticated = $rateRequest
    ->getWebAuthenticationDetail()
    ->getUserCredential()
    ->getKey() == FedExKernelTestBase::TEST_KEY;
  $authenticated &= $rateRequest
    ->getWebAuthenticationDetail()
    ->getUserCredential()
    ->getPassword() == FedExKernelTestBase::TEST_PASS;
  $authenticated &= $rateRequest
    ->getClientDetail()
    ->getAccountNumber() == FedExKernelTestBase::TEST_ACCOUNT_NUMBER;
  $authenticated &= $rateRequest
    ->getClientDetail()
    ->getMeterNumber() == FedExKernelTestBase::TEST_METER_NUMBER;
  if (!$authenticated) {
    return $this
      ->authenticationFailed();
  }

  /*TODO add more validation */
  return $this
    ->allInOneResults();
}