Exemple #1
0
 public function setMethod($method)
 {
     if (mb_strpos($method, 'rpc.') === 0) {
         throw new RequestException('Invalid use of reserved method name.');
     }
     return parent::setMethod($method);
 }
Exemple #2
0
 /**
  * @param \FritzPayment\JsonRpc\Request $request
  *
  * @return bool
  */
 public function isCodecRequest(Request $request)
 {
     return $request->getVersion() == self::VERSION;
 }
Exemple #3
0
 /**
  * @param \FritzPayment\JsonRpc\Request $request
  *
  * @return string|void
  * @throws \FritzPayment\JsonRpc\Exception\TransportException
  */
 public function send(Request $request)
 {
     // TODO: Implement send() method.
     $ch = curl_init();
     if ($ch === false) {
         throw new TransportException('Could not initialize cURL handle.');
     }
     $options = $this->createCurlOptions();
     if (isset($options[CURLOPT_POST]) && $options[CURLOPT_POST]) {
         $options[CURLOPT_POSTFIELDS] = $request->getRequestBody();
     }
     if (!curl_setopt_array($ch, $options)) {
         throw new TransportException('Could not initialize cURL options.');
     }
     $responseBody = curl_exec($ch);
     if ($responseBody === false) {
         $this->errorNo = curl_errno($ch);
         $this->errorMsg = curl_error($ch);
     }
     curl_close($ch);
     return $responseBody;
 }