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

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) ⇒ MockSearchOneway

Returns a new instance of MockSearchOneway.



5
6
7
8
9
10
11
12
# File 'lib/mock_search/mock_search_oneway.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)
  	@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

#advanced_bussinnesObject



18
19
20
# File 'lib/mock_search/mock_search_oneway.rb', line 18

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

#generate_airports_disambiguation_search_url(city) ⇒ Object



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

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

#generate_anticipated_search_urlObject



35
36
37
# File 'lib/mock_search/mock_search_oneway.rb', line 35

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

#generate_city_disambiguation_search_urlObject



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

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

#generate_query_string_search_urlObject



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

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

#generate_search_urlObject



14
15
16
# File 'lib/mock_search/mock_search_oneway.rb', line 14

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

#generate_search_url_for_cabotageObject



39
40
41
# File 'lib/mock_search/mock_search_oneway.rb', line 39

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

#generate_search_url_for_country(site_country) ⇒ Object



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

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

#get_indec_airlines(env) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/mock_search/mock_search_oneway.rb', line 48

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

#to_city_descriptionObject



59
60
61
# File 'lib/mock_search/mock_search_oneway.rb', line 59

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