Class: MockSearchMultipleoneway
- Inherits:
-
MockSearch
- Object
- MockSearch
- MockSearchMultipleoneway
- Defined in:
- lib/mock_search/mock_search_multipleoneway.rb
Instance Attribute Summary collapse
-
#city_from_1 ⇒ Object
readonly
Returns the value of attribute city_from_1.
-
#city_to_1 ⇒ Object
readonly
Returns the value of attribute city_to_1.
-
#date_from_1 ⇒ Object
readonly
Returns the value of attribute date_from_1.
-
#date_to_1 ⇒ Object
readonly
Returns the value of attribute date_to_1.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from MockSearch
#adt, #cabotage, #cnn, #host, #inf, #itinerary, #json
Instance Method Summary collapse
- #add_day_to_search ⇒ Object
-
#generate_url_anticipated_search ⇒ Object
genero una url para una busqueda anticipada.
-
#generate_url_disambiguation_airports(city) ⇒ Object
genero una url para ingresar a desambiguacion de aeropuertos.
-
#generate_url_disambiguation_city ⇒ Object
genero una url para ingresar a desambiguacion de ciudades.
-
#generate_url_landing_home ⇒ Object
genero la url para ingresar a la home de vuelos.
-
#generate_url_landing_search(dep, ret) ⇒ Object
genero la url de resultados de landing a partir de una ciudad de salida y una ciudad de destino.
-
#generate_url_results_search(params = "", site_country = nil) ⇒ Object
genero una url de busqueda basica.
-
#generate_url_results_search_paginate_service(page, hash) ⇒ Object
genero la url del paginado.
-
#generate_url_results_search_service(type = "FARE") ⇒ Object
genero la url del servicio de resultados.
-
#generate_url_results_search_service_streaming(type = "FARE") ⇒ Object
genero la url del servicio de resultados.
- #get_advanced_bussinnes ⇒ Object
- #get_indec_airlines(env) ⇒ Object
- #get_ticket_date ⇒ Object
- #get_to_city_description ⇒ Object
-
#initialize(site, env, cabotage, params = {}) ⇒ MockSearchMultipleoneway
constructor
A new instance of MockSearchMultipleoneway.
- #set_from_date(date_from) ⇒ Object
- #set_new_date(date_from, date_to) ⇒ Object
- #set_passengers_for_2tc(adt, cnn, inf) ⇒ Object
Methods inherited from MockSearch
#des, #digest_md5, #encrypt, #generar_host, #generate_post_alert_url, #generate_url_checkout, #get_childrens, #get_results_search_service, #get_results_search_service_streaming, #paginate, #passengers, #reset_json, #set_from_city, #set_header_json, #set_to_city, #to_city_change
Constructor Details
#initialize(site, env, cabotage, params = {}) ⇒ MockSearchMultipleoneway
Returns a new instance of MockSearchMultipleoneway.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 5 def initialize(site,env,cabotage,params={}) super(site,env,cabotage) unless (params.nil? or params.empty?) @city_from_1 = MockCity.new(@site,params["from"]) @city_to_1 = MockCity.new(@site,params["to"]) else @city_from_1 = MockCity.new(@site) @city_to_1 = @city_from_1.generate_to_city(@cabotage) end @date_from_1 = Date.today + 120 + rand(15) @date_to_1 = @date_from_1 + 5 + rand(15) @description = "multipleoneway" passengers_aux = passengers @path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers_aux}" @path_service = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers_aux}" end |
Instance Attribute Details
#city_from_1 ⇒ Object (readonly)
Returns the value of attribute city_from_1.
3 4 5 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 3 def city_from_1 @city_from_1 end |
#city_to_1 ⇒ Object (readonly)
Returns the value of attribute city_to_1.
3 4 5 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 3 def city_to_1 @city_to_1 end |
#date_from_1 ⇒ Object (readonly)
Returns the value of attribute date_from_1.
3 4 5 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 3 def date_from_1 @date_from_1 end |
#date_to_1 ⇒ Object (readonly)
Returns the value of attribute date_to_1.
3 4 5 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 3 def date_to_1 @date_to_1 end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 3 def description @description end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 3 def path @path end |
Instance Method Details
#add_day_to_search ⇒ Object
116 117 118 119 120 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 116 def add_day_to_search() @date_from_1 = @date_from_1 + 1 @date_to_1 = @date_to_1 + 1 @path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}" end |
#generate_url_anticipated_search ⇒ Object
genero una url para una busqueda anticipada
48 49 50 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 48 def generate_url_anticipated_search() return @host + "/shop/flights/test/data/search/begin/multipleoneway/" + @path end |
#generate_url_disambiguation_airports(city) ⇒ Object
genero una url para ingresar a desambiguacion de aeropuertos
37 38 39 40 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 37 def generate_url_disambiguation_airports(city) @path = "#{@city_from_1.code}/#{city}/#{@date_from_1}/#{@date_to_1}/#{passengers}" return @host + "/shop/flights/results/multipleoneway/" + @path end |
#generate_url_disambiguation_city ⇒ Object
genero una url para ingresar a desambiguacion de ciudades
43 44 45 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 43 def generate_url_disambiguation_city() return @host + "/shop/flights/search/multipleoneway/" + @path.gsub(/(\D{3})\/(\D{3})\//,"___/___/") + "?toDescriptions=test1&fromDescriptions=test2" end |
#generate_url_landing_home ⇒ Object
genero la url para ingresar a la home de vuelos
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 66 def generate_url_landing_home() landing = case @site when "BR" then "/passagens-aereas" when "US" then "/flights" when "CN" then "/flights" when "IN" then "/flights" when "PT" then "/passagens-aereas" else "/vuelos" end return @host + landing end |
#generate_url_landing_search(dep, ret) ⇒ Object
genero la url de resultados de landing a partir de una ciudad de salida y una ciudad de destino
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 53 def generate_url_landing_search(dep,ret) landing = case @site when "BR" then "/passagens-aereas" when "US" then "/flights" when "CN" then "/flights" when "IN" then "/flights" when "PT" then "/passagens-aereas" else "/vuelos" end return @host + landing + "/#{dep}/#{ret}" end |
#generate_url_results_search(params = "", site_country = nil) ⇒ Object
genero una url de busqueda basica
31 32 33 34 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 31 def generate_url_results_search(params = "",site_country=nil) to_city_change(site_country) if site_country return @host + "/shop/flights/results/multipleoneway/" + @path + params end |
#generate_url_results_search_paginate_service(page, hash) ⇒ Object
genero la url del paginado
89 90 91 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 89 def generate_url_results_search_paginate_service(page,hash) return "#{@host}/shop/flights/data/refine/#{@description.upcase}/#{@city_from_1.code}/#{@city_to_1.code}/#{@cabotage ? 'DOMESTIC' : 'INTERNATIONAL'}/NA/#{hash}/1/PRECLUSTER/FARE/ASCENDING/#{page}/NA/NA/BRL/BRL/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA/NA" end |
#generate_url_results_search_service(type = "FARE") ⇒ Object
genero la url del servicio de resultados
79 80 81 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 79 def generate_url_results_search_service(type="FARE") return @host + "/shop/flights/data/search/oneway/" + @path_service + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{des()}&itemType=SINGLETYPE&pageSize=25&tripType=MULTIPLEONEWAY&prevDate=&nextDate=#{@date_to_1}" end |
#generate_url_results_search_service_streaming(type = "FARE") ⇒ Object
genero la url del servicio de resultados
84 85 86 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 84 def generate_url_results_search_service_streaming(type="FARE") return @host + "/shop/flights/data/search/oneway/" + @path_service + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{digest_md5()}&itemType=SINGLETYPE&pageSize=25&tripType=MULTIPLEONEWAY&prevDate=&nextDate=#{@date_to_1}&streaming=true" end |
#get_advanced_bussinnes ⇒ Object
98 99 100 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 98 def get_advanced_bussinnes() return "/NA/NA/C/NA/NA" end |
#get_indec_airlines(env) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 102 def get_indec_airlines(env) servers = { "rc"=>"http://lb.despegar.it/", "beta"=>"http://backoffice.despegar.com/", "produccion"=>"http://backoffice.despegar.com/" } respond = HTTParty.get("#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}") return respond end |
#get_ticket_date ⇒ Object
93 94 95 96 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 93 def get_ticket_date() super() @result_hash['itinerary_hash'] = @itinerary['itinerariesBox']['matchingInfoMap']['_0_0']['itineraryId'] end |
#get_to_city_description ⇒ Object
112 113 114 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 112 def get_to_city_description() return @city_to_1.name.no_accents end |
#set_from_date(date_from) ⇒ Object
128 129 130 131 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 128 def set_from_date(date_from) @date_from_1 = date_from @path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}" end |
#set_new_date(date_from, date_to) ⇒ Object
122 123 124 125 126 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 122 def set_new_date(date_from,date_to) @date_from_1 = date_from @date_to_1 = date_to @path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{passengers}" end |
#set_passengers_for_2tc(adt, cnn, inf) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/mock_search/mock_search_multipleoneway.rb', line 22 def set_passengers_for_2tc(adt,cnn,inf) @adt = adt @cnn = cnn @inf = inf @path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_1}/#{@adt}/#{@cnn}/#{@inf}" @path_service = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@adt}/#{@cnn}/#{@inf}" end |