@apillon/sdk
Version:
▶◀ Apillon SDK for NodeJS ▶◀
45 lines • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Hosting = void 0;
const apillon_1 = require("../../lib/apillon");
const apillon_api_1 = require("../../lib/apillon-api");
const common_1 = require("../../lib/common");
const hosting_website_1 = require("./hosting-website");
class Hosting extends apillon_1.ApillonModule {
constructor() {
super(...arguments);
/**
* Base API url for hosting.
*/
this.API_PREFIX = '/hosting';
}
/**
* List all websites
* @param {IWebsiteFilters} params Query filters for listing websites
* @returns A list of HostingWebsite instances.
*/
async listWebsites(params) {
const url = (0, common_1.constructUrlWithQueryParams)(`${this.API_PREFIX}/websites`, params);
const data = await apillon_api_1.ApillonApi.get(url);
return Object.assign(Object.assign({}, data), { items: data.items.map((website) => new hosting_website_1.HostingWebsite(website['websiteUuid'], website)) });
}
/**
* @param uuid Unique website identifier.
* @returns An empty instance of HostingWebsite.
*/
website(uuid) {
return new hosting_website_1.HostingWebsite(uuid);
}
/**
* Generate a short link for a given target URL
* @param {string} targetUrl - The targer URL to generate a shortened URL for
* @returns {ShortUrl}
*/
async generateShortUrl(targetUrl) {
return await apillon_api_1.ApillonApi.post(`${this.API_PREFIX}/short-url`, {
targetUrl,
});
}
}
exports.Hosting = Hosting;
//# sourceMappingURL=hosting.js.map