Files
mail_manager/src/models/provider.ts
Sebastian Krupinski 65435b526c
All checks were successful
Build Test / test (pull_request) Successful in 23s
JS Unit Tests / test (pull_request) Successful in 22s
PHP Unit Tests / test (pull_request) Successful in 1m5s
refactor: standardize manager design
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-02-25 00:18:28 -05:00

63 lines
1.3 KiB
TypeScript

/**
* Class model for Provider Interface
*/
import type {
ProviderInterface,
ProviderCapabilitiesInterface
} from "@/types/provider";
export class ProviderObject implements ProviderInterface {
_data!: ProviderInterface;
constructor() {
this._data = {
'@type': 'mail:provider',
identifier: '',
label: '',
capabilities: {},
};
}
fromJson(data: ProviderInterface): ProviderObject {
this._data = data;
return this;
}
toJson(): ProviderInterface {
return this._data;
}
capable(capability: keyof ProviderCapabilitiesInterface): boolean {
const value = this._data.capabilities?.[capability];
return value !== undefined && value !== false;
}
capability(capability: keyof ProviderCapabilitiesInterface): any | null {
if (this._data.capabilities) {
return this._data.capabilities[capability];
}
return null;
}
/** Immutable Properties */
get '@type'(): string {
return this._data['@type'];
}
get identifier(): string {
return this._data.identifier;
}
get label(): string {
return this._data.label;
}
get capabilities(): ProviderCapabilitiesInterface {
return this._data.capabilities;
}
}