Class: MockSearchOneway

Inherits:
MockSearch show all
Defined in:
lib/mock_search/mock_search_oneway.rb

Instance Attribute Summary collapse

Attributes inherited from MockSearch

#adt, #cabotage, #cnn, #host, #inf, #itinerary, #json

Instance Method Summary collapse

Methods inherited from MockSearch

#des, #digest_md5, #encrypt, #generar_host, #generate_post_alert_url, #generate_url_checkout, #generate_url_landing_airline, #generate_url_landing_arrival_airport, #generate_url_landing_disambiguation_airports, #generate_url_landing_origin_airport, #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 = {}) ⇒ MockSearchOneway

Returns a new instance of MockSearchOneway.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mock_search/mock_search_oneway.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)
  	@description  = "oneway"
  	@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers}"
end

Instance Attribute Details

#city_from_1Object (readonly)

Returns the value of attribute city_from_1.



3
4
5
# File 'lib/mock_search/mock_search_oneway.rb', line 3

def city_from_1
  @city_from_1
end

#city_to_1Object (readonly)

Returns the value of attribute city_to_1.



3
4
5
# File 'lib/mock_search/mock_search_oneway.rb', line 3

def city_to_1
  @city_to_1
end

#date_from_1Object (readonly)

Returns the value of attribute date_from_1.



3
4
5
# File 'lib/mock_search/mock_search_oneway.rb', line 3

def date_from_1
  @date_from_1
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/mock_search/mock_search_oneway.rb', line 3

def description
  @description
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/mock_search/mock_search_oneway.rb', line 3

def path
  @path
end

Instance Method Details

#generate_url_anticipated_searchObject

genero una url para una busqueda anticipada



37
38
39
# File 'lib/mock_search/mock_search_oneway.rb', line 37

def generate_url_anticipated_search()
 	return @host + "/shop/flights/test/data/search/begin/oneway/" + @path
end

#generate_url_disambiguation_airports(city) ⇒ Object

genero una url para ingresar a desambiguacion de aeropuertos



26
27
28
29
# File 'lib/mock_search/mock_search_oneway.rb', line 26

def generate_url_disambiguation_airports(city)
  @path = "#{@city_from_1.code}/#{city}/#{@date_from_1}/#{passengers}"
  return @host + "/shop/flights/results/oneway/" + @path
end

#generate_url_disambiguation_cityObject

genero una url para ingresar a desambiguacion de ciudades



32
33
34
# File 'lib/mock_search/mock_search_oneway.rb', line 32

def generate_url_disambiguation_city()
 	return @host + "/shop/flights/search/oneway/" + @path.gsub(/(\D{3})\/(\D{3})\//,"___/___/") + "?toDescriptions=test1&fromDescriptions=test2"
end

#generate_url_landing_homeObject

genero la url para ingresar a la home de vuelos



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mock_search/mock_search_oneway.rb', line 70

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



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/mock_search/mock_search_oneway.rb', line 57

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



20
21
22
23
# File 'lib/mock_search/mock_search_oneway.rb', line 20

def generate_url_results_search(params = "",site_country=nil)
    to_city_change(site_country) if site_country
  	return @host + "/shop/flights/results/oneway/" + @path + params
end

#generate_url_results_search_paginate_service(page, hash) ⇒ Object

genero la url del paginado



52
53
54
# File 'lib/mock_search/mock_search_oneway.rb', line 52

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 = "TOTALFARE") ⇒ Object

genero la url del servicio de resultados



42
43
44
# File 'lib/mock_search/mock_search_oneway.rb', line 42

def generate_url_results_search_service(type="TOTALFARE")
	return @host + "/shop/flights/data/search/oneway/" + @path + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{des()}"
end

#generate_url_results_search_service_streaming(type = "TOTALFARE") ⇒ Object

genero la url del servicio de resultados



47
48
49
# File 'lib/mock_search/mock_search_oneway.rb', line 47

def generate_url_results_search_service_streaming(type="TOTALFARE")
	return @host + "/shop/flights/data/search/oneway/" + @path + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{digest_md5()}&streaming=true"
end

#get_advanced_bussinnesObject



87
88
89
# File 'lib/mock_search/mock_search_oneway.rb', line 87

def get_advanced_bussinnes()
	return "/NA/C/NA/NA"
end

#get_indec_airlines(env) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/mock_search/mock_search_oneway.rb', line 91

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_dateObject



82
83
84
85
# File 'lib/mock_search/mock_search_oneway.rb', line 82

def get_ticket_date()
	super()
	@result_hash['itinerary_hash']  = @itinerary['itinerariesBox']['matchingInfoMap']['_0_-1']['itineraryId']
end

#set_from_date(date_from) ⇒ Object



105
106
107
108
# File 'lib/mock_search/mock_search_oneway.rb', line 105

def set_from_date(date_from)
 	@date_from_1 = date_from
 	@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers}"
end

#set_new_date(date_from, date_to) ⇒ Object



110
111
112
113
# File 'lib/mock_search/mock_search_oneway.rb', line 110

def set_new_date(date_from,date_to)
	@date_from_1 = date_from
	@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{passengers}"
end

#to_city_descriptionObject



101
102
103
# File 'lib/mock_search/mock_search_oneway.rb', line 101

def to_city_description()
   	return @city_to_1.name.no_accents
end