PHP code example of branvo / ebranvo-php-sdk

1. Go to this page and download the library: Download branvo/ebranvo-php-sdk 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/ */

    

branvo / ebranvo-php-sdk example snippets


$ebranvo = new \Ebranvo\EbranvoSdk(
    new \Ebranvo\Store('TOKEN AQUI'),
    new \Ebranvo\Environment('live ou sandbox')
);

$response = $ebranvo->addCustomer([
    'type'=> 'PF',
    'name'=> 'Nome do Cliente',
    'document'=> '000.000.000-00',
    'phone'=> '(00) 0000-0000',
    'mail'=> '[email protected]',
    'birthDate'=> '0000-00-00',
    'gender'=> 1,
    'active'=> true,
    'addresses'=> [
        [
            'street'=> 'Rua exemplo',
            'number'=> '0',
            'complement'=> 'Sala 00',
            'district'=> 'Centro',
            'city'=> 'São Paulo',
            'state'=> 'SP',
            'postcode'=> '00000-000',
            'responsibleName'=> 'Nome do Responsável',
            'type'=> 1,
            'active'=> true
        ]
    ]
]);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}



// A presença do id indica que é uma operação de atualização
$response = $ebranvo->addCustomer([
    'id' => 123
    'active' => false
]);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}


$response = $ebranvo->getCustomer($id = 123);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}

$response = $ebranvo->allCustomers($page = 1);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}

$response = $ebranvo->delCustomer($id = 123);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}

$response = $ebranvo->addAddress([
    'idClient' => 123,
    'street'=> 'Rua exemplo',
    'number'=> '0',
    'complement'=> 'Sala 00',
    'district'=> 'Centro',
    'city'=> 'São Paulo',
    'state'=> 'SP',
    'postcode'=> '00000-000',
    'responsibleName'=> 'Nome do Responsável',
    'type'=> 1,
    'active'=> true
]);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}



// A presença do id indica que é uma operação de atualização
$response = $ebranvo->addAddress([
    'id' => 321
    'active' => false
]);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}


$response = $ebranvo->getAddress($id = 321);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}

$response = $ebranvo->allAddresses($idCustomer = 123);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}

$response = $ebranvo->delAddress($id = 321);

if ($response['success']) {
    echo $response['data'];
} else {
    echo $response['errorMessage'];
}