Class: DeviceAtlas::Carrier::CarrierApi
- Inherits:
-
Object
- Object
- DeviceAtlas::Carrier::CarrierApi
- Defined in:
- lib/deviceatlas/carrier/carrier_api.rb
Direct Known Subclasses
Constant Summary collapse
- API_VERSION =
'2.1.0'
- HEADERS_TO_CHECK =
A list of HTTP headers to choose the original client IP address from. In addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final fallback.
%w[ x-forwarded-for client-ip x-client-ip rlnclientipaddr proxy-client-ip wl-proxy-client-ip x-forwarded forwarded-for forwarded ].freeze
Instance Method Summary collapse
-
#get_api_version ⇒ String
Get the version of the Carrier API.
-
#get_data_file_copyright ⇒ String
Get the carrier data file copyright.
-
#get_data_file_creation_date ⇒ String
Get the carrier data file creation date.
-
#get_data_file_version ⇒ String
Get the carrier data file version.
-
#get_ip(key_vals) ⇒ Object
Get the most suitable IP address from the given key_vals set of HTTP headers.
-
#get_properties(data) ⇒ Object
Get the Carrier properties for a given IP address or a given Hash of HTTP headers.
-
#get_property(data, property_name) ⇒ Object
Try and get a specific property for a given IP address or a given Hash of HTTP headers.
-
#get_property_names ⇒ Object
A set of all the possible property names.
-
#initialize ⇒ Object
constructor
Creates a new DeviceAtlas::Carrier::CarrierApi instance.
-
#load_data_from_file(path) ⇒ Object
Load the Carrier data file from the provided `path`.
-
#public_ip?(ip_str) ⇒ Boolean
Check if an IP address is public.
Constructor Details
#initialize ⇒ Object
Creates a new DeviceAtlas::Carrier::CarrierApi instance.
Instance Method Details
#get_api_version ⇒ String
Get the version of the Carrier API.
#get_data_file_copyright ⇒ String
Get the carrier data file copyright.
#get_data_file_creation_date ⇒ String
Get the carrier data file creation date.
#get_data_file_version ⇒ String
Get the carrier data file version.
#get_ip(key_vals) ⇒ Object
Get the most suitable IP address from the given key_vals set of HTTP headers. This function checks the headers defined in HEADERS_TO_CHECK.
#get_properties(data) ⇒ Object
Get the Carrier properties for a given IP address or a given Hash of HTTP headers.
#get_property(data, property_name) ⇒ Object
Try and get a specific property for a given IP address or a given Hash of HTTP headers. In case a Hash of HTTP headers is passed, the API will choose the most appropriate IP to use.
NOTE: if multiple properties are needed for the same IP, it is more efficient to call get_properties() once than repeated calls to get_property().
#get_property_names ⇒ Object
A set of all the possible property names. The Set contains objects that each have a name and an associated data type.
return
-
Array of possible property names.
#load_data_from_file(path) ⇒ Object
Load the Carrier data file from the provided `path`. The data file is reloaded every time this method is called.
#public_ip?(ip_str) ⇒ Boolean
Check if an IP address is public.