Please enable JS

Examples

Create Customer & Supplier

Name
Tax Number
Type

Source Code

<?php

require_once '../vendor/autoload.php';

use Swagger\Client\Api\AccountApi;
use Swagger\Client\Model\Account;
use Swagger\Client\ApiException;

// PARAMETERS
$name       = clear('name');
$vat_number = clear('vat_number');
$type       = clear('type');

// RECORD
$account = new Account();
$account->setName($name);
$account->setVatNumber($vat_number);
$account->setType($type);

// E2E ACCESS KEYS
$client = new GuzzleHttp\Client([
    'headers' => [
        'api_key' => 'JHSV2V6KyqcbxvMHshRlPfunJymVt7GDfXyoK229o=',
        'company_key' => 'E2ELIVE',
    ]
]);

try {
    
    // CREATE ACCOUNT
    $api = new AccountApi($client);
    $result = $api->accountCreate($account);
    
    header('Content-Type: application/json; charset=utf-8');
    echo $result->__toString();
    
} catch (Exception $e) {
    
    http_response_code($e->getCode());
    
    $msg = $e instanceof ApiException ? $e->getResponseBody() : $e->getMessage();
    
    if (!empty($msg)) {
        echo $msg;
    }
}

function clear($field)
{
    return empty($_REQUEST[$field]) ? null : $_REQUEST[$field];
}