UNPKG

@eulerstream/euler-api-sdk

Version:

Node.js module for interacting with the Euler Stream TikTok LIVE API.

1,337 lines 326 kB
import globalAxios from "axios"; //#region src/sdk/base.ts const BASE_PATH = "https://tiktok.eulerstream.com".replace(/\/+$/, ""); var BaseAPI = class { constructor(configuration, basePath = BASE_PATH, axios = globalAxios) { this.basePath = basePath; this.axios = axios; if (configuration) { this.configuration = configuration; this.basePath = configuration.basePath ?? basePath; } } }; var RequiredError = class extends Error { constructor(field, msg) { super(msg); this.field = field; this.name = "RequiredError"; } }; const operationServerMap = {}; //#endregion //#region src/sdk/common.ts const DUMMY_BASE_URL = "https://example.com"; /** * * @throws {RequiredError} */ const assertParamExists = function(functionName, paramName, paramValue) { if (paramValue === null || paramValue === void 0) throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); }; const setApiKeyToObject = async function(object, keyParamName, configuration) { if (configuration && configuration.apiKey) object[keyParamName] = typeof configuration.apiKey === "function" ? await configuration.apiKey(keyParamName) : await configuration.apiKey; }; function setFlattenedQueryParams(urlSearchParams, parameter, key = "") { if (parameter == null) return; if (typeof parameter === "object") if (Array.isArray(parameter) || parameter instanceof Set) parameter.forEach((item) => setFlattenedQueryParams(urlSearchParams, item, key)); else Object.keys(parameter).forEach((currentKey) => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== "" ? "." : ""}${currentKey}`)); else if (urlSearchParams.has(key)) urlSearchParams.append(key, parameter); else urlSearchParams.set(key, parameter); } const setSearchParams = function(url, ...objects) { const searchParams = new URLSearchParams(url.search); setFlattenedQueryParams(searchParams, objects); url.search = searchParams.toString(); }; /** * JSON serialization helper function which replaces instances of unserializable types with serializable ones. * This function will run for every key-value pair encountered by JSON.stringify while traversing an object. * Converting a set to a string will return an empty object, so an intermediate conversion to an array is required. */ const replaceWithSerializableTypeIfNeeded = function(key, value) { if (value instanceof Set) return Array.from(value); else return value; }; const serializeDataIfNeeded = function(value, requestOptions, configuration) { const nonString = typeof value !== "string"; return (nonString && configuration && configuration.isJsonMime ? configuration.isJsonMime(requestOptions.headers["Content-Type"]) : nonString) ? JSON.stringify(value !== void 0 ? value : {}, replaceWithSerializableTypeIfNeeded) : value || ""; }; const toPathString = function(url) { return url.pathname + url.search + url.hash; }; const createRequestFunction = function(axiosArgs, globalAxios, BASE_PATH, configuration) { return (axios = globalAxios, basePath = BASE_PATH) => { const axiosRequestArgs = { ...axiosArgs.options, url: (axios.defaults.baseURL ? "" : configuration?.basePath ?? basePath) + axiosArgs.url }; return axios.request(axiosRequestArgs); }; }; //#endregion //#region src/sdk/api.ts const AccountScopes = { NUMBER_MINUS_1: -1, NUMBER_0: 0, NUMBER_1: 1, NUMBER_3: 3, NUMBER_10: 10, NUMBER_11: 11, NUMBER_8: 8, NUMBER_6: 6, NUMBER_12: 12, NUMBER_13: 13, NUMBER_14: 14, NUMBER_15: 15, NUMBER_16: 16 }; const ExchangeTokenRequestGrantTypeEnum = { AuthorizationCode: "authorization_code", RefreshToken: "refresh_token" }; /** * Friendly catalog sort options, mapped to the gifts-server enum below. */ const GiftCatalogOrderBy = { Price: "price", Name: "name" }; const IntrospectRequestBodyTokenTypeHintEnum = { AccessToken: "access_token", RefreshToken: "refresh_token" }; const IntrospectionResponseTokenTypeEnum = { Bearer: "Bearer" }; const LivePushAlertTargetFormat = { NUMBER_0: 0, NUMBER_1: 1, NUMBER_MINUS_1: -1 }; const LivePushAlertTargetStatus = { NUMBER_0: 0, NUMBER_1: 1, NUMBER_4: 4, NUMBER_MINUS_1: -1 }; /** * Mute duration in seconds */ const MuteDuration = { NUMBER_MINUS_1: -1, NUMBER_5: 5, NUMBER_30: 30, NUMBER_60: 60, NUMBER_300: 300 }; const OAuthClientMode = { Dark: "dark", Light: "light", Auto: "auto" }; const OAuthScope = { WebcastFetch: "webcast:fetch", WebcastRankings: "webcast:rankings", WebcastBulkLiveCheck: "webcast:bulk_live_check", WebcastUserEarnings: "webcast:user_earnings", WebcastSignUrl: "webcast:sign_url", WebcastChat: "webcast:chat", WebcastMute: "webcast:mute", WebcastBan: "webcast:ban", WebcastComments: "webcast:comments", WebcastModerators: "webcast:moderators", WebcastLiveAnalytics: "webcast:live_analytics", UserConsents: "user:consents", UserInfo: "user:info", WebcastSensitiveWords: "webcast:sensitive_words" }; const PeerPresenceTypeEnum = { Api: "api", Agent: "agent" }; const PeerRole = { Public: "public", Enterprise: "enterprise", Staging: "staging" }; /** * Region enum shared across providers that route through the pooled DC vendors. Lives in its own file (with zero imports) so consumers can load it without dragging in `pooled-dc.ts`\'s singleton init — which itself depends on `OculusDc` / `OxyLabsDc` and would otherwise close a module-init cycle the bundler resolves into a TDZ violation. */ const PooledProxyRegion = { Us: "US", Gb: "GB", De: "DE", Ro: "RO", Es: "ES", Be: "BE", Fr: "FR", Ca: "CA", Jp: "JP", Br: "BR", Mx: "MX", Co: "CO", Ar: "AR", Cl: "CL", Au: "AU", Kr: "KR", Pe: "PE", Pl: "PL", Sg: "SG", It: "IT", Id: "ID", Th: "TH", Sa: "SA", Il: "IL", Nl: "NL", Ie: "IE", Pt: "PT", Gr: "GR", At: "AT", Ch: "CH", Hu: "HU", Sk: "SK", Dk: "DK", No: "NO", Se: "SE", Nz: "NZ" }; const RankingLeagueLevel = { NUMBER_100: 100, NUMBER_200: 200, NUMBER_300: 300, NUMBER_400: 400, NUMBER_500: 500, NUMBER_600: 600, NUMBER_700: 700, NUMBER_800: 800, NUMBER_900: 900, NUMBER_1000: 1e3, NUMBER_1100: 1100, NUMBER_1200: 1200, NUMBER_1300: 1300, NUMBER_1400: 1400, NUMBER_1500: 1500, NUMBER_1800: 1800, NUMBER_1900: 1900, NUMBER_2000: 2e3 }; const RateLimitType = { Webcast: "WEBCAST", Alerts: "ALERTS", RateLimits: "RATE_LIMITS", Rankings: "RANKINGS" }; const RevokeRequestBodyTokenTypeHintEnum = { AccessToken: "access_token", RefreshToken: "refresh_token" }; const SignTikTokUrlBodyMethodEnum = { Get: "GET", Post: "POST", Options: "OPTIONS", Put: "PUT", Delete: "DELETE", Patch: "PATCH", Head: "HEAD" }; const SignTikTokUrlBodyTypeEnum = { Fetch: "fetch", Xhr: "xhr" }; const StreamType = { HlsLd: "hls_ld", HlsSd: "hls_sd", FlvLd: "flv_ld", FlvSd: "flv_sd" }; /** * Logical \"client name\" recorded against each request — supplied by the caller via the `metadata.client_name` RPC field. Free-form on the wire, but conventionally one of the values below. */ const TikTokSignLiveClient = { TtliveJava: "ttlive-java", TtliveNode: "ttlive-node", TtlivePython: "ttlive-python", TtliveNet: "ttlive-net", TtliveRust: "ttlive-rust", GotiktokLive: "gotiktok_live", TtliveCloudflare: "ttlive-cloudflare", TtliveOther: "ttlive-other", Internal: "internal" }; const TokenResponseTokenTypeEnum = { Bearer: "Bearer" }; const WebcastFetchPlatform = { Mobile: "mobile", Web: "web" }; const WebcastGiftGalleryDataAnchorRankingLeagueEnum = { ToString: "toString", ToFixed: "toFixed", ToExponential: "toExponential", ToPrecision: "toPrecision", ValueOf: "valueOf", ToLocaleString: "toLocaleString" }; const WebcastLanguage = { Aa: "aa", Ab: "ab", Af: "af", Ak: "ak", Am: "am", An: "an", Ar: "ar", As: "as", Av: "av", Ay: "ay", Az: "az", Ba: "ba", Be: "be", Bg: "bg", Bh: "bh", Bi: "bi", Bm: "bm", Bn: "bn", Bo: "bo", Br: "br", Bs: "bs", Ca: "ca", Ce: "ce", Ch: "ch", Co: "co", Cr: "cr", Cs: "cs", Cu: "cu", Cv: "cv", Cy: "cy", Da: "da", De: "de", Dv: "dv", Dz: "dz", Ee: "ee", El: "el", En: "en", Eo: "eo", Es: "es", Et: "et", Eu: "eu", Fa: "fa", Ff: "ff", Fi: "fi", Fj: "fj", Fo: "fo", Fr: "fr", Fy: "fy", Ga: "ga", Gd: "gd", Gl: "gl", Gn: "gn", Gu: "gu", Gv: "gv", Ha: "ha", He: "he", Hi: "hi", Ho: "ho", Hr: "hr", Ht: "ht", Hu: "hu", Hy: "hy", Hz: "hz", Ia: "ia", Id: "id", Ie: "ie", Ig: "ig", Ii: "ii", Ik: "ik", Io: "io", Is: "is", It: "it", Iu: "iu", Ja: "ja", Jv: "jv", Ka: "ka", Kg: "kg", Ki: "ki", Kj: "kj", Kk: "kk", Kl: "kl", Km: "km", Kn: "kn", Ko: "ko", Kr: "kr", Ks: "ks", Ku: "ku", Kv: "kv", Kw: "kw", Ky: "ky", La: "la", Lb: "lb", Lg: "lg", Li: "li", Ln: "ln", Lo: "lo", Lt: "lt", Lu: "lu", Lv: "lv", Mg: "mg", Mh: "mh", Mi: "mi", Mk: "mk", Ml: "ml", Mn: "mn", Mr: "mr", Ms: "ms", Mt: "mt", My: "my", Na: "na", Nb: "nb", Nd: "nd", Ne: "ne", Ng: "ng", Nl: "nl", Nn: "nn", No: "no", Nr: "nr", Nv: "nv", Ny: "ny", Oc: "oc", Oj: "oj", Om: "om", Or: "or", Os: "os", Pa: "pa", Pi: "pi", Pl: "pl", Ps: "ps", Pt: "pt", Qu: "qu", Rm: "rm", Rn: "rn", Ro: "ro", Ru: "ru", Rw: "rw", Sa: "sa", Sc: "sc", Sd: "sd", Se: "se", Sg: "sg", Si: "si", Sk: "sk", Sl: "sl", Sm: "sm", Sn: "sn", So: "so", Sq: "sq", Sr: "sr", Ss: "ss", St: "st", Su: "su", Sv: "sv", Sw: "sw", Ta: "ta", Te: "te", Tg: "tg", Th: "th", Ti: "ti", Tk: "tk", Tl: "tl", Tn: "tn", To: "to", Tr: "tr", Ts: "ts", Tt: "tt", Tw: "tw", Ty: "ty", Ug: "ug", Uk: "uk", Ur: "ur", Uz: "uz", Ve: "ve", Vi: "vi", Vo: "vo", Wa: "wa", Wo: "wo", Xh: "xh", Yi: "yi", Yo: "yo", Za: "za", Zh: "zh", Zu: "zu" }; const WebcastUserEarningsOutputEarningsEstimateCurrencyEnum = { Usd: "USD" }; const WebcastUserEarningsOutputPeriod = { Daily: "daily" }; /** * AccountsApi - axios parameter creator */ const AccountsApiAxiosParamCreator = function(configuration) { return { /** * Retrieve the rate limits for the provided API key (or the unauthenticated limits if no key is provided) * @param {RateLimitType} [type] Which set of rate limits to retrieve. Defaults to the webcast (account) limits. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getRateLimits: async (type, options = {}) => { const localVarUrlObj = new URL(`/accounts/me/rate_limits`, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); if (type !== void 0) localVarQueryParameter["type"] = type; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Retrieve an account from the Sign API * @param {*} [options] Override http request option. * @throws {RequiredError} */ retrieveAccountSelf: async (options = {}) => { const localVarUrlObj = new URL(`/accounts/me`, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; } }; }; /** * AccountsApi - functional programming interface */ const AccountsApiFp = function(configuration) { const localVarAxiosParamCreator = AccountsApiAxiosParamCreator(configuration); return { /** * Retrieve the rate limits for the provided API key (or the unauthenticated limits if no key is provided) * @param {RateLimitType} [type] Which set of rate limits to retrieve. Defaults to the webcast (account) limits. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getRateLimits(type, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.getRateLimits(type, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AccountsApi.getRateLimits"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Retrieve an account from the Sign API * @param {*} [options] Override http request option. * @throws {RequiredError} */ async retrieveAccountSelf(options) { const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveAccountSelf(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AccountsApi.retrieveAccountSelf"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); } }; }; /** * AccountsApi - factory interface */ const AccountsApiFactory = function(configuration, basePath, axios) { const localVarFp = AccountsApiFp(configuration); return { /** * Retrieve the rate limits for the provided API key (or the unauthenticated limits if no key is provided) * @param {RateLimitType} [type] Which set of rate limits to retrieve. Defaults to the webcast (account) limits. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getRateLimits(type, options) { return localVarFp.getRateLimits(type, options).then((request) => request(axios, basePath)); }, /** * Retrieve an account from the Sign API * @param {*} [options] Override http request option. * @throws {RequiredError} */ retrieveAccountSelf(options) { return localVarFp.retrieveAccountSelf(options).then((request) => request(axios, basePath)); } }; }; /** * AccountsApi - object-oriented interface */ var AccountsApi = class extends BaseAPI { /** * Retrieve the rate limits for the provided API key (or the unauthenticated limits if no key is provided) * @param {RateLimitType} [type] Which set of rate limits to retrieve. Defaults to the webcast (account) limits. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getRateLimits(type, options) { return AccountsApiFp(this.configuration).getRateLimits(type, options).then((request) => request(this.axios, this.basePath)); } /** * Retrieve an account from the Sign API * @param {*} [options] Override http request option. * @throws {RequiredError} */ retrieveAccountSelf(options) { return AccountsApiFp(this.configuration).retrieveAccountSelf(options).then((request) => request(this.axios, this.basePath)); } }; /** * AnalyticsApi - axios parameter creator */ const AnalyticsApiAxiosParamCreator = function(configuration) { return { /** * Retrieve the currently connected agents * @param {*} [options] Override http request option. * @throws {RequiredError} */ fetchAgents: async (options = {}) => { const localVarUrlObj = new URL(`/analytics/agents`, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Retrieve the list of API hosts (used for horizontal scaling) * @param {*} [options] Override http request option. * @throws {RequiredError} */ getHosts: async (options = {}) => { const localVarUrlObj = new URL(`/analytics/hosts`, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Retrieve stats as an SVG * @param {string} [labelColour] Specify label colour in SVG * @param {string} [valueColour] Specify value colour in SVG * @param {number} [hours] The number of hours to retrieve the stat for * @param {TikTokSignLiveClient} [client] The client to filter for * @param {boolean} [json] Add the ability to retrieve the pip as JSON * @param {*} [options] Override http request option. * @throws {RequiredError} */ pips: async (labelColour, valueColour, hours, client, json, options = {}) => { const localVarUrlObj = new URL(`/analytics/pips`, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; if (labelColour !== void 0) localVarQueryParameter["labelColour"] = labelColour; if (valueColour !== void 0) localVarQueryParameter["valueColour"] = valueColour; if (hours !== void 0) localVarQueryParameter["hours"] = hours; if (client !== void 0) localVarQueryParameter["client"] = client; if (json !== void 0) localVarQueryParameter["json"] = json; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; } }; }; /** * AnalyticsApi - functional programming interface */ const AnalyticsApiFp = function(configuration) { const localVarAxiosParamCreator = AnalyticsApiAxiosParamCreator(configuration); return { /** * Retrieve the currently connected agents * @param {*} [options] Override http request option. * @throws {RequiredError} */ async fetchAgents(options) { const localVarAxiosArgs = await localVarAxiosParamCreator.fetchAgents(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AnalyticsApi.fetchAgents"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Retrieve the list of API hosts (used for horizontal scaling) * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getHosts(options) { const localVarAxiosArgs = await localVarAxiosParamCreator.getHosts(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AnalyticsApi.getHosts"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Retrieve stats as an SVG * @param {string} [labelColour] Specify label colour in SVG * @param {string} [valueColour] Specify value colour in SVG * @param {number} [hours] The number of hours to retrieve the stat for * @param {TikTokSignLiveClient} [client] The client to filter for * @param {boolean} [json] Add the ability to retrieve the pip as JSON * @param {*} [options] Override http request option. * @throws {RequiredError} */ async pips(labelColour, valueColour, hours, client, json, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.pips(labelColour, valueColour, hours, client, json, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AnalyticsApi.pips"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); } }; }; /** * AnalyticsApi - factory interface */ const AnalyticsApiFactory = function(configuration, basePath, axios) { const localVarFp = AnalyticsApiFp(configuration); return { /** * Retrieve the currently connected agents * @param {*} [options] Override http request option. * @throws {RequiredError} */ fetchAgents(options) { return localVarFp.fetchAgents(options).then((request) => request(axios, basePath)); }, /** * Retrieve the list of API hosts (used for horizontal scaling) * @param {*} [options] Override http request option. * @throws {RequiredError} */ getHosts(options) { return localVarFp.getHosts(options).then((request) => request(axios, basePath)); }, /** * Retrieve stats as an SVG * @param {string} [labelColour] Specify label colour in SVG * @param {string} [valueColour] Specify value colour in SVG * @param {number} [hours] The number of hours to retrieve the stat for * @param {TikTokSignLiveClient} [client] The client to filter for * @param {boolean} [json] Add the ability to retrieve the pip as JSON * @param {*} [options] Override http request option. * @throws {RequiredError} */ pips(labelColour, valueColour, hours, client, json, options) { return localVarFp.pips(labelColour, valueColour, hours, client, json, options).then((request) => request(axios, basePath)); } }; }; /** * AnalyticsApi - object-oriented interface */ var AnalyticsApi = class extends BaseAPI { /** * Retrieve the currently connected agents * @param {*} [options] Override http request option. * @throws {RequiredError} */ fetchAgents(options) { return AnalyticsApiFp(this.configuration).fetchAgents(options).then((request) => request(this.axios, this.basePath)); } /** * Retrieve the list of API hosts (used for horizontal scaling) * @param {*} [options] Override http request option. * @throws {RequiredError} */ getHosts(options) { return AnalyticsApiFp(this.configuration).getHosts(options).then((request) => request(this.axios, this.basePath)); } /** * Retrieve stats as an SVG * @param {string} [labelColour] Specify label colour in SVG * @param {string} [valueColour] Specify value colour in SVG * @param {number} [hours] The number of hours to retrieve the stat for * @param {TikTokSignLiveClient} [client] The client to filter for * @param {boolean} [json] Add the ability to retrieve the pip as JSON * @param {*} [options] Override http request option. * @throws {RequiredError} */ pips(labelColour, valueColour, hours, client, json, options) { return AnalyticsApiFp(this.configuration).pips(labelColour, valueColour, hours, client, json, options).then((request) => request(this.axios, this.basePath)); } }; /** * AuthenticationApi - axios parameter creator */ const AuthenticationApiAxiosParamCreator = function(configuration) { return { /** * Create a JWT for a given API key. Note that these JWT keys are only valid for the non-authenticated Webcast endpoints. They function to attach the rate limits of the API key to the request for client-sided applications. * @param {number} accountId The ID of the account to create the JWT for * @param {JWTCreateConfig} jWTCreateConfig The configuration for the JWT * @param {*} [options] Override http request option. * @throws {RequiredError} */ createJWT: async (accountId, jWTCreateConfig, options = {}) => { assertParamExists("createJWT", "accountId", accountId); assertParamExists("createJWT", "jWTCreateConfig", jWTCreateConfig); const localVarPath = `/accounts/{account_id}/jwt/create`.replace("{account_id}", encodeURIComponent(String(accountId))); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "POST", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); localVarHeaderParameter["Content-Type"] = "application/json"; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; localVarRequestOptions.data = serializeDataIfNeeded(jWTCreateConfig, localVarRequestOptions, configuration); return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Create a new API key * @param {number} accountId The ID of the account to create the key for * @param {CreateKeyPayload} createKeyPayload The configuration for the new key * @param {*} [options] Override http request option. * @throws {RequiredError} */ createKey: async (accountId, createKeyPayload, options = {}) => { assertParamExists("createKey", "accountId", accountId); assertParamExists("createKey", "createKeyPayload", createKeyPayload); const localVarPath = `/accounts/{account_id}/api_keys/create`.replace("{account_id}", encodeURIComponent(String(accountId))); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "PUT", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); localVarHeaderParameter["Content-Type"] = "application/json"; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; localVarRequestOptions.data = serializeDataIfNeeded(createKeyPayload, localVarRequestOptions, configuration); return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Delete an API key by its key value, name, or ID * @param {number} accountId The ID of the account to delete the key for * @param {DeleteKeyDeleteByEnum} deleteBy The API key field to delete by * @param {string} deleteParam The API key field value to delete by * @param {*} [options] Override http request option. * @throws {RequiredError} */ deleteKey: async (accountId, deleteBy, deleteParam, options = {}) => { assertParamExists("deleteKey", "accountId", accountId); assertParamExists("deleteKey", "deleteBy", deleteBy); assertParamExists("deleteKey", "deleteParam", deleteParam); const localVarPath = `/accounts/{account_id}/api_keys/delete`.replace("{account_id}", encodeURIComponent(String(accountId))); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "DELETE", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); if (deleteBy !== void 0) localVarQueryParameter["delete_by"] = deleteBy; if (deleteParam !== void 0) localVarQueryParameter["delete_param"] = deleteParam; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {string} retrieveParam The API key field value to retrieve by * @param {GetKeyRetrieveByEnum} [retrieveBy] The API key field to retrieve by * @param {*} [options] Override http request option. * @throws {RequiredError} */ getKey: async (accountId, retrieveParam, retrieveBy, options = {}) => { assertParamExists("getKey", "accountId", accountId); assertParamExists("getKey", "retrieveParam", retrieveParam); const localVarPath = `/accounts/{account_id}/api_keys/retrieve`.replace("{account_id}", encodeURIComponent(String(accountId))); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); if (retrieveBy !== void 0) localVarQueryParameter["retrieve_by"] = retrieveBy; if (retrieveParam !== void 0) localVarQueryParameter["retrieve_param"] = retrieveParam; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {*} [options] Override http request option. * @throws {RequiredError} */ listKeys: async (accountId, options = {}) => { assertParamExists("listKeys", "accountId", accountId); const localVarPath = `/accounts/{account_id}/api_keys/list`.replace("{account_id}", encodeURIComponent(String(accountId))); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; }, /** * Update an existing API key * @param {number} accountId The account to update the key for * @param {UpdateKeyUpdateByEnum} updateBy The API key field to update by * @param {string} updateParam The API key field value to update by * @param {UpdateKeyPayload} updateKeyPayload The new configuration for the key * @param {*} [options] Override http request option. * @throws {RequiredError} */ updateKey: async (accountId, updateBy, updateParam, updateKeyPayload, options = {}) => { assertParamExists("updateKey", "accountId", accountId); assertParamExists("updateKey", "updateBy", updateBy); assertParamExists("updateKey", "updateParam", updateParam); assertParamExists("updateKey", "updateKeyPayload", updateKeyPayload); const localVarPath = `/accounts/{account_id}/api_keys/update`.replace("{account_id}", encodeURIComponent(String(accountId))); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "PATCH", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration); if (updateBy !== void 0) localVarQueryParameter["update_by"] = updateBy; if (updateParam !== void 0) localVarQueryParameter["update_param"] = updateParam; localVarHeaderParameter["Content-Type"] = "application/json"; localVarHeaderParameter["Accept"] = "application/json"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; localVarRequestOptions.data = serializeDataIfNeeded(updateKeyPayload, localVarRequestOptions, configuration); return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; } }; }; /** * AuthenticationApi - functional programming interface */ const AuthenticationApiFp = function(configuration) { const localVarAxiosParamCreator = AuthenticationApiAxiosParamCreator(configuration); return { /** * Create a JWT for a given API key. Note that these JWT keys are only valid for the non-authenticated Webcast endpoints. They function to attach the rate limits of the API key to the request for client-sided applications. * @param {number} accountId The ID of the account to create the JWT for * @param {JWTCreateConfig} jWTCreateConfig The configuration for the JWT * @param {*} [options] Override http request option. * @throws {RequiredError} */ async createJWT(accountId, jWTCreateConfig, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.createJWT(accountId, jWTCreateConfig, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AuthenticationApi.createJWT"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Create a new API key * @param {number} accountId The ID of the account to create the key for * @param {CreateKeyPayload} createKeyPayload The configuration for the new key * @param {*} [options] Override http request option. * @throws {RequiredError} */ async createKey(accountId, createKeyPayload, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.createKey(accountId, createKeyPayload, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AuthenticationApi.createKey"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Delete an API key by its key value, name, or ID * @param {number} accountId The ID of the account to delete the key for * @param {DeleteKeyDeleteByEnum} deleteBy The API key field to delete by * @param {string} deleteParam The API key field value to delete by * @param {*} [options] Override http request option. * @throws {RequiredError} */ async deleteKey(accountId, deleteBy, deleteParam, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.deleteKey(accountId, deleteBy, deleteParam, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AuthenticationApi.deleteKey"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {string} retrieveParam The API key field value to retrieve by * @param {GetKeyRetrieveByEnum} [retrieveBy] The API key field to retrieve by * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getKey(accountId, retrieveParam, retrieveBy, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.getKey(accountId, retrieveParam, retrieveBy, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AuthenticationApi.getKey"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {*} [options] Override http request option. * @throws {RequiredError} */ async listKeys(accountId, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.listKeys(accountId, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AuthenticationApi.listKeys"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Update an existing API key * @param {number} accountId The account to update the key for * @param {UpdateKeyUpdateByEnum} updateBy The API key field to update by * @param {string} updateParam The API key field value to update by * @param {UpdateKeyPayload} updateKeyPayload The new configuration for the key * @param {*} [options] Override http request option. * @throws {RequiredError} */ async updateKey(accountId, updateBy, updateParam, updateKeyPayload, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.updateKey(accountId, updateBy, updateParam, updateKeyPayload, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["AuthenticationApi.updateKey"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); } }; }; /** * AuthenticationApi - factory interface */ const AuthenticationApiFactory = function(configuration, basePath, axios) { const localVarFp = AuthenticationApiFp(configuration); return { /** * Create a JWT for a given API key. Note that these JWT keys are only valid for the non-authenticated Webcast endpoints. They function to attach the rate limits of the API key to the request for client-sided applications. * @param {number} accountId The ID of the account to create the JWT for * @param {JWTCreateConfig} jWTCreateConfig The configuration for the JWT * @param {*} [options] Override http request option. * @throws {RequiredError} */ createJWT(accountId, jWTCreateConfig, options) { return localVarFp.createJWT(accountId, jWTCreateConfig, options).then((request) => request(axios, basePath)); }, /** * Create a new API key * @param {number} accountId The ID of the account to create the key for * @param {CreateKeyPayload} createKeyPayload The configuration for the new key * @param {*} [options] Override http request option. * @throws {RequiredError} */ createKey(accountId, createKeyPayload, options) { return localVarFp.createKey(accountId, createKeyPayload, options).then((request) => request(axios, basePath)); }, /** * Delete an API key by its key value, name, or ID * @param {number} accountId The ID of the account to delete the key for * @param {DeleteKeyDeleteByEnum} deleteBy The API key field to delete by * @param {string} deleteParam The API key field value to delete by * @param {*} [options] Override http request option. * @throws {RequiredError} */ deleteKey(accountId, deleteBy, deleteParam, options) { return localVarFp.deleteKey(accountId, deleteBy, deleteParam, options).then((request) => request(axios, basePath)); }, /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {string} retrieveParam The API key field value to retrieve by * @param {GetKeyRetrieveByEnum} [retrieveBy] The API key field to retrieve by * @param {*} [options] Override http request option. * @throws {RequiredError} */ getKey(accountId, retrieveParam, retrieveBy, options) { return localVarFp.getKey(accountId, retrieveParam, retrieveBy, options).then((request) => request(axios, basePath)); }, /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {*} [options] Override http request option. * @throws {RequiredError} */ listKeys(accountId, options) { return localVarFp.listKeys(accountId, options).then((request) => request(axios, basePath)); }, /** * Update an existing API key * @param {number} accountId The account to update the key for * @param {UpdateKeyUpdateByEnum} updateBy The API key field to update by * @param {string} updateParam The API key field value to update by * @param {UpdateKeyPayload} updateKeyPayload The new configuration for the key * @param {*} [options] Override http request option. * @throws {RequiredError} */ updateKey(accountId, updateBy, updateParam, updateKeyPayload, options) { return localVarFp.updateKey(accountId, updateBy, updateParam, updateKeyPayload, options).then((request) => request(axios, basePath)); } }; }; /** * AuthenticationApi - object-oriented interface */ var AuthenticationApi = class extends BaseAPI { /** * Create a JWT for a given API key. Note that these JWT keys are only valid for the non-authenticated Webcast endpoints. They function to attach the rate limits of the API key to the request for client-sided applications. * @param {number} accountId The ID of the account to create the JWT for * @param {JWTCreateConfig} jWTCreateConfig The configuration for the JWT * @param {*} [options] Override http request option. * @throws {RequiredError} */ createJWT(accountId, jWTCreateConfig, options) { return AuthenticationApiFp(this.configuration).createJWT(accountId, jWTCreateConfig, options).then((request) => request(this.axios, this.basePath)); } /** * Create a new API key * @param {number} accountId The ID of the account to create the key for * @param {CreateKeyPayload} createKeyPayload The configuration for the new key * @param {*} [options] Override http request option. * @throws {RequiredError} */ createKey(accountId, createKeyPayload, options) { return AuthenticationApiFp(this.configuration).createKey(accountId, createKeyPayload, options).then((request) => request(this.axios, this.basePath)); } /** * Delete an API key by its key value, name, or ID * @param {number} accountId The ID of the account to delete the key for * @param {DeleteKeyDeleteByEnum} deleteBy The API key field to delete by * @param {string} deleteParam The API key field value to delete by * @param {*} [options] Override http request option. * @throws {RequiredError} */ deleteKey(accountId, deleteBy, deleteParam, options) { return AuthenticationApiFp(this.configuration).deleteKey(accountId, deleteBy, deleteParam, options).then((request) => request(this.axios, this.basePath)); } /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {string} retrieveParam The API key field value to retrieve by * @param {GetKeyRetrieveByEnum} [retrieveBy] The API key field to retrieve by * @param {*} [options] Override http request option. * @throws {RequiredError} */ getKey(accountId, retrieveParam, retrieveBy, options) { return AuthenticationApiFp(this.configuration).getKey(accountId, retrieveParam, retrieveBy, options).then((request) => request(this.axios, this.basePath)); } /** * Retrieve an API key by its key value, name, or ID * @param {number} accountId The ID of the account to retrieve the key for * @param {*} [options] Override http request option. * @throws {RequiredError} */ listKeys(accountId, options) { return AuthenticationApiFp(this.configuration).listKeys(accountId, options).then((request) => request(this.axios, this.basePath)); } /** * Update an existing API key * @param {number} accountId The account to update the key for * @param {UpdateKeyUpdateByEnum} updateBy The API key field to update by * @param {string} updateParam The API key field value to update by * @param {UpdateKeyPayload} updateKeyPayload The new configuration for the key * @param {*} [options] Override http request option. * @throws {RequiredError} */ updateKey(accountId, updateBy, updateParam, updateKeyPayload, options) { return AuthenticationApiFp(this.configuration).updateKey(accountId, updateBy, updateParam, updateKeyPayload, options).then((request) => request(this.axios, this.basePath)); } }; const DeleteKeyDeleteByEnum = { Value: "value", Id: "id" }; const GetKeyRetrieveByEnum = { Value: "value", Id: "id" }; const UpdateKeyUpdateByEnum = { Value: "value", Id: "id" }; /** * TikTokCaptchasApi - axios parameter creator */ const TikTokCaptchasApiAxiosParamCreator = function(configuration) { return { /** * The icons captcha requires just one image & a prompt string. ## Example Image <img src=\"https://www.eulerstream.com/_static/captchas/icon.png\" alt=\"Icons Captcha Example\" width=\"480\" /> ## Usage The `prompt` is the text prompt provided by TikTok. The Icon captcha solution is provided as a list of points, where each point marks a location on the image that needs to be clicked. These points are expressed as ratios relative to the image\'s width and height. A point of (0.0, 0.0) corresponds to the image’s upper-left corner, while (1.0, 1.0) represents the lower-right corner. For reference, (0.5, 0.5) sits at the exact center. The captcha image selector is `.captcha-verify-image` * @param {string} prompt The prompt string provided by TikTok * @param {File} captchaImage The uploaded image file * @param {*} [options] Override http request option. * @throws {RequiredError} */ completeIconCaptcha: async (prompt, captchaImage, options = {}) => { assertParamExists("completeIconCaptcha", "prompt", prompt); assertParamExists("completeIconCaptcha", "captchaImage", captchaImage); const localVarUrlObj = new URL(`/tiktok/captchas/icons`, DUMMY_BASE_URL); let baseOptions; if (configuration) baseOptions = configuration.baseOptions; const localVarRequestOptions = { method: "POST", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; const localVarFormParams = new (configuration && configuration.formDataCtor || FormData)(); await setApiKeyToObject(localVarQueryParameter, "apiKey", configuration); await setApiKeyToObject(localVarHeaderParamet