Module: FlightStats
- Defined in:
- lib/flightstats.rb
Defined Under Namespace
Classes: Airline, Airport, DataFeed, Flight
Constant Summary
collapse
- SERVER =
"https://www.pathfinder-xml.com"
- PATH =
"/development/xml"
Class Method Summary
collapse
Class Method Details
.authentication_token ⇒ Object
13
14
15
|
# File 'lib/flightstats.rb', line 13
def authentication_token
{'login.guid' => FLIGHTSTATS_GUID}
end
|
.query(params, path = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/flightstats.rb', line 22
def query(params, path = nil)
url = uri(params, path)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
body = http.request_get(url.path+'?'+url.query) { |response|
if response.is_a?(Net::HTTPSuccess) and !(response.read_body =~ /<Error[^>]*MajorCode="\d".*>/i)
return StringIO.new(response.read_body)
else
raise StandardError, response.read_body
end
}
end
|
.uri(params, path = nil) ⇒ Object
17
18
19
20
|
# File 'lib/flightstats.rb', line 17
def uri(params, path = nil)
params.merge!(authentication_token){ |key,old,new| old }
URI.parse(SERVER + (path || PATH) + '?' + params.collect{ |k,v| "#{k}=#{v}"}.join('&'))
end
|