-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprices-calendar.go
54 lines (49 loc) · 1.83 KB
/
prices-calendar.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
package aviasales
import "fmt"
type InputPricesCalendar struct {
Origin string
Destination string
DepartDate string
ReturnDate string
CalendarType string
TripDuration int
Currency string
}
type DataFlightCalendar struct {
Success bool `json:"success" bson:"success"`
Data map[string]FlightCalendar `json:"data" bson:"data"`
}
type FlightCalendar struct {
Price int `json:"price" bson:"price"`
Airline string `json:"airline" bson:"airline"`
FlightNumber int `json:"flight_number" bson:"flight_number"`
DepartureAt string `json:"departure_at" bson:"departure_at"`
ReturnAt string `json:"return_at" bson:"return_at"`
ExpiresAt string `json:"expires_at" bson:"expires_at"`
Origin string `json:"origin" bson:"origin"`
Destination string `json:"destination" bson:"destination"`
Transfers int `json:"transfers" bson:"transfers"`
}
// PricesCalendar returns the cheapest ticket (without transfer, with one or two changes) for the specified direction for each day of the selected month.
//
// Documentation:
// https://support.travelpayouts.com/hc/ru/articles/203956163#07
//
// Example URI:
// http://api.travelpayouts.com/v1/prices/calendar?depart_date=2016-11&origin=MOW&destination=BCN&calendar_type=departure_date&token=YOUR_TOKEN
func (a *AviasalesApi) PricesCalendar(input InputPricesCalendar) (flights DataFlightCalendar, err error) {
query := map[string]string{
"currency": input.Currency,
"origin": input.Origin,
"destination": input.Destination,
"depart_date": input.DepartDate,
"return_date": input.ReturnDate,
"calendar_type": input.CalendarType,
"token": a.token,
}
if input.TripDuration > 0 {
query["trip_duration"] = fmt.Sprintf("%d", input.TripDuration)
}
err = a.getJson("v1/prices/calendar", query, &flights)
return
}