Class: FiveonebookFlight

Inherits:
Object
  • Object
show all
Extended by:
AbstractFlight
Includes:
Auth, HTTParty
Defined in:
lib/flight_info/fiveonebook_flight.rb

Class Method Summary collapse

Methods included from AbstractFlight

query, translateFlight

Class Method Details

.body_content(args) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/flight_info/fiveonebook_flight.rb', line 41

def self.body_content(args)
  {
    'Content-Type' => 'application/json',
    'USERNAME' => Auth.username,
    'SIGN' => Digest::MD5.hexdigest(build_query(args).to_json + Auth.password),
    'Accept-Charset' => 'utf-8',
    'contentType' => 'utf-8'
  }
end

.build_query(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/flight_info/fiveonebook_flight.rb', line 9

def self.build_query(args)
  cabin_class, direct_flight, adult_num, child_num, depart_airport, arri_airport, depart_time, current_time, return_airport, home_airport, back_time = args.values_at(:cabin_class, :direct_flight, :adult_num, :child_num, :depart_airport, :arri_airport, :depart_time, :current_time, :return_airport, :home_airport, :back_time)
  {
    agencyCode: Auth.username,
    rsIsGzip: true,
    timeStamp: current_time,
    RQData: {
      cabinClass: cabin_class,
      directFlight: direct_flight,
      routeType: 'RT',
      resourceChannel: 1,
      passengerNumberVo: [{
        passengerType: 'ADT',
        passengerNumber: adult_num
      }, {
        passengerType: 'CHD',
        passengerNumber: child_num
      }],
      segmentList: [{
        departureAirport: depart_airport,
        arrivalAirport: arri_airport,
        departureTime: depart_time
      },
                    {
                      departureAirport: return_airport,
                      arrivalAirport: home_airport,
                      departureTime: back_time
                    }]
    }
  }
end

.search_flight(args) ⇒ Object



51
52
53
# File 'lib/flight_info/fiveonebook_flight.rb', line 51

def self.search_flight(args)
  query '/searchFlight', args
end