Example #1
0
 /**
  * @return array
  */
 public function send(IMessage $message)
 {
     try {
         $response = $this->client->send(sprintf('%s/%s.%s', $this->config->getEndpointUrl(), $message->getEndpointName(), $this->config->getFormat()), $this->config->getApiKey(), $message->getParams());
     } catch (\Exception $e) {
         throw new ClientException('There was an error while contacting the Mandrill API.', NULL, $e);
     }
     $answer = $this->getAdapter($this->config->getFormat())->process($response);
     if ($response->getStatusCode() !== 200 || !Arrays::isList($answer)) {
         throw new MandrillException(sprintf('%s: %s', isset($answer['name']) ? $answer['name'] : self::UNKNOWN_ERROR_NAME, isset($answer['message']) ? $answer['message'] : self::UNKNOWN_ERROR_MESSAGE), isset($answer['code']) ? $answer['code'] : self::UNKNOWN_ERROR_CODE);
     }
     return $answer;
 }