PHP code example of vitorccs / alterdata-bimer-php

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

    

vitorccs / alterdata-bimer-php example snippets


$person = Bimer\PersonCharacteristic::all();

$person = Bimer\Person::find($strId);

$customer = Bimer\Customer::create($arrayData);

$person = Bimer\Person::update($strId, $arrayData);

$postalCode = Bimer\PostalCode::getByCode('03943000');
$people = Bimer\Person::getByName('maria', true);
$people = Bimer\Person::getByCpfCnpj('123.456.789-01');

error_reporting(E_ALL);
ini_set('display_errors', 1);

('BIMER_API_ID=client_id');
putenv('BIMER_API_SECRET=client_secret');
putenv('BIMER_API_USER=username');
putenv('BIMER_API_PWD=password');

use Bimer\Exceptions\BimerApiException;
use Bimer\Exceptions\BimerRequestException;

try {
    $characteristics = Bimer\PersonCharacteristic::all();
    print_r($characteristics); // array of objects

    $person = Bimer\Person::find('00A0000SQ4');
    print_r($person); // object

    $person = Bimer\Person::update('00A0000SQ4', [
       'Nome' => 'Nome Completo2',
       'NomeCurto' => 'Nome Curto2'
    ]);
    print_r($person); // object

    $people = Bimer\Person::getByName('NOME', true);
    print_r($people); // array of objects

    $people = Bimer\Person::getByCpfCnpj('123.456.789-01');
    print_r($people); // array of objects

    $customer = Bimer\Customer::create([
        'Identificador' => '',
        'IdentificadorRepresentantePrincipal' => '',
        'Tipo' => 'F',
        'Codigo' => '',
        'CpfCnpj' => '01234567894',
        'DataNascimento' => '1980-04-26T00:00:00:000Z',
        'Nome' => 'Nome Completo',
        'NomeCurto' => 'Nome Curto'
    ]);
    print_r($customer); // object

} catch (BimerApiException $e) { // erros retornados pela API Bimer
    echo sprintf("%s (%s)", $e->getMessage(), $e->getErrorCode());
} catch (BimerRequestException $e) { // erros de servidor (erros HTTP 4xx e 5xx)
    echo sprintf("%s (%s)", $e->getMessage(), $e->getErrorCode());
} catch (\Exception $e) { // demais erros
    echo $e->getMessage();
}
bash
composer