zangra/exact-online-bundle

Exact Online API 的打包工具

安装: 0

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

类型:symfony-bundle

5.4.0 2024-08-22 06:59 UTC

README

作者: Bianchi Jefferson / Lambot Maxime

邮箱: jefferson@zangra.com / maxime@zangra.com

Exact Online 文档: https://support.exactonline.com/community/s/knowledge-base#All-All-DNO-Content-getting-started

要求

Symfony HTTP Client 5.1

分支针对

Symfony 版本 4.4

php 版本 7.2

步骤 1

在 : https://apps.exactonline.com/be/fr-BE/V2/Manage/ 创建您的 APP

步骤 2

 composer require zangra/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 zangra\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); // use init for the first Authentification, after that you should to use forceRefreshToken();
      $exactManager->forceRefreshToken();
}

然后访问 http:// YOUR URL.com/ExactRequest 您将需要认证登录,此会话将在 10 分钟后过期。当您使用 self::refreshAccessToken(); 方法向 Exact 发起请求时,令牌将自动更新。

用法

初始化

$code = $request->query->get('code');
$exactManager = $this->get("exact_online.manager");
//$exactManager->init($code); // first init
$exactManager->forceRefreshToken(); // 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");

persist()

$item = new Item();
$item->setCode(rand());
$item->setCostPriceStandard(5);
$item->setDescription("description de test");
$item->setIsSalesItem(true);
$item->setSalesVatCode('VN');
$exactManager->persist($item);

update()

$account = $exactManager->getModel("Account")->find("587707b8-94aa-426a-b7db-56d434d9e83a");
$account->setWebsite("https://zangra.com");
$exactManager->update($account);

remove()

$account = $exactManager->getModel("Account")->find("587707b8-94aa-426a-b7db-56d434d9e83a");
$exactManager->remove($account);