Class: SearchApi::GoogleFlightsOptions

Inherits:
Object
  • Object
show all
Includes:
DynamicSchema::Definable, Helpers
Defined in:
lib/searchapi/google_flights_options.rb

Constant Summary collapse

FLIGHT_TYPES =
%w[ round_trip one_way multi_city ]
STOPS =
%w[ any nonstop one_stop_or_fewer two_stops_or_fewer ]
SORT_BY =
%w[ top_flights price departure_time arrival_time duration emissions ]
TRAVEL_CLASSES =
%w[ economy premium_economy business first_class ]
NORMALIZE_DOWNCASE =
->(v) { v.to_s.downcase }

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#string_camelize

Constructor Details

#initialize(options = {}, api_options: nil) ⇒ GoogleFlightsOptions

Returns a new instance of GoogleFlightsOptions.



73
74
75
76
# File 'lib/searchapi/google_flights_options.rb', line 73

def initialize( options = {}, api_options: nil )
  @options = self.class.builder.build( options || {} )
  @options = api_options.merge( @options ) if api_options
end

Class Method Details

.build(options = nil, &block) ⇒ Object



65
66
67
# File 'lib/searchapi/google_flights_options.rb', line 65

def self.build( options = nil, &block )
  new( api_options: builder.build( options, &block ) )
end

.build!(options = nil, &block) ⇒ Object



69
70
71
# File 'lib/searchapi/google_flights_options.rb', line 69

def self.build!( options = nil, &block )
  new( api_options: builder.build!( options, &block ) )
end

Instance Method Details

#to_hObject



78
79
80
81
82
# File 'lib/searchapi/google_flights_options.rb', line 78

def to_h
  result = @options.to_h
  result[ :engine ] = 'google_flights'
  result
end