clicksports/lex-office-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

clicksports/lex-office-api

最新稳定版本:1.6.0

Composer 安装命令:

composer require clicksports/lex-office-api

包简介

Simple API Integration for Lexoffice

README 文档

README

tests test coverage type coverage Latest Stable Version License

Requirements

PHP: >= 8.1 Extensions:

Install

composer: composer require sysix/lex-office-api

Usage

Search for the official API Documentation. You need an API Key for that.

Basic

// store keys in .env file
$apiKey = getenv('LEXOFFICE_API_KEY');

// in this example we are using guzzlehttp/guzzle package, it can be any PSR-18 HTTP Client
// see: https://packagist.org/providers/psr/http-client-implementation
$httpClient = \GuzzleHttp\Client();
$api = new \Sysix\LexOffice\Api($apiKey, $httpClient);

Optimize your HTTP Client

This library only prepares the \Psr\Http\Message\RequestInterface for the HTTP Client and returns its Response. There are almost no error checks, no caching and no rate limiting. Your PSR-18 HTTP Client should come with a way to deal with it.

Here is a example with guzzlehttp/guzzle , kevinrob/guzzle-cache-middleware and spatie/guzzle-rate-limiter-middleware:

$apiKey = getenv('LEXOFFICE_API_KEY');

$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(new \Kevinrob\GuzzleCache\CacheMiddleware(), 'cache');
$stack->push(\Spatie\GuzzleRateLimiterMiddleware\RateLimiterMiddleware::perSecond(2));

$httpClient = \GuzzleHttp\Client(['handler' => $stack]);
$api = new \Sysix\LexOffice\Api($apiKey, $httpClient);

Endpoints

Article Endpoint

/** @var \Sysix\LexOffice\Api $api */
$client = $api->article();

// filters
$client->size = 100;
$client->sortDirection = 'DESC';

$client->articleNumber = 'LXW-BUHA-2024-001';
$client->gtin = '9783648170632';
$client->type = 'PRODUCT';


// get a page
$response = $client->getPage(0);

// other methods
$response = $client->get($entityId);
$response = $client->create($data);
$response = $client->update($entityId, $data);
$response = $client->delete($entityId);

Contact Endpoint

$client = $api->contact();

// filters
$client->size = 100;
$client->email = 'john.doe@example.com';
$client->name = 'John Doe';
$client->number = 123456;
$client->customer = true;
$client->vendor = false;

// get a page
$response = $client->getPage(0);

// other methods
$response = $client->get($entityId);
$response = $client->create($data);
$response = $client->update($entityId, $data);

Country Endpoint

$response = $api->country()->getAll();

Credit Notes Endpoint

$voucherList = $api->creditNote()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->creditNote()->get($entityId);
$response = $api->creditNote()->create($data);
$response = $api->creditNote()->create($data, true); // finalized
$response = $api->creditNote()->pursue($precedingSalesVoucherId, $data);
$response = $api->creditNote()->pursue($precedingSalesVoucherId, $data, true); // finalized
$response = $api->creditNote()->file($entityId); // get file content
$response = $api->creditNote()->file($entityId, 'application/xml'); // as XRechnung

// deprecated methods:
$response = $api->creditNote()->document($entityId); // get document ID
$response = $api->creditNote()->document($entityId, true); // get file content
$response = $api->creditNote()->document($entityId, true, 'application/xml'); // as XRechnung

Deliverys Notes Endpoint

$voucherList = $api->deliveryNote()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->deliveryNote()->get($entityId);
$response = $api->deliveryNote()->create($data);
$response = $api->deliveryNote()->pursue($precedingSalesVoucherId, $data);
$response = $api->deliveryNote()->file($entityId); // get file content

// deprecated methods:
$response = $api->deliveryNote()->document($entityId); // get document ID
$response = $api->deliveryNote()->document($entityId, true); // get file content

Down Payment Invoices Endpoint

$voucherList = $api->downPaymentInvoice()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->downPaymentInvoice()->get($entityId);
$response = $api->downPaymentInvoice()->create($data);
$response = $api->downPaymentInvoice()->file($entityId); // get file content
$response = $api->downPaymentInvoice()->file($entityId, 'application/xml'); // as XRechnung

// deprecated methods:
$response = $api->downPaymentInvoice()->document($entityId); // get document ID
$response = $api->downPaymentInvoice()->document($entityId, true); // get file content
$response = $api->downPaymentInvoice()->document($entityId, true, 'application/xml'); // as XRechnung

Dunnings Endpoint

$response = $api->dunning()->get($entityId);
$response = $api->dunning()->pursue($precedingSalesVoucherId, $data);
$response = $api->dunning()->file($entityId); // get file content

// deprecated methods:
$response = $api->dunning()->document($entityId); // get document ID
$response = $api->dunning()->document($entityId, true); // get file content

Event Subscriptions Endpooint

$response = $api->event()->get($entityId);
$response = $api->event()->create($data);
$response = $api->event()->delete($entityId);
$response = $api->event()->getAll();

File Endpoint

$response = $api->file()->upload($filePath, $voucherType);
$response = $api->file()->get($entityId); // accept every file
$response = $api->file()->get($entityId, 'image/*'); // accept only images
$response = $api->file()->get($entityId, 'application/xml'); // get XRechung XML File (if possible)

Invoices Endpoint

$voucherList = $api->invoice()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->invoice()->get($entityId);
$response = $api->invoice()->create($data);
$response = $api->invoice()->create($data, true); // finalized
$response = $api->invoice()->pursue($precedingSalesVoucherId, $data);
$response = $api->invoice()->pursue($precedingSalesVoucherId, $data, true); // finalized
$response = $api->invoice()->file($entityId); // get file content
$response = $api->invoice()->file($entityId, 'application/xml'); // as XRechnung

// deprecated methods:
$response = $api->invoice()->document($entityId); // get document ID
$response = $api->invoice()->document($entityId, true); // get file content
$response = $api->invoice()->document($entityId, true, 'application/xml'); // as XRechung XML File

Order Confirmation Endpoint

$voucherList = $api->orderConfirmation()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->orderConfirmation()->get($entityId);
$response = $api->orderConfirmation()->create($data);
$response = $api->orderConfirmation()->pursue($precedingSalesVoucherId, $data);
$response = $api->orderConfirmation()->file($entityId); // get file content

// deprecated methods:
$response = $api->orderConfirmation()->document($entityId); // get document ID
$response = $api->orderConfirmation()->document($entityId, true); // get file content

Payment Endpoint

$response = $api->payment()->get($entityId);

Payment Conditions Endpoint

$response = $api->paymentCondition()->getAll();

Posting Categories Endpoint

$response = $api->postingCategory()->getAll();

Print Layouts Endpoint

$response = $api->printLayout()->getAll();

Profile Endpoint

$response = $api->profile()->get();

Quotation Endpoint

$voucherList = $api->quotation()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->quotation()->get($entityId);
$response = $api->quotation()->create($data);
$response = $api->quotation()->create($data, true); // finalized
$response = $api->quotation()->file($entityId); // get file content

// deprecated methods:
$response = $api->quotation()->document($entityId); // get document ID
$response = $api->quotation()->document($entityId, true); // get file content

Recurring Templates Endpoint

$client = $api->recurringTemplate();

// filters
$client->size = 100;
$client->sortDirection = 'DESC';
$client->sortColumn = 'updatedDate';

// get a page
$response = $client->getPage(0);

// other methods
$response = $api->recurringTemplate()->get($entityId);

Voucher Endpoint

$response = $api->voucher()->get($entityId);
$response = $api->voucher()->create($data);
$response = $api->voucher()->update($entityId, $data);
$response = $api->voucher()->upload($entitiyId, $filepath);

Voucherlist Endpoint

$client = $api->voucherlist();

$client->size = 100;
$client->sortDirection = 'DESC';
$client->sortColumn = 'voucherNumber';

// filters required
$client->types = [
    'salesinvoice',
    'salescreditnote',
    'purchaseinvoice',
    'purchasecreditnote',
    'invoice',
    'downpaymentinvoice',
    'creditnote',
    'orderconfirmation',
    'quotation'
];
$client->statuses = [
    'draft',
    'open',
    'paid',
    'paidoff',
    'voided',
    //'overdue', overdue can only be fetched alone
    'accepted',
    'rejected'
];

// filters optional
$client->archived = true;
$client->contactId = 'some-uuid-string';
$client->voucherDateFrom = new \DateTime('2023-12-01');
$client->voucherDateTo = new \DateTime('2023-12-01');
$client->createdDateFrom = new \DateTime('2023-12-01');;
$client->createdDateTo = new \DateTime('2023-12-01');
$client->updatedDateFrom = new \DateTime('2023-12-01');
$client->updatedDateTo = new \DateTime('2023-12-01');

// get a page
$response = $client->getPage(0);

Utils

get JSON from Success and Error Response

// can be possible null because the response body can be empty
$json = \Sysix\LexOffice\Utils::getJsonFromResponse($response); // as object
$json = \Sysix\LexOffice\Utils::getJsonFromResponse($response, true); // as associative array

clicksports/lex-office-api 适用场景与选型建议

clicksports/lex-office-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49.06k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2020 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rest」 「api」 「lex-office」 「lexoffice」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 clicksports/lex-office-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 clicksports/lex-office-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 clicksports/lex-office-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 49.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 4
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-01