Class: LevelTravel::Search::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/level_travel/search/request.rb

Class Method Summary collapse

Class Method Details

.actualize(request_id, tour_id:) ⇒ Object

Parameters:

  • request_id (String)

    Request ID from the ‘enqueue` request

  • tour_id (String)

    Tour ID from the ‘get_hotel_offers` request



39
40
41
# File 'lib/level_travel/search/request.rb', line 39

def self.actualize(request_id, tour_id:)
  ::LevelTravel::Request.get('/search/actualize', request_id: request_id, tour_id: tour_id)
end

.enqueue(search_params) ⇒ Object

Parameters:



7
8
9
# File 'lib/level_travel/search/request.rb', line 7

def self.enqueue(search_params)
  ::LevelTravel::Request.get('/search/enqueue', search_params.to_h)
end

.get_grouped_hotels(request_id, operator_ids: []) ⇒ Object

Parameters:

  • request_id (String)

    Request ID from the ‘enqueue` request

  • operator_ids (Array<Integer>) (defaults to: [])

    Operators’ IDs. Succeeded IDs from the result of status request.



19
20
21
22
23
# File 'lib/level_travel/search/request.rb', line 19

def self.get_grouped_hotels(request_id, operator_ids: [])
  params = prepare_params(operator_ids: operator_ids)

  ::LevelTravel::Request.get('/search/get_grouped_hotels', request_id: request_id, **params)
end

.get_hotel_offers(request_id, hotel_id:, operator_ids: [], compact: false) ⇒ Object

:reek:BooleanParameter :reek:LongParameterList

Parameters:

  • request_id (String)

    Request ID from the ‘enqueue` request

  • hotel_id (Integer)

    Hotel ID from the ‘get_grouped_hotels` request

  • operator_ids (Array<Integer>) (defaults to: [])

    Operators’ IDs. Succeeded IDs from the result of status request.

  • compact (Boolean) (defaults to: false)

    Return tours without additional information if it’s true.



31
32
33
34
35
# File 'lib/level_travel/search/request.rb', line 31

def self.get_hotel_offers(request_id, hotel_id:, operator_ids: [], compact: false)
  params = prepare_params(operator_ids: operator_ids, compact: compact)

  ::LevelTravel::Request.get('/search/get_hotel_offers', request_id: request_id, hotel_id: hotel_id, **params)
end

.get_offer(request_id, tour_id:, from_package: nil) ⇒ Object

Parameters:

  • request_id (String)

    Request ID from the ‘enqueue` request

  • tour_id (String)

    Tour ID from the ‘get_hotel_offers` request

  • from_package (Integer) (defaults to: nil)

    To link previous offer to the current



46
47
48
49
# File 'lib/level_travel/search/request.rb', line 46

def self.get_offer(request_id, tour_id:, from_package: nil)
  params = from_package ? { from_package: from_package } : {}
  ::LevelTravel::Request.get('/search/get_offer', request_id: request_id, tour_id: tour_id, **params)
end

.status(request_id) ⇒ Object

Parameters:

  • request_id (String)

    Request ID from the ‘enqueue` request



12
13
14
15
# File 'lib/level_travel/search/request.rb', line 12

def self.status(request_id)
  # TODO: return an object like { succeeded: [], failed: [] }
  ::LevelTravel::Request.get('/search/status', request_id: request_id)
end