-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprices-cheap.go
43 lines (39 loc) · 1.55 KB
/
prices-cheap.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
package aviasales
type InputPricesCheap struct {
Origin string
Destination string
DepartDate string
ReturnDate string
Currency string
}
type DataFlight struct {
Success bool `json:"success" bson:"success"`
Data map[string]map[string]Flight `json:"data" bson:"data"`
}
type Flight 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"`
}
// PricesCheap returns the cheapest direct, as well as 1 and 2 transfers to the chosen direction with filters by date of departure and return. Tickets return flight there and back.
// Note! If the request specifies the old date, as a result of his work is not an error, but no data will not be back.
//
// Documentation:
// https://support.travelpayouts.com/hc/ru/articles/203956163#05
//
// Example URI:
// http://api.travelpayouts.com/v1/prices/cheap?origin=MOW&destination=HKT&depart_date=2016-11&return_date=2016-12&token=YOUR_TOKEN
func (a *AviasalesApi) PricesCheap(input InputPricesCheap) (flights DataFlight, err error) {
err = a.getJson("v1/prices/cheap", map[string]string{
"currency": input.Currency,
"origin": input.Origin,
"destination": input.Destination,
"depart_date": input.DepartDate,
"return_date": input.ReturnDate,
"token": a.token,
}, &flights)
return
}