{"version":3,"sources":["../../src/global/index.ts","../../src/apikey.ts","../../src/global/search.ts","../../src/apiInformation.ts"],"sourcesContent":["import { setGlobalApiKey } from \"../apikey\";\r\nimport { DiscordToRoblox, RobloxToDiscord } from \"./search\";\r\n\r\nexport default {\r\n  setGlobalApiKey,\r\n  DiscordToRoblox,\r\n  RobloxToDiscord,\r\n};\r\n","export let globalApiKey = \"\";\r\n\r\n/**\r\n * Set's the default API key for global API requests\r\n *\r\n * @param {string} newKey\r\n * @returns {void}\r\n */\r\nexport const setGlobalApiKey = (newKey: string) => (globalApiKey = newKey);\r\n\r\nexport let guildApiKey = \"\";\r\n\r\n/**\r\n * Set's the default API key for guild API requests\r\n *\r\n * @param {string} newKey\r\n * @returns {void}\r\n */\r\nexport const setGuildApiKey = (newKey: string) => (guildApiKey = newKey);\r\n","import axios, { HttpStatusCode } from \"axios\";\r\nimport { apiBaseUrl, apiVersion } from \"../apiInformation\";\r\nimport { globalApiKey } from \"../apikey\";\r\nimport type {\r\n  GlobalDiscordToRobloxResponse,\r\n  GlobalRobloxToDiscordResponse,\r\n} from \"../types\";\r\n\r\n/**\r\n * Send's an API request to Bloxlink to get the Roblox ID of a Discord user\r\n *\r\n * @method `GET`\r\n *\r\n * @param {string} discordUserId The ID of the Discord user you want to get\r\n * @param {boolean} premiumResponse If you have API Premium or be using an guild API key with Server Premium, you can set this to true to get an enriched response\r\n * @param {string?} apiKey Optional API key to specifically use (see {@link [apikey#setGuildApiKey](../apiKey.ts)} to set an API key across all of your request)\r\n * @returns {DiscordToRobloxResponse}\r\n */\r\nexport const DiscordToRoblox = async <Premium extends boolean = boolean>(\r\n  discordUserId: string,\r\n  //@ts-ignore surpress as it is being used for types\r\n  premiumResponse?: Premium,\r\n  apiKey?: string\r\n): Promise<GlobalDiscordToRobloxResponse> => {\r\n  try {\r\n    const response = await axios<\r\n      Omit<GlobalDiscordToRobloxResponse, \"statusCode\">\r\n    >({\r\n      method: \"GET\",\r\n      url: `${apiBaseUrl}/${apiVersion}/public/discord-to-roblox/${discordUserId}`,\r\n      headers: {\r\n        Authorization: apiKey || globalApiKey,\r\n      },\r\n      validateStatus: (status) => status === HttpStatusCode.Ok,\r\n    });\r\n\r\n    return {\r\n      ...response.data,\r\n      statusCode: response.status,\r\n    };\r\n  } catch (error) {\r\n    throw new Error(`[BLOXLINK API] ${error.response.data.error}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Send's an API request to Bloxlink to get the Discord ID of a Roblox user\r\n *\r\n * @method `GET`\r\n *\r\n * @param {string} robloxUserId The ID of the Roblox user you want to get\r\n * @param {string?} apiKey Optional API key to specifically use (see {@link [apikey#setGuildApiKey](../apiKey.ts)} to set an API key across all of your request)\r\n * @returns {GlobalRobloxToDiscordResponse}\r\n */\r\nexport const RobloxToDiscord = async (\r\n  robloxUserId: string,\r\n  apiKey?: string\r\n): Promise<GlobalRobloxToDiscordResponse> => {\r\n  try {\r\n    const response = await axios<\r\n      Omit<GlobalRobloxToDiscordResponse, \"statusCode\">\r\n    >({\r\n      method: \"GET\",\r\n      url: `${apiBaseUrl}/${apiVersion}/public/roblox-to-discord/${robloxUserId}`,\r\n      headers: {\r\n        Authorization: apiKey || globalApiKey,\r\n      },\r\n      validateStatus: (status) => status === HttpStatusCode.Ok,\r\n    });\r\n\r\n    return {\r\n      ...response.data,\r\n      statusCode: response.status,\r\n    } as GlobalRobloxToDiscordResponse;\r\n  } catch (error) {\r\n    throw new Error(`[BLOXLINK API] ${error.response.data.error}`);\r\n  }\r\n};\r\n","export const apiBaseUrl = \"https://api.blox.link\";\r\nexport const apiVersion = \"v4\";\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAI,eAAe;AAQnB,IAAM,kBAAkB,CAAC,WAAoB,eAAe;;;ACRnE,mBAAsC;;;ACA/B,IAAM,aAAa;AACnB,IAAM,aAAa;;;ADiBnB,IAAM,kBAAkB,OAC7B,eAEA,iBACA,WAC2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