Respond with an array of responses or a single response.

@param array $response

@return array|\Shoperti\PayMe\Contracts\ResponseInterface
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);
    }
912337
protected function _withCustomHeaders($response)
    {
        foreach ((array)$this->getConfig('headers') as $key => $value) {
            $response = $response->withHeader($key, $value);
        }

        return $response;
    }
799176
private static function withCorsHeaders(ResponseInterface $response, array $headers): ResponseInterface
	{
		foreach ($headers as $name => $value) {
			$response = $response->withHeader($name, $value);
		}

		return $response;
	}
683651
protected function response(Response $response)
    {
        return $this->response->create(
            (string)$response->getContent(),
            $response->getStatusCode(),
            (array)$response->headers->all()
        );
    }
1102182
public static function buildFromPsrResponse(ResponseInterface $response)
    {
        return new static(
            $response->getStatusCode(),
            $response->getHeaders(),
            $response->getBody(),
            $response->getProtocolVersion(),
            $response->getReasonPhrase()
        );
    }
446061
protected function respond($response, $code)
    {
        if (isset($response[0])) {
            foreach ($response as $responseItem) {
                $responses[] = $this->respond($responseItem, $code);
            }

            return $responses;
        }

        return $this->mapResponse($this->isSuccess($response, $code), $response);
    }
515696
protected function parseResponse($response)
    {
        if ($response instanceof ResponseInterface) {
            $response = $response->getBody();
        }

        return new Collection((array) XML::parse($response));
    }
856760
private function _createClient(array $response)
    {
        $model = new Client();
        $model->setId($response['id']);
        $model->setEmail($response['email']);
        $model->setDescription($response['description']);
        $model->setCreatedAt($response['created_at']);
        $model->setUpdatedAt($response['updated_at']);
        $model->setSubscription($this->_handleRecursive($response['subscription'], 'subscription'));
        $model->setAppId($response['app_id']);
        $model->setPayment($this->_handleRecursive($response['payment'], 'payment'));
        return $model;
    }
879326
protected function configureResponse(ResponseInterface $Response){
        $Response->setRequest($this->Request);
        $Response->extract();
        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;
    }
337294
protected function sendResponse($response)
	{
		return $this->responsePreparer->readyForResponses() && ! $this->runningInConsole()
								? $response
								: $response->send();
	}
660653
protected function formatResponse($response)
    {
        if (static::FORMAT_ARRAY === $this->output) {
            $response = static::xmlToArray($response);
        } else if (static::FORMAT_JSON === $this->output) {
            $response = static::xmlToArray($response);
            $response = json_encode($response, JSON_UNESCAPED_SLASHES);
        }

        return $response;
    }
788835
protected function withStaticHeaders(ResponseInterface $response, array $headers): ResponseInterface
    {
        foreach ($headers as $name => $header) {
            $response = $response->withAddedHeader($name, $header);
        }

        return $response;
    }
237233
private function fromPsrResponse(ResponseInterface $response)
    {
        return new Response(
            $response->getStatusCode(),
            $response->getHeaders(),
            $response->getBody(),
            $response->getProtocolVersion(),
            $response->getReasonPhrase()
        );
    }
271999
public function response($response)
    {
        if (!($response instanceof ResponseInterface)) {
            if (is_array($response) || $response instanceof \stdClass || $response instanceof \JsonSerializable) {
                $response = Response::make(json_encode($response));
                $response = $response->withHeader('Content-Type', 'application/json');
            } elseif (is_object($response) && method_exists($response, 'render')) {
                $response = Response::make($realResponse->render());
            } elseif (is_string($response) || is_numeric($response) || is_bool($response)) {
                $response = Response::make($response);
            } else {
                throw new \InvalidArgumentException(sprintf(
                    'Invalid response "%s"; must be an string or object has render method',
                    gettype($response)
                ));
            }
        }
        return $response;
    }
50690
public function handleResponse($response)
    {
        // recursion for batch
        if (is_array($response)) {
            $response_arr = array();
            foreach ($response as $res) {
                $response_arr[$res->id] = $this->handleResponse($res);
            }
            return $response_arr;
        }

        // return error response
        if (property_exists($response, 'error')) {
            return new Response(null, $response->id, $response->error->code, $response->error->message);
        }

        // return successful response
        return new Response($response->result, $response->id);
    }
672660
protected function modifyResponse(array $response = array())
    {
        if (empty($response['html']))
        {
            if (strtolower($response['type']) == 'photo')
            {
                $html  = '<a href="' . $response['url'] . '" target="_blank">';
                $html .= '<img class="deviantart-oembed" src="' . $response['thumbnail_url_200h'] . '" width="' . $response['thumbnail_width_200h'] . '" height="' . $response['thumbnail_height_200h'] . '" alt="' . htmlspecialchars($response['title'], ENT_QUOTES, 'UTF-8') . '" title="' . htmlspecialchars($response['title'], ENT_QUOTES, 'UTF-8') . '">';
                $html .= '</a>';

                $response['html'] = $html;
            }
        }

        return $response;
    }