Assert that the response is a valid success response.

@param  mixed $data
@param  int   $status
@return JsonResponse
508979
protected function seeSuccessResponse($data = null, $status = 200):JsonResponse
    {
        $response = app(Responder::class)->success($data, $status);

        $this->seeStatusCode($response->getStatusCode())->seeJson([
            'success' => true,
            'status' => $response->getStatusCode()
        ])->seeJsonStructure(['data']);

        return $response;
    }
818502
public function stop($data = false, $status = null){

        $this->exit = true;

        if ($status) {
           $this->response->status = $status;
        }

        if ($data) {
            $this->response->body = $data;
        }

        if (\is_numeric($data) && isset(self::$statusCodes[$data])) {

            $this->response->status = $data;

            if ($this->response->mime == 'json') {
                $this->response->body = \json_encode(['error' => self::$statusCodes[$data]]);
            } else {
                $this->response->body = self::$statusCodes[$data];
            }
        }

        if ($data || $status) {
            echo $this->response->flush();
        }

        exit;
    }
979472
public function composeJson(array $data = [], int $status = 200, array $config = []): SymfonyResponse
    {
        return Response::make($this->createJsonResponse($data, $config)(), $status, [
            'Content-Type' => 'application/json',
        ]);
    }
279450
public function respondWithData(array $data)
    {

        $responseData = $this->getResponseStructure(true, $data, '');
        $response = new JsonResponse($responseData, $this->getStatusCode(), $this->getHeaders());
        return $response;
    }
427433
protected function returnJson($data, $httpStatus = 200)
    {
        header(HTTPToolkit::statusCodeHeader($httpStatus));
        Context::getInstance()->getResponse()->setContentHeader('application/json');
        $this->response = $this->getPsrResponse()->withBody(stream_for(json_encode($data)));
    }
241917
public function json($status_code, $message, $data = null)
    {
        return response()->json([
                                    'status_code' => $status_code,
                                    'message'     => $message,
                                    'data'        => $data,
                                    'request'     => \request()->all(),
                                ]);
    }
678495
public function response($data, $format, $is_success=true, $status_code = 200)
    {
        $this->httpCode($status_code);
        if ($is_success) {
            $data['status'] = 1;
        } else {
            $data['status'] = 0;
        }
        switch ($format) {
            case self::RESPONSE_TYPE_JSON:
                $response_content = JsonHelper::encode($data);
                break;
            case self::RESPONSE_TYPE_XML:
                header('Content-type:application/xml');
                $response_content = XMLHelper::encode($data);
                break;
            default:
                $response_content = '';
        }
        if (!$is_success) {
            Lb::app()->stop($response_content);
        } else {
            echo $response_content;
        }
    }
1156489
public static function json( $data = array(), $status = 200, $beautify = true ) 
	{
		if ( !is_array( $data ) )
		{
			throw new CCException( "CCResponse::json - first argument has to be an array." );
		}

		$response = new static( CCJson::encode( $data, $beautify ), $status );
		$response->header( 'Content-Type', 'text/json' );

		return $response;
	}
391920
public function setStatus($status)
    {
        $result = \Eix\Services\Net\Http::isStatusCodeValid($status);
        if ($result) {
            $this->status = $status;
        }

        return $result;
    }
432103
public static function print_status($status = 200, $data = [], $options = JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK, $return = false) {
        if (is_numeric($status)) $status_code = $status;
        else if (is_bool($status)) $status_code = $status ? 200 : 400;
        else $status_code = strtolower($status) === 'ok' ? 200 : 400;

        $status_name = self::http_code($status_code);
        self::set_status($status_code);

        if (!is_array($data) && !$data) {
            $data = ['message' => $status_name];
        } else if (is_string($data)) {
            $data = ['message' => $data];
        }

        if ($status_code >= 400 || $status_code < 200) $data['error'] = $status_name;

        $json = json_encode($data, $options);
        if ($return) return $json;
        else echo $json;
    }
587787
protected function checkTransactionStatus($status)
    {
        if ($this->transactionInfo instanceof TransactionResponse) {
            $match = (int) $this->transactionInfo->getTransactionResponseField('ResponseCode') === (int) $status;
        } else {
            $match = (int) $this->transactionResponse->responseCode === $status;
        }
        return $match;
    }
945674
public function toRestResponse(int$status = 200, array $headers = []): RestResponseContract
	{
		return (new Response())->setData($this->toArray())->setStatus($status)->setHeaders($headers);
	}
207121
public function json(array $data, $status = 200, $encodingOptions = 0)
    {
        return $this->response->withJson($data, $status, $encodingOptions);
    }
792069
public function json($data, $status = HttpMessage::HTTP_OK, $encodingOptions = 0)
    {
        $json = json_encode($data, $encodingOptions);
        $this->withStatusCode($status)
            ->withHeader('content-type', 'application/json')
            ->getBody()->write($json);
        return $this;
    }
265010
public function status($status)
  {
    if (is_string($status)) {
      switch ($status) {
        case 'success':
          $this->status = JSendResponse::STATUS_SUCCESS;
          break;
        case 'error':
          $this->status = JSendResponse::STATUS_ERROR;
          break;
        case 'fail':
          $this->status = JSendResponse::STATUS_FAIL;
          break;
        default:
          throw new \InvalidArgumentException("Unable to parse status '${status}'");
      }
    } else {
      $this->status = $status;
    }

    return $this;
  }
77202
public function successResponse($data = null, $statusCode = null, array $meta = []):JsonResponse
    {
        return app(Responder::class)->success($data, $statusCode, $meta);
    }
879981
public function success(string $id, string $message, int $status = 200)
    {
        Log::info($id . ' : ' . $message);

        return response ()->json (['success' => true, 'id' => $id, 'message' => $message], $status);
    }