Также доступны реализации для других языков программирования:
Go: goiikoapi — реализация iiko Cloud API на языке Go
Пользуем pip:
pip install pyiikocloudapi
Зависимости
requests
pydantic
Начиная с версии 0.0.20
requests
pydantic>=2.9.2
Все названия методов соответствуют названию в ссылке (смотрите документацию iiko Transport).
Пример названия метода:
- /api/1/auth/ -
access_token - /api/1/order/create -
order_create
Если вам нужно чтобы ответ был в dict - то либо
api = IikoTransport(api_login, return_dict=True)
# Либо
api.return_dict = True
from pyiikocloudapi import IikoTransport
from pyiikocloudapi.models import CouriersModel
# инициализация класса
api = IikoTransport(api_login)
# получаем организации получить из можно api.organizations_ids: dict or api.organizations_ids_models: OrganizationsModel
api.organizations()
# получаю список курьеров организации
couriers: CouriersModel = api.couriers(api.organizations_ids)
from pyiikocloudapi.models import WebHookDeliveryOrderEventInfoModel
# Пример данных WebHook события
data = {
"eventType": "DeliveryOrderUpdate",
"eventTime": "2019-08-24 14:15:22.123",
"organizationId": "7bc05553-4b68-44e8-b7bc-37be63c6d9e9",
"correlationId": "48fb4cd3-2ef6-4479-bea1-7c92721b988c",
"eventInfo": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"posId": "7f542382-3a91-4db8-938e-e9f86b88057c",
"externalNumber": "string",
"organizationId": "7bc05553-4b68-44e8-b7bc-37be63c6d9e9",
"timestamp": 1566650122,
"creationStatus": "Success",
"errorInfo": None,
"order": {
# ... данные заказа
}
}
}
# Валидация данных WebHook
webhook_event = WebHookDeliveryOrderEventInfoModel.model_validate(data)
# Доступ к данным после валидации
print(webhook_event.event_type) # "DeliveryOrderUpdate"
print(webhook_event.organization_id) # "7bc05553-4b68-44e8-b7bc-37be63c6d9e9"
# В зависимости от event_type, event_info будет разного типа:
# - DeliveryOrderUpdate -> EventInfo
# - StopListUpdate -> EventInfoStopList
# - TableOrderError -> EventInfoTableOrder
# - ReserveUpdate / ReserveError -> EventInfoReserve
# - PersonalShift -> EventInfoPersonalShift
Каждый метод проверяет время жизни маркера доступа, если время жизни маркера прошло то будет автоматически запрошен заново.
Время жизни маркера доступа равно ~60 минутам.
###Дополнительная информация iiko Transport(iiko Cloud API) по словам разработчиков это по сути горячие хранилище без доступа к данным БД
sourceKey это "Источник заказа" из настроек в iikoWeb
- Authorization
- Notifications
- Organizations
- Terminal groups
- Dictionaries
- Menu
- Operations
- Deliveries: Create and update
- Create delivery.
- Update order problem.
- Update delivery status.
- Update order courier.
- Add order items.
- Close order.
- Cancel delivery order.
- Change time when client wants the order to be delivered.
- Change order's delivery point information.
- Change order's delivery type.
- Change order's payments.
- Change delivery comment.
- Print delivery bill.
- Confirm delivery.
- Cancel delivery confirmation.
- Assign/change the order operator.
- WebHook notification about delivery order update. Webhook ???
- WebHook notification about delivery order saving error. Webhook ???
- Deliveries: Retrieve
- Addresses
- Delivery restrictions
- Employees
- Method of obtaining drivers' coordinates history.
- Returns list of all employees which are delivery drivers in specified restaurants.
- Returns list of all employees which are delivery drivers in specified restaurants, and checks whether each employee has passed role.
- Returns list of all active (courier session is opened) courier's locations which are delivery drivers in specified restaurant and are clocked in on specified delivery terminal.
- Returns list of all active (courier session is opened) courier's locations which are delivery drivers in specified restaurants.
- Returns employee info.
- Open personal session.
- Close personal session.
- Check if personal session is open.
- Check if personal session is open.
- wMarketing sources
- Drafts
- Orders
- Banquets/reserves
- Returns all organizations of current account (determined by Authorization request header) for which banquet/reserve booking are available.
- Returns all terminal groups of specified organizations, for which banquet/reserve booking are available.
- Returns all restaurant sections of specified terminal groups, for which banquet/reserve booking are available.
- Returns all banquets/reserves for passed restaurant sections.
- Create banquet/reserve.
- Retrieve banquets/reserves statuses by IDs.
- WebHook notification about reserve update. Webhook ???
- WebHook notification about reserve saving error. Webhook ???
- Discounts and promotions
- Calculate discounts and other loyalty items for an order.
- Get all organization's manual conditions.
- Get all loyalty programs for organization.
- Get information about the specified coupon.
- Get a list of coupon series in which there are not deleted and not activated coupons.
- Get list of non-activated coupons.
- Customers
- Get customer info by specified criterion.
- Create or update customer info by id or phone or card track.
- Add new customer for program.
- Add new card for customer.
- Delete existing card for customer.
- Hold customer's money in loyalty program. Payment will be process on POS during processing of an order.
- Refill customer balance.
- Withdraw customer balance.
- ....
