import requests
import json

api_key = "14ff7834-95c7-41bf-b883-6a6edc3bd5cb"


def sendAadharOTP(id_number):

    url = "https://api.quickekyc.com/api/v1/aadhaar-v2/generate-otp"

    payload = json.dumps({"key": api_key, "id_number": id_number})
    headers = {"Content-Type": "application/json"}

    response = requests.request("POST", url, headers=headers, data=payload)

    if response.status_code == 200:
        return response.json()
    else:
        return None


def verifyAadharOTP(request_id, otp):

    url = "https://api.quickekyc.com/api/v1/aadhaar-v2/submit-otp"

    payload = json.dumps({"key": api_key, "request_id": request_id, "otp": otp})
    headers = {"Content-Type": "application/json"}

    response = requests.request("POST", url, headers=headers, data=payload)

    if response.status_code == 200:
        return response.json()
    else:
        return None


def verifyPANCard(id_number):

    url = "https://api.quickekyc.com/api/v1/pan/pan"

    payload = json.dumps({"key": api_key, "id_number": id_number})
    headers = {"Content-Type": "application/json"}

    response = requests.request("POST", url, headers=headers, data=payload)

    if response.status_code == 200:
        return response.json()
    else:
        return None


# print(verifyPANCard('DXKPP7384A'))
#{'pan_number': 'DXKPP7384A', 'full_name': 'NEERAJ  PATHAK', 'category': 'individual'}

# print(sendAadharOTP('357340311706'))
# {'data': {'otp_sent': True, 'if_number': True, 'valid_aadhaar': True, 'status': 'generate_otp_success'}, 'status_code': 200, 'message': 'OTP Sent.', 'status': 'success', 'request_id': 2275479}


# print(verifyAadharOTP('2275479', '342327'))
# {'data': {'full_name': 'Neeraj Pathak', 'aadhaar_number': '357340311706', 'dob': '1996-06-01', 'gender': 'M', 'address': {'country': 'India', 'dist': 'Udham Singh Nagar', 'state': 'Uttarakhand', 'po': 'Gularbhoj', 'loc': '', 'vtc': 'Gularbhoj', 'subdist': '', 'street': '', 'house': '', 'landmark': ''}, 'face_status': False, 'face_score': -1, 'zip': '262401', 'profile_image': '', 'care_of': 'S/O Durga Dutt Pathak', 'share_code': '9370', 'mobile_verified': False, 'aadhaar_pdf': None, 'status': 'success_aadhaar'}, 'status_code': 200, 'message': None, 'status': 'success', 'request_id': 2275479}