-
Notifications
You must be signed in to change notification settings - Fork 0
/
struct_config.go
48 lines (44 loc) · 1.25 KB
/
struct_config.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
package main
// Config represents the entire YAML file
type Config struct {
OutputFile string `yaml:"output_file"`
FirstDayDates struct {
CheckIn string `yaml:"check_in"`
CheckOut string `yaml:"check_out"`
} `yaml:"first_day_dates"`
Searches []Search `yaml:"searches"`
Listings []Listing `yaml:"listings"`
Amenities []string `yaml:"amenities"`
}
// Search is a single instance of a search, with all its parameters
type Search struct {
Name string `yaml:"name"`
Dates struct {
CheckIn string `yaml:"check_in"`
CheckOut string `yaml:"check_out"`
} `yaml:"dates"`
SearchQuery string `yaml:"search_query"`
SouthWest []float64 `yaml:"sw"`
NorthEast []float64 `yaml:"ne"`
Guests struct {
Adults int `yaml:"adults"`
Children int `yaml:"children"`
Infants int `yaml:"infants"`
} `yaml:"guests"`
}
// GetTotalGuests returns the total number of guests
func (search Search) GetTotalGuests() int {
guestCount := 0
guestCount += search.Guests.Adults
guestCount += search.Guests.Children
guestCount += search.Guests.Infants
return guestCount
}
// Listing is the array of listings we're looking at.
type Listing struct {
URL string
Dates struct {
CheckIn string `yaml:"check_in"`
CheckOut string `yaml:"check_out"`
}
}