Class: MockSearchRoundtrip

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

Instance Attribute Summary collapse

Attributes inherited from MockSearch

#adt, #cabotage, #cnn, #host, #inf

Instance Method Summary collapse

Methods inherited from MockSearch

#generar_host, #generate_post_alert_url, #get_childrens, #passengers, #set_from_city, #set_to_city, #to_city_change

Constructor Details

#initialize(site, env, cabotage) ⇒ MockSearchRoundtrip

Returns a new instance of MockSearchRoundtrip.



5
6
7
8
9
10
11
12
13
# File 'lib/mock_search/mock_search_roundtrip.rb', line 5

def initialize(site,env,cabotage)
	super(site,env,cabotage)
	@city_from_1   = MockCity.new(@site)
 	@city_to_1     = @city_from_1.generate_to_city(@cabotage)
 	@date_from_1   = Date.today + 60 + rand(15)
 	@date_to_1     = @date_from_1 + rand(15)
 	@description  = "roundtrip"
 	@path = "#{@city_from_1.code}/#{@city_to_1.code}/#{@date_from_1}/#{@date_to_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_roundtrip.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_roundtrip.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_roundtrip.rb', line 3

def date_from_1
  @date_from_1
end

#date_to_1Object (readonly)

Returns the value of attribute date_to_1.



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

def date_to_1
  @date_to_1
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#add_day_to_searchObject



74
75
76
77
78
# File 'lib/mock_search/mock_search_roundtrip.rb', line 74

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

#advanced_bussinnesObject



19
20
21
# File 'lib/mock_search/mock_search_roundtrip.rb', line 19

def advanced_bussinnes
  return "/NA/NA/C/NA/NA"    
end

#generate_airports_disambiguation_search_url(city) ⇒ Object



27
28
29
30
# File 'lib/mock_search/mock_search_roundtrip.rb', line 27

def generate_airports_disambiguation_search_url(city)
  @path = "#{@city_from_1.code}/#{city}/#{@date_from_1}/#{@date_to_1}/#{passengers}"
  return @host + "/shop/flights/disambiguation/airports/roundtrip/" + @path
end

#generate_anticipated_search_urlObject



36
37
38
# File 'lib/mock_search/mock_search_roundtrip.rb', line 36

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

#generate_city_disambiguation_search_urlObject



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

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

#generate_home_landingObject



54
55
56
57
# File 'lib/mock_search/mock_search_roundtrip.rb', line 54

def generate_home_landing()
 	landing = (@site == "BR" ? "/passagens-aereas" : "/vuelos")
 	return @host + landing
end

#generate_query_string_search_urlObject



23
24
25
# File 'lib/mock_search/mock_search_roundtrip.rb', line 23

def generate_query_string_search_url()
 		return @host + "/shop/flights/search/roundtrip/" + @path + "?param1=1"
end

#generate_results_landing(dep, ret) ⇒ Object



49
50
51
52
# File 'lib/mock_search/mock_search_roundtrip.rb', line 49

def generate_results_landing(dep,ret)
	landing = (@site == "BR" ? "/passagens-aereas" : "/vuelos")
   	return @host + landing + "/#{dep}/#{ret}"
end

#generate_search_urlObject



15
16
17
# File 'lib/mock_search/mock_search_roundtrip.rb', line 15

def generate_search_url()
 		return @host + "/shop/flights/results/roundtrip/" + @path
end

#generate_search_url_for_cabotageObject



40
41
42
# File 'lib/mock_search/mock_search_roundtrip.rb', line 40

def generate_search_url_for_cabotage()
   	return @host + "/shop/flights/results/roundtrip/" + @path
end

#generate_search_url_for_country(site_country) ⇒ Object



44
45
46
47
# File 'lib/mock_search/mock_search_roundtrip.rb', line 44

def generate_search_url_for_country(site_country)
   	to_city_change(site_country)
   	return @host + "/shop/flights/results/roundtrip/" + @path
end

#get_indec_airlines(env) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/mock_search/mock_search_roundtrip.rb', line 59

def get_indec_airlines(env)
  servers = {
    "rc"=>"http://lb.despegar.it/",
    "beta"=>"http://backoffice.despegar.com/",
    "produccion"=>"http://backoffice.despegar.com/"
  }
  puts "#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}"
  respond = HTTParty.get("#{servers[env.downcase]}indec/airlines/byroute/#{@site}/#{@city_from_1.code}/#{@city_to_1.code}")
  return respond
end

#set_new_date(date_from, date_to) ⇒ Object



80
81
82
83
84
# File 'lib/mock_search/mock_search_roundtrip.rb', line 80

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

#to_city_descriptionObject



70
71
72
# File 'lib/mock_search/mock_search_roundtrip.rb', line 70

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