feat(unifi): implement comprehensive UniFi API client with controllers, protect, access, account, managers, resources, HTTP client, interfaces, logging, plugins, and tests
This commit is contained in:
57
ts/classes.site.ts
Normal file
57
ts/classes.site.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { UnifiAccount } from './classes.unifi-account.js';
|
||||
import type { IUnifiSite } from './interfaces/index.js';
|
||||
|
||||
/**
|
||||
* Represents a UniFi site from Site Manager
|
||||
*/
|
||||
export class UnifiSite implements IUnifiSite {
|
||||
/** Reference to parent account */
|
||||
private unifiAccount?: UnifiAccount;
|
||||
|
||||
// IUnifiSite properties
|
||||
public siteId: string;
|
||||
public name: string;
|
||||
public description?: string;
|
||||
public isDefault?: boolean;
|
||||
public timezone?: string;
|
||||
public meta?: {
|
||||
type?: string;
|
||||
address?: string;
|
||||
};
|
||||
public createdAt?: string;
|
||||
public updatedAt?: string;
|
||||
|
||||
constructor() {
|
||||
this.siteId = '';
|
||||
this.name = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a site instance from API response object
|
||||
*/
|
||||
public static createFromApiObject(
|
||||
apiObject: IUnifiSite,
|
||||
unifiAccount?: UnifiAccount
|
||||
): UnifiSite {
|
||||
const site = new UnifiSite();
|
||||
Object.assign(site, apiObject);
|
||||
site.unifiAccount = unifiAccount;
|
||||
return site;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw API object representation
|
||||
*/
|
||||
public toApiObject(): IUnifiSite {
|
||||
return {
|
||||
siteId: this.siteId,
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
isDefault: this.isDefault,
|
||||
timezone: this.timezone,
|
||||
meta: this.meta,
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user