UNPKG

@trophyso/node

Version:
121 lines (120 loc) 6.12 kB
"use strict"; // This file was auto-generated by Fern from our API Definition. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TrophyApiClient = void 0; const Client_1 = require("./api/resources/achievements/client/Client"); const Client_2 = require("./api/resources/admin/client/Client"); const Client_3 = require("./api/resources/leaderboards/client/Client"); const Client_4 = require("./api/resources/metrics/client/Client"); const Client_5 = require("./api/resources/points/client/Client"); const Client_6 = require("./api/resources/streaks/client/Client"); const Client_7 = require("./api/resources/users/client/Client"); const BaseClient_1 = require("./BaseClient"); const core = __importStar(require("./core")); const environments = __importStar(require("./environments")); class TrophyApiClient { constructor(options) { this._options = (0, BaseClient_1.normalizeClientOptionsWithAuth)(options); } get achievements() { var _a; return ((_a = this._achievements) !== null && _a !== void 0 ? _a : (this._achievements = new Client_1.AchievementsClient(this._options))); } get metrics() { var _a; return ((_a = this._metrics) !== null && _a !== void 0 ? _a : (this._metrics = new Client_4.MetricsClient(this._options))); } get users() { var _a; return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new Client_7.UsersClient(this._options))); } get streaks() { var _a; return ((_a = this._streaks) !== null && _a !== void 0 ? _a : (this._streaks = new Client_6.StreaksClient(this._options))); } get points() { var _a; return ((_a = this._points) !== null && _a !== void 0 ? _a : (this._points = new Client_5.PointsClient(this._options))); } get leaderboards() { var _a; return ((_a = this._leaderboards) !== null && _a !== void 0 ? _a : (this._leaderboards = new Client_3.LeaderboardsClient(this._options))); } get admin() { var _a; return ((_a = this._admin) !== null && _a !== void 0 ? _a : (this._admin = new Client_2.AdminClient(this._options))); } /** * Make a passthrough request using the SDK's configured auth, retry, logging, etc. * This is useful for making requests to endpoints not yet supported in the SDK. * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL. * * @param {Request | string | URL} input - The URL, path, or Request object. * @param {RequestInit} init - Standard fetch RequestInit options. * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal). * @returns {Promise<Response>} A standard Response object. */ fetch(input, init, requestOptions) { return __awaiter(this, void 0, void 0, function* () { var _a; return core.makePassthroughRequest(input, init, { baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : (() => __awaiter(this, void 0, void 0, function* () { var _a; const env = yield core.Supplier.get(this._options.environment); return typeof env === "string" ? env : ((_a = env === null || env === void 0 ? void 0 : env.api) !== null && _a !== void 0 ? _a : environments.TrophyApiEnvironment.Production.api); })), headers: this._options.headers, timeoutInSeconds: this._options.timeoutInSeconds, maxRetries: this._options.maxRetries, fetch: this._options.fetch, logging: this._options.logging, getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }), }, requestOptions); }); } } exports.TrophyApiClient = TrophyApiClient;