flight_info 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flight_info.gemspec +2 -3
- data/lib/flight_info/abstract_flight.rb +19 -4
- data/lib/flight_info/auth.rb +7 -0
- data/lib/flight_info/fiveonebook_flight.rb +50 -3
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b73e671a1321a1db46075de24eaaffbfce50193
|
4
|
+
data.tar.gz: d98116d7e6427c2ebdcf236fdab97cc4cba286d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b71967aa0b838a6e7a4ac7fe7e11f9c4e4ca1ae28ce7ce88d75b3ac5c6b631d45ffd2052f2fd65dbb215f733df7dec212ddb77fbb1d03ee8786adcdc12c685d7
|
7
|
+
data.tar.gz: 857a1c616a6c78bec9ff1a417e4b1fc2e58aa155e8713b16f61e8361381120c24729d33e4267b7256b95c3933772f1dd64ccbe36c0c45c60d78355a98aede825
|
data/flight_info.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
|
@@ -18,5 +16,6 @@ Gem::Specification.new do |spec|
|
|
18
16
|
spec.required_ruby_version = '>= 2.0.0'
|
19
17
|
spec.required_rubygems_version = '>= 1.3.5'
|
20
18
|
spec.summary = 'Ruby toolkit for querying flight information'
|
21
|
-
spec.version = '0.0.
|
19
|
+
spec.version = '0.0.3'
|
20
|
+
spec.add_runtime_dependency 'activesupport'
|
22
21
|
end
|
@@ -1,6 +1,21 @@
|
|
1
|
-
|
1
|
+
require 'logger'
|
2
|
+
require 'HTTParty'
|
3
|
+
require 'yaml'
|
4
|
+
require 'pry'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
module AbstractFlight
|
7
|
+
include HTTParty
|
8
|
+
def query(method_name, args)
|
9
|
+
post(method_name, headers: body_content(args), body: build_query(args).to_json, format: :json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def translateFlight(hash, translate)
|
13
|
+
new_hash = Marshal.load(Marshal.dump(hash))
|
14
|
+
hash.each do |key, _value|
|
15
|
+
translateFlight(hash[key], translate) if hash[key].is_a? Hash
|
16
|
+
new_hash[translate[key]] = new_hash.delete key
|
17
|
+
end
|
18
|
+
hash = new_hash
|
19
|
+
end
|
20
|
+
logger ::Logger.new("#{Dir.pwd}/tmp/httparty.log"), :debug, :curl
|
6
21
|
end
|
@@ -1,6 +1,53 @@
|
|
1
1
|
require_relative 'abstract_flight'
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
require_relative 'auth'
|
3
|
+
require 'active_support'
|
4
|
+
|
5
|
+
class FiveonebookFlight
|
6
|
+
extend AbstractFlight
|
7
|
+
include HTTParty
|
8
|
+
include Auth
|
9
|
+
|
10
|
+
def self.build_query(args)
|
11
|
+
cabin_class, direct_flight, audlt_num, child_num, depart_airport, arri_airport, depart_time, current_time = args.values_at(:cabin_class, :direct_flight, :audlt_num, :child_num, :depart_airport, :arri_airport, :depart_time, :current_time)
|
12
|
+
{
|
13
|
+
agencyCode: Auth.username,
|
14
|
+
rsIsGzip: true,
|
15
|
+
timeStamp: current_time,
|
16
|
+
RQData: {
|
17
|
+
cabinClass: cabin_class,
|
18
|
+
directFlight: direct_flight,
|
19
|
+
airline: 'CA',
|
20
|
+
routeType: 'OW',
|
21
|
+
resourceChannel: 1,
|
22
|
+
passengerNumberVo: [{
|
23
|
+
passengerType: 'ADT',
|
24
|
+
passengerNumber: audlt_num
|
25
|
+
}, {
|
26
|
+
passengerType: 'CHD',
|
27
|
+
passengerNumber: child_num
|
28
|
+
}],
|
29
|
+
segmentList: [{
|
30
|
+
departureAirport: depart_airport,
|
31
|
+
arrivalAirport: arri_airport,
|
32
|
+
departureTime: depart_time
|
33
|
+
}]
|
34
|
+
}
|
35
|
+
}
|
5
36
|
end
|
37
|
+
|
38
|
+
def self.body_content(args)
|
39
|
+
{
|
40
|
+
'Content-Type' => 'application/json',
|
41
|
+
'USERNAME' => Auth.username,
|
42
|
+
'SIGN' => Digest::MD5.hexdigest(build_query(args).to_json + Auth.password),
|
43
|
+
'Accept-Charset' => 'utf-8',
|
44
|
+
'contentType' => 'utf-8'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.search_flight(args)
|
49
|
+
query '/' + __method__.to_s.camelize(:lower), args
|
50
|
+
end
|
51
|
+
|
52
|
+
base_uri "interws.51book.com/#{Auth.username}/search/"
|
6
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flight_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruochen Shen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 0.8.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activesupport
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
description: Simple wrapper for the flight_info API
|
48
62
|
email:
|
49
63
|
- src655@gmail.com
|
@@ -54,6 +68,7 @@ files:
|
|
54
68
|
- flight_info.gemspec
|
55
69
|
- lib/flight_info.rb
|
56
70
|
- lib/flight_info/abstract_flight.rb
|
71
|
+
- lib/flight_info/auth.rb
|
57
72
|
- lib/flight_info/fiveonebook_flight.rb
|
58
73
|
homepage: https://github.com/ceclinux/flight_info
|
59
74
|
licenses:
|