timothydc/exact-online-base-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

timothydc/exact-online-base-client

最新稳定版本:v4.0.0

Composer 安装命令:

composer require timothydc/exact-online-base-client

包简介

Exact Online base client

关键字:

README 文档

README

This package provides a wrapper for the Exact Online API.

Usage

The basic configuration looks like this:

use TimothyDC\ExactOnline\BaseClient\ExactOnlineClient;
use TimothyDC\ExactOnline\BaseClient\ClientConfiguration;
use TimothyDC\ExactOnline\BaseClient\Authentication\TokenVault;
use Psr\Log\LogLevel;

$clientConfiguration = new ClientConfiguration(
    'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // client ID
    'yyyy', // client secret
    'zzzz',  // webhook secret
    'your-public-callback-url', // redirect URL - should be _exactly_ the same as the URL defined in the EOL app center
    'https://start.exactonline.be' // API base URL. Note the ".be" for Belgium
 );

$tokenVault = new TokenVault();
$tokenVault->setStoragePath('path/to/tokens.json');

$client = new ExactOnlineClient($clientConfiguration, $tokenVault);
$client->setLogger($this->logger); // optional logging
$client->setDefaultLogLevel(LogLevel::ERROR); // optional log level

Authorization

If you want to start a new authentication process, then call:

$client->startAuthorization();

During the authentication process, EOL will redirect you to your callback URL. There you will need to do:

$client->completeAuthorization('code-from-query-parameters');

Now your $eolClient-object is ready to make API requests:

use Picqer\Financials\Exact\Item;

$items = (new Item($client->getConnection()))->get();

Disconnect

If you want to disconnect and delete the access tokens, call the disconnection function on your client.

$client->disconnect();

Internationalisation

If you want to retrieve the language dependent fields in a different language (e.g. Item description and Item long description), call the connection with a language parameter.

use Picqer\Financials\Exact\Item;

$items = (new Item($client->getConnection('FR-BE')))->get();

See also the Support\ExactLocale.php file. For more information, see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=LogisticsItems#goodToKnow

Customization

Storage driver

Tokens will be saved, by default, in a json file on the local disk.

To make a custom driver, create a custom Vault class which extends the TokenVaultInterface-interface.

use TimothyDC\ExactOnline\BaseClient\Interfaces\AccessTokenInterface;
use TimothyDC\ExactOnline\BaseClient\Interfaces\TokenVaultInterface;

class TokenVault implements TokenVaultInterface
{
    public function makeToken(?string $accesToken, ?string $refreshToken, int $expiresAt): AccessTokenInterface
    {
    }
    
    public function store(AccessTokenInterface $accessToken): void
    {
    }
    
    public function retrieve(): AccessTokenInterface
    {
    }
    
    public function clear(): void
    {
    }
}

And also a custom Token class which extends the AccessTokenInterface-interface.

use TimothyDC\ExactOnline\BaseClient\Interfaces\AccessTokenInterface;

class Token implements AccessTokenInterface
{
    public function getAccessToken(): ?string
    {
    }
    
    public function getRefreshToken(): ?string
    {
    }
    
    public function getExpiresAt(): int
    {
    }
}

统计信息

  • 总下载量: 218
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-13