-
Notifications
You must be signed in to change notification settings - Fork 4
/
hosting.ts
40 lines (35 loc) · 1.16 KB
/
hosting.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { ApillonModule } from '../../lib/apillon';
import { ApillonApi } from '../../lib/apillon-api';
import { constructUrlWithQueryParams } from '../../lib/common';
import { IApillonList } from '../../types/apillon';
import { IWebsiteFilters } from '../../types/hosting';
import { HostingWebsite } from './hosting-website';
export class Hosting extends ApillonModule {
/**
* Base API url for hosting.
*/
private API_PREFIX = '/hosting/websites';
/**
* @param {IWebsiteFilters} params Query filters for listing websites
* @returns A list of HostingWebsite instances.
*/
public async listWebsites(
params?: IWebsiteFilters,
): Promise<IApillonList<HostingWebsite>> {
const url = constructUrlWithQueryParams(this.API_PREFIX, params);
const data = await ApillonApi.get<IApillonList<HostingWebsite>>(url);
return {
...data,
items: data.items.map(
(website) => new HostingWebsite(website['websiteUuid'], website),
),
};
}
/**
* @param uuid Unique website identifier.
* @returns An instance of HostingWebsite.
*/
public website(uuid: string): HostingWebsite {
return new HostingWebsite(uuid);
}
}