コード例 #1
0
 /**
  * Validate credentials for token authentication
  *
  * @param array $credentials
  * @return TokenAuthentication
  * @throws \RuntimeException
  */
 protected function createTokenAuthentication(array $credentials)
 {
     Helper::validateFields($credentials, ['token'], 'authentication.types.token');
     return new TokenAuthentication($credentials['token']);
 }
コード例 #2
0
 /**
  * Fire call to API and return data
  *
  * @param string $method
  * @return string|null
  */
 private function send($method)
 {
     $client = $this->getGuzzleClient();
     if (method_exists($client, $method) && !empty($this->endpoint)) {
         /** @var Response $response */
         $response = $client->{$method}($this->endpoint, $this->options);
         $contents = $response->getBody()->getContents();
         // Cleanup options, 'cause we don't need them again after the call was made
         $this->options = [];
         return $contents;
     } else {
         Helper::validateFields($this->config, ['mailFrom', 'mailTo', 'configuration'], 'email');
         // Send an error email
         $mailer = new Mailer($this->config['mailFrom'], $this->config['mailTo'], $this->config['configuration']['url']);
         $mailer->sendErrorMail($method, $this->endpoint, 'Chosen method doesn\'t exist in Guzzle', '', $this->options);
     }
     return null;
 }