import {AuthService} from "../services/auth.service"; import {UserService} from "../services/user.service"; import {GroupService} from "../services/group.service"; import {RoleService} from "../services/role.service"; import {DeviceService} from "../services/device.service"; import {ApplicationService} from "../services/application.service"; import {PropertyService} from "../services/property.service"; import {OrganisationService} from "../services/organisation.service"; import {LocalDataService} from "@haventec/common-js/ts"; export class HaventecCloudPortal { private authService: AuthService; private userService: UserService; private groupService: GroupService; private roleService: RoleService; private deviceService: DeviceService; private applicationService: ApplicationService; private organisationService: OrganisationService; private propertyService: PropertyService; private localDataService: LocalDataService; constructor( public domainUrl: string, public test?: boolean ) { this.localDataService = new LocalDataService(test); this.authService = new AuthService(domainUrl, this.localDataService); this.userService = new UserService(domainUrl, this.localDataService); this.groupService = new GroupService(domainUrl, this.localDataService); this.roleService = new RoleService(domainUrl, this.localDataService); this.deviceService = new DeviceService(domainUrl, this.localDataService); this.applicationService = new ApplicationService(domainUrl, this.localDataService); this.organisationService = new OrganisationService(domainUrl, this.localDataService); this.propertyService = new PropertyService(domainUrl, this.localDataService); } public activate(username: string, pin: string, deviceName: string, activationToken: string) { return this.authService.activate(username, pin, deviceName, activationToken); } public login(username: string, pin: string) { return this.authService.login(username, pin); } public logout() { return this.authService.logout(); } public forgotpin(username: string, pin: string) { return this.authService.forgotpin(username, pin); } public reprovision(username: string, pin: string, requestId: string, activationToken: string) { return this.authService.reprovision(username, pin, requestId, activationToken); } public tenantCreate(tenantName: string, username: string, email: string, pin: string) { return this.authService.tenantCreate(tenantName, username, email, pin); } public createOrganisation(organisationName: string, username: string, email: string){ return this.authService.createOrganisation(organisationName, username, email); } public sessionValid() { return this.authService.accessTokenIsValid(); } public getAuthService() : AuthService { return this.authService; } public getSmtpConfiguration() { return this.propertyService.getSmtpDetails(); } public setSmtpConfiguration(host: string, port: string, username: string, password: string, enabled: boolean, tlsEnabled: boolean) { return this.propertyService.updateSmtpDetails(host, port, username, password, enabled, tlsEnabled); } public testStoredSmtpConfiguration() { return this.propertyService.testStoredSmtpConfiguration(); } public listOrganisations(page: number, size: number) { return this.organisationService.list(page, size); } public listCloudPortalUsers(page: number, size: number) { return this.userService.listCloudPortalUsers(page, size); } public listUsersForApplication(applicationUuid: string, page: number, size: number) { return this.userService.listForApplication(applicationUuid, page, size); } public getUser(username: string) { return this.userService.get(username); } public changeUserLockStatus(username: string) { return this.userService.changelockstatus(username); } public deleteUser(username: string) { return this.userService.delete(username); } public preprovision(username: string, deviceName: string, groupName: string) { return this.userService.preprovision(username, deviceName, groupName); } public getUserGroups(username: string) { return this.userService.getGroups(username); } public updateUserGroups(username: string, groupNames: Array) { return this.userService.updateGroups(username, groupNames); } public listGroups(page: number, size: number) { return this.groupService.list(page, size); } public getGroup(name: string) { return this.groupService.get(name); } public updateGroup(name: string, description: string) { return this.groupService.update(name, description); } public deleteGroup(name: string) { return this.groupService.delete(name); } public getGroupRoles(name: string) { return this.groupService.getRoles(name); } public updateGroupRoles(name: string, roleNames: Array) { return this.groupService.updateRoles(name, roleNames); } public listRoles(page: number, size: number) { return this.roleService.list(page, size); } public getRole(name: string) { return this.roleService.get(name); } public updateRole(name: string, description: string) { return this.roleService.update(name, description); } public deleteRole(name: string) { return this.roleService.delete(name); } public listDevices(page: number, size: number) { return this.deviceService.list(page, size); } public getDevice(udid: string) { return this.deviceService.get(udid); } public updateDevice(udid: string, deviceName: string, failedAttempts: number) { return this.deviceService.update(udid, deviceName, failedAttempts); } public changeDeviceLockStatus(udid: string) { return this.deviceService.changelockstatus(udid); } public deleteDevice(udid: string) { return this.deviceService.delete(udid); } public listApplications(page: number, size: number) { return this.applicationService.list(page, size); } public getApplication(name: string) { return this.applicationService.get(name); } public getApplications() { return this.applicationService.getAll(); } public updateApplication(name: string, description: string, uuid: string, apiKey: string) { return this.applicationService.update(name, description, uuid, apiKey); } public listCategories() { return this.propertyService.list(); } public getPropertiesForCategory(categoryname: string) { return this.propertyService.get(categoryname); } public updatePropertyForCategory(categoryname: string, propertyname: string, propertyvalue: string) { return this.propertyService.update(categoryname, propertyname, propertyvalue); } public deletePropertyForCategory(categoryname: string, propertyname: string) { return this.propertyService.deleteCategoryProperty(categoryname, propertyname); } public deleteCategory(name: string) { return this.propertyService.deleteCategory(name); } }