Created
April 16, 2013 08:57
-
-
Save Timrael/5394468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HotelsApi | |
class Search | |
include NanoApi::Model | |
HOTELSCOMBINED_MAP = { | |
:search => :destination, | |
:file_name => :fileName, | |
:checkin => :depart_date, | |
:checkout => :return_date, | |
:rooms => :rooms, | |
:persons => :adults, | |
:label => :label | |
} | |
attribute :destination_name | |
attribute :file_name | |
attribute(:depart_date) {Date.current} | |
attribute(:return_date) {Date.current + 6.days} | |
attribute :rooms, in: (1..6), default: 1 | |
attribute :adults, in: (1..9), default: 1 | |
attribute :children, in: (0..5), default: 1 | |
attribute :infants, in: (0..5), default: 1 | |
attribute :label | |
URL = 'http://nano.aviasales.ru/hotel_clicks?%s' | |
def link | |
URL % hotelscombined_params.to_query | |
end | |
private | |
def hotelscombined_params | |
HOTELSCOMBINED_MAP.each_with_object({}) do |(name, value), result| | |
result[value] = send(name) if send(name).present? | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment