#
# import json
#
# import requests
# import tls_client
# session = tls_client.Session(client_identifier='chrome_112')
# px = 'http://127.0.0.1:8890'
# session.proxies = {
#     'http': px,
#     'https': px,
# }
#
# headers, cks = ({'Host': 'apigw.volaris.com', 'sec-ch-ua-mobile': '?0', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36', 'Content-Type': 'application/json', 'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJBUEkiLCJqdGkiOiJjOGU4YzQyYS1kZTE4LWQ1ZjgtYzcwZS0yYTk3NTE0NWUxM2IiLCJpc3MiOiJkb3RSRVogQVBJIn0.R85O4rA0tLfMAcrHu8MlZWfFmjMYS5eaWfOBF-kB3Yk', 'cookies': 'Bearer eyJraWQiOiJCaE10N01OTFVBNXdLbE5PRmFNU0liOUIwYUYxWWV0Z0VkaVJmWkJVYzJnPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI1cTB0NDRzazlrNjB2M3M5ZHZnZjZnbGZqOCIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoicnNcL3dyaXRlIHJzXC9yZWFkIiwiYXV0aF90aW1lIjoxNjkyNjk5MTc2LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtd2VzdC0yLmFtYXpvbmF3cy5jb21cL3VzLXdlc3QtMl9GamFneTNwT0IiLCJleHAiOjE2OTI3MDI3NzYsImlhdCI6MTY5MjY5OTE3NiwidmVyc2lvbiI6MiwianRpIjoiZDc4MWI1Y2QtNjk3OS00N2ZkLTgyMmQtODE4NjE5Y2E1YzI4IiwiY2xpZW50X2lkIjoiNXEwdDQ0c2s5azYwdjNzOWR2Z2Y2Z2xmajgifQ.jXOnbJeSlb_8Nd4a0PZb19lYd0kfQ70FPM5Aeo5Tyg_zmhysxweQG9mvVz15QNy-QZjHCUjzzrx6XZzm8wf13ygS1pp-ApP03cPlsaaTeBV7Kb8WvbqQqm0ibZPQ1uGddv_VEqTDR3AHQEzyrQQFv2AXINl1TXBqtGLPVFcx03VN8B3yUSaQe-2oi7-sNiAe7EVcT4bT56XSogA2s_vsZbTBwZ529P3VtfmJNHu5JhSclzHvm7B_AZXwp6541WdxerURm5m-mNx09WUtS8BxWzJfewWVRm77eHs9NqMywHL9u8gpGYRjcSlf6Cu2RHsPVQiwOJsdqBWMPZj3lA30ng', 'Accept': 'application/json', 'sec-ch-ua-platform': '"macOS"', 'Origin': 'https://www.volaris.com', 'Referer': 'https://www.volaris.com/', 'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ru;q=0.6'}, {'visid_incap_2041990': 'CwqOa7sPQDW09M0vj11rgyOK5GQAAAAAQUIPAAAAAACZNuTl6TgOfjQB+cpaul8e', 'nlbi_2041990': 'xU1VXrtlhzok5Dy61UqjOAAAAADOWWXmoaFMvql6IS09jMAB', 'incap_ses_1563_2041990': 'FH+nT/CZRExtQwz0b+SwFSWK5GQAAAAAZzzt6Q9NEsO7Yiye0YVCtA==', 'nlbi_2041990_2147483392': 'm0OnYc4ijAGgMKPp1UqjOAAAAAAtupPdNcbbvlu+pLRF9dl9', 'nlbi_2306356': 'wKT+cnwPz2oun+KtXEW6EwAAAADuQWtKXZQSk5bxMCE86Vkv', 'visid_incap_2306356': '+DDVWdI3S3OdG1ITygdgjSmK5GQAAAAAQUIPAAAAAAC2MSTxXl3eg+4rs6BogUu7', 'incap_ses_1563_2306356': 'svTlfMEtSyPbWAz0b+SwFSmK5GQAAAAAHENLmwuNnUpY4RvrE0kaiw==', 'reese84': '3:m5/7WcMyayLIegGCcoV8Hw==:x5P3sx63zLh4tOYZhW6Ly8SPuMV0TsOfG4wELJML64TzEaFcPScFU4WDAH3YX9ahB3n0DNxPa1FfacwiIxe2PPAmLW73GHvzVzGKo15joCSv1u0GxXThdXDAGxWYlGcx+5zRFcqHSG2T6+wcBJpykdVMKo/+Dh4VgH0jqv9HQnE5gbSVcO6YN5WWG7wFt0QRTDziBnaPpTibYF6QUYTduMWZ/BBhfMydNeoDz2MRD7zg2+D3VdKpppeTYRDGL8Y6aHpNqZTBMNMICS3TY7fZkJjeRRardOoc6qVKclFDe0d24bO6+kf6QG+stod7cdOCdVzFlE9U2O2oRNsbwhwqUuB+kcofmatdARbdv2EZNWaUEYy6M7rSPniUhdM8rK5/u5wt4AIQJbGrvfhhbBavGXbMhxFGaX/sMs4PgoccB9ZDRVtSgx9kAiLsHQywky/BfpqDDlF5fgLlfbf58ytrhk5pfq1zwdtvqx+M0Vkz9v0YykyKwHMQ8tk4gH1sOrkvffPKAXyzmnLho/nIM9h7+RtLTUeAdDx9NwZCs20Zgo6dMscPEC1KrWvJLv+iA9xUzFgGxpgEvinZjEWZZCVaIg==:2hWNySCnGJOPEJ67ZuJxP82VQw5agMu6RPhKR+h2TOM='})
#
# url = "https://apigw.volaris.com/prod/api/availability/search"
# data = {
#     "passengers": {
#         "types": [
#             {
#                 "type": "APL",
#                 "count": 1
#             }
#         ]
#     },
#     "criteria": [
#         {
#             "stations": {
#                 "originStationCodes": [
#                     "ACA"
#                 ],
#                 "destinationStationCodes": [
#                     "BOG"
#                 ]
#             },
#             "dates": {
#                 "beginDate": "Fri, Aug 11, 2023"
#             },
#             "filters": {
#                 "fareTypes": [
#                     "R"
#                 ],
#                 "maxConnections": 20
#             }
#         }
#     ],
#     "codes": {
#         "currencyCode": "MXN",
#         "promotionCode": "VUEH50"
#     },
#     "taxesAndFees": 2
# }
# data = json.dumps(data, separators=(',', ':'))
# response = session.post(url, headers=headers, data=data, cookies=cks)
#
# print(response.text)
# print(response)


import json

import requests
import tls_client

headers, cookies = ({'authority': 'ibe.api.flyscoot.com', 'accept': 'application/json, text/plain, */*',
                     'accept-language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ru;q=0.6',
                     'authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkMWE4NzBjYi1iNDRmLTRlYmUtOTJlYi00ZmUxNmFhOTZkMDQiLCJpYXQiOjE2OTk1ODE1NjAsInRrbiI6ImV5SmhiR2NpT2lKSVV6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUp6ZFdJaU9pSlZibXR1YjNkdUlpd2lhblJwSWpvaVptSXlPREUxWkdRdFpEQTNOeTA1WkdSaExUYzJOR1l0TWpsbU1EUTNNVEppTkRrNUlpd2lhWE56SWpvaVpHOTBVa1ZhSUVGUVNTSjkuZWhQbFdEcG96bmh2NFhoaXg5MkxoNjdjdTJqVWN2ZzNTQWxWRWZRanE0MCIsImlzcyI6InNjb290LWNtdyIsImF1ZCI6InNjb290LWFwcCJ9.oRKnnps36CcoEQSFKq3tm7B8DNvC6jFlbxYYKwRMicg',
                     'cache-control': 'no-cache', 'content-type': 'application/json',
                     'origin': 'https://beta.makeabooking.flyscoot.com', 'pragma': 'no-cache',
                     'sec-ch-ua': '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"',
                     'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"macOS"', 'sec-fetch-dest': 'empty',
                     'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site',
                     'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
                     'x-scoot-appsource': 'IBE-WEB', 'x-scoot-client-environment': 'PROD',
                     'x-scoot-client-session': '4ddf4d27-d6a1-4b50-b533-04558f7ab4b8',
                     'x-scoot-client-version': '0.0.0'}, {
                        'reese84': '3:RE8IM3WosMFbO8y6Tr1GSA==:B7VgwCqR7SAyccFGqrGEAPOmPt/KiCAXrCa+wq7oYZ0CQi13fUoJzVsUlm99sCbr2vmlAS/dodzRrYQN220claoyR+pDIHC9V88dhuJ2gWzlRB5Z+4DPztpleUHVKoFmoJnWdZfhZe4c0jJy7QgYyeF5V2yOUwFcKu+IKLJq3q5hqv8VnO8lY6+Z5Zc8oyz2JZdWiclopiEIbHUfa+kghr/9fvObZiwjR43TZUEdao0v88sG2LB+cDZP2lawxus5qyCgoy6SqiFrKTSqgRMNWQENJt5JrcN85a3Ap7gnLQyD4xIBqcFuKetIQs+WTDN7YhRq/z+3LgOEaFCOa/XIahzXT9dLNN0WDC+Sa27I/6mIbjDYDAPOT0GfkuXxW7uipCnW2u9tXkI7kNI2YwX6NRTsOuEzXqQcX9LQegUPvpHCoeVMi44l7FO8u9jcAEQFWex1VOWbkts2Ltjp/7RUiKENOWWL4WRTipFV8hLC34c=:keTIyaFZccXB9YfQJMysUawMOaoRXtgYl5j8YdNQMKM=',
                        'visid_incap_2572958': 'U3Mp2sJtRPOiSl3AFtqtcXiOTWUAAAAAQUIPAAAAAADb9yiqfGzs8PAXdkqvYiX0',
                        'nlbi_2572958': '/UmbQy8FLnM+YSMF3Zs2agAAAADuqSIkz2b+ZXmKGagmQgoj',
                        'incap_ses_635_2572958': '8+nLY5ZxiF39fpDSKfrPCHiOTWUAAAAAgKDrt2jJx9Lp7yI25w4sgA=='})

url = "https://ibe.api.flyscoot.com/v1/booking/flight/availability"
data = {
    "flightCriteria": [
        {
            "origin": "HKG",
            "destination": "SIN",
            "departureDate": "2023-11-28"
        }
    ],
    "passengerCriteria": {
        "adult": 1,
        "child": 0,
        "infant": 0
    },
    "currencyCode": "HKD",
    "promoCode": None,
    "salesCode": None,
    "flightFare": {
        "fareType": [],
        "classOfService": []
    },
    "cultureCode": "en-SG"
}
data = json.dumps(data, separators=(',', ':'))
# ,cookies=cookies

session = tls_client.Session(client_identifier='chrome_112')
session = requests.Session()
session.verify = False
session.proxies = {
    'http': 'http://127.0.0.1:8890',
    'https': 'http://127.0.0.1:8890',
}
response = session.post(url, headers=headers, data=data, cookies=cookies)

print(response.text)
print(response)
