trevweb/cin7-core-api-v2-client
最新稳定版本:v1.0.1
Composer 安装命令:
composer require trevweb/cin7-core-api-v2-client
包简介
A Cin7 Core API V2 Client for PHP
README 文档
README
A PHP client for interacting with the Cin7 Core (formerly DEAR Inventory) API V2.
Installation
composer require trevweb/cin7-core-api-v2-client:^1.0
Usage
Initialise the client
$accountId = 'your_account_id'; $applicationKey = 'your_application_key'; $client = new Cin7CoreApiV2Client($accountId, $applicationKey);
Get a specific product
try { $product = $client->get(Cin7CoreEndpoints::PRODUCT, ['Name' => 'Big Tyre']); print_r($product); } catch (Exception $e) { // Handle exception echo "Error fetching product: " . $e->getMessage(); }
Create a sale
try { $saleData = [ "CustomerID" => "guid-of-customer", "TaxRule" => "Tax on Sales", "Location" => "Main Warehouse", // ... other required fields ]; $response = $client->post('sale', $saleData); echo "Created Sale ID: " . $response['ID']; } catch (Exception $e) { echo "Error creating sale: " . $e->getMessage(); }
Fetch all products (pagination)
try { $products = $client->fetchAll(Cin7CoreEndpoints::PRODUCT, 'Products'); foreach ($products as $product) { print_r($product); } } catch (Exception $e) { echo "Error fetching products: " . $e->getMessage(); }
Examples
See the examples directory for more usage examples. Place a file in the examples directory named 'cin7-example-api-credentials.php' with the following contents:
<?php DEFINE('CIN7_ACCOUNT_ID', 'your-id-here'); DEFINE('CIN7_APPLICATION_KEY', 'your-key-here');
Testing
This package uses PHPUnit for testing. To run the tests, first ensure you have installed the development dependencies:
composer install
Then, run the tests using the following command:
./vendor/bin/phpunit
The tests use a mocked version of the client to avoid making actual API calls.
License
This project is licensed under the MIT License - see the LICENSE file for details.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-21