1. Go to this page and download the library: Download ybelenko/dtf-dbs-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ybelenko / dtf-dbs-client example snippets
// config.dev.php
// contains sensitive data
// should be excluded from source base in .gitignore file
return [
'DtfDbsApi.dealerId' => 'test01',
'DtfDbsApi.clientId' => 'xxxxxxxxxxxxxxxxx',
'DtfDbsApi.clientSecret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'DtfDbsApi.environment' => 'cert',// cert|qual|prod
];
// config.php
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use GuzzleHttp\RequestOptions;
use Psr\Http\Client\ClientInterface;
use Ybelenko\DtfDbsClient\ApiClient;
use Ybelenko\DtfDbsClient\ApiClientConfig;
return [
// Guzzle Client with DTF DBS API
ClientInterface::class => \DI\autowire(Client::class)
->constructor([
RequestOptions::HTTP_ERRORS => false,// important to handle non 2xx statuses properly
]),
ApiClient::class => \DI\autowire(),
ApiClientConfig::class => \DI\autowire()
->constructorParameter('requestFactory', \DI\create(HttpFactory::class))
->constructorParameter('uriFactory', \DI\create(HttpFactory::class))
->constructorParameter('streamFactory', \DI\create(HttpFactory::class))
->constructorParameter('dealerId', \DI\get('DtfDbsApi.dealerId'))
->constructorParameter('clientId', \DI\get('DtfDbsApi.clientId'))
->constructorParameter('clientSecret', \DI\get('DtfDbsApi.clientSecret'))
->constructorParameter('environment', \DI\get('DtfDbsApi.environment'))
->constructorParameter('authScope', 'dtf:dbs:file:write dtf:dbs:file:read'),
];
// index.php
uilder;
use Psr\Container\ContainerInterface;
$builder = new ContainerBuilder();
// Main configuration
$builder->addDefinitions("config.php");
// Config file for the environment
$builder->addDefinitions("config.$environment.php");
/** @var ContainerInterface */
$container = $builder->build();
// index.php
ient;
use GuzzleHttp\Psr7\HttpFactory;
use GuzzleHttp\RequestOptions;
use Ybelenko\DtfDbsClient\ApiClient;
use Ybelenko\DtfDbsClient\ApiClientConfig;
$client = new ApiClient(
new ApiClientConfig(
new Client([RequestOptions::HTTP_ERRORS => false]),// httpClient
new HttpFactory(),// requestFactory
new HttpFactory(),// uriFactory
new HttpFactory(),// streamFactory
'xxxxxxxxxxxxxxxxx',// clientId
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',// clientSecret
'test01',// dealerId
'cert',// environment cert|qual|prod
'dtf:dbs:file:write dtf:dbs:file:read'// scopes
)
);
// ready to call API services