爱彼智云/exact-online-bundle

Exact Online API 的Bundle

安装: 184

依赖者: 0

建议者: 0

安全性: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

4.4 2021-04-28 11:26 UTC

This package is auto-updated.

Last update: 2024-09-28 19:09:49 UTC


README

作者: Jefferson Bianchi

网站: https://aibianchi.com

邮箱: Jefferson@aibianchi.com

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);