PHP code example of apihub-cdc / fico-score-insurance-client-php

1. Go to this page and download the library: Download apihub-cdc/fico-score-insurance-client-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 / fico-score-insurance-client-php example snippets


/**
* Esto es parte del setUp() de las pruebas unitarias.
*/
$password = getenv('KEY_PASSWORD');
$this->signer = new \FicoScoreInsurance\Client\Interceptor\KeyHandler(
    "/example/route/keypair.p12",
    "/example/route/cdc_cert.pem",
    $password
);


public function setUp()
{
    $password = getenv('KEY_PASSWORD');
    $this->signer = new \FicoScoreInsurance\Client\Interceptor\KeyHandler(null, null, $password);     
    $events = new \FicoScoreInsurance\Client\Interceptor\MiddlewareEvents($this->signer);
    $handler = \GuzzleHttp\HandlerStack::create();
    $handler->push($events->add_signature_header('x-signature'));
    $handler->push($events->verify_signature_header('x-signature'));

    $client = new \GuzzleHttp\Client(['handler' => $handler, 'verify' => false]);
    $config = new \FicoScoreInsurance\Client\Configuration();
    $config->setHost('the_url');
    
    $this->apiInstance = new \FicoScoreInsurance\Client\Api\FicoScoreInsuranceApi($client,$config);
}    



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

*/
public function testGetFicoscore()    
{
    $x_api_key = "your_api_key";
    $username = "your_username";
    $password = "your_password";

    $requestPersona = new \FicoScoreInsurance\Client\Model\Persona();
    $requestDomicilio = new \FicoScoreInsurance\Client\Model\Domicilio();

    $requestDomicilio->setDireccion(null);
    $requestDomicilio->setColonia(null);
    $requestDomicilio->setCiudad(null);
    $requestDomicilio->setCodigoPostal(null);
    $requestDomicilio->setMunicipio(null);
    $requestDomicilio->setEstado($requestDomicilio::ESTADO_AGS);
    
    $requestPersona->setPrimerNombre("NOMBRE");
    $requestPersona->setSegundoNombre(null);
    $requestPersona->setApellidoPaterno("PATERNO");
    $requestPersona->setApellidoMaterno("MATERNO");
    $requestPersona->setApellidoAdicional(null);
    $requestPersona->setFechaNacimiento("07-01-1980");
    $requestPersona->setRfc(null);
    $requestPersona->setCurp(null);
    $requestPersona->setDomicilio($requestDomicilio);

    try {
        $result = $this->apiInstance->getFicoscore($x_api_key, $username, $password, $requestPersona);
        print_r($result);
    } catch (Exception $e) {
        echo 'Exception when calling ApiTest->getFicoscore: ', $e->getMessage(), PHP_EOL;
    }        
}
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
sh
export KEY_PASSWORD=your_password
sh
export PRIVATE_KEY_FILE=pri_key.pem
export CERTIFICATE_FILE=certificate.pem
export SUBJECT=/C=MX/ST=MX/L=MX/O=CDC/CN=CDC
export PKCS12_FILE=keypair.p12
export ALIAS=circulo_de_credito