import json

import requests

from .get_bf6_data import *


async def get_data_bf3(user_name, platform):
    url = f"https://api.gametools.network/bf3/all/?format_values=true&name={user_name}&platform={platform}"

    payload = {}
    headers = {
        'accept': 'application/json'
    }
    response = requests.request("GET", url, headers=headers, data=payload)
    data_json = json.loads(response.text)
    return data_json


async def get_data_bf4(user_name, platform):
    url = f"https://api.gametools.network/bf4/all/?format_values=true&name={user_name}&platform={platform}"
    payload = {}
    headers = {
        'accept': 'application/json'
    }
    response = requests.request("GET", url, headers=headers, data=payload)
    data_json = json.loads(response.text)
    return data_json


async def get_data_bf1(user_name, platform):
    url = f"https://api.gametools.network/bf1/all/?format_values=true&name={user_name}&platform={platform}&skip_battlelog=false&lang=en-us"

    payload = {}
    headers = {
        'accept': 'application/json'
    }
    response = requests.request("GET", url, headers=headers, data=payload)
    data_json = json.loads(response.text)
    return data_json


async def get_data_bfv(user_name, platform):
    url = f"https://api.gametools.network/bfv/all/?format_values=true&name={user_name}&platform={platform}&skip_battlelog=false&lang=en-us"

    payload = {}
    headers = {
        'accept': 'application/json'
    }
    response = requests.request("GET", url, headers=headers, data=payload)
    data_json = json.loads(response.text)
    return data_json


async def get_data_bf6(user_name, search_type):
    flag, data_json = await get_info(user_name, search_type)
    return flag, data_json
