1. Go to this page and download the library: Download blarx/dodois-api 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/ */
blarx / dodois-api example snippets
use Dodois\Events\Connected;
use Dodois\Events\CallbackRedirected;
...
protected $listen = [
Connected::class => [
YourTokenListener::class,
],
CallbackRedirected::class => [
YourRedirectListener::class,
],
];
use Dodois\Events\CallbackRedirected;
class YourTokenListener
{
public function handle(CallbackRedirected $event)
{
$event->response->with([
'message' => $event->errorMessage ?: __('Account was added'),
]);
}
}
use Dodois\Contracts\ClientContract;
use Dodois\Contracts\PublicApiContract;
...
class PageController {
public function page(ClientContract $dodois, ...) {
...
// Query to auth/ resource
$units = $dodois->withToken('access_token')
->auth()->units()->list();
$roles = $dodois->withToken('access_token')
->auth()->roles()->list();
// Prefix config
$products = $dodois->withToken('access_token')
->accounting('dodopizza', 'ru') // Default
->products()
->where('isProducible', true)
->list();
// Where Variant One
$sales = $dodois->withToken('access_token')
->accounting()->sales()
->whereBetween(
now()->subDay(), // From
now(), // To
)
->where('units', $units->pluck('id'))
->where('salesChannel', 'Delivery')
->list();
// Where Variant Two
$products = $dodois->withToken('access_token')
->accounting()->semiFinishedProductsProduction()
->list([
'from' => now()->subDay(),
'to' => now(),
'units' => $units->pluck('id'),
]);
}
public function other(PublicApiContract $dodois, ...)
{
$units = $dodois->units();
$unitsKz = $dodois->units('kz');
}
}