![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
![Last Commit](https://img.shields.io/github/last-commit/barabum0/asyyclients?style=for-the-badge)
[![Licence](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)](./LICENSE)
# Asynchronous YCLIENTS API
[![PyPI version](https://img.shields.io/pypi/v/asyyclients.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/yclients-api)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/asyyclients.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/yclients-api)
[//]: # ([![Tests Passing](https://github.com/CoolmixZero/yclients-api-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/CoolmixZero/yclients-api-python/actions))
[![PyPI downloads](https://img.shields.io/pypi/dm/asyyclients.svg?style=flat-square)](https://pypi.org/project/yclients-api)
### **Python [Async YCLIENTS API WRAPPER](https://github.com/barabum0/asyyclients/blob/main/yclients/yclients.py "Opens yclients.py") with [ujson](https://pypi.org/project/ujson/ "Opens ujson documentation") and [httpx](https://www.python-httpx.org/ "Opens httpx documentation") packages:**
- PyPI page of project: https://pypi.org/project/asyyclients/
- The code changed `httpx ⟵ requests` and `ujson ⟵ json` packages.
> `ujson` and `httpx` **faster** than `json` and `requests`
- An example of using library also implemented in the [example.py](https://github.com/barabum0/asyyclients/blob/main/example.py "Opens example.py").
- This is an async implementation of [this project](https://github.com/CoolmixZero/yclients-api-python). Original author is Nikita Shalashkov
> Please note that sending requests to get customer data can take time, especially if your database is quite large, since YCLIENTS API can return only 200 results at once. Also if sending one request takes more than a few seconds, you may need to connect to another Internet network.
>
# Installation:
```shell
pip install asyyclients
```
____
# Usage:
## Create API object
```python
from asyyclients import AsyncYClientsAPI
TOKEN = "your token"
СID = 'your company id'
FID = 'form id'
async def main():
api = AsyncYClientsAPI(token=TOKEN, company_id=СID, form_id=FID)
```
## Show debugging process
```python
api.show_debugging()
```
## Booking commands:
- ### Get staff info
> Returns list of staff for specific service and date
```python
all_staff = await api.get_staff()
print(all_staff)
staff_id = all_staff['data'].get('id')
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": [
{
"id": "16",
"name": "Вася",
"bookable": true,
"specialization": "Фельдшер",
"position": {
"id": 1,
"title": "Администратор"
},
"show_rating": "1",
"rating": "3",
"votes_count": "1",
"avatar": "https://yclients.com/images/no-master.png",
"comments_count": "0",
"weight": "11",
"information": "<span></span>",
"seance_date": 1443139200,
"seances": []
},
{
"id": "32",
"name": "Петя",
"bookable": false,
"specialization": "Терапевт",
"position": [],
"show_rating": "1",
"rating": "4",
"votes_count": "1",
"avatar": "https://yclients.com/images/no-master.png",
"comments_count": "0",
"weight": "8",
"information": "<span></span>"
}
],
"meta": []
}
```
</details>
____
- ### Get services info
> Returns list of services for specific staff and date
```python
services = await api.get_services(staff_id=staff_id)
print(services)
service_id = services['data']['services'].get('id')
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": {
"events": [],
"services": [
{
"id": 1896208,
"title": "Мытье волос",
"category_id": 1895571,
"price_min": 0,
"price_max": 0,
"discount": 0,
"comment": "",
"weight": 0,
"active": 0,
"sex": 0,
"image": "",
"prepaid": "forbidden",
"seance_length": 3600
},
{
"id": 1896303,
"title": "Окрашивание",
"category_id": 1895574,
"price_min": 0,
"price_max": 0,
"discount": 0,
"comment": "",
"weight": 0,
"active": 0,
"sex": 0,
"image": "",
"prepaid": "forbidden",
"seance_length": 3600
}
],
"category": [
{
"id": 1895571,
"title": "Уходы для волос",
"sex": 0,
"api_id": 0,
"weight": 60
},
{
"id": 1895574,
"title": "Окрашивание волос",
"sex": 0,
"api_id": 0,
"weight": 7
}
]
},
"meta": []
}
```
</details>
____
- ### Get booking dates
> Returns all available days for specific staff and service
```python
booking_days = await api.get_available_days(staff_id=staff_id, service_id=service_id)
print(booking_days)
day = booking_days['data'].get('booking_dates') # or .get('booking_days')
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": {
"booking_days": {
"9": [
"4",
"5",
"8",
"9",
"12",
"13",
"16",
"17",
"20",
"21",
"24",
"25",
"28",
"29",
"30"
],
"10": [
"1",
"4",
"5",
"8",
"9",
"12",
"13",
"16",
"17",
"20",
"21",
"24",
"25"
]
},
"booking_dates": [
1441324800,
1441411200,
1441670400,
1441756800,
1442016000,
1442102400,
1442361600,
1442448000,
1442707200,
1442793600,
1443052800,
1443139200,
1443398400,
1443484800,
1443571200,
1443657600,
1443916800,
1444003200,
1444262400,
1444348800,
1444608000,
1444694400,
1444953600,
1445040000,
1445299200,
1445385600,
1445644800,
1445731200
],
"working_days": {
"9": [
"4",
"5",
"8",
"9",
"12",
"13",
"16",
"17",
"20",
"21",
"24",
"25",
"28",
"29",
"30"
],
"10": [
"1",
"4",
"5",
"8",
"9",
"12",
"13",
"16",
"17",
"20",
"21",
"24",
"25"
]
},
"working_dates": [
1441324800,
1441411200,
1441670400,
1441756800,
1442016000,
1442102400,
1442361600,
1442448000,
1442707200,
1442793600,
1443052800,
1443139200,
1443398400,
1443484800,
1443571200,
1443657600,
1443916800,
1444003200,
1444262400,
1444348800,
1444608000,
1444694400,
1444953600,
1445040000,
1445299200,
1445385600,
1445644800,
1445731200
]
},
"meta": []
}
```
</details>
____
- ### Get booking times
> Returns all available times slots on specific day staff and service
```python
time_slots = await api.get_available_times(staff_id=staff_id, service_id=service_id, day=day)
print(time_slots)
date_time = time_slots['data'].get('time') # or .get('datetime')
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": [
{
"time": "12:00",
"seance_length": 3600,
"datetime": 1443513600
},
{
"time": "13:00",
"seance_length": 3600,
"datetime": 1443517200
},
{
"time": "14:00",
"seance_length": 3600,
"datetime": 1443520800
},
{
"time": "15:00",
"seance_length": 3600,
"datetime": 1443524400
},
{
"time": "16:00",
"seance_length": 3600,
"datetime": 1443528000
}
],
"meta": []
}
```
</details>
____
- ### Book
```python
booked, message = await api.book(booking_id=0,
fullname='my name',
phone='53425345',
email='myemail@email.com,
service_id=service_id,
date_time=date_time,
staff_id=staff_id,
comment='some comment')
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": [
{
"id": 1,
"record_id": 2820023,
"record_hash": "567df655304da9b98487769426d4e76e"
},
{
"id": 2,
"record_id": 2820024,
"record_hash": "34a45ddabdd446d5d33bdd27fbf855b2"
}
],
"meta": []
}
```
</details>
<details>
<summary>Payload(JSON) example ...</summary>
```json
{
"phone": "79000000000",
"fullname": "ДИМА",
"email": "d@asyyclients.com",
"code": "38829",
"comment": "тестовая запись!",
"type": "mobile",
"notify_by_sms": 6,
"notify_by_email": 24,
"api_id": "777",
"appointments": [
{
"id": 1,
"services": [
331
],
"staff_id": 6544,
"datetime": 1443517200,
"custom_fields": {
"my_custom_field": 123,
"some_another_field": [
"first value",
"next value"
]
}
},
{
"id": 2,
"services": [
99055
],
"staff_id": 6544,
"datetime": 1443614400,
"custom_fields": {
"my_custom_field": 456,
"some_another_field": [
"next value",
"last value"
]
}
}
]
}
```
</details>
____
## User commands:
- ### Get USER TOKEN from the system
> You can save this TOKEN (like BEARER TOKEN) and there is no need to update it every time
```python
login = "example@gmail.com"
password = "password"
user_token = await api.get_user_token(login, password)
```
____
<details>
<summary>Response ...</summary>
```json
{
"id": 123456,
"user_token": "wec23fh8cDfFV4432fc352456",
"name": "Иван Попов",
"phone": "79161001010",
"login": "79161001010",
"email": "test@test.com",
"avatar": "https://assets.yclients.com/general/0/01/123456789098765_12345678909876.png"
}
```
</details>
____
- ### Update autorisation parameters of the API class with USER TOKEN
> After USER TOKEN was obtained you need to include it in header of requests that you are sending
```python
await api.update_user_token(user_token)
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": {
"user_token": "4de9d8cc108c0"
},
"meta": []
}
```
</details>
____
- ### Shows USER permissions
```python
await api.show_user_permissions()
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": {
"timetable": {
"timetable_access": true,
"master_id": 1000238,
"position_id": 0,
"last_days_count": 1000,
"schedule_edit_access": true,
"timetable_phones_access": true,
"timetable_transferring_record_access": true,
"timetable_statistics_access": true
},
"record_form": {
"record_form_access": true,
"record_form_client_access": true,
"records_autocomplete_access": true,
"create_records_access": true,
"edit_records_access": true,
"edit_records_attendance_access": true,
"records_services_cost_access": true,
"records_services_discount_access": true,
"record_edit_full_paid_access": true,
"delete_records_access": true,
"delete_customer_came_records_access": true,
"delete_paid_records_access": true,
"records_goods_access": true,
"records_goods_create_transaction_access": true,
"records_goods_create_last_days_count": -1,
"records_goods_edit_transaction_access": true,
"records_goods_edit_last_days_count": -1,
"records_goods_cost_access": true,
"records_goods_discount_access": true,
"records_finances_access": true,
"records_finances_last_days_count": -1,
"records_finances_pay_from_deposits_access": true,
"records_group_id_access": true,
"records_group_id": 134178
},
"finances": {
"finances_access": true,
"finances_accounts_ids": [],
"finances_transactions_access": true,
"finances_last_days_count": -1,
"finances_create_transactions_access": true,
"finances_create_last_days_count": -1,
"finances_edit_transactions_access": true,
"finances_edit_last_days_count": -1,
"finances_delete_transactions_access": true,
"finances_transactions_excel_access": true,
"finances_expenses_ids": [],
"finances_accounts_access": true,
"finances_accounts_banalce_access": true,
"finances_suppliers_read_access": true,
"finances_suppliers_create_access": true,
"finances_suppliers_update_access": true,
"finances_suppliers_delete_access": true,
"finances_suppliers_excel_access": true,
"finances_expenses_read_access": true,
"expenses_read_access": true,
"finances_expenses_create_access": true,
"expenses_create_access": true,
"finances_expenses_update_access": true,
"expenses_update_access": true,
"finances_expenses_delete_access": true,
"expenses_delete_access": true,
"finances_kkm_transactions_access": true,
"kkm_transactions_accounts_access": true,
"finances_kkm_settings_read_access": true,
"kkm_settings_reed_access": true,
"finances_kkm_settings_update_access": true,
"kkm_settings_update_access": true,
"finances_settings_invoicing_read_access": true,
"settings_invoicing_read_access": true,
"finances_settings_invoicing_update_access": true,
"settings_invoicing_update_access": true,
"finances_options_read_access": true,
"options_read_access": true,
"finances_options_update_access": true,
"options_update_access": true,
"finances_salary_schemes_access": true,
"finances_salary_calc_access": true,
"finances_salary_not_limitation_today_access": true,
"finances_payroll_calculation_create_access": true,
"finances_payroll_calculation_create_not_limitation_today_access": true,
"finances_salary_access_master_checkbox": true,
"finances_salary_access_master_id": 1000237,
"get_salary_access_master_id": 1000237,
"finances_salary_master_not_limitation_today_access": true,
"finances_payroll_calculation_create_by_master_access": true,
"calculation_create_by_master_not_limitation_today_access": true,
"finances_period_report_access": true,
"finances_period_report_excel_access": true,
"finances_year_report_access": true,
"finances_year_report_excel_access": true,
"finances_print_check_access": true,
"finances_z_report_access": true,
"finances_z_report_no_limit_today_access": true,
"finances_z_report_excel_access": true
},
"clients": {
"clients_access": true,
"client_phones_access": true,
"clients_phones_email_access": true,
"clients_card_phone_access": true,
"clients_delete_access": true,
"clients_excel_access": true,
"excel_access": true,
"client_comments_list_access": true,
"client_comments_add_access": true,
"client_comments_own_edit_access": true,
"client_comments_other_edit_access": true,
"client_files_list_access": true,
"client_files_upload_access": true,
"client_files_delete_access": true,
"clients_visit_master_id": 0,
"get_visit_master_id": 0
},
"dashboard": {
"dashboard_access": true,
"dash_access": true,
"dash_phones_access": true,
"dash_records_access": true,
"dash_records_last_days_count": -1,
"dash_records_excel_access": true,
"dash_records_phones_access": true,
"dash_message_access": true,
"dash_message_excel_access": true,
"dash_message_phones_access": true,
"dash_reviews_access": true,
"dash_reviews_delete_access": true,
"dashboard_calls_access": true,
"dashboard_calls_excel_access": true,
"dashboard_calls_phones_access": true
},
"notification": {
"notification": true,
"web_push": true,
"web_phone_push": true,
"notification_sms_ending_license": true,
"notification_sms_low_balance": true,
"notification_email_ending_license": true
},
"loyalty": {
"loyalty_access": true,
"has_loyalty_access": true,
"loyalty_cards_manual_transactions_access": true,
"has_loyalty_cards_manual_transactions_access": true,
"loyalty_certificate_and_abonement_manual_transactions_access": true
},
"storages": {
"storages_access": true,
"storages_ids": [],
"storages_transactions_access": true,
"storages_last_days_count": -1,
"storages_move_goods_access": true,
"storages_create_transactions_access": true,
"storages_create_last_days_count": -1,
"storages_create_transactions_buy_access": true,
"storages_create_transactions_sale_access": true,
"storages_edit_transactions_access": true,
"storages_edit_last_days_count": -1,
"storages_edit_transactions_buy_access": true,
"storages_edit_transactions_sale_access": true,
"storages_delete_transactions_access": true,
"storages_transactions_excel_access": true,
"storages_transactions_types": [],
"storages_inventory_access": true,
"storages_inventory_create_edit_access": true,
"storages_inventory_delete_access": true,
"storages_inventory_excel_access": true,
"storages_remnants_report_access": true,
"storages_remnants_report_excel_access": true,
"storages_sales_report_access": true,
"storages_sales_report_excel_access": true,
"storages_consumable_report_access": true,
"storages_consumable_report_excel_access": true,
"storages_write_off_report_access": true,
"storages_write_off_report_excel_access": true,
"storages_turnover_report_access": true,
"storages_turnover_report_excel_access": true,
"storages_goods_crud_access": true,
"storages_goods_create_access": true,
"storages_goods_update_access": true,
"storages_goods_title_edit_access": true,
"storages_goods_category_edit_access": true,
"storages_goods_selling_price_edit_access": true,
"storages_goods_cost_price_edit_access": true,
"storages_goods_units_edit_access": true,
"storages_goods_critical_balance_edit_access": true,
"storages_goods_masses_edit_access": true,
"storages_goods_comment_edit_access": true,
"storages_goods_archive_access": true,
"storages_goods_delete_access": true
},
"settings": {
"settings_access": true,
"settings_basis_access": true,
"settings_information_access": true,
"users_access": true,
"delete_users_access": true,
"create_users_access": true,
"edit_users_access": true,
"limited_users_access": false,
"settings_services_access": true,
"settings_services_create_access": true,
"services_edit": true,
"settings_services_edit_title_access": true,
"settings_services_relation_category_access": true,
"settings_services_edit_price_access": true,
"settings_services_edit_image_access": true,
"settings_services_edit_online_seance_date_time_access": true,
"settings_services_edit_online_pay_access": true,
"settings_services_edit_services_related_resource_access": true,
"settings_positions_read": true,
"settings_positions_create": true,
"settings_positions_delete": true,
"edit_master_service_and_duration": true,
"tech_card_edit": true,
"services_delete": true,
"settings_master_access": true,
"master_create": true,
"master_edit": true,
"master_delete": true,
"settings_master_dismiss_access": true,
"schedule_edit": true,
"settings_notifications_access": true,
"settings_email_notifications_access": true,
"settings_template_notifications_access": true,
"webhook_read_access": true
},
"other": {
"stat_access": true,
"billing_access": true,
"send_sms": true,
"auth_enable_check_ip": false,
"auth_list_allowed_ip": []
}
},
"meta": []
}
```
</details>
____
## Client commands:
- ### Get clients list
> YCLIENTS API can't return all clients at once and returns in groups of **maximum size of 200**. Those groups are called pages and you can choose how many clients it will return
```python
clients_data_list = await api.get_clients_data()
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": [
{
"name": "Петров",
"id": 2
},
{
"name": "Сидоров",
"id": 3
},
{
"name": "Иванов",
"id": 1
}
],
"meta": {
"total_count": 908
}
}
```
</details>
____
- ### Parse clients data
```python
df = api.parse_clients_data(clients_data_list)
```
- ### Show ID, name and number of visits for all clients
```python
print(df[['id', 'name', 'visits']])
```
- ### Clients IDs list
```python
all_clients_ids = list(df['id'])
```
## Visits commands:
- ### Show all visits for client with Client_ID
> YCLIENTS API can't return all visits at once and returns in groups of **maximum size of 200**. Those groups are called pages and you can choose how many visits it will return
```python
cid = 20419758
client_visits = await api.get_visits_for_client(cid)
print(f'Client {cid} visits')
print(f'{pd.DataFrame(client_visits)}')
```
____
<details>
<summary>Response ...</summary>
```json
{
"success": true,
"data": [
{
"id": 2,
"company_id": 4564,
"staff_id": 9,
"services": [
{
"id": 1,
"title": "Наращивание волос",
"cost": 100,
"manual_cost": 100,
"cost_per_unit": 100,
"discount": 0,
"first_cost": 100,
"amount": 1
}
],
"goods_transactions": [],
"staff": {
"id": 9,
"name": "Оксана",
"specialization": "наращивание волос",
"position": {
"id": 1,
"title": "Администратор"
},
"avatar": "http://yclients.com/images/no-master-sm.png",
"avatar_big": "http://yclients.com/images/no-master.png",
"rating": 0,
"votes_count": 0
},
"date": 1547654400,
"datetime": 1547622000,
"create_date": "2019-01-16T20:35:11+0900",
"comment": "не записывать",
"online": false,
"visit_attendance": 0,
"attendance": 0,
"confirmed": 1,
"seance_length": 3600,
"length": 3600,
"sms_before": 0,
"sms_now": 0,
"sms_now_text": "",
"email_now": 0,
"notified": 0,
"master_request": 0,
"api_id": "",
"from_url": "",
"review_requested": 0,
"visit_id": "8262996",
"created_user_id": 1073232,
"deleted": false,
"paid_full": 0,
"prepaid": false,
"prepaid_confirmed": false,
"last_change_date": "2019-01-16T20:35:15+0900",
"custom_color": "",
"custom_font_color": "",
"record_labels": [],
"activity_id": 0,
"custom_fields": [],
"documents": [
{
"id": 8172893,
"type_id": 7,
"storage_id": 0,
"user_id": 746310,
"company_id": 4564,
"number": 4163,
"comment": "",
"date_created": 1530615600,
"category_id": 0,
"visit_id": 3,
"record_id": 2,
"type_title": "Визит"
}
],
"sms_remain_hours": 5,
"email_remain_hours": 1,
"bookform_id": 0,
"record_from": "",
"is_mobile": 0,
"is_sale_bill_printed": false,
"consumables": [],
"finance_transactions": []
},
{
"id": 9,
"company_id": 4564,
"staff_id": 49,
"services": [],
"goods_transactions": [],
"staff": {
"id": 49,
"name": "Сергей",
"specialization": "стилист",
"position": {
"id": 1,
"title": "Администратор"
},
"avatar": "http://yclients.com/images/no-master-sm.png",
"avatar_big": "http://yclients.com/images/no-master.png",
"rating": 0,
"votes_count": 0
},
"date": 1547654400,
"datetime": 1547622000,
"create_date": "2019-01-16T20:35:11+0900",
"comment": "",
"online": true,
"visit_attendance": 1,
"attendance": 1,
"confirmed": 1,
"seance_length": 10800,
"length": 10800,
"sms_before": 0,
"sms_now": 0,
"sms_now_text": "",
"email_now": 0,
"notified": 0,
"master_request": 1,
"api_id": "",
"from_url": "",
"review_requested": 0,
"visit_id": "8262996",
"created_user_id": 1073232,
"deleted": false,
"paid_full": 0,
"prepaid": false,
"prepaid_confirmed": false,
"last_change_date": "2017-01-09T20:45:30+0900",
"custom_color": "f44336",
"custom_font_color": "#ffffff",
"record_labels": [
{
"id": "67345",
"title": "Сотрудник не важен",
"color": "#009800",
"icon": "unlock",
"font_color": "#ffffff"
},
{
"id": "104474",
"title": "важная категория",
"color": "#3b2c54",
"icon": "odnoklassniki",
"font_color": "#ffffff"
}
],
"activity_id": 0,
"custom_fields": [],
"documents": [
{
"id": 8172893,
"type_id": 7,
"storage_id": 0,
"user_id": 746310,
"company_id": 4564,
"number": 4163,
"comment": "",
"date_created": 1530615600,
"category_id": 0,
"visit_id": 3,
"record_id": 2,
"type_title": "Визит"
}
],
"sms_remain_hours": 5,
"email_remain_hours": 1,
"bookform_id": 0,
"record_from": "",
"is_mobile": 0,
"is_sale_bill_printed": false,
"consumables": [],
"finance_transactions": []
}
],
"meta": {
"page": 1,
"total_count": 10
}
}
```
</details>
____
- ### Show all visits for all clients
```python
all_clients_visits = await api.get_visits_data_for_clients_list(all_clients_ids)
for cid in all_clients_visits.keys():
print(f'Client {cid} visits')
print(f'{pd.DataFrame(all_clients_visits[cid])}')
```
- ### Show all attended visits for client with Client_ID
> Attendance explanation from Yclient API:
>> 2 - The user has confirmed the entry,
>>> 1 - The user has arrived, the services are provided,
>>>> 0 - the user is waiting,
>>>>> -1 - the user did not come for a visit
```python
cid = 20419758
client_visits = await api.get_attended_visits_for_client(cid)
print(f'Client {cid} attended visits')
print(f'{pd.DataFrame(client_visits)}')
```
- ### Show attended visits information for clients:
```python
df = await api.get_attended_visits_dates_information(all_clients_ids)
print(f'Attended visits dataframe: {df}')
```
- ### Show attended visits information for clients with at least one visit:
```python
print(f"Attended visits ndataframe with no gaps {df[df['visits_number']>0]}")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/barabum0/asyyclients",
"name": "asyyclients",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "yclients,api,wrapper,python,httpx,ujson,async,asyncio,asynchronous",
"author": "Roman Poltorabatko",
"author_email": "barabum@duck.com",
"download_url": "https://files.pythonhosted.org/packages/52/01/8ae30e3f0edd74297c9513c9b45ba645ff3e2787c2187569d608e4402120/asyyclients-0.0.1.1.tar.gz",
"platform": "any",
"description": "![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)\r\n![Last Commit](https://img.shields.io/github/last-commit/barabum0/asyyclients?style=for-the-badge)\r\n[![Licence](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)](./LICENSE)\r\n\r\n# Asynchronous YCLIENTS API \r\n[![PyPI version](https://img.shields.io/pypi/v/asyyclients.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/yclients-api)\r\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/asyyclients.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/yclients-api)\r\n\r\n[//]: # ([![Tests Passing](https://github.com/CoolmixZero/yclients-api-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/CoolmixZero/yclients-api-python/actions))\r\n[![PyPI downloads](https://img.shields.io/pypi/dm/asyyclients.svg?style=flat-square)](https://pypi.org/project/yclients-api)\r\n\r\n### **Python [Async YCLIENTS API WRAPPER](https://github.com/barabum0/asyyclients/blob/main/yclients/yclients.py \"Opens yclients.py\") with [ujson](https://pypi.org/project/ujson/ \"Opens ujson documentation\") and [httpx](https://www.python-httpx.org/ \"Opens httpx documentation\") packages:**\r\n- PyPI page of project: https://pypi.org/project/asyyclients/\r\n\r\n- The code changed `httpx \u27f5 requests` and `ujson \u27f5 json` packages.\r\n > `ujson` and `httpx` **faster** than `json` and `requests`\r\n\r\n- An example of using library also implemented in the [example.py](https://github.com/barabum0/asyyclients/blob/main/example.py \"Opens example.py\").\r\n- This is an async implementation of [this project](https://github.com/CoolmixZero/yclients-api-python). Original author is Nikita Shalashkov\r\n\r\n> Please note that sending requests to get customer data can take time, especially if your database is quite large, since YCLIENTS API can return only 200 results at once. Also if sending one request takes more than a few seconds, you may need to connect to another Internet network.\r\n> \r\n# Installation:\r\n```shell\r\npip install asyyclients\r\n```\r\n____\r\n# Usage:\r\n## Create API object\r\n\r\n```python\r\nfrom asyyclients import AsyncYClientsAPI\r\n\r\nTOKEN = \"your token\"\r\n\u0421ID = 'your company id'\r\nFID = 'form id'\r\n\r\nasync def main():\r\n api = AsyncYClientsAPI(token=TOKEN, company_id=\u0421ID, form_id=FID)\r\n```\r\n## Show debugging process\r\n```python\r\napi.show_debugging()\r\n```\r\n## Booking commands:\r\n- ### Get staff info\r\n > Returns list of staff for specific service and date\r\n```python\r\nall_staff = await api.get_staff()\r\nprint(all_staff)\r\n\r\nstaff_id = all_staff['data'].get('id')\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": [\r\n {\r\n \"id\": \"16\",\r\n \"name\": \"\u0412\u0430\u0441\u044f\",\r\n \"bookable\": true,\r\n \"specialization\": \"\u0424\u0435\u043b\u044c\u0434\u0448\u0435\u0440\",\r\n \"position\": {\r\n \"id\": 1,\r\n \"title\": \"\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\"\r\n },\r\n \"show_rating\": \"1\",\r\n \"rating\": \"3\",\r\n \"votes_count\": \"1\",\r\n \"avatar\": \"https://yclients.com/images/no-master.png\",\r\n \"comments_count\": \"0\",\r\n \"weight\": \"11\",\r\n \"information\": \"<span></span>\",\r\n \"seance_date\": 1443139200,\r\n \"seances\": []\r\n },\r\n {\r\n \"id\": \"32\",\r\n \"name\": \"\u041f\u0435\u0442\u044f\",\r\n \"bookable\": false,\r\n \"specialization\": \"\u0422\u0435\u0440\u0430\u043f\u0435\u0432\u0442\",\r\n \"position\": [],\r\n \"show_rating\": \"1\",\r\n \"rating\": \"4\",\r\n \"votes_count\": \"1\",\r\n \"avatar\": \"https://yclients.com/images/no-master.png\",\r\n \"comments_count\": \"0\",\r\n \"weight\": \"8\",\r\n \"information\": \"<span></span>\"\r\n }\r\n ],\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Get services info\r\n > Returns list of services for specific staff and date\r\n```python\r\nservices = await api.get_services(staff_id=staff_id)\r\nprint(services)\r\n\r\nservice_id = services['data']['services'].get('id')\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": {\r\n \"events\": [],\r\n \"services\": [\r\n {\r\n \"id\": 1896208,\r\n \"title\": \"\u041c\u044b\u0442\u044c\u0435 \u0432\u043e\u043b\u043e\u0441\",\r\n \"category_id\": 1895571,\r\n \"price_min\": 0,\r\n \"price_max\": 0,\r\n \"discount\": 0,\r\n \"comment\": \"\",\r\n \"weight\": 0,\r\n \"active\": 0,\r\n \"sex\": 0,\r\n \"image\": \"\",\r\n \"prepaid\": \"forbidden\",\r\n \"seance_length\": 3600\r\n },\r\n {\r\n \"id\": 1896303,\r\n \"title\": \"\u041e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u043d\u0438\u0435\",\r\n \"category_id\": 1895574,\r\n \"price_min\": 0,\r\n \"price_max\": 0,\r\n \"discount\": 0,\r\n \"comment\": \"\",\r\n \"weight\": 0,\r\n \"active\": 0,\r\n \"sex\": 0,\r\n \"image\": \"\",\r\n \"prepaid\": \"forbidden\",\r\n \"seance_length\": 3600\r\n }\r\n ],\r\n \"category\": [\r\n {\r\n \"id\": 1895571,\r\n \"title\": \"\u0423\u0445\u043e\u0434\u044b \u0434\u043b\u044f \u0432\u043e\u043b\u043e\u0441\",\r\n \"sex\": 0,\r\n \"api_id\": 0,\r\n \"weight\": 60\r\n },\r\n {\r\n \"id\": 1895574,\r\n \"title\": \"\u041e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u043b\u043e\u0441\",\r\n \"sex\": 0,\r\n \"api_id\": 0,\r\n \"weight\": 7\r\n }\r\n ]\r\n },\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Get booking dates\r\n > Returns all available days for specific staff and service\r\n```python\r\nbooking_days = await api.get_available_days(staff_id=staff_id, service_id=service_id)\r\nprint(booking_days)\r\n\r\nday = booking_days['data'].get('booking_dates') # or .get('booking_days')\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": {\r\n \"booking_days\": {\r\n \"9\": [\r\n \"4\",\r\n \"5\",\r\n \"8\",\r\n \"9\",\r\n \"12\",\r\n \"13\",\r\n \"16\",\r\n \"17\",\r\n \"20\",\r\n \"21\",\r\n \"24\",\r\n \"25\",\r\n \"28\",\r\n \"29\",\r\n \"30\"\r\n ],\r\n \"10\": [\r\n \"1\",\r\n \"4\",\r\n \"5\",\r\n \"8\",\r\n \"9\",\r\n \"12\",\r\n \"13\",\r\n \"16\",\r\n \"17\",\r\n \"20\",\r\n \"21\",\r\n \"24\",\r\n \"25\"\r\n ]\r\n },\r\n \"booking_dates\": [\r\n 1441324800,\r\n 1441411200,\r\n 1441670400,\r\n 1441756800,\r\n 1442016000,\r\n 1442102400,\r\n 1442361600,\r\n 1442448000,\r\n 1442707200,\r\n 1442793600,\r\n 1443052800,\r\n 1443139200,\r\n 1443398400,\r\n 1443484800,\r\n 1443571200,\r\n 1443657600,\r\n 1443916800,\r\n 1444003200,\r\n 1444262400,\r\n 1444348800,\r\n 1444608000,\r\n 1444694400,\r\n 1444953600,\r\n 1445040000,\r\n 1445299200,\r\n 1445385600,\r\n 1445644800,\r\n 1445731200\r\n ],\r\n \"working_days\": {\r\n \"9\": [\r\n \"4\",\r\n \"5\",\r\n \"8\",\r\n \"9\",\r\n \"12\",\r\n \"13\",\r\n \"16\",\r\n \"17\",\r\n \"20\",\r\n \"21\",\r\n \"24\",\r\n \"25\",\r\n \"28\",\r\n \"29\",\r\n \"30\"\r\n ],\r\n \"10\": [\r\n \"1\",\r\n \"4\",\r\n \"5\",\r\n \"8\",\r\n \"9\",\r\n \"12\",\r\n \"13\",\r\n \"16\",\r\n \"17\",\r\n \"20\",\r\n \"21\",\r\n \"24\",\r\n \"25\"\r\n ]\r\n },\r\n \"working_dates\": [\r\n 1441324800,\r\n 1441411200,\r\n 1441670400,\r\n 1441756800,\r\n 1442016000,\r\n 1442102400,\r\n 1442361600,\r\n 1442448000,\r\n 1442707200,\r\n 1442793600,\r\n 1443052800,\r\n 1443139200,\r\n 1443398400,\r\n 1443484800,\r\n 1443571200,\r\n 1443657600,\r\n 1443916800,\r\n 1444003200,\r\n 1444262400,\r\n 1444348800,\r\n 1444608000,\r\n 1444694400,\r\n 1444953600,\r\n 1445040000,\r\n 1445299200,\r\n 1445385600,\r\n 1445644800,\r\n 1445731200\r\n ]\r\n },\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Get booking times\r\n > Returns all available times slots on specific day staff and service\r\n```python\r\ntime_slots = await api.get_available_times(staff_id=staff_id, service_id=service_id, day=day)\r\nprint(time_slots)\r\n\r\ndate_time = time_slots['data'].get('time') # or .get('datetime')\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": [\r\n {\r\n \"time\": \"12:00\",\r\n \"seance_length\": 3600,\r\n \"datetime\": 1443513600\r\n },\r\n {\r\n \"time\": \"13:00\",\r\n \"seance_length\": 3600,\r\n \"datetime\": 1443517200\r\n },\r\n {\r\n \"time\": \"14:00\",\r\n \"seance_length\": 3600,\r\n \"datetime\": 1443520800\r\n },\r\n {\r\n \"time\": \"15:00\",\r\n \"seance_length\": 3600,\r\n \"datetime\": 1443524400\r\n },\r\n {\r\n \"time\": \"16:00\",\r\n \"seance_length\": 3600,\r\n \"datetime\": 1443528000\r\n }\r\n ],\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Book\r\n```python\r\nbooked, message = await api.book(booking_id=0, \r\n fullname='my name', \r\n phone='53425345', \r\n email='myemail@email.com, \r\n service_id=service_id, \r\n date_time=date_time, \r\n staff_id=staff_id, \r\n comment='some comment')\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": [\r\n {\r\n \"id\": 1,\r\n \"record_id\": 2820023,\r\n \"record_hash\": \"567df655304da9b98487769426d4e76e\"\r\n },\r\n {\r\n \"id\": 2,\r\n \"record_id\": 2820024,\r\n \"record_hash\": \"34a45ddabdd446d5d33bdd27fbf855b2\"\r\n }\r\n ],\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n<details>\r\n<summary>Payload(JSON) example ...</summary>\r\n \r\n```json\r\n{\r\n \"phone\": \"79000000000\",\r\n \"fullname\": \"\u0414\u0418\u041c\u0410\",\r\n \"email\": \"d@asyyclients.com\",\r\n \"code\": \"38829\",\r\n \"comment\": \"\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c!\",\r\n \"type\": \"mobile\",\r\n \"notify_by_sms\": 6,\r\n \"notify_by_email\": 24,\r\n \"api_id\": \"777\",\r\n \"appointments\": [\r\n {\r\n \"id\": 1,\r\n \"services\": [\r\n 331\r\n ],\r\n \"staff_id\": 6544,\r\n \"datetime\": 1443517200,\r\n \"custom_fields\": {\r\n \"my_custom_field\": 123,\r\n \"some_another_field\": [\r\n \"first value\",\r\n \"next value\"\r\n ]\r\n }\r\n },\r\n {\r\n \"id\": 2,\r\n \"services\": [\r\n 99055\r\n ],\r\n \"staff_id\": 6544,\r\n \"datetime\": 1443614400,\r\n \"custom_fields\": {\r\n \"my_custom_field\": 456,\r\n \"some_another_field\": [\r\n \"next value\",\r\n \"last value\"\r\n ]\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n## User commands:\r\n- ### Get USER TOKEN from the system\r\n > You can save this TOKEN (like BEARER TOKEN) and there is no need to update it every time\r\n```python\r\nlogin = \"example@gmail.com\"\r\npassword = \"password\"\r\n\r\nuser_token = await api.get_user_token(login, password)\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"id\": 123456,\r\n \"user_token\": \"wec23fh8cDfFV4432fc352456\",\r\n \"name\": \"\u0418\u0432\u0430\u043d \u041f\u043e\u043f\u043e\u0432\",\r\n \"phone\": \"79161001010\",\r\n \"login\": \"79161001010\",\r\n \"email\": \"test@test.com\",\r\n \"avatar\": \"https://assets.yclients.com/general/0/01/123456789098765_12345678909876.png\"\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Update autorisation parameters of the API class with USER TOKEN\r\n > After USER TOKEN was obtained you need to include it in header of requests that you are sending\r\n```python\r\nawait api.update_user_token(user_token)\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": {\r\n \"user_token\": \"4de9d8cc108c0\"\r\n },\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Shows USER permissions\r\n```python\r\nawait api.show_user_permissions()\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": {\r\n \"timetable\": {\r\n \"timetable_access\": true,\r\n \"master_id\": 1000238,\r\n \"position_id\": 0,\r\n \"last_days_count\": 1000,\r\n \"schedule_edit_access\": true,\r\n \"timetable_phones_access\": true,\r\n \"timetable_transferring_record_access\": true,\r\n \"timetable_statistics_access\": true\r\n },\r\n \"record_form\": {\r\n \"record_form_access\": true,\r\n \"record_form_client_access\": true,\r\n \"records_autocomplete_access\": true,\r\n \"create_records_access\": true,\r\n \"edit_records_access\": true,\r\n \"edit_records_attendance_access\": true,\r\n \"records_services_cost_access\": true,\r\n \"records_services_discount_access\": true,\r\n \"record_edit_full_paid_access\": true,\r\n \"delete_records_access\": true,\r\n \"delete_customer_came_records_access\": true,\r\n \"delete_paid_records_access\": true,\r\n \"records_goods_access\": true,\r\n \"records_goods_create_transaction_access\": true,\r\n \"records_goods_create_last_days_count\": -1,\r\n \"records_goods_edit_transaction_access\": true,\r\n \"records_goods_edit_last_days_count\": -1,\r\n \"records_goods_cost_access\": true,\r\n \"records_goods_discount_access\": true,\r\n \"records_finances_access\": true,\r\n \"records_finances_last_days_count\": -1,\r\n \"records_finances_pay_from_deposits_access\": true,\r\n \"records_group_id_access\": true,\r\n \"records_group_id\": 134178\r\n },\r\n \"finances\": {\r\n \"finances_access\": true,\r\n \"finances_accounts_ids\": [],\r\n \"finances_transactions_access\": true,\r\n \"finances_last_days_count\": -1,\r\n \"finances_create_transactions_access\": true,\r\n \"finances_create_last_days_count\": -1,\r\n \"finances_edit_transactions_access\": true,\r\n \"finances_edit_last_days_count\": -1,\r\n \"finances_delete_transactions_access\": true,\r\n \"finances_transactions_excel_access\": true,\r\n \"finances_expenses_ids\": [],\r\n \"finances_accounts_access\": true,\r\n \"finances_accounts_banalce_access\": true,\r\n \"finances_suppliers_read_access\": true,\r\n \"finances_suppliers_create_access\": true,\r\n \"finances_suppliers_update_access\": true,\r\n \"finances_suppliers_delete_access\": true,\r\n \"finances_suppliers_excel_access\": true,\r\n \"finances_expenses_read_access\": true,\r\n \"expenses_read_access\": true,\r\n \"finances_expenses_create_access\": true,\r\n \"expenses_create_access\": true,\r\n \"finances_expenses_update_access\": true,\r\n \"expenses_update_access\": true,\r\n \"finances_expenses_delete_access\": true,\r\n \"expenses_delete_access\": true,\r\n \"finances_kkm_transactions_access\": true,\r\n \"kkm_transactions_accounts_access\": true,\r\n \"finances_kkm_settings_read_access\": true,\r\n \"kkm_settings_reed_access\": true,\r\n \"finances_kkm_settings_update_access\": true,\r\n \"kkm_settings_update_access\": true,\r\n \"finances_settings_invoicing_read_access\": true,\r\n \"settings_invoicing_read_access\": true,\r\n \"finances_settings_invoicing_update_access\": true,\r\n \"settings_invoicing_update_access\": true,\r\n \"finances_options_read_access\": true,\r\n \"options_read_access\": true,\r\n \"finances_options_update_access\": true,\r\n \"options_update_access\": true,\r\n \"finances_salary_schemes_access\": true,\r\n \"finances_salary_calc_access\": true,\r\n \"finances_salary_not_limitation_today_access\": true,\r\n \"finances_payroll_calculation_create_access\": true,\r\n \"finances_payroll_calculation_create_not_limitation_today_access\": true,\r\n \"finances_salary_access_master_checkbox\": true,\r\n \"finances_salary_access_master_id\": 1000237,\r\n \"get_salary_access_master_id\": 1000237,\r\n \"finances_salary_master_not_limitation_today_access\": true,\r\n \"finances_payroll_calculation_create_by_master_access\": true,\r\n \"calculation_create_by_master_not_limitation_today_access\": true,\r\n \"finances_period_report_access\": true,\r\n \"finances_period_report_excel_access\": true,\r\n \"finances_year_report_access\": true,\r\n \"finances_year_report_excel_access\": true,\r\n \"finances_print_check_access\": true,\r\n \"finances_z_report_access\": true,\r\n \"finances_z_report_no_limit_today_access\": true,\r\n \"finances_z_report_excel_access\": true\r\n },\r\n \"clients\": {\r\n \"clients_access\": true,\r\n \"client_phones_access\": true,\r\n \"clients_phones_email_access\": true,\r\n \"clients_card_phone_access\": true,\r\n \"clients_delete_access\": true,\r\n \"clients_excel_access\": true,\r\n \"excel_access\": true,\r\n \"client_comments_list_access\": true,\r\n \"client_comments_add_access\": true,\r\n \"client_comments_own_edit_access\": true,\r\n \"client_comments_other_edit_access\": true,\r\n \"client_files_list_access\": true,\r\n \"client_files_upload_access\": true,\r\n \"client_files_delete_access\": true,\r\n \"clients_visit_master_id\": 0,\r\n \"get_visit_master_id\": 0\r\n },\r\n \"dashboard\": {\r\n \"dashboard_access\": true,\r\n \"dash_access\": true,\r\n \"dash_phones_access\": true,\r\n \"dash_records_access\": true,\r\n \"dash_records_last_days_count\": -1,\r\n \"dash_records_excel_access\": true,\r\n \"dash_records_phones_access\": true,\r\n \"dash_message_access\": true,\r\n \"dash_message_excel_access\": true,\r\n \"dash_message_phones_access\": true,\r\n \"dash_reviews_access\": true,\r\n \"dash_reviews_delete_access\": true,\r\n \"dashboard_calls_access\": true,\r\n \"dashboard_calls_excel_access\": true,\r\n \"dashboard_calls_phones_access\": true\r\n },\r\n \"notification\": {\r\n \"notification\": true,\r\n \"web_push\": true,\r\n \"web_phone_push\": true,\r\n \"notification_sms_ending_license\": true,\r\n \"notification_sms_low_balance\": true,\r\n \"notification_email_ending_license\": true\r\n },\r\n \"loyalty\": {\r\n \"loyalty_access\": true,\r\n \"has_loyalty_access\": true,\r\n \"loyalty_cards_manual_transactions_access\": true,\r\n \"has_loyalty_cards_manual_transactions_access\": true,\r\n \"loyalty_certificate_and_abonement_manual_transactions_access\": true\r\n },\r\n \"storages\": {\r\n \"storages_access\": true,\r\n \"storages_ids\": [],\r\n \"storages_transactions_access\": true,\r\n \"storages_last_days_count\": -1,\r\n \"storages_move_goods_access\": true,\r\n \"storages_create_transactions_access\": true,\r\n \"storages_create_last_days_count\": -1,\r\n \"storages_create_transactions_buy_access\": true,\r\n \"storages_create_transactions_sale_access\": true,\r\n \"storages_edit_transactions_access\": true,\r\n \"storages_edit_last_days_count\": -1,\r\n \"storages_edit_transactions_buy_access\": true,\r\n \"storages_edit_transactions_sale_access\": true,\r\n \"storages_delete_transactions_access\": true,\r\n \"storages_transactions_excel_access\": true,\r\n \"storages_transactions_types\": [],\r\n \"storages_inventory_access\": true,\r\n \"storages_inventory_create_edit_access\": true,\r\n \"storages_inventory_delete_access\": true,\r\n \"storages_inventory_excel_access\": true,\r\n \"storages_remnants_report_access\": true,\r\n \"storages_remnants_report_excel_access\": true,\r\n \"storages_sales_report_access\": true,\r\n \"storages_sales_report_excel_access\": true,\r\n \"storages_consumable_report_access\": true,\r\n \"storages_consumable_report_excel_access\": true,\r\n \"storages_write_off_report_access\": true,\r\n \"storages_write_off_report_excel_access\": true,\r\n \"storages_turnover_report_access\": true,\r\n \"storages_turnover_report_excel_access\": true,\r\n \"storages_goods_crud_access\": true,\r\n \"storages_goods_create_access\": true,\r\n \"storages_goods_update_access\": true,\r\n \"storages_goods_title_edit_access\": true,\r\n \"storages_goods_category_edit_access\": true,\r\n \"storages_goods_selling_price_edit_access\": true,\r\n \"storages_goods_cost_price_edit_access\": true,\r\n \"storages_goods_units_edit_access\": true,\r\n \"storages_goods_critical_balance_edit_access\": true,\r\n \"storages_goods_masses_edit_access\": true,\r\n \"storages_goods_comment_edit_access\": true,\r\n \"storages_goods_archive_access\": true,\r\n \"storages_goods_delete_access\": true\r\n },\r\n \"settings\": {\r\n \"settings_access\": true,\r\n \"settings_basis_access\": true,\r\n \"settings_information_access\": true,\r\n \"users_access\": true,\r\n \"delete_users_access\": true,\r\n \"create_users_access\": true,\r\n \"edit_users_access\": true,\r\n \"limited_users_access\": false,\r\n \"settings_services_access\": true,\r\n \"settings_services_create_access\": true,\r\n \"services_edit\": true,\r\n \"settings_services_edit_title_access\": true,\r\n \"settings_services_relation_category_access\": true,\r\n \"settings_services_edit_price_access\": true,\r\n \"settings_services_edit_image_access\": true,\r\n \"settings_services_edit_online_seance_date_time_access\": true,\r\n \"settings_services_edit_online_pay_access\": true,\r\n \"settings_services_edit_services_related_resource_access\": true,\r\n \"settings_positions_read\": true,\r\n \"settings_positions_create\": true,\r\n \"settings_positions_delete\": true,\r\n \"edit_master_service_and_duration\": true,\r\n \"tech_card_edit\": true,\r\n \"services_delete\": true,\r\n \"settings_master_access\": true,\r\n \"master_create\": true,\r\n \"master_edit\": true,\r\n \"master_delete\": true,\r\n \"settings_master_dismiss_access\": true,\r\n \"schedule_edit\": true,\r\n \"settings_notifications_access\": true,\r\n \"settings_email_notifications_access\": true,\r\n \"settings_template_notifications_access\": true,\r\n \"webhook_read_access\": true\r\n },\r\n \"other\": {\r\n \"stat_access\": true,\r\n \"billing_access\": true,\r\n \"send_sms\": true,\r\n \"auth_enable_check_ip\": false,\r\n \"auth_list_allowed_ip\": []\r\n }\r\n },\r\n \"meta\": []\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n## Client commands:\r\n- ### Get clients list\r\n > YCLIENTS API can't return all clients at once and returns in groups of **maximum size of 200**. Those groups are called pages and you can choose how many clients it will return\r\n```python\r\nclients_data_list = await api.get_clients_data()\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": [\r\n {\r\n \"name\": \"\u041f\u0435\u0442\u0440\u043e\u0432\",\r\n \"id\": 2\r\n },\r\n {\r\n \"name\": \"\u0421\u0438\u0434\u043e\u0440\u043e\u0432\",\r\n \"id\": 3\r\n },\r\n {\r\n \"name\": \"\u0418\u0432\u0430\u043d\u043e\u0432\",\r\n \"id\": 1\r\n }\r\n ],\r\n \"meta\": {\r\n \"total_count\": 908\r\n }\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Parse clients data\r\n```python\r\ndf = api.parse_clients_data(clients_data_list)\r\n``` \r\n- ### Show ID, name and number of visits for all clients\r\n```python\r\nprint(df[['id', 'name', 'visits']])\r\n```\r\n- ### Clients IDs list\r\n```python\r\nall_clients_ids = list(df['id'])\r\n```\r\n## Visits commands:\r\n- ### Show all visits for client with Client_ID\r\n > YCLIENTS API can't return all visits at once and returns in groups of **maximum size of 200**. Those groups are called pages and you can choose how many visits it will return\r\n```python\r\ncid = 20419758\r\nclient_visits = await api.get_visits_for_client(cid)\r\nprint(f'Client {cid} visits')\r\nprint(f'{pd.DataFrame(client_visits)}')\r\n```\r\n\r\n____\r\n\r\n<details>\r\n<summary>Response ...</summary>\r\n \r\n```json\r\n{\r\n \"success\": true,\r\n \"data\": [\r\n {\r\n \"id\": 2,\r\n \"company_id\": 4564,\r\n \"staff_id\": 9,\r\n \"services\": [\r\n {\r\n \"id\": 1,\r\n \"title\": \"\u041d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u043b\u043e\u0441\",\r\n \"cost\": 100,\r\n \"manual_cost\": 100,\r\n \"cost_per_unit\": 100,\r\n \"discount\": 0,\r\n \"first_cost\": 100,\r\n \"amount\": 1\r\n }\r\n ],\r\n \"goods_transactions\": [],\r\n \"staff\": {\r\n \"id\": 9,\r\n \"name\": \"\u041e\u043a\u0441\u0430\u043d\u0430\",\r\n \"specialization\": \"\u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u043b\u043e\u0441\",\r\n \"position\": {\r\n \"id\": 1,\r\n \"title\": \"\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\"\r\n },\r\n \"avatar\": \"http://yclients.com/images/no-master-sm.png\",\r\n \"avatar_big\": \"http://yclients.com/images/no-master.png\",\r\n \"rating\": 0,\r\n \"votes_count\": 0\r\n },\r\n \"date\": 1547654400,\r\n \"datetime\": 1547622000,\r\n \"create_date\": \"2019-01-16T20:35:11+0900\",\r\n \"comment\": \"\u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\",\r\n \"online\": false,\r\n \"visit_attendance\": 0,\r\n \"attendance\": 0,\r\n \"confirmed\": 1,\r\n \"seance_length\": 3600,\r\n \"length\": 3600,\r\n \"sms_before\": 0,\r\n \"sms_now\": 0,\r\n \"sms_now_text\": \"\",\r\n \"email_now\": 0,\r\n \"notified\": 0,\r\n \"master_request\": 0,\r\n \"api_id\": \"\",\r\n \"from_url\": \"\",\r\n \"review_requested\": 0,\r\n \"visit_id\": \"8262996\",\r\n \"created_user_id\": 1073232,\r\n \"deleted\": false,\r\n \"paid_full\": 0,\r\n \"prepaid\": false,\r\n \"prepaid_confirmed\": false,\r\n \"last_change_date\": \"2019-01-16T20:35:15+0900\",\r\n \"custom_color\": \"\",\r\n \"custom_font_color\": \"\",\r\n \"record_labels\": [],\r\n \"activity_id\": 0,\r\n \"custom_fields\": [],\r\n \"documents\": [\r\n {\r\n \"id\": 8172893,\r\n \"type_id\": 7,\r\n \"storage_id\": 0,\r\n \"user_id\": 746310,\r\n \"company_id\": 4564,\r\n \"number\": 4163,\r\n \"comment\": \"\",\r\n \"date_created\": 1530615600,\r\n \"category_id\": 0,\r\n \"visit_id\": 3,\r\n \"record_id\": 2,\r\n \"type_title\": \"\u0412\u0438\u0437\u0438\u0442\"\r\n }\r\n ],\r\n \"sms_remain_hours\": 5,\r\n \"email_remain_hours\": 1,\r\n \"bookform_id\": 0,\r\n \"record_from\": \"\",\r\n \"is_mobile\": 0,\r\n \"is_sale_bill_printed\": false,\r\n \"consumables\": [],\r\n \"finance_transactions\": []\r\n },\r\n {\r\n \"id\": 9,\r\n \"company_id\": 4564,\r\n \"staff_id\": 49,\r\n \"services\": [],\r\n \"goods_transactions\": [],\r\n \"staff\": {\r\n \"id\": 49,\r\n \"name\": \"\u0421\u0435\u0440\u0433\u0435\u0439\",\r\n \"specialization\": \"\u0441\u0442\u0438\u043b\u0438\u0441\u0442\",\r\n \"position\": {\r\n \"id\": 1,\r\n \"title\": \"\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\"\r\n },\r\n \"avatar\": \"http://yclients.com/images/no-master-sm.png\",\r\n \"avatar_big\": \"http://yclients.com/images/no-master.png\",\r\n \"rating\": 0,\r\n \"votes_count\": 0\r\n },\r\n \"date\": 1547654400,\r\n \"datetime\": 1547622000,\r\n \"create_date\": \"2019-01-16T20:35:11+0900\",\r\n \"comment\": \"\",\r\n \"online\": true,\r\n \"visit_attendance\": 1,\r\n \"attendance\": 1,\r\n \"confirmed\": 1,\r\n \"seance_length\": 10800,\r\n \"length\": 10800,\r\n \"sms_before\": 0,\r\n \"sms_now\": 0,\r\n \"sms_now_text\": \"\",\r\n \"email_now\": 0,\r\n \"notified\": 0,\r\n \"master_request\": 1,\r\n \"api_id\": \"\",\r\n \"from_url\": \"\",\r\n \"review_requested\": 0,\r\n \"visit_id\": \"8262996\",\r\n \"created_user_id\": 1073232,\r\n \"deleted\": false,\r\n \"paid_full\": 0,\r\n \"prepaid\": false,\r\n \"prepaid_confirmed\": false,\r\n \"last_change_date\": \"2017-01-09T20:45:30+0900\",\r\n \"custom_color\": \"f44336\",\r\n \"custom_font_color\": \"#ffffff\",\r\n \"record_labels\": [\r\n {\r\n \"id\": \"67345\",\r\n \"title\": \"\u0421\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a \u043d\u0435 \u0432\u0430\u0436\u0435\u043d\",\r\n \"color\": \"#009800\",\r\n \"icon\": \"unlock\",\r\n \"font_color\": \"#ffffff\"\r\n },\r\n {\r\n \"id\": \"104474\",\r\n \"title\": \"\u0432\u0430\u0436\u043d\u0430\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\",\r\n \"color\": \"#3b2c54\",\r\n \"icon\": \"odnoklassniki\",\r\n \"font_color\": \"#ffffff\"\r\n }\r\n ],\r\n \"activity_id\": 0,\r\n \"custom_fields\": [],\r\n \"documents\": [\r\n {\r\n \"id\": 8172893,\r\n \"type_id\": 7,\r\n \"storage_id\": 0,\r\n \"user_id\": 746310,\r\n \"company_id\": 4564,\r\n \"number\": 4163,\r\n \"comment\": \"\",\r\n \"date_created\": 1530615600,\r\n \"category_id\": 0,\r\n \"visit_id\": 3,\r\n \"record_id\": 2,\r\n \"type_title\": \"\u0412\u0438\u0437\u0438\u0442\"\r\n }\r\n ],\r\n \"sms_remain_hours\": 5,\r\n \"email_remain_hours\": 1,\r\n \"bookform_id\": 0,\r\n \"record_from\": \"\",\r\n \"is_mobile\": 0,\r\n \"is_sale_bill_printed\": false,\r\n \"consumables\": [],\r\n \"finance_transactions\": []\r\n }\r\n ],\r\n \"meta\": {\r\n \"page\": 1,\r\n \"total_count\": 10\r\n }\r\n}\r\n```\r\n \r\n</details>\r\n\r\n____\r\n\r\n- ### Show all visits for all clients\r\n```python\r\nall_clients_visits = await api.get_visits_data_for_clients_list(all_clients_ids)\r\nfor cid in all_clients_visits.keys():\r\n print(f'Client {cid} visits')\r\n print(f'{pd.DataFrame(all_clients_visits[cid])}')\r\n```\r\n- ### Show all attended visits for client with Client_ID\r\n > Attendance explanation from Yclient API:\r\n >> 2 - The user has confirmed the entry,\r\n >>> 1 - The user has arrived, the services are provided,\r\n >>>> 0 - the user is waiting,\r\n >>>>> -1 - the user did not come for a visit\r\n```python\r\ncid = 20419758\r\nclient_visits = await api.get_attended_visits_for_client(cid)\r\nprint(f'Client {cid} attended visits')\r\nprint(f'{pd.DataFrame(client_visits)}')\r\n```\r\n- ### Show attended visits information for clients:\r\n```python\r\ndf = await api.get_attended_visits_dates_information(all_clients_ids)\r\nprint(f'Attended visits dataframe: {df}')\r\n```\r\n- ### Show attended visits information for clients with at least one visit:\r\n```python\r\nprint(f\"Attended visits ndataframe with no gaps {df[df['visits_number']>0]}\")\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python asynchronous YCLIENTS REST API wrapper on ujson and httpx",
"version": "0.0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/barabum0/asyyclients/issues",
"Homepage": "https://github.com/barabum0/asyyclients"
},
"split_keywords": [
"yclients",
"api",
"wrapper",
"python",
"httpx",
"ujson",
"async",
"asyncio",
"asynchronous"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "03c21b9e52bf51bc878f988e5fad4662bd8215d59565c62507426124e774a263",
"md5": "969a69f97a439426229ff8901482e7d4",
"sha256": "06714cd8c3d48fcf89d1f7608ad8988f817ada93fa855dbb4fbaa7cd321c1155"
},
"downloads": -1,
"filename": "asyyclients-0.0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "969a69f97a439426229ff8901482e7d4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12639,
"upload_time": "2023-07-13T18:40:37",
"upload_time_iso_8601": "2023-07-13T18:40:37.829008Z",
"url": "https://files.pythonhosted.org/packages/03/c2/1b9e52bf51bc878f988e5fad4662bd8215d59565c62507426124e774a263/asyyclients-0.0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "52018ae30e3f0edd74297c9513c9b45ba645ff3e2787c2187569d608e4402120",
"md5": "107e0c242af02f1f90a41de7c6130cdc",
"sha256": "255db0ec16729ab8ea2f87806444faa1e2cc9745ece0587d6ed22e298174a33e"
},
"downloads": -1,
"filename": "asyyclients-0.0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "107e0c242af02f1f90a41de7c6130cdc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 18527,
"upload_time": "2023-07-13T18:40:40",
"upload_time_iso_8601": "2023-07-13T18:40:40.523223Z",
"url": "https://files.pythonhosted.org/packages/52/01/8ae30e3f0edd74297c9513c9b45ba645ff3e2787c2187569d608e4402120/asyyclients-0.0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-13 18:40:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "barabum0",
"github_project": "asyyclients",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "asyyclients"
}