爱彼智云 / exact-online-bundle
Exact Online API 的Bundle
4.4
2021-04-28 11:26 UTC
Requires
- php: ^7.2
- doctrine/doctrine-bundle: *
- guzzlehttp/guzzle: ^6.2
- symfony/framework-bundle: ^4.4
This package is auto-updated.
Last update: 2024-09-28 19:09:49 UTC
README
作者: Jefferson Bianchi
Exact Online 文档: https://support.exactonline.com/community/s/knowledge-base#All-All-DNO-Content-getting-started
需求
Guzzle 6分支为
Symfony 版本 4.4
php 版本 7.2
步骤 1
在: https://apps.exactonline.com/be/fr-BE/V2/Manage/ 创建您的 APP
步骤 2
composer require aibianchi/exact-online-bundle
步骤 3
现在您可以使用多账户(按国家)
config/package/exact_online.yaml
exact_online:
Belgium:
baseUrl: https://start.exactonline.be/
apiUrl: api/v1
authUrl: api/oauth2/auth
tokenUrl: api/oauth2/token
redirectUrl: https://YOURURL/ExactRequest
clientId: YOURID
clientSecret: YOURSECRET
France:
baseUrl: https://start.exactonline.fr/
apiUrl: api/v1
authUrl: api/oauth2/auth
tokenUrl: api/oauth2/token
redirectUrl: https://YOURURL/ExactRequest
clientId: YOURID
clientSecret: YOURSECRET
Nerderland:
baseUrl: https://start.exactonline.nl/
apiUrl: api/v1
authUrl: api/oauth2/auth
tokenUrl: api/oauth2/token
redirectUrl: https://YOURURL/ExactRequest
clientId: YOURID
clientSecret: YOURSECRET
Spain:
baseUrl: https://start.exactonline.es/
apiUrl: api/v1
authUrl: api/oauth2/auth
tokenUrl: api/oauth2/token
redirectUrl: https://YOURURL/ExactRequest
clientId: YOURID
clientSecret: YOURSECRET
步骤 4
您应该更新您的数据库php app/console doctrine:schema:update --force
步骤 5
在您的控制器中
use aibianchi\ExactOnlineBundle\Manager\ExactManager;
public function indexAction(Request $request, ExactManager $exactManager)
{
// the code sended by exact online when the first auth
$code = $request->query->get('code');
//$exactManager->init($code, "Belgium"); // use init for the first Authentification, after that you should to use refreshtoken();
$exactManager->refreshToken("Belgium");
}
接下来访问 http:// YOUR URL.com/ExactRequest 您需要认证登录,此会话将在 10 分钟后过期 如果您想保持会话活跃,您应该将函数 init() 替换为 refreshToken()
使用方法
初始化
$code = $request->query->get('code');
$exactManager = $this->get("exact_online.manager");
//$exactManager->init($code); // first init
$exactManager->refreshToken(); // after first init
getList($page, $maxPerPage)
(带分页)$listAccount = $exactManager->getModel("Account")->getList(1,5);
foreach ($listAccount as $account){
dump($account);
}
findBy()
$criteria = array('AddressLine1' => 'Koningin Astridlaan 166');
$select = array ("AddressLine1", "BusinessType", "CountryName", "Created");
$orderBy = array('Created' => 'desc');
$limit = 1 ;
$account = $exactManager->getModel("Account")->findBy($criteria,$select,$orderBy,$limit);
dump($account);
find
(guid)account = $exactManager->getModel("Account")->find("587707b8-94aa-426a-b7db-56d434d9e83a");
持久化
$item = new Item();
$item->setCode(rand());
$item->setCostPriceStandard(5);
$item->setDescription("description de test");
$item->setIsSalesItem(true);
$item->setSalesVatCode('VN');
$exactManager->persist($item);
更新
$account = $exactManager->getModel("Account")->find("587707b8-94aa-426a-b7db-56d434d9e83a");
$account->setWebsite("https://aibianchi.com");
$exactManager->update($account);
删除
$account = $exactManager->getModel("Account")->find("587707b8-94aa-426a-b7db-56d434d9e83a");
$exactManager->remove($account);