-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDailyWeather.model.ts
75 lines (72 loc) · 1.88 KB
/
DailyWeather.model.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
type DailyWeatherModel = {
idcity: number,
moon: string[],
rainbow: string,
description: string,
date: string,
temperature: {
min: number,
max: number
},
rain: {
precipitation: number,
probability: number
},
wind: {
compass: string,
velocity: number
},
humidity: {
min: number,
max: number
},
sun: {
morning: string,
afternoon: string
}
}
export const toElastic = (weather: DailyWeatherModel) => ({
idcity: weather.idcity,
moon: weather.moon,
rainbow: weather.rainbow,
description: weather.description,
date: weather.date,
'temperature-min': weather.temperature.min,
'temperature-max': weather.temperature.max,
'rain-precipitation': weather.rain.precipitation,
'rain-probability': weather.rain.probability,
'wind-compass': weather.wind.compass,
'wind-velocity': weather.wind.velocity,
'humidity-min': weather.humidity.min,
'humidity-max': weather.humidity.max,
'sun-morning': weather.sun.morning,
'sun-afternoon': weather.sun.afternoon
});
export const ofElastic = (weather: any) => ({
idcity: weather.idcity,
moon: weather.moon,
rainbow: weather.rainbow,
description: weather.description,
date: weather.date,
temperature: {
min: weather['temperature-min'],
max: weather['temperature-max']
},
rain: {
precipitation: weather['rain-precipitation'],
probability: weather['rain-probability']
},
wind: {
compass: weather['wind-compass'],
velocity: weather['wind-velocity']
},
humidity: {
min: weather['humidity-min'],
max: weather['humidity-max']
},
sun: {
morning: weather['sun-morning'],
afternoon: weather['sun-afternoon']
}
} as DailyWeatherModel);
export default DailyWeatherModel;