PHP code example of shufflingpixels / bokio-php

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

    

shufflingpixels / bokio-php example snippets




hufflingpixels\BokioApi\Api;
use Shufflingpixels\BokioApi\Auth;
use Shufflingpixels\BokioApi\Enum\CustomerType;
use Shufflingpixels\BokioApi\Enum\LanguageEnum;
use Shufflingpixels\BokioApi\Exception\ApiException;
use Shufflingpixels\BokioApi\Exception\Exception;
use Shufflingpixels\BokioApi\Objects\Customer;

$api = new Api(new Auth('<company_id>', '<token>'));

try {
    $customer = new Customer([
        'name' => "Created From Api",
        'type' => CustomerType::COMPANY,
        'vatNumber' => "SE1234567890",
        'orgNumber' => "123456-7890",
        'contactsDetails' => [
            [
                'name' => 'Person 1',
                'email' => '[email protected]',
                'phone' => '0739281831',
                'isDefault' => true,
            ],
            [
                'name' => 'Person 2',
            ],
        ],
        "address" => [
            'line1' => 'Älvsborgsvägen 10',
            'city' => 'Göteborg',
            'postalCode' => '123 45',
            'country' => 'SE',
        ],
        'language' => LanguageEnum::SV,
    ]);

    $response = $api->customer()->create($customer);

    print_r($response);
} catch (ApiException $e) {
    print_r($e->getError());
} catch (Exception $e) {
    print_r($e);
}