Beispiel #1
0
 /**
  * @param array $notification
  * 
  * @return string
  */
 public function notifyValidate(array $notification)
 {
     $request = new FormRequest();
     $request->setField('cmd', self::CMD_NOTIFY_VALIDATE);
     $request->addFields($notification);
     $request->setMethod('POST');
     $request->fromUrl($this->getIpnEndpoint());
     $response = new Response();
     $this->client->send($request, $response);
     if (false == $response->isSuccessful()) {
         throw HttpException::factory($request, $response);
     }
     if (self::NOTIFY_VERIFIED === $response->getContent()) {
         return self::NOTIFY_VERIFIED;
     }
     return self::NOTIFY_INVALID;
 }
Beispiel #2
0
 /**
  * Executes a http request.
  *
  * @param Request $request The http request.
  *
  * @return Response The http response.
  */
 public function execute(Request $request)
 {
     $method = $request->getMethod();
     $endpoint = $request->getEndpoint();
     $params = $request->getParams();
     $headers = $request->getHeaders();
     try {
         if ($method === 'GET') {
             $buzzResponse = $this->client->call($endpoint . '?' . http_build_query($params), $method, $headers, array());
         } else {
             $buzzRequest = new FormRequest();
             $buzzRequest->fromUrl($endpoint);
             $buzzRequest->setMethod($method);
             $buzzRequest->setHeaders($headers);
             foreach ($params as $key => $value) {
                 if ($value instanceof Image) {
                     $value = new FormUpload($value->getData());
                 }
                 $buzzRequest->setField($key, $value);
             }
             $buzzResponse = new BuzzResponse();
             $this->client->send($buzzRequest, $buzzResponse);
         }
     } catch (RequestException $e) {
         throw new Exception($e->getMessage());
     }
     return static::convertResponse($request, $buzzResponse);
 }
 /**
  * @param $referenceFull
  *
  * @return Response
  *
  * @throws MediaStorageClientApiException
  */
 public function getMedia($referenceFull)
 {
     if (empty($referenceFull)) {
         throw new MediaStorageClientApiException('Param referenceFull is empty');
     }
     try {
         $request = new FormRequest();
         $request->setMethod(FormRequest::METHOD_GET);
         $request->setHost($this->getApiUrlConfig('base_url'));
         $url = $this->getApiUrlConfig('get_media_by_reference_full_url') . '/' . ltrim($referenceFull, '/');
         $request->setResource($url);
         $this->logger->debug('Send ' . $this->getApiUrlConfig('base_url') . $url);
         /** @var Response $response */
         $response = $this->client->send($request, null);
         $this->logger->debug('Response: ' . $response->getStatusCode() . ' ' . substr($response->getContent(), 0, 300));
     } catch (\Exception $e) {
         throw new MediaStorageClientApiException($e->getMessage());
     }
     return $response;
 }
Beispiel #4
0
 /**
  * @param FormRequest $request
  *
  * @throws HttpException
  *
  * @return array
  */
 protected function doRequest(FormRequest $request)
 {
     $request->setMethod('POST');
     $request->fromUrl($this->getApiEndpoint());
     $this->client->send($request, $response = new Response());
     if (false == $response->isSuccessful()) {
         throw HttpException::factory($request, $response);
     }
     $result = array();
     parse_str($response->getContent(), $result);
     foreach ($result as &$value) {
         $value = urldecode($value);
     }
     return $result;
 }
Beispiel #5
0
    /**
     * @param \Buzz\Message\Form\FormRequest $request
     *
     * @throws \Payum\Core\Exception\Http\HttpException
     *
     * @return \Payum\Core\Bridge\Buzz\JsonResponse
     */
    protected function doRequest(FormRequest $request)
    {
        $request->setMethod('POST');
        $request->fromUrl($this->getApiEndpoint());

        $this->client->send($request, $response = new JsonResponse());

        if (false == $response->isSuccessful()) {
            throw HttpException::factory($request, $response);
        }

        return $response;
    }