-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
69 lines (53 loc) · 2.09 KB
/
main.py
File metadata and controls
69 lines (53 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
Code last update 15.05.2021
This is example use of yclients library.
"""
from yclients import YClientsAPI
import pandas as pd
if __name__ == '__main__':
TOKEN = "your_token"
СID = 'your_company_id'
FID = 'form id'
# Your yclients autorisation information
login = "example@gmail.com"
password = "password"
# Create api object
api = YClientsAPI(token=TOKEN, company_id=СID, form_id=FID)
# Show debugging process
api.show_debugging()
# Get user token from the system
# You can save this token (like bearer token)
# and there is no need to update it every time
user_token = api.get_user_token(login, password)
# Update autorisation parameters of the api class with user token
api.update_user_token(user_token)
# Shows user permissions
api.show_user_permissions()
# Get clients list
clients_data_list = api.get_clients_data()
# parse clients data
df = api.parse_clients_data(clients_data_list)
# show id, name and number of visits for all clients
print(df[['id', 'name', 'visits']])
# clients ids list
all_clients_ids = list(df['id'])
# show all visits for client with cid
cid = 20419758
client_visits = api.get_visits_for_client(cid)
print(f'Client {cid} visits')
print(f'{pd.DataFrame(client_visits)}')
# show all visits for all clients
all_clients_visits = 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 cid
cid = 20419758
client_visits = 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:
df = 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:
print(f"Attended visits ndataframe with no gaps {df[df['visits_number']>0]}")