Requirements:
- php >=8.1
- Laravel 8+
- add to
repositories
section of yourcomposer.json
{
"type": "vcs",
"url": "https://github.com/KoTRpa/iiko-transport"
}
- install via
php composer install kma/iiko-transport
- add to
.env
IIKO_LOGIN=your_apiLogin
- optional add to
.env
url to iiko api (default ishttps://api-ru.iiko.services/api/1/
)
IIKO_URL="url_to_iiko_api"
In Laravel, you can use Service Provider
use IikoTransport;
...
public function myFunction()
{
IikoTransport::nomenclature();
}
or dependency injection
public function myFunction(IikoTransport $iiko)
{
$iiko->nomenclature();
}
Iiko Transport API documentation lives here
All methods require a Request entity as param and returns Response entity
All entities can be created by different ways:
- directly with
new
and after assign attributes
$entity = new EntityName;
$entity->id = 'id';
- you can path to constructor a prepared array
$data = [
'id' => 'id'
];
$entity = new EntityName($data);
- or using static calls (recommended)
$entity = EntityName::fromArray($data);
$entity = EntityName::fromJson($jsonString);
Also, all entities has some convert methods to json or array
$entity->toArray();
$entity->toJson();
use KMA\IikoTransport\Endpoints\General\Organizations\OrganizationsRequest;
use KMA\IikoTransport\Endpoints\General\Organizations\OrganizationsResponse;
...
$response = IikoTransport::organizations(new OrganizationsRequest);
use KMA\IikoTransport\Endpoints\General\Menu\NomenclatureRequest;
use KMA\IikoTransport\Endpoints\General\Menu\NomenclatureResponse;
...
$response = IikoTransport::nomenclature(new NomenclatureRequest);
use KMA\IikoTransport\Endpoints\General\TerminalGroups\TerminalGroupsRequest;
use KMA\IikoTransport\Endpoints\General\TerminalGroups\TerminalGroupsResponse;
...
$response = IikoTransport::terminalGroups(new TerminalGroupsRequest);
continue...