Skip to content

Commit

Permalink
Updated condition for request method type for get_list
Browse files Browse the repository at this point in the history
numberOfResults acceptable values are 0 < val < 200,
according to expedia API documentation.
Instead a POST request should be made 
if a 'long' hotelIdList is provided. 
The boundaries for length of a long list are not specified 
in the documentation.
  • Loading branch information
Martijn Bleeker committed Sep 10, 2014
1 parent eaea41d commit b517ed0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/expedia/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ class Api
# @param args [Hash] All the params required for 'get_list' call
# @return [Expedia::HTTPService::Response] on success. A response object representing the results from Expedia
# @return [Expedia::APIError] on Error.
# @note A POST request is made instead of GET if 'numberOfResults' > 200
# @note A POST request is made instead of GET if 'hotelIdList' length > 200
def get_list(args)
no_of_results = 'numberOfResults'
method = (args[no_of_results.to_sym].to_i > 200 || args[no_of_results].to_i > 200) ||
args[no_of_results.downcase.to_sym].to_i > 200 || args[no_of_results.downcase].to_i > 200 ? :post : :get
method = (args[:hotelIdList] || args["hotelIdList"] || []).length > 200 ? :post : :get
services('/ean-services/rs/hotel/v3/list', args, method)
end

Expand Down

0 comments on commit b517ed0

Please sign in to comment.