Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cohaolain committed Feb 26, 2022
2 parents 4ce17d8 + 0239d36 commit c6145f5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

# [v1.0.2] - 2022.02.26

### Added
- Allow an optional argument to `get_flights` specifying a specific destination country code.

### Fixed
- Update repo URL so packages managers have a working source reference.

# [v1.0.1] - 2022.02.20

### Added
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ pip install ryanair-py
Creating an instance is done as follows:
```python
from ryanair import Ryanair
ryanair = Ryanair("YOUR-CURRENCY")
ryanair = Ryanair("EUR") # Euro currency, so could also be GBP etc. also
```
### Get one-way flights
```python
flights = ryanair.getFlights("DUB", "2018-10-27", "2018-10-30")
flights = ryanair.getFlights("DUB", "2022-10-27", "2022-10-30")
```
Returns an array of Flight objects, like this:
```python
flights[0] # Flight(origin='DUB', originFull='Dublin, Ireland', destination='MAN', destinationFull='Manchester, United Kingdom', departureTime='2018-10-30T06:25:00', price=9.78)
flights[0] # Flight(origin='DUB', originFull='Dublin, Ireland', destination='MAN', destinationFull='Manchester, United Kingdom', departureTime='2022-10-30T06:25:00', price=9.78)
cheapestFlightPrice = flight.price # price is now a float containing the price (in the unit of currency originally declared earlier) of this flight
```
### Get return flights
```python
trips = ryanair.getReturnFlights("DUB", "2018-10-27", "2018-10-30", "2018-11-01", "2018-11-03")
trips = ryanair.getReturnFlights("DUB", "2022-10-27", "2022-10-30", "2022-11-01", "2022-11-03")
```
Returns an array of Trip objects, like this:
```python
trips[0] # Trip(outbound=Flight(origin='DUB', originFull='Dublin, Ireland', destination='LPL', destinationFull='Liverpool, United Kingdom', departureTime='2018-10-30T20:50:00', price=9.99), inbound=Flight(origin='LPL', originFull='Liverpool, United Kingdom', destination='DUB', destinationFull='Dublin, Ireland', departureTime='2018-11-01T08:25:00', price=18.51), totalPrice=28.5)
trips[0] # Trip(outbound=Flight(origin='DUB', originFull='Dublin, Ireland', destination='LPL', destinationFull='Liverpool, United Kingdom', departureTime='2022-10-30T20:50:00', price=9.99), inbound=Flight(origin='LPL', originFull='Liverpool, United Kingdom', destination='DUB', destinationFull='Dublin, Ireland', departureTime='2022-11-01T08:25:00', price=18.51), totalPrice=28.5)
trips[0].outbound.price # 9.99
trips[0].totalPrice # 28.5
```
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
requests
tabulate
requests
4 changes: 3 additions & 1 deletion ryanair/ryanair.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Ryanair:
REPEAT_WAIT_SECONDS = 10

def __init__(self, currency):
def get_flights(airport, date_from, date_to):
def get_flights(airport, date_from, date_to, destination_country=None):
query_url = ''.join((Ryanair.BASE_API_URL,
"farfnd/v4/oneWayFares"))

Expand All @@ -24,6 +24,8 @@ def get_flights(airport, date_from, date_to):
"outboundDepartureDateFrom": self._format_date_for_api(date_from),
"outboundDepartureDateTo": self._format_date_for_api(date_to),
"currency": self.currency}
if destination_country:
params['arrivalCountryCode'] = destination_country

response = _safe_query_fares(query_url, params)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
long_description = f.read()

setup(name='ryanair-py',
version='1.0.1',
version='1.0.2',
description='A module which allows you to retrieve the cheapest flights, with/out return flights, '
'within a fixed set of dates.',
long_description=long_description,
long_description_content_type='text/markdown',
author='Ciarán Ó hAoláin',
author_email='ciaran@cohaolain.ie',
url='https://github.com/cohaolain/ryanairPython',
url='https://github.com/cohaolain/ryanair-py',
packages=['ryanair'],
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit c6145f5

Please sign in to comment.