miroslavmerinsky / iucto-api-php-sdk
iÚčto PHP SDK库
dev-master
2023-06-06 11:06 UTC
Requires
- php: ^8.1
- ext-json: *
- composer/ca-bundle: ^1.3
- guzzlehttp/guzzle: ^7.7
This package is not auto-updated.
Last update: 2024-09-25 15:48:51 UTC
README
这是https://www.iucto.cz应用的官方PHP SDK库。
文档可在https://iucto.docs.apiary.io找到
库的安装
composer require iucto/iucto-api-php-sdk
使用示例
读取已发出发票的列表
require __DIR__ . '/../vendor/autoload.php'; $iUcto = IUcto\IUctoFactory::create('your-secret-key'); try { $invoiceList = $iUcto->getInvoiceIssued(); foreach ($invoiceList as $invoice) { var_dump($invoice->getId()); } } catch (IUcto\ConnectionException $e) { // handle connection exception } catch (\IUcto\ValidationException $e) { //handle validation exception }
创建联系人
require __DIR__ . '/../vendor/autoload.php'; $iUcto = IUcto\IUctoFactory::create('your-secret-key'); try { $customer = new \IUcto\Command\SaveCustomer(); $customer->setName('Jan Novák'); $customer->setComid('123456'); $customer->setVatid('CZ123456'); $customer->setVatPayer(true); $customer->setPhone('+420123123123'); $customer->setUsualMaturity(14); $customer->setPreferredPaymentMethod('transfer'); $customer->setInvoiceLanguage('cs'); $address = new \IUcto\Dto\Address(); $address->setCountry('CZ'); $address->setStreet('Lanova 52/12'); $address->setCity('Praha'); $address->setPostalcode('21005'); // Přiřazení adresy k zákazníkovi $customer->setAddress($address); $iUcto->createCustomer($customer); } catch (IUcto\ConnectionException $e) { // handle connection exception } catch (\IUcto\ValidationException $e) { //handle validation exception }