class FlightStats::API

Constants

ERRORS

Error mapping by status code.

Public Class Methods

accept_language() click to toggle source

@return [String, nil] Accept-Language header value

# File lib/flightstats/api.rb, line 16
def accept_language
  headers['Accept-Language']
end
accept_language=(language) click to toggle source

@param [String] language Accept-Language header value

# File lib/flightstats/api.rb, line 21
def accept_language=(language)
  headers['Accept-Language'] = language
end
base_uri() click to toggle source

@return [URI::Generic]

# File lib/flightstats/api.rb, line 56
def base_uri
  URI.parse @@base_uri
end
delete(uri, options = {}) click to toggle source

@return [Net::HTTPNoContent, Net::HTTPResponse] @raise [ResponseError] With a non-2xx status code.

# File lib/flightstats/api.rb, line 51
def delete uri, options = {}
  request :delete, uri, options
end
get(uri, params = {}) click to toggle source

@return [Net::HTTPOK, Net::HTTPResponse] @raise [ResponseError] With a non-2xx status code.

# File lib/flightstats/api.rb, line 33
def get uri, params = {}, options = {}
  request :get, uri, { :params => params }.merge(options)
end
head(uri, params = {}) click to toggle source

@return [Net::HTTPOK, Net::HTTPResponse] @raise [ResponseError] With a non-2xx status code.

# File lib/flightstats/api.rb, line 27
def head uri, params = {}, options = {}
  request :head, uri, { :params => params }.merge(options)
end
headers() click to toggle source

Additional HTTP headers sent with each API call @return [Hash{String => String}]

# File lib/flightstats/api.rb, line 11
def headers
  @headers ||= { 'Accept' => accept, 'User-Agent' => user_agent }
end
post(uri, body = nil, options = {}) click to toggle source

@return [Net::HTTPCreated, Net::HTTPResponse] @raise [ResponseError] With a non-2xx status code.

# File lib/flightstats/api.rb, line 39
def post uri, body = nil, options = {}
  request :post, uri, { :body => body.to_s }.merge(options)
end
put(uri, body = nil, options = {}) click to toggle source

@return [Net::HTTPOK, Net::HTTPResponse] @raise [ResponseError] With a non-2xx status code.

# File lib/flightstats/api.rb, line 45
def put uri, body = nil, options = {}
  request :put, uri, { :body => body.to_s }.merge(options)
end
user_agent() click to toggle source

@return [String]

# File lib/flightstats/api.rb, line 61
def user_agent
  "FlightStats/#{FlightStats::Version}; #{RUBY_DESCRIPTION}"
end

Private Class Methods

accept() click to toggle source
# File lib/flightstats/api.rb, line 67
def accept
  'application/json'
end
Also aliased as: content_type
content_type()
Alias for: accept