-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.mts
43 lines (39 loc) · 1008 Bytes
/
api.mts
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
41
42
43
import type { LoginPostData } from '@olivierzal/heatzy-api'
import type Homey from 'homey/lib/Homey'
import type HeatzyApp from './app.mjs'
import type { DeviceSettings, DriverSetting, Settings } from './types.mjs'
const getApp = (homey: Homey): HeatzyApp => homey.app as HeatzyApp
const api = {
getDeviceSettings({ homey }: { homey: Homey }): DeviceSettings {
return getApp(homey).getDeviceSettings()
},
getDriverSettings({
homey,
}: {
homey: Homey
}): Partial<Record<string, DriverSetting[]>> {
return getApp(homey).getDriverSettings()
},
getLanguage({ homey }: { homey: Homey }): string {
return homey.i18n.getLanguage()
},
async login({
body,
homey,
}: {
body: LoginPostData
homey: Homey
}): Promise<boolean> {
return getApp(homey).login(body)
},
async setDeviceSettings({
body,
homey,
}: {
body: Settings
homey: Homey
}): Promise<void> {
return getApp(homey).setDeviceSettings(body)
},
}
export default api