Class: TAPI::V3::Flights::Search

Inherits:
GenericSearch show all
Defined in:
lib/tapi/v3/flights/search.rb

Constant Summary collapse

AIRPORTCODEEXPR =
/^[\w]{3}$/

Instance Attribute Summary collapse

Attributes inherited from GenericSearch

#client, #client_urls, #errors, #start_time, #started_at

Instance Method Summary collapse

Methods inherited from GenericSearch

#add_error, #api_key, #api_url, #get, #has_errors?, #id, #id=, #load_client, #method_missing, #post_url, #reload, #restart!, #start!, #valid?

Methods included from TAPI::Validations

#add_error, #has_errors?, #inherited_validations, #validate, #validates_date_format_of, #validates_numericality_of, #validates_presence_of, #validations

Methods included from Utils

append_query, coerce_date, parse_date, symbolize_keys

Methods included from Configurable

#config, included

Constructor Details

#initialize(options = {}) ⇒ Search

Returns a new instance of Search.



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/tapi/v3/flights/search.rb', line 92

def initialize(options = {})
  @errors = {}
  self.origin = options[:origin]
  self.destination = options[:destination]
  self.leaves_on = options[:leaves_on]
  self.returns_on = options[:returns_on]
  self.one_way = options[:one_way]
  self.adults = options[:adults] || 1
  self.children = options[:children] || 0
  self.infants = options[:infants] || 0
  self.comfort = (options[:comfort] || "E").upcase
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TAPI::V3::GenericSearch

Instance Attribute Details

#adultsObject

Returns the value of attribute adults.



10
11
12
# File 'lib/tapi/v3/flights/search.rb', line 10

def adults
  @adults
end

#childrenObject

Returns the value of attribute children.



10
11
12
# File 'lib/tapi/v3/flights/search.rb', line 10

def children
  @children
end

#comfortObject

Returns the value of attribute comfort.



9
10
11
# File 'lib/tapi/v3/flights/search.rb', line 9

def comfort
  @comfort
end

#destinationObject

Returns the value of attribute destination.



9
10
11
# File 'lib/tapi/v3/flights/search.rb', line 9

def destination
  @destination
end

#infantsObject

Returns the value of attribute infants.



10
11
12
# File 'lib/tapi/v3/flights/search.rb', line 10

def infants
  @infants
end

#leaves_onObject

Returns the value of attribute leaves_on.



10
11
12
# File 'lib/tapi/v3/flights/search.rb', line 10

def leaves_on
  @leaves_on
end

#one_wayObject

Returns the value of attribute one_way.



10
11
12
# File 'lib/tapi/v3/flights/search.rb', line 10

def one_way
  @one_way
end

#originObject

Returns the value of attribute origin.



9
10
11
# File 'lib/tapi/v3/flights/search.rb', line 9

def origin
  @origin
end

#returns_onObject

Returns the value of attribute returns_on.



10
11
12
# File 'lib/tapi/v3/flights/search.rb', line 10

def returns_on
  @returns_on
end

Instance Method Details

#item_pathObject



88
89
90
# File 'lib/tapi/v3/flights/search.rb', line 88

def item_path
  'flights'
end

#parametersObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/tapi/v3/flights/search.rb', line 105

def parameters
  {
    :key => config[:key],
    :format => 'json',
    :origin => origin,
    :destination => destination,
    :leaves_on => leaves_on.to_s,
    :returns_on => returns_on.to_s,
    :one_way => one_way,
    :adults => adults,
    :children => children,
    :infants => infants,
    :comfort => comfort
  }
end