lasserafn / php-ordrestyring
PHP Api 封装 Ordrestyring.dk
0.03
2020-05-15 11:16 UTC
Requires
- guzzlehttp/guzzle: ^6.2
- illuminate/support: ^5.3|^5.4
This package is auto-updated.
Last update: 2024-09-19 21:41:00 UTC
README
REST Api 封装 Ordrestyring v2 API。
它受到 Laravel 的查询构建器和类似工具的启发,并使用流畅的语法。示例
$ordrestyring->cases() ->with('hours', 'type') ->where('status', 1) ->sortDescending() ->sortBy('id') ->perPage(15) ->page(4) ->get();
这将返回一个按 id 降序排序并包含相关小时和类型的 Illuminate/Collection
案例集合,从第 4 页取 15 个结果。
您还可以做类似的事情
$ordrestyring->users()->find(10);
$ordrestyring->debtors()->first();
$ordrestyring->departments()->where('number', '!=', 19)->all();
$ordrestyring->debtors()->where('id', [1,2,3,4])->get(); // Will get debtors with id 1, 2, 3 and/or 4
安装
composer require lasserafn/php-ordrestyring
用法
第一步是联系 Ordrestyring 获取您的 Ordrestyring 帐户的 API 令牌。
$ordrestyring = new LasseRafn\Ordrestyring\Ordrestyring('API-KEY'); $ordrestyring->cases()->get();
您可能想添加一个使用语句
use LasseRafn\Ordrestyring\Ordrestyring;
异常
所有请求异常都将抛出异常,该异常扩展 GuzzleHttp\Exception\ClientException
。返回的异常是 LasseRafn\Ordrestyring\Exceptions\RequestException
,如果存在错误消息,将从 Ordrestyring 获取错误消息,如果不存在,则默认为 ClientException 消息。因此,处理异常可以非常简单,如下所示
try { // try to get something from the api, but nothing is found. } catch( LasseRafn\Ordrestyring\Exceptions\RequestException $exception ) { echo $exception->message; // could redirect back with the message. }
会输出类似于 "此项目不存在" 的内容(根据他们的 API)
支持的端点
- 债务人
- 债务人发票
- 送货地址
- 案例
- 更多即将推出...
测试
测试正在进行中...