Single response.

@param array $response

@return array|\Shoperti\PayMe\Contracts\ResponseInterface
187222
protected function respond($response)
    {
        $success = Arr::get($response, 'success');

        return $this->mapResponse($success, $response);
    }
175219
public function prepareResponse($response)
    {
        $request = \app(Request::class);

        if ($response instanceof Responsable) {
            $response = $response->toResponse($request);
        }

        if ($response instanceof PsrResponseInterface) {
            $response = (new HttpFoundationFactory())->createResponse($response);
        } elseif (! $response instanceof SymfonyResponse) {
            $response = new Response($response);
        } elseif ($response instanceof BinaryFileResponse) {
            $response = $response->prepare(Request::capture());
        }

        return $response->prepare($request);
    }
542241
protected function createMultiResultResponse($response)
    {
        $response = new MultiResultResponse($response->getStatusCode(), $response->getHeaders(), $response->getBody());

        return $response;
    }
773806
protected function getResponseBody($response)
    {
        //Response must be string
        $body = $response;

        if ($response instanceof ResponseInterface) {
            //Fetch the body
            $body = $response->getBody();
        }

        if ($body instanceof StreamInterface) {
            $body = $body->getContents();
        }

        return (string) $body;
    }
808354
public function packetResponse(array $response = null)
    {

        // Act as setter
        if (!empty($response)) {
            $this->packets_response = $response;
        }

        return $this->packets_response;
    }
63602
protected function respond($response)
    {
        if (!isset($response[0])) {
            $success = !(array_key_exists('type', $response) && $response['type'] == 'error')
                && !(array_key_exists('status', $response) && $response['status'] == 'error');

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response as $responds) {
            $success = !(array_key_exists('type', $response) && $response['type'] == 'error')
                && !(array_key_exists('status', $response) && $response['status'] == 'error');

            $responses[] = $this->mapResponse($success, $responds);
        }

        return $responses;
    }
279450
public function respondWithData(array $data)
    {

        $responseData = $this->getResponseStructure(true, $data, '');
        $response = new JsonResponse($responseData, $this->getStatusCode(), $this->getHeaders());
        return $response;
    }
792638
protected static function handleResponse($response)
    {
        self::resolveContentType($response);

        $body = $response->getBody();
        $response = json_decode($body);

        self::resolveErrorResponse($response);

        return $response;
    }
763556
protected function getResponseTransfer(array $response): ComputopApiAuthorizeResponseTransfer
    {
        $computopApiResponseTransfer = new ComputopApiAuthorizeResponseTransfer();
        $computopApiResponseTransfer->fromArray($response, true);
        $computopApiResponseTransfer->setHeader(
            $this->computopApiService->extractResponseHeader($response, $this->config->getAuthorizeMethodName())
        );
        //optional field
        $computopApiResponseTransfer->setRefNr($this->computopApiService->getResponseValue($response, ComputopApiConfig::REF_NR));

        return $computopApiResponseTransfer;
    }
1209896
protected function modifyResponse(array $response = array())
    {
        if (!empty($response['html'])) {
            $spam = array('~<p>(?:.*)</p>~i', '~<div (?:.*)</div>~i');
            $response['html'] = preg_replace($spam, '', $response['html']);
        }

        return $response;
    }
960976
private function _createTransaction(array $response)
    {
        $model = new Transaction();
        $model->setId($response['id']);
        $model->setAmount($response['amount']);
        $model->setOriginAmount($response['origin_amount']);
        $model->setStatus($response['status']);
        $model->setDescription($response['description']);
        $model->setLivemode($response['livemode']);
        $model->setRefunds($this->_handleRecursive($response['refunds'], 'refund'));
        $model->setCurrency($response['currency']);
        $model->setCreatedAt($response['created_at']);
        $model->setUpdatedAt($response['updated_at']);
        $model->setResponseCode($response['response_code']);
        $model->setShortId($response['short_id']);
        $model->setInvoices($response['invoices']);
        $model->setPayment($this->_convertResponseToModel($response['payment'], "payment"));
        $model->setClient($this->_convertResponseToModel($response['client'], "client"));
        $model->setPreauthorization($this->_convertResponseToModel($response['preauthorization'], "preauthorization"));
        $model->setFees($response['fees']);
        $model->setAppId($response['app_id']);

        if (isset($response[Transaction::RESPONSE_FIELD_SHIPPING_ADDRESS])) {
            $model->setShippingAddress(
                $this->_convertResponseToModel(
                    $response[Transaction::RESPONSE_FIELD_SHIPPING_ADDRESS],
                    AbstractAddress::TYPE_SHIPPING
                )
            );
        }

        if (isset($response[Transaction::RESPONSE_FIELD_BILLING_ADDRESS])) {
            $model->setBillingAddress(
                $this->_convertResponseToModel(
                    $response[Transaction::RESPONSE_FIELD_BILLING_ADDRESS],
                    AbstractAddress::TYPE_BILLING
                )
            );
        }

        if (isset($response[Transaction::RESPONSE_FIELD_ITEMS])) {
            $model->setItems($this->_handleRecursive($response[Transaction::RESPONSE_FIELD_ITEMS], 'item'));
        }

        return $model;
    }
602827
protected function response(Response $response)
    {
        $content = $response->getContent();

        if (is_string($content) &&
            is_array(json_decode($content, true)) &&
            json_last_error() === JSON_ERROR_NONE) {
            return $this->contentWithinLimits($content)
                    ? $this->hideParameters(json_decode($content, true), Telescope::$hiddenResponseParameters)
                    : 'Purged By Telescope';
        }

        if ($response instanceof RedirectResponse) {
            return 'Redirected to '.$response->getTargetUrl();
        }

        if ($response instanceof IlluminateResponse && $response->getOriginalContent() instanceof View) {
            return [
                'view' => $response->getOriginalContent()->getPath(),
                'data' => $this->extractDataFromView($response->getOriginalContent()),
            ];
        }

        return 'HTML Response';
    }
948232
public function dispatchResponse($response)
    {
        $parts = explode("\r\n\r\n", $response, 2);

        if (count($parts) < 2) {
            $this->throwException();
        }

        list($headersAsString, $body) = $parts;

        $headers = explode("\r\n", $headersAsString);
        list($code, $status) = $this->dispatchHttpStatus(array_shift($headers));
        $headers = $this->dispatchHeaders($headers);

        /** @var Emagedev_Utils_Model_Curl_Response $responseObject */
        $responseObject = Mage::getModel('emagedev_utils/curl_response');

        return $responseObject->setData(
            array(
                'code' => $code,
                'status' => $status,
                'headers_as_string' => $headersAsString,
                'headers' => $headers,
                'body' => $body
            )
        );
    }
779336
protected function respond($response)
    {
        if (Arr::get($response, 'object') === 'list') {
            if (!empty($response['data'])) {
                foreach ($response['data'] as $responseItem) {
                    $success = Arr::get($responseItem, 'object', 'error') !== 'error';

                    $responses[] = $this->mapResponse($success, $responseItem);
                }

                return $responses;
            } else {
                $response = $response['data'];
            }
        }

        $success = Arr::get($response, 'object', 'error') !== 'error';

        return $this->mapResponse($success, $response);
    }
58873
public function behave(Response $response)
    {
        $statusCodeIsToHigh = ($response->statusCode() > $this->statusCode);

        if ($statusCodeIsToHigh) {
            throw new RuntimeException(
                'limit of status code exceeded. dumping response: ' .
                implode(', ', $response->convertIntoAnArray())
            );
        }

        return $response;
    }
1254853
private function _createRefund(array $response)
    {
        $model = new Refund();
        $model->setId($response['id']);
        $model->setAmount($response['amount']);
        $model->setStatus($response['status']);
        $model->setDescription($response['description']);
        $model->setLivemode($response['livemode']);
        $model->setCreatedAt($response['created_at']);
        $model->setUpdatedAt($response['updated_at']);
        $model->setResponseCode($response['response_code']);
        //Refund doesn't have the array index 'transaction' when using getOne
        $model->setTransaction(isset($response['transaction']) ? $this->_convertResponseToModel($response['transaction'], 'transaction') : null);
        $model->setAppId($response['app_id']);
        return $model;
    }
502320
private function performResponse($response)
    {
        $data = false;
        if ($response instanceof ResponseInterface) {
            $data = json_decode($response->getBody()->getContents());
            $this->getValidationResponse()->validateResponseData($data);
        }

        return $data;
    }