Skyscanner / skyscanner-python-sdk

Skyscanner Python SDK
Other
122 stars 33 forks source link

carhire_service.get_result(...) Missing data #28

Open davidch413 opened 7 years ago

davidch413 commented 7 years ago

I have reused the example from the documentation but every time I make a request I receive a response without submitted_query, images and car_classes lists. I'm using python 3.4.6

`from skyscanner.skyscanner import CarHire

carhire_service = CarHire('my_api_key')

result = carhire_service.get_result( market='UK', currency='GBP', locale='en-GB', pickupplace='27544008', dropoffplace='27544008', pickupdatetime='2017-04-18T10:00', dropoffdatetime='2017-04-25T10:00', driverage='21', userip='127.0.0.1').parsed

print(result) `

davidch413 commented 7 years ago

I found out what the issue is. The documentation says:

... supplying &deltaExcludeWebsites= removes all images, the query, and the car classes lookup. The Location header in the first poll will include this parameter, even if it’s an empty string, in order that you don’t fetch that information multiple times.

To fix it, I have overwritten the create_session method and added

poll_path = poll_path.split('&deltaExcludeWebsites', 1)[0]

This removes &deltaExcludeWebsites from the poll_path allowing images, car classes and query to be returned.

A better way would be saving the data from initial request and merging it with data from the final poll. I will try that approach once I have some spare time.