@softvision/webpdf-wsclient-typescript
Version:
A simplified and optimized API client library for the webPDF server
44 lines • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractSession = void 0;
const exception_1 = require("../exception");
const connection_1 = require("./connection");
class AbstractSession {
constructor(webServiceProtocol, serverContext, authProvider) {
this.serverContext = new connection_1.SessionContextSettings(serverContext);
this.authProvider = authProvider;
this.webServiceProtocol = webServiceProtocol;
this.basePath = "rest/";
let toUrl = this.serverContext.getUrl().toString();
if (!toUrl.endsWith("/")) {
toUrl += "/";
}
try {
this.baseUrl = new URL(toUrl);
}
catch (ex) {
throw new exception_1.ClientResultException(exception_1.WsclientErrors.INVALID_URL, ex);
}
}
getAuthProvider() {
return this.authProvider;
}
getWebServiceProtocol() {
return this.webServiceProtocol;
}
getSessionContext() {
return this.serverContext;
}
getURL(subPath, parameters) {
let url = new URL(this.baseUrl);
url.pathname += this.basePath + subPath;
if (typeof parameters !== "undefined") {
for (let [key, value] of parameters.entries()) {
url.searchParams.append(key, value);
}
}
return url;
}
}
exports.AbstractSession = AbstractSession;
//# sourceMappingURL=AbstractSession.js.map