-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaadhaar.py
52 lines (48 loc) · 1.34 KB
/
aadhaar.py
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
from datetime import datetime
import requests
import uuid
def generate_unique_token():
token = str(uuid.uuid4())
return token
def get_details(aadhaar):
url = f"https://testapi-11co.onrender.com/aadhaar/{aadhaar}"
response = requests.get(url)
length=len(response.json())
if length>1:
data = response.json()
dob = data['DOB']
age = calculate_age(dob)
else:
return None
return {
'aadhaar': data['adhar_no'],
'name': data['name'],
'dob': dob,
'age': age,
'gender': data['gender'],
'address': data['address'],
'mobile': data['mobile_no']
}
def get_licence_detail(licence):
url = f"https://pharmacyapi.onrender.com/licence/{licence}"
response = requests.get(url)
length=len(response.json())
print(response.json())
if length>1:
data = response.json()
else:
return None
return {
'licence': data['licence'],
'gst' : data['gst_no'],
'name': data['name'],
'address': data['address'],
'mobile': data['mobile_number']
}
def calculate_age(dob):
dob_datetime = datetime.strptime(dob, "%Y-%m-%d").date()
today = datetime.now().date()
age = today.year - dob_datetime.year
if today < dob_datetime.replace(year=today.year):
age -= 1
return age