This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
marshal.go
66 lines (62 loc) · 2.27 KB
/
marshal.go
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
package loader
import (
"github.com/dgraph-io/travel/business/data/advisory"
"github.com/dgraph-io/travel/business/data/place"
"github.com/dgraph-io/travel/business/data/weather"
advisoryfeed "github.com/dgraph-io/travel/business/feeds/advisory"
placesfeed "github.com/dgraph-io/travel/business/feeds/places"
weatherfeed "github.com/dgraph-io/travel/business/feeds/weather"
)
// marshalPlace marshals a Place value from the places package into
// a data Place value.
func marshalPlace(feedData placesfeed.Place, cityID string, category string) place.Place {
return place.Place{
PlaceID: feedData.PlaceID,
Category: category,
City: place.City{ID: cityID},
CityName: feedData.CityName,
Name: feedData.Name,
Address: feedData.Address,
Lat: feedData.Lat,
Lng: feedData.Lng,
LocationType: feedData.LocationType,
AvgUserRating: feedData.AvgUserRating,
NumberOfRatings: feedData.NumberOfRatings,
GmapsURL: feedData.GmapsURL,
PhotoReferenceID: feedData.PhotoReferenceID,
}
}
// marshalAdvisory marshals a Advisory value from the advisory package into
// a data Advisory value.
func marshalAdvisory(feedData advisoryfeed.Advisory, cityID string) advisory.Advisory {
return advisory.Advisory{
City: advisory.City{ID: cityID},
Country: feedData.Country,
CountryCode: feedData.CountryCode,
Continent: feedData.Continent,
Score: feedData.Score,
LastUpdated: feedData.LastUpdated,
Message: feedData.Message,
Source: feedData.Source,
}
}
// marshalWeather marshals a Weather value from the weather package into
// a data Weather value.
func marshalWeather(feedData weatherfeed.Weather, cityID string) weather.Weather {
return weather.Weather{
City: weather.City{ID: cityID},
CityName: feedData.CityName,
Visibility: feedData.Visibility,
Desc: feedData.Desc,
Temp: feedData.Temp,
FeelsLike: feedData.FeelsLike,
MinTemp: feedData.MinTemp,
MaxTemp: feedData.MaxTemp,
Pressure: feedData.Pressure,
Humidity: feedData.Humidity,
WindSpeed: feedData.WindSpeed,
WindDirection: feedData.WindDirection,
Sunrise: feedData.Sunrise,
Sunset: feedData.Sunset,
}
}