traimmu / mf-cloud-invoice
MFCloud Invoice API 封装器
v0.0.9
2018-04-02 05:36 UTC
Requires
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ^5.5
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is not auto-updated.
Last update: 2024-09-29 09:56:51 UTC
README
mf_cloud-invoice-php
MFクラウド請求書API 的 PHP 客户端库
此库受 moneyforward/mf_cloud-invoice-ruby 启发
安装
composer require traimmu/mf-cloud-invoice
使用方法
构建客户端
use Traimmu\MfCloud\Invoice\Client; $client = new Client('YOUR_ACCESS_TOKEN'); $client->billings()->all(); // => your billings
获取 My Office
$office = $client->office(); // => returns Traimmu\MfCloud\Invoice\Models\Office instance echo $office->name; // => '株式会社Traimmu' $office->update([ 'name' => 'section9', 'zip' => '101-1111', ]); echo $office->name; // => 'section9'
获取合作伙伴
$client->partners()->all(); $client->partners()->find('MF INVOICE PARTNER ID');
获取账单
$client->billings()->all();
项目
$client->items()->all();
Laravel 集成
将 Traimmu\MfCloud\Invoice\Misc\ServiceProvider 提供者添加到 config/app.php 中的 providers 数组
'providers' => [ // ... Traimmu\MfCloud\Invoice\Misc\ServiceProvider::class, ],
然后添加外观到你的 aliases 数组
'aliases' => [ // ... 'Invoice' => Traimmu\MfCloud\Invoice\Misc\Facade::class, ],
最后,在 config/services.php 中添加以下行
// ... 'mfcloud' => [ 'secret' => env('MFCLOUD_INVOICE_API_TOKEN'), ],
示例
获取拥有一个以上部门的合作伙伴
<?php $client->partners()->all()->filter(function ($partner) { return count($partner->departments) > 0; });
加载图
- 添加测试
- 客户端
- API
- 模型
- 为 Laravel 添加服务提供者
- 添加 Eloquent 模型方法和关系
- api->firstOrCreate()
- 创建部门模型
-
$client->partners()->first()->departments()->create($params) -
$client->partners()->first()->departments->first() - 合作伙伴与部门多对多关系
- 部门与账单多对多关系
- 账单与项目多对多关系
- 添加异常
- 添加 circle.yml 并自动构建
- 添加更多文档
- 添加获取 OAuth 令牌的认证
开发
检出仓库后,运行 composer install 以安装依赖项。
然后运行 vendor/bin/phpunit 并确保所有测试通过。
贡献
欢迎在 GitHub 上提交错误报告和 pull requests:https://github.com/Traimmu/mf_cloud-invoice-php
许可
此包根据 MIT 许可 条款提供开源。