PHP code example of jeidison / serpro-php

1. Go to this page and download the library: Download jeidison/serpro-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/ */

    

jeidison / serpro-php example snippets


...
use Jeidison\SerproPHP\CpfConsultation\ConsultCpfParameter;
use Jeidison\SerproPHP\SerproPHP;

$parameter = ConsultCpfParameter::new();
$parameter->setConsumerKey('SUA CONSUMER KEY');
$parameter->setConsumeSecret('SUA CONSUMER SECRET');
$parameter->setCpf('40442820135');
$response = SerproPHP::new()->consultCpf($parameter);

// métodos disponíveis
$response->getResult();
$response->isSuccess();
$response->toJson();
$response->toArray();
$response->toObject();

...
use Jeidison\SerproPHP\SerproPHP;
use Jeidison\SerproPHP\DataValid\Address;
use Jeidison\SerproPHP\DataValid\Affiliation;
use Jeidison\SerproPHP\DataValid\CNH;
use Jeidison\SerproPHP\DataValid\DataValidParameter;
use Jeidison\SerproPHP\DataValid\Document;

$cnh = CNH::new()
        ->setFirstCnhDate('9999-99-05')
        ->setCategory('AB')
        ->setExpirationDate('9999-99-99')
        ->setLastEmissionDate('9999-99-99')
        ->setNumber('9999')
        ->setNumberForeign('1')
        ->setSituationCode('1');

    $affiliation = Affiliation::new()
        ->setFatherName('XXXX XXXX XXXX')
        ->setMotherName('XXXX XXXX XXXX');

    $address = Address::new()
        ->setNumber('999')
        ->setAddress('XXX XXX XXX')
        ->setCity('XXXX')
        ->setNeighborhood('XXXXX')
        ->setUf('SP')
        ->setZipCode('999999');

    $document = Document::new()
        ->setNumber('9999999')
        ->setDispatchingBody('SSP')
        ->setDispatchingUf('SP')
        ->setType('1');

    $parameter = DataValidParameter::new()
        ->setConsumerKey('SUA CONSUMER KEY')
        ->setConsumeSecret('SUA CONSUMER SECRET')
        ->setCnh($cnh)
        ->setAffiliation($affiliation)
        ->setAddress($address)
        ->setDocument($document)
        ->setName('xxxx xxxx xxxx')
        ->setCpf('111')
        ->setBirthDate('9999-99-99')
        ->setSex('M')
        ->setCpfSituation('regular')
        ->setNationality('1');

    $response = SerproPHP::new()->dateValidate($parameter);
    echo $response->toJson();
bash
$ composer