Get the instance as a json response object.

@param  int    $status
@param  array  $headers
@param  int    $options

@return \Illuminate\Http\JsonResponse
487364
public function toResponse($status = 200, array $headers = [], $options = 0)
    {
        return new JsonResponse($this->transform(), $status, $headers, $options);
    }
127843
private function prepareOptions($body, array $query, array $headers, array $options)
    {
        $options = array_merge($options, [
            RequestOptions::QUERY => $query,
            RequestOptions::HEADERS => $headers,
        ]);

        if (!empty($body) && (is_array($body) || $body instanceof \JsonSerializable)) {
            $options[RequestOptions::JSON] = $body;
        } else {
            $options[RequestOptions::BODY] = $body;
        }

        return $options;
    }
3384
public static function toHeader($headers, $options = [])
    {
        $data = [];
        foreach ($headers as $key => $header) {
            $data[] = $header->to('header', $options);
        }
        return $data ? join(self::EOL, $data) : '';
    }
1146618
public static function toJson($resource, $options = 0) {
        if ($resource instanceof JsonSerializable) {
            // pass-through

        } else if ($resource instanceof Jsonable) {
            return $resource->toJson($options);

        } else if (static::isJson($resource)) {
            return $resource;

        } else if (static::isObject($resource)) {
            $resource = static::buildArray($resource);

        } else if (static::isXml($resource)) {
            $resource = static::xmlToArray(simplexml_load_string($resource));

        } else if (static::isSerialized($resource)) {
            $resource = unserialize($resource);
        }

        return json_encode($resource, $options);
    }
455567
public function request($options)
    {
        $request = $this->getRequest($options);
        $requestOptions = isset($options['query']) ? ['query' => $options['query']] : [];

        // Try to perform request
        try {
            $response = $this->httpClient->send($request, $requestOptions);
        } catch (GuzzleRequestException $err) {
            $hasResponse = $err->hasResponse();
            if (!$hasResponse) {
                // @todo how do we handle, wrap guzzle err
                throw $err;
            }

            $response = $err->getResponse();
            $code = $response->getStatusCode();

            if ($code >= 500) {
                throw new ServerException($response);
            } elseif ($code >= 400) {
                throw new ClientException($response);
            }
        }

        $contentType = $response->getHeader('Content-Type')[0];
        $isJson = stripos($contentType, 'application/json') !== false;
        $rawBody = (string) $response->getBody();
        $body = $isJson ? json_decode($rawBody, true) : $rawBody;

        return $body;
    }
1020891
public function asResponse($input, $status = self::OK, array $header = [])
    {
        return ResponseHelper::fill($this->response, $input, $status, $header);
    }
1309078
public function response($version, $status, $reason, $headers = array(), $body = '')
    {
        return new Response($status, $headers, $this->body($body), $version, $reason);
    }
159773
protected function respond($response, $request, $options, $statusCode)
    {
        if (array_key_exists('webhooks', $response)) {
            $results = [];
            foreach ($response['webhooks'] as $result) {
                $results[] = $this->mapResponse($result, $statusCode);
            }

            return $results;
        }

        // IPN response
        if (in_array(Arr::get($response, 'body'), ['VERIFIED', 'INVALID'])) {
            $response = array_merge($request, $response);
        }
        // charge request
        elseif (array_key_exists('continue_url', $options)) {
            $response['continue_url'] = $options['continue_url'];
            $response['is_redirect'] = true;
        }

        return $this->mapResponse($response, $statusCode);
    }
703163
public function respond(int $statusCode = null, array $headers = []):JsonResponse
    {
        if (! is_null($statusCode)) {
            $this->setStatus($statusCode);
        }

        $data = $this->toArray();
        $data = $this->includeStatusCode($data);
        $data = $this->includeSuccessFlag($data);

        return $this->responseFactory->json($data, $this->statusCode, $headers);
    }
340609
public function refresh($status = 302, $headers = [])
    {
        return $this->to($this->generator->getRequest()->path(), $status, $headers);
    }
1182440
function getResponseHeaders($options = array()){
		$options = array_merge(array(
			"as_hash" => false,
			"lowerize_keys" => false
		),$options);

		$this->fetchContent();

		$out = $this->_ResponseHeaders;

		if($options["as_hash"]){
			$headers = explode("\n",$out);
			$out = array();
			foreach($headers as $h){
				if(preg_match("/^([^ ]+):(.*)/",trim($h),$matches)){
					$key = $options["lowerize_keys"] ? strtolower($matches[1]) : $matches[1];
					$out[$key] = trim($matches[2]);
				}
			}
		}

		return $out;
	}
1100712
protected function createJsonApiResponse(
        ?string $content,
        int $statusCode,
        array $headers = [],
        $addContentType = true
    ) {
        if ($addContentType === true) {
            $headers[self::HEADER_CONTENT_TYPE] = $this->getMediaType()->getMediaType();
        }

        return $this->createResponse($content, $statusCode, $headers);
    }
243608
public function jsonResponseError(array $data = [], $status = 400, $code = 'error', array $headers = [], $options = 0)
    {
        return $this->jsonResponse()->error($data, $status, $code, $headers, $options);
    }
534281
public function withJson($data, $status = null, $encodingOptions = JSON_ENCODE_OPTION)
    {
        return parent::withJson($data, $status, $encodingOptions);
    }
184478
public function getTopRated(array $options = [], array $headers = [])
    {
        return $this->getFactory()->createResultCollection(
            $this->getApi()->getTopRated($options, $headers)
        );
    }
682286
public function get(array $options)
    {
        $options = $this->options($options);

        $response = $this->client->request('GET', $this->api_host.$this->api_prefix, $options);
        $content = $response->getBody()->getContents();

        $content = $this->repair->repair($content);
        $content = $this->detector->detect($content);

        return $content;
    }
992117
public function json($data = [], $status = 200, array $headers = [], $options = false)
    {
        $options = ($options === false) ? JSON_PRETTY_PRINT : $options;

        return new JsonResponse($data, $status, $headers, $options);
    }