{"id":15813556,"url":"https://github.com/ybelenko/dtf-dbs-client","last_synced_at":"2026-01-11T16:48:29.643Z","repository":{"id":41441576,"uuid":"487246837","full_name":"ybelenko/dtf-dbs-client","owner":"ybelenko","description":"API client of DTF API for Dealer Business System","archived":false,"fork":false,"pushed_at":"2024-06-05T11:59:07.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-06T04:02:55.140Z","etag":null,"topics":["api","client","dbs","dtf"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ybelenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-30T10:25:41.000Z","updated_at":"2024-06-05T11:59:10.000Z","dependencies_parsed_at":"2024-12-07T04:31:30.605Z","dependency_job_id":null,"html_url":"https://github.com/ybelenko/dtf-dbs-client","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"dc1eac86fe9b1a7d8c10518a14d8cce3a3f2e08c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybelenko%2Fdtf-dbs-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybelenko%2Fdtf-dbs-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybelenko%2Fdtf-dbs-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybelenko%2Fdtf-dbs-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ybelenko","download_url":"https://codeload.github.com/ybelenko/dtf-dbs-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709909,"owners_count":20821298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","dbs","dtf"],"created_at":"2024-10-05T04:03:05.088Z","updated_at":"2026-01-11T16:48:29.614Z","avatar_url":"https://github.com/ybelenko.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DTF DBS API Client\n\n[![Tests](https://github.com/ybelenko/dtf-dbs-client/actions/workflows/main.yml/badge.svg)](https://github.com/ybelenko/dtf-dbs-client/actions/workflows/main.yml)\n[![Coverage Status](https://coveralls.io/repos/github/ybelenko/dtf-dbs-client/badge.svg?branch=main)](https://coveralls.io/github/ybelenko/dtf-dbs-client?branch=main)\n\n## Requirements\n* PHP 7.4 or 8.x\n* HTTP client(this readme describes Guzzle example, but you can use any other [PSR18](https://www.php-fig.org/psr/psr-18/) complaint package). Check these packages [https://packagist.org/providers/psr/http-client-implementation](https://packagist.org/providers/psr/http-client-implementation) if you need Guzzle alternative.\n\n## Installation via [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos)\nRun in command line:\n```console\ncomposer require ybelenko/dtf-dbs-client\n```\n\n## Setup\n### Via [PHP-DI](https://php-di.org/doc/getting-started.html) container\n```php\n\u003c?php\n// config.dev.php\n// contains sensitive data\n// should be excluded from source base in .gitignore file\nreturn [\n    'DtfDbsApi.dealerId' =\u003e 'test01',\n    'DtfDbsApi.clientId' =\u003e 'xxxxxxxxxxxxxxxxx',\n    'DtfDbsApi.clientSecret' =\u003e 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',\n    'DtfDbsApi.environment' =\u003e 'cert',// cert|qual|prod\n];\n```\n\n```php\n\u003c?php\n// config.php\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Psr7\\HttpFactory;\nuse GuzzleHttp\\RequestOptions;\nuse Psr\\Http\\Client\\ClientInterface;\nuse Ybelenko\\DtfDbsClient\\ApiClient;\nuse Ybelenko\\DtfDbsClient\\ApiClientConfig;\n\nreturn [\n    // Guzzle Client with DTF DBS API\n    ClientInterface::class =\u003e \\DI\\autowire(Client::class)\n        -\u003econstructor([\n            RequestOptions::HTTP_ERRORS =\u003e false,// important to handle non 2xx statuses properly\n        ]),\n\n    ApiClient::class =\u003e \\DI\\autowire(),\n    ApiClientConfig::class =\u003e \\DI\\autowire()\n        -\u003econstructorParameter('requestFactory', \\DI\\create(HttpFactory::class))\n        -\u003econstructorParameter('uriFactory', \\DI\\create(HttpFactory::class))\n        -\u003econstructorParameter('streamFactory', \\DI\\create(HttpFactory::class))\n        -\u003econstructorParameter('dealerId', \\DI\\get('DtfDbsApi.dealerId'))\n        -\u003econstructorParameter('clientId', \\DI\\get('DtfDbsApi.clientId'))\n        -\u003econstructorParameter('clientSecret', \\DI\\get('DtfDbsApi.clientSecret'))\n        -\u003econstructorParameter('environment', \\DI\\get('DtfDbsApi.environment'))\n        -\u003econstructorParameter('authScope', 'dtf:dbs:file:write dtf:dbs:file:read'),\n];\n```\n\n```php\n\u003c?php\n// index.php\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\nuse DI\\ContainerBuilder;\nuse Psr\\Container\\ContainerInterface;\n\n$builder = new ContainerBuilder();\n\n// Main configuration\n$builder-\u003eaddDefinitions(\"config.php\");\n\n// Config file for the environment\n$builder-\u003eaddDefinitions(\"config.$environment.php\");\n\n/** @var ContainerInterface */\n$container = $builder-\u003ebuild();\n```\n\n### Manual\n```php\n\u003c?php\n// index.php\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Psr7\\HttpFactory;\nuse GuzzleHttp\\RequestOptions;\nuse Ybelenko\\DtfDbsClient\\ApiClient;\nuse Ybelenko\\DtfDbsClient\\ApiClientConfig;\n\n$client = new ApiClient(\n    new ApiClientConfig(\n        new Client([RequestOptions::HTTP_ERRORS =\u003e false]),// httpClient\n        new HttpFactory(),// requestFactory \n        new HttpFactory(),// uriFactory\n        new HttpFactory(),// streamFactory\n        'xxxxxxxxxxxxxxxxx',// clientId \n        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',// clientSecret \n        'test01',// dealerId \n        'cert',// environment cert|qual|prod \n        'dtf:dbs:file:write dtf:dbs:file:read'// scopes\n    )\n);\n\n// ready to call API services\n```\n## API services\n### File List Service\n```php\n// $client initialization omitted\ntry {\n    /** @var array[] */\n    $filesList = $client-\u003ecallFileListService();\n    // Approx shape [{\"name\": \"order.dat\", \"links\": [{\"rel\": \"download\", \"href\": \"http:\"}, {\"rel\": \"details\", \"href\": \"http:\"}]}, ...]\n    foreach ($filesList as $file) {\n        // do something\n    }\n} catch (\\Throwable $e) {\n    // echo or log exception for following investigation\n}\n```\n\n### File Upload Service\n```php\n// $client initialization omitted\ntry {\n    $factory = new \\GuzzleHttp\\Psr7\\HttpFactory();\n    $testFile = $factory-\u003ecreateStreamFromFile(__DIR__ . '/tests/samplecommonfile.txt', 'r');\n    /** @var bool */\n    $success = $client-\u003ecallFileUploadService(\n        $testFile, \n        null,// filename, optional\n        true// overwrite param\n    );\n    if (!$success) {\n        throw new \\Exception('Unable to upload file');\n    }\n} catch (\\Throwable $e) {\n    // echo or log exception for following investigation\n}\n```\n\n### File Download Service\n```php\n// $client initialization omitted\ntry {\n    // can be retrieved from File List Service above\n    $filename = 'samplecommonfile.txt';\n    /** @var \\Psr\\Http\\Message\\StreamInterface */\n    $fileStream = $client-\u003ecallFileDownloadService($filename);\n    $uploaded = new \\GuzzleHttp\\Psr7\\UploadedFile($fileStream, $fileStream-\u003egetSize(), \\UPLOAD_ERR_OK, $filename);\n    $uploaded-\u003emoveTo(__DIR__ . '\\/output\\/' . $filename);\n    // saved to output folder\n} catch (\\Throwable $e) {\n    // echo or log exception for following investigation\n}\n```\n\n## Author\n[Yuriy Belenko](https://github.com/ybelenko)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybelenko%2Fdtf-dbs-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fybelenko%2Fdtf-dbs-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybelenko%2Fdtf-dbs-client/lists"}