tiloweb / matpe-bundle
该包的最新版本(dev-master)没有可用的许可证信息。
将自动化API集成作为Symfony服务
dev-master
2018-02-16 13:06 UTC
Requires
- php: >=5.3.3
- symfony/cache: ^3.2
- symfony/framework-bundle: >=3.1
This package is auto-updated.
Last update: 2024-09-16 02:11:40 UTC
README
此Bundle将MaTPE API v1集成为Symfony服务。
要求
- cURL
- Symfony >= 3.1
安装
步骤1:下载Bundle
打开命令行,进入项目目录,并执行以下命令以下载此Bundle的最新稳定版本
$ composer require tiloweb/matpe-bundle "dev-master"
此命令需要您已全局安装Composer,具体请参考Composer文档的安装章节。
步骤2:启用Bundle
然后,通过将其添加到项目app/AppKernel.php
文件中注册的Bundle列表中来启用此Bundle。
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Tiloweb\MaTPEBundle\MaTPEBundle(), ); // ... } // ... }
步骤3:配置Symfony
# app/config/config.yml ma_tpe: login: "yourLoginAPI" key: "yourAPIkey" firm: "yourFirmID"
步骤4:享受吧!
现在您可以从Controller或Symfony的任何地方通过matpe
服务访问API。
文档
列出所有客户
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->listCustomers()); }
创建客户
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->createCustomer(array( 'last_name' => 'Doe', // Required 'first_name' => 'John', // Required 'email' => 'fakemail@test.com', 'country' => 'fr' // Required ))); }
获取客户信息
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->getCustomer(13423); }
更新客户信息
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->updateCustomer(13423, array( 'name' => 'New name', 'email' => 'anotheremail@test.com' ))); }
列出所有发票
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->listInvoices()); }
列出客户的发票
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->listInvoices(12345)); }
创建发票
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); $customerId = 12345; $datetime = new \DateTime(); $invoice = array( 'kind' => 'income', // Required 'issue_date' => $datetime->format('Y-m-d') // Required ); $items = array( array( 'concept' => 'Product 1', 'unitary_amount' => "10", 'quantity' => 30, 'vat_percent' => 20, 'retention_percent' => 0 ), array( 'concept' => 'Product 2', 'unitary_amount' => "5", 'quantity' => 10, 'vat_percent' => 20, 'retention_percent' => 0 ) ); dump($matpe->createInvoice($customerId, $invoice, $items)); }
获取发票信息
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); dump($matpe->getInvoice(13423); }
更新发票信息
<?php // src/AppBundle/Controller/DefaultController.php public function MaTPEAction() { $matpe = $this->get("matpe"); $datetime = new DateTime(); dump($matpe->updateInvoice(13423, array( 'paid_at' => $datetime->format('Y-m-d') ))); }