adbros / shoptet-sdk
Shoptet API SDK
v0.8.2
2024-09-30 07:32 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.8
- nette/utils: ^3.0 | ^4.0
Requires (Dev)
- contributte/qa: ^0.3.1
- php-parallel-lint/php-console-highlighter: ^1.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-strict-rules: ^1.5
- tracy/tracy: ^2.10
- vlucas/phpdotenv: ^5.6
README
Installation
composer require adbros/shoptet-sdk
Usage
<?php declare(strict_types = 1); use Adbros\Shoptet\OAuth; use Adbros\Shoptet\Sdk; // Initialize OAuth $oAuth = new OAuth( clientId: getenv('CLIENT_ID'), clientSecret: getenv('CLIENT_SECRET'), eshopUrl: getenv('ESHOP_URL'), ); // Get oAuthAccessToken in installation process $oAuthAccessToken = $oAuth->getOAuthAccessToken( code: $_GET['code'], redirectUri: 'https://example.com/install', ); // Get apiAccessToken before API call $apiAccessToken = $oAuth->getApiAccessToken( oAuthAccessToken: $oAuthAccessToken->accessToken, ); // Initialize SDK $sdk = new Sdk( apiAccessToken: $apiAccessToken->accessToken, ); // Get customers $page = 1; do { $customers = $sdk->getCustomers($page); foreach ($customers->customers as $customer) { // Get customer $customerDetail = $sdk->getCustomer($customer->guid); } } while ($page++ < $customers->paginator->pageCount);