axro / shopware-oauth2-client
Shopware 6 OAuth2 API Client
Installs: 1 400
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- guzzlehttp/guzzle: >=7.8
- psr/log: ^3.0 || ^2.0
Requires (Dev)
- enlightn/security-checker: ^2.0
- phpro/grumphp: ^2.4
- phpstan/phpstan: ^1.10
- squizlabs/php_codesniffer: ^3.8
README
Use it to send requests to Shopware 6 API.
Controls the authentication and renewal of the token independently.
Installation
Install package:
composer require axro/shopware-oauth2-client
Usage
Requests
use AxroShopware\Client\ShopwareClient;
// Create an instance with your credentials
$client = new ShopwareClient(
$baseUrl, $clientId, $clientSecret
);
// add your monolog logger LoggerInterface
$client->setLogger($logger);
// send a request with the payload requested by the api.
$client->request('PATCH', '/api/_action/example_extension/update', $payload);
// to return a object instead of an array, set 4th argument to true
$client->request('PATCH', '/api/_action/example_extension/update', $payload, true);
$client->request('GET', 'api/product/', [], true);
Async Requests
use AxroShopware\Client\ShopwareClient;
// Create an instance with your credentials
$client = new ShopwareClient(
$baseUrl, $clientId, $clientSecret
);
// add your monolog logger LoggerInterface
$client->setLogger($logger);
// send a request with the payload requested by the api.
foreach(something...) {
// create $payload with your data from foreach etc.
$client->requestAsync('PATCH', '/api/_action/example_extension/update', $payload);
}
$responses = $client->promise();
// to return objects in numeric array instead of an array, set argument to true
$responses = $client->promise(true);
You can use the HTTP methods: GET, POST, PATCH, PUT, DELETE
Indexing
Indexing is set by default to "use-queue-indexing".
You can change it to synchronously or disable.
$client->indexing(const::INDEXING_SYNC)->requestAsync('PATCH', '/api/_action/example_extension/update', $payload);
Following constants are defined for sync behavior in ShopwareClient:
INDEXING_SYNC => Data will be indexed synchronously
INDEXING_QUEUE => Data will be indexed asynchronously
INDEXING_DISABLE => Data indexing is completely disabled