PHP code example of cserepesmark / acounto-api

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

    

cserepesmark / acounto-api example snippets


return [
    'api_key' => env('ACOUNTO_API_KEY', ''),
    'base_url' => env('ACOUNTO_ENV', 'dev') === 'prod'
        ? 'https://bulk.acounto.com/'
        : 'https://bulk.acounto.dev/',
];

use Cserepesmark\AcountoApi\AcountoApiClient;

$client = new AcountoApiClient();

$fileContent = Storage::disk('local')->get($filePath);
$fileName = basename($filePath);

$response = $client->upload()->uploadFile($fileContent, $fileName, [
    'resourceType' => 'expense',
    'externalId' => 'example-id-123',
    'description' => 'Example description',
    'invoiceNumber' => 'AB-2024-01',
]);

echo $response->json();

$response = $client->exists()->checkIfExists('example-id-123');

if ($response->json('exists')) {
    echo "The resource exists!";
} else {
    echo "The resource does not exist.";
}

$response = $client->resourceByExternalId()->getResource('example-id-123');

echo $response->json();

$response = $client->resourceByDates()->getResourcesByDates([
    'page' => 0,
    'size' => 100,
    'fromDate' => '2024-01-01',
    'toDate' => '2024-12-31',
]);

print_r($response->json());

use Cserepesmark\AcountoApi\Http\Controllers\AcountoApiTestController;

Route::get('/acounto/upload', [AcountoApiTestController::class, 'uploadExample']);
Route::get('/acounto/exists', [AcountoApiTestController::class, 'existsExample']);
Route::get('/acounto/resource', [AcountoApiTestController::class, 'resourceExample']);