<commit_before><?php

namespace backend\modules\api\controllers;

use yii\rest\Controller;
use yii\httpclient\Client;
use Yii;
/**
 * Default controller for the `api` module
 */
class SynchronizationController extends Controller
{
    
    protected function verbs(){
        return [
            'create' => ['POST'],
            'update' => ['PUT', 'PATCH','POST'],
            'delete' => ['DELETE'],
            'view' => ['GET'],
            'index'=>['GET'],
        ];
    }
    /**
     * Renders the index view for the module
     * @return string
     */
     public function actionIndex()
    {
        return "True";
    }
    public function actionUpdate( )
    {
        $data = Yii::$app->request->getBodyParams();
        if(array_key_exists("start_date", $data) && array_key_exists("end_date", $data)){
            $content = [
            "entity_id" => $data['id'],
            "table_name" => $data['table_name'],
            "start_date" => $data['start_date'],
            "end_date" => $data['end_date'],   
            ];
        }else{
            $content = [
            "entity_id" => $data['id'],
            "table_name" => $data['table_name'],
            ];
        }
        
        $bod = [
            "synchronize" => $content,
        ];
        //$urlSOAP = 'http://192.168.88.212/axis2/services/IvcWebServices.IvcWebServicesHttpEndpoint/synchronize';
        $urlSOAP = "http://private-d4f2fa-ivc.apiary-mock.com/synchronization";
        $client = new Client();
        $response = $client->createRequest()
        ->setFormat(Client::FORMAT_JSON)
        ->setMethod('POST')
        ->setUrl($urlSOAP)
        ->setData($bod)
        ->send();
        /*
        if($response->isOk){
        return $response->getData()["synchronizeResponse"]["return"];
        }
        return $response->getData()["Fault"]["faultstring"];<commit_msg>Restringida la consulta a salud a un solo dia en particular<commit_after><?php

namespace backend\modules\api\controllers;

use yii\rest\Controller;
use yii\httpclient\Client;
use Yii;
/**
 * Default controller for the `api` module
 */
class SynchronizationController extends Controller
{
    
    protected function verbs(){
        return [
            'create' => ['POST'],
            'update' => ['PUT', 'PATCH','POST'],
            'delete' => ['DELETE'],
            'view' => ['GET'],
            'index'=>['GET'],
        ];
    }
    /**
     * Renders the index view for the module
     * @return string
     */
     public function actionIndex()
    {
        return "True";
    }
    public function actionUpdate( )
    {
        $data = Yii::$app->request->getBodyParams();
        if(array_key_exists("consult_date", $data)){
            $content = [
            "entity_id" => $data['id'],
            "table_name" => $data['table_name'],
            "consult_date" => $data['consult_date'],
            
            ];
        }else{
            $content = [
            "entity_id" => $data['id'],
            "table_name" => $data['table_name'],
            ];
        }
        
        $bod = [
            "synchronize" => $content,
        ];
        //$urlSOAP = 'http://192.168.88.212/axis2/services/IvcWebServices.IvcWebServicesHttpEndpoint/synchronize';
        $urlSOAP = "http://private-d4f2fa-ivc.apiary-mock.com/synchronization";
        $client = new Client();
        $response = $client->createRequest()
        ->setFormat(Client::FORMAT_JSON)
        ->setMethod('POST')
        ->setUrl($urlSOAP)
        ->setData($bod)
        ->send();
        /*
        if($response->isOk){
        return $response->getData()["synchronizeResponse"]["return"];
        }
        return $response->getData()["Fault"]["faultstring"];
{'fraction_non_alphanumeric': 0.1676486341724692, 'fraction_numerical': 0.007498660953401178, 'mean_word_length': 1.985611510791367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4042565', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1113, 'n_words': 191}