-
Notifications
You must be signed in to change notification settings - Fork 1
/
arguments.go
46 lines (37 loc) · 995 Bytes
/
arguments.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
package flyjapan
import (
"time"
"github.com/mkfsn/flyjapan/airlines"
)
type QueryArgument func(*queryArguments)
type dateFromTo struct {
from time.Time
to time.Time
}
// Query(DateFromTo(from, to), SourceAirport(), DestinationAirport(), SortBy(fn), Airline(), Airline(), RepeatWeeks(n), FilterBy(fn))
type queryArguments struct {
DateFromTo []dateFromTo
SourceAirport string
DestinationAirport string
Airline airlines.Airline
}
func DateFromTo(from, to time.Time) QueryArgument {
return func(o *queryArguments) {
o.DateFromTo = append(o.DateFromTo, dateFromTo{from: from, to: to})
}
}
func SourceAirport(airport string) QueryArgument {
return func(o *queryArguments) {
o.SourceAirport = airport
}
}
func DestinationAirport(airport string) QueryArgument {
return func(o *queryArguments) {
o.DestinationAirport = airport
}
}
func Airline(airline airlines.Airline) QueryArgument {
return func(o *queryArguments) {
o.Airline = airline
}
}