import routes from "@/routes";
import { getBaseHeaders } from "../utils";

interface ResponseGetSuccess {
    ip: string;
    city: string;
    region: string;
    region_code: string;
    country: string;
    country_code: string;
    country_code_iso3: string;
    country_name: string;
    country_capital: string;
    country_tld: string;
    country_area: string;
    country_population: string;
    continent_code: string;
    in_eu: boolean;
    postal: string;
    latitude: number;
    longitude: number;
    latlong: string;
    timezone: string;
    utc_offset: string;
    country_calling_code: string;
    currency: string;
    currency_name: string;
    languages: string;
    asn: string;
    org: string;
    hostname: string;
}

interface ResponseGetError {
    ip: string,
    error: boolean,
    reason: string,
    reserved?: boolean,
    version?: string;
}

export type ResponseGet = ResponseGetSuccess & ResponseGetError;

export const createRequest = (): Request => {
    const url = new URL(routes.server.userLocale());
    return new Request(url, { method: "GET", headers: getBaseHeaders() });
};
