ipqs-node-sdk
Version:
React package to interface with the various IPQS APIs
34 lines (33 loc) • 1.79 kB
JavaScript
;
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.getReportResult = void 0;
const request_1 = require("../utils/request");
const const_1 = require("../report/const");
const utils_1 = require("../utils");
const const_2 = require("../utils/request/const");
const getReportResult = (privateKey, params) => __awaiter(void 0, void 0, void 0, function* () {
return yield (0, request_1.getResult)({ type: "GET", privateKey, params, validateFn: validateParams, urlFn: whichUrl, urlPropName: const_1.URL_PROP_NAME });
});
exports.getReportResult = getReportResult;
const validateParams = (params) => {
const errors = [];
if (!(0, utils_1.disallowPKConfigs)(params)) {
errors.push(const_1.ERRORS.PK_CONFIG_NOT_ALLOWED);
}
return errors;
};
const whichUrl = (privateKey, params, urlPropName) => {
const { config: { exportType } } = params;
const sanitizedExportType = (0, utils_1.sanitizeExportType)(exportType);
return `${const_2.BASE_URL}/${sanitizedExportType}/${urlPropName}/${privateKey}`;
};
exports.default = exports.getReportResult;