PHP code example of apihub-cdc / rc-peru-client-simulacion-php

1. Go to this page and download the library: Download apihub-cdc/rc-peru-client-simulacion-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

apihub-cdc / rc-peru-client-simulacion-php example snippets


public function setUp()
{
    $handler = \GuzzleHttp\HandlerStack::create();
    $config = new \rc\simulacion\pe\Client\Configuration();
    $config->setHost('the_url');

    $client = new \GuzzleHttp\Client(['handler' => $handler]);
    $this->apiInstance = new \rc\simulacion\pe\Client\Api\ReporteCreditoPeruSimulacionApi($client, $config);
    $this->x_api_key = "your_api_key";
} 

/**
* Este es el método que se será ejecutado en la prueba ubicado en path/to/repository/test/Api/ApiTest.php
*/
public function testGetRC()
{

    $request = new \rc\simulacion\pe\Client\Model\Peticion();

    $request->setFolio("10000200");
    $request->setNumeroDocumento("67544489");
    $request->setTipoDocumento("1");

    try {
        $result = $this->apiInstance->getRC($this->x_api_key, $request);
        
        if($this->apiInstance->getStatusCode() == 200){
            print_r($result);
        }
    } catch (ApiException $e) {

        if($e->getCode() !== 204){
            echo ' code. Exception when calling ApiTest->getRC: ', $e->getResponseBody(), PHP_EOL;
        }
    }
    $this->assertTrue($this->apiInstance->getStatusCode() == 200);

}
sh
#ejemplo con php en versión 7.3 para otra versión colocar php{version}-curl
apt-get install php7.3-curl
apt-get install php7.3-mbstring