Create a response to request the OTP.

@return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
14850
public function makeRequestOneTimePasswordResponse()
    {
        event(
            app()->version() < '5.4'
                ? new OneTimePasswordRequested53($this->getUser())
                : new OneTimePasswordRequested($this->getUser())
        );

        $expectJson = app()->version() < '5.4'
            ? $this->getRequest()->wantsJson()
            : $this->getRequest()->expectsJson();

        return $expectJson
            ? $this->makeJsonResponse($this->makeStatusCode())
            : $this->makeHtmlResponse($this->makeStatusCode());
    }
602794
protected function response()
	{
		if (!isset($this->response)) {
			$this->response = Response::make();
		}
		
		return $this->response;
	}
902153
protected function postRequest()
    {
        $response = $this->client->post($this->buildUrl(),
            [
                'auth'    => $this->getAuth(),
                'json'    => $this->getBody(),
                'headers' => [
                    'Accept' => 'application/json',
                ],
            ]);

        if ($response->getStatusCode() != 201 && $response->getStatusCode() != 200) {
            throw new \Exception('Unable to request from API. HTTP Error: '.$response->getStatusCode());
        }

        return $response;
    }
822171
protected function createResponseBuilder()
	{
		try
		{
			$body = $this->streamFactory->createStream(fopen('php://temp', 'w+'));
		}
		catch (\InvalidArgumentException $e)
		{
			throw new \RuntimeException('Can not create "php://temp" stream.');
		}

		$response = $this->messageFactory->createResponse(200, null, [], $body);

		return new ResponseBuilder($response);
	}
522728
public function send()
    {
        try {
            return $this->sendData($this->getData());
        } catch (GoCardlessProException $e) {
            if ($e->getMessage() == 'Rate limit exceeded') {
                sleep($this->sleepTimeout);
                try {
                    return $this->sendData($this->getData());
                } catch (GoCardlessProException $f) {
                    $e = $f;
                }
            }
            $response = new ErrorResponse($this, $e);

            return $response;
        } catch (\Exception $e) {
            $response = new ErrorResponse($this, $e);

            return $response;
        }
    }
1339102
public function readResponse()
    {
        list($response, $status) = $this->call->wait();
        if ($status->code == Code::OK) {
            return $response;
        } else {
            throw ApiException::createFromStdClass($status);
        }
    }
215701
public function toResponseJSON()
    {
        // successful response
        $arr = array('jsonrpc' => self::JSON_RPC_VERSION);
        if ($this->result !== null) {
            $arr['result'] = $this->result;
            $arr['id'] = $this->id;
            return json_encode($arr);
        // error response
        } else {
            $arr['error'] = array('code' => $this->error_code, 'message' => $this->error_message);
            $arr['id'] = $this->id;
            return json_encode($arr);
        }
    }
550070
protected function sendRequest()
    {
        $context = stream_context_create($this->request);
        $response = trim(file_get_contents($this->endpoint, FALSE, $context));
        $this->response = new Response($http_response_header, $response, $this->request);

        return $this->response;
    }
353820
public function request()
    {
        $reqUrl = sprintf('%s?APIKEY=%s', self::END_POINT_URL, rawurlencode($this->apikey));
        $reqBody = json_encode($this->getParameter()->makeParameter());

        $curl = new Curl();
        $curl->setHeader('Content-Type', 'application/json; charset=UTF-8');
        $ret = $curl->post($reqUrl, $reqBody);
        if ($curl->error) {
            trigger_error('docomo dialogue: Error ' . $curl->errorCode . ': ' . $curl->errorMessage, E_USER_WARNING);
            return false;
        }
        return new Response($ret);
    }
1229063
public function response()
    {
        return new MultiErrorResponse($this->httpStatusCode, $this->code, $this->message, $this->validationMessages);
    }
1240773
public function toResponse(): Response
    {
        return new Response(
            $this->status,
            $this->headers,
            $this->body,
            $this->httpVersion,
            $this->reason
        );
    }
1249421
public function api_respond() {
		// Is a data response type not defined or not available?
		if ( !isset($this->response->type) || !array_key_exists($this->response->type, $this->config['rest']['mime_types']) ) {
			// Use a short-style ternary (PHP 5.3) to either grab the default or use this hard-coded default
			$this->response->type = $this->config['rest']['defaults']['data_type'] ?: 'json';
		}

		// Set our data response header
		$this->response->header( 'Content-Type', $this->config['rest']['mime_types'][$this->response->type] );

		// Set our allowed methods response header
		if ( !is_null( $this->response->possible_methods ) ) {
			$this->response->header( 'Allow', implode( ', ', $this->response->possible_methods ) );
		}

		// Send our access control headers
		$this->response->header( 'Access-Control-Allow-Headers', $this->config['rest']['http_access_control']['allow_headers']);
		$this->response->header( 'Access-Control-Allow-Methods', $this->config['rest']['http_access_control']['allow_methods']);
		$this->response->header( 'Access-Control-Allow-Origin', $this->config['rest']['http_access_control']['allow_origin']);

		// Let's build our response data
		$response_data = new stdClass();
		$response_data->meta = (object) array(
			'status_code' => (int) $this->response->code(),
			'status' => (string) $this->get_status(),
			'message' => (string) $this->response->message ?: (string) null,
			'more_info' => $this->response->more_info ?: (object) null,
		);
		$response_data->data = $this->response->data ?: (object) null;

		// Only add paging data if it exists
		if ( isset($this->response->paging) ) {
			$response_data->paging = $this->response->paging;
		}

		// If global template processing is turned on
		if ( $this->config['template']['global_template_processing'] ) {
			// If we only want to process our returned "data"
			if ( $this->config['template']['only_process_returned_data'] ) {
				// Set our data to be processed as the "data" property of our response data
				$raw_data = &$response_data->data;
			}
			else {
				// Otherwise, set our raw data as our entire response data object
				$raw_data = &$response_data;
			}

			// Process our data for templating
			$raw_data = $this->process_template( $raw_data );
		}

		// Let's encode our response based on our set type
		if ( $this->response->type == 'json' ) {
			$this->response->json( $response_data );
		}
		elseif ( $this->response->type == 'jsonp' ) {
			$this->response->json( $response_data, $this->config['rest']['defaults']['jsonp_padding'] ?: 'callback' );
		}
		// If all else fails, just var_dump
		else {
			var_dump( $response_data );
		}

		// Finally, should we include our execution time header?
		if ( defined( 'PAULUS_ALLOW_BENCHMARK_HEADER' ) === true ) {
			// If our benchmark header is set to true
			if ( $this->request->header( PAULUS_BENCHMARK_HEADER_NAME, false ) ) {
				// Set our benchmark header to the time difference between the app start and now
				$this->response->header(
					PAULUS_BENCHMARK_HEADER_NAME,
					( microtime( true) - PAULUS_START_TIME )
				);
			}
		}
		// If its been flagged to always show
		elseif ( defined( 'PAULUS_BENCHMARK_ALWAYS' ) === true ) {
			// Set our benchmark header to the time difference between the app start and now
			$this->response->header(
				PAULUS_BENCHMARK_HEADER_NAME,
				( microtime( true) - PAULUS_START_TIME )
			);
		}

		// We need to EXIT here, since we want this to be our last output
		// ... but be able to turn it off...
		if ( isset( $this->config['rest']['exit_after_rest_response'] ) && $this->config['rest']['exit_after_rest_response'] ) {
			exit;
		}
	}
1132932
public function getResponse()
	{
	    $id = 'response';
	    if (!$this->has($id)) {
	        $this->set($id, function () {
	            return new Response();
	        });
	    }
	    return $this->get($id);
	}
1342403
public function make()
    {
        $this->image->encode($this->format, $this->quality);
        $data = $this->image->getEncoded();

        $mime = MimeType::getMimeTypeByContent($data);
        $length = \strlen($data);

        return Factory::response(200, $data, [
            'Content-Type' => $mime,
            'Content-Length' => $length,
        ]);
    }
810494
public function createRequest()
    {
        return $this->getHttpClient()
            ->createRequest()
            ->addOptions($this->defaultRequestOptions())
            ->addOptions($this->getRequestOptions());
    }
569889
public function query()
    {
        $sourceUUID = $this->getSourceUUID();
        if (empty($sourceUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Source UUID header must be defined',
            ], 400);
        }

        $authorUUID = $this
            ->userCredentialsProvider
            ->getUUID();

        $queryParameterBag = $this
            ->request
            ->query;

        $page = (int) $queryParameterBag->get('page', 1);
        $numPerPage = (int) $queryParameterBag->get('num_per_page', 10);
        $sortBy = json_decode($queryParameterBag->get(
            'sort_by',
            ['created_at' => 'desc']
        ), true);
        $indexedMetadataSortBy = [
            'indexed_metadata.' . key($sortBy) => $sortBy[key($sortBy)],
        ];

        $role = $this->userCredentialsProvider->isModerator()
            ? Author::ROLE_MODERATOR
            : Author::ROLE_USER;

        $result = $this
            ->commentRepository
            ->getCommentsBySource(
                $sourceUUID,
                $page,
                $numPerPage,
                $indexedMetadataSortBy,
                $role
            );

        if (!empty($authorUUID)) {
            foreach ($result->getComments() as $comment) {
                $this->setEditableInComment(
                    $comment,
                    $authorUUID
                );
            }
        }
        
        return new JsonResponse([
            'comments_result' => $result->toArray(),
            'user' => $this->userCredentialsProvider->toArray(),
        ], 200);
    }
303244
public function createJsMessages()
    {
        $contents = $this->getMessagesJson();

        return response($contents)
            ->header('Content-Type', 'text/javascript')
            ->setLastModified(MessageCachingService::getLastRefreshTimestamp());
    }