cserepesmark/acounto-api
最新稳定版本:v1.2.0
Composer 安装命令:
composer require cserepesmark/acounto-api
包简介
Laravel package for Acounto Bulk API integration.
README 文档
README
The configuration file config/acounto-api.php contains the following settings:
return [ 'api_key' => env('ACOUNTO_API_KEY', ''), 'base_url' => env('ACOUNTO_ENV', 'dev') === 'prod' ? 'https://bulk.acounto.com/' : 'https://bulk.acounto.dev/', ];
Usage
Initializing the Client You can initialize the API client in your application like this:
use Cserepesmark\AcountoApi\AcountoApiClient; $client = new AcountoApiClient();
Uploading a File
To upload a file, use the upload() method:
$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();
Checking if a Resource Exists
To check if a resource exists by its external ID:
$response = $client->exists()->checkIfExists('example-id-123'); if ($response->json('exists')) { echo "The resource exists!"; } else { echo "The resource does not exist."; }
Querying a Resource by External ID
To query a resource by its external ID:
$response = $client->resourceByExternalId()->getResource('example-id-123'); echo $response->json();
Querying Resources by Dates
To query resources uploaded within a date range:
$response = $client->resourceByDates()->getResourcesByDates([ 'page' => 0, 'size' => 100, 'fromDate' => '2024-01-01', 'toDate' => '2024-12-31', ]); print_r($response->json());
Example Routes
For quick testing, you can add the following routes to your application:
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']);
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-11-28