<commit_before><?php
namespace frontend\controllers;

use Yii;
use yii\web\Controller;
use yii\helpers\Json;
use frontend\models\Restget;
use frontend\modules\Payqr\models\Button;
use frontend\modules\Payqr\models\Market;

class ApiController extends Controller
{
    public $market;
    
    public function actionView()
    {
        $this->_checkAuth();

        //Yii::$app->request->get("user_id")
        
//        if(empty($pasport))
//            $this->_sendResponse(404, "No Item found with id " . Yii::$app->request->get("user_id"));
//        else
//            $this->_sendResponse(200, Json::encode($pasport));
        
        $this->_sendResponse(200, Json::encode(["data" => "List OK"]));

        Yii::$app->end();
    }
    
    public function actionGet()
    {
        $param = array();
                
        $this->_checkAuth();
        
        $typeResource = \Yii::$app->request->get("type");
        
        if(strtolower($typeResource) == "button")
        {
            $param["button"]["place"] = \Yii::$app->request->get("place") ? \Yii::$app->request->get("place") : "cart";
        }
        
        $callback = \Yii::$app->request->get("callback");
        
        $sendData = Restget::getResource($typeResource, $this->market, $param);
        
        if(is_array($sendData))
        {
            $this->_sendResponse(200, $callback . "(" . Json::encode($sendData) . ")" );
        }
        else
        {
            $this->_sendResponse(200, $callback . "(" . Json::encode(["data" => $sendData]) . ")" );
        }
    }
    
    private function _sendResponse($status = 200, $body = '', $content_type = 'text/html; charset=utf-8')
    {
        // set the status
        $status_header = 'HTTP/1.1 ' . $status . ' ' . $this->_getStatusCodeMessage($status);
        header($status_header);
        // and the content type
        header('Content-type: ' . $content_type);

        // pages with body are easy
        if($body != '')
        {
            // send the body
            echo $body;
        }
        // we need to create the body if none is passed
        else
        {
            // create some body messages
            $message = '';<commit_msg>Api v1.5<commit_after><?php
namespace frontend\controllers;

use Yii;
use yii\web\Controller;
use yii\helpers\Json;
use frontend\models\Restget;
use frontend\modules\Payqr\models\Button;
use frontend\modules\Payqr\models\Market;

class ApiController extends Controller
{
    public $market;
    
    public function actionView()
    {
        $this->_checkAuth();

        //Yii::$app->request->get("user_id")
        
//        if(empty($pasport))
//            $this->_sendResponse(404, "No Item found with id " . Yii::$app->request->get("user_id"));
//        else
//            $this->_sendResponse(200, Json::encode($pasport));
        
        $this->_sendResponse(200, Json::encode(["data" => "List OK"]));

        Yii::$app->end();
    }
    
    public function actionGet()
    {
        $param = array();
                
        $this->_checkAuth();
        
        $typeResource = \Yii::$app->request->get("type");
        
        if(strtolower($typeResource) == "button")
        {
            $param["button"]["place"] = \Yii::$app->request->get("place") ? \Yii::$app->request->get("place") : "cart";
        }
        
        $callback = \Yii::$app->request->get("callback");
        
        $sendData = Restget::getResource($typeResource, $this->market, $param);
        
        if(is_array($sendData))
        {
            $this->_sendResponse(200, $callback . "(" . Json::encode(["data" => $sendData]) . ")" );
        }
        else
        {
            $this->_sendResponse(200, $callback . "(" . Json::encode(["data" => $sendData]) . ")" );
        }
    }
    
    private function _sendResponse($status = 200, $body = '', $content_type = 'text/html; charset=utf-8')
    {
        // set the status
        $status_header = 'HTTP/1.1 ' . $status . ' ' . $this->_getStatusCodeMessage($status);
        header($status_header);
        // and the content type
        header('Content-type: ' . $content_type);

        // pages with body are easy
        if($body != '')
        {
            // send the body
            echo $body;
        }
        // we need to create the body if none is passed
        else
        {
            // create some body messages
            $message = '';
{'fraction_non_alphanumeric': 0.17054438671786762, 'fraction_numerical': 0.009939010616670432, 'mean_word_length': 1.903606557377049, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6945077', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1327, 'n_words': 242}