Module: TL::Parser
- Defined in:
- lib/TL/parser.rb,
lib/TL/parser/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- LOGIN_KEY =
'TL-INT-'
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.load_offers(url:, start_date: Date.today, finish_date: Date.tomorrow, adults_count: 2, children_ages: []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/TL/parser.rb', line 13 def load_offers(url:, start_date: Date.today, finish_date: Date.tomorrow, adults_count: 2, children_ages: []) doc = load_page(url) login = get_login(doc) hotel_id = get_hotel_id(login) offers_link = "https://ibe.tlintegration.com/ApiWebDistribution/BookingForm/hotel_availability?include_rates=true" offers_link += "&include_transfers=true&include_all_placements=true&include_promo_restricted=true&language=ru-ru" offers_link += "&criterions[0].hotels[0].code=#{hotel_id}" offers_link += "&criterions[0].dates=#{start_date.strftime("%Y-%m-%d")};#{finish_date.strftime("%Y-%m-%d")}&criterions[0].adults=#{adults_count}" response = get_js(offers_link) return nil unless response.class.in?([Net::HTTPSuccess, Net::HTTPFound, Net::HTTPOK]) p JSON.parse(response.body) end |