You are here

public function MailchimpTestHttpClient::handleRequest in Mailchimp 8

@inheritdoc

Overrides MailchimpHttpClientInterface::handleRequest

File

lib/mailchimp-api-php/tests/src/MailchimpTestHttpClient.php, line 27

Class

MailchimpTestHttpClient
A dummy HTTP client used when running unit tests. Does not make any real API requests.

Namespace

Mailchimp\Tests

Code

public function handleRequest($method, $uri = '', $options = [], $parameters = [], $returnAssoc = FALSE) {
  if (!empty($parameters)) {
    if ($method == 'GET') {

      // Send parameters as query string parameters.
      $options['query'] = $parameters;
    }
    else {

      // Send parameters as JSON in request body.
      $options['json'] = (object) $parameters;
    }
  }
  $this->method = $method;
  $this->uri = $uri;
  $this->options = $options;
  return new MailchimpTestHttpResponse();
}