README.md in IPinfo-1.1.0 vs README.md in IPinfo-2.2.1

- old
+ new

@@ -38,10 +38,11 @@ access_token = '123456789abc' handler = IPinfo::create(access_token) ip_address = '216.239.36.21' details = handler.details(ip_address) +details_v6 = handler.details_v6() # to get details from ipinfo's IPv6 host city = details.city # Emeryville loc = details.loc # 37.8342,-122.2900 ``` ##### Note about Rails 6+ @@ -56,21 +57,22 @@ require 'ipinfo' unless defined?(IPinfo) ``` #### Usage -The `IPinfo.details()` method accepts an IP address as an optional, positional +The `IPinfo.details()` and `IPinfo.details_v6()` methods accept an IP address as an optional, positional argument. If no IP address is specified, the API will return data for the IP address from which it receives the request. ```ruby require 'ipinfo' access_token = '123456789abc' handler = IPinfo::create(access_token) details = handler.details() +details_v6 = handler.details_v6() # to get details from ipinfo's IPv6 host city = details.city # "Emeryville" loc = details.loc # 37.8342,-122.2900 ``` #### Authentication @@ -84,44 +86,44 @@ handler = IPinfo::create(access_token) ``` #### Details Data -`handler.details()` will return a `Response` object that contains all fields +`handler.details()` and `handler.details_v6` will return a `Response` object that contains all fields listed in the [IPinfo developerdocs](https://ipinfo.io/developers/responses#full-response) with a few minor additions. Properties can be accessed directly. ```ruby hostname = details.hostname # cpe-104-175-221-247.socal.res.rr.com ``` ##### Country Name -`details.country_name` will return the country name, as supplied by the -`countries.json` file. See below for instructions on changing that file for use +`details.country_name` will return the country name, as defined by `DEFAULT_COUNTRY_LIST` +within `countriesData.rb`. See below for instructions on changing that file for use with non-English languages. `details.country` will still return the country code. ```ruby country = details.country # US country_name = details.country_name # United States ``` ##### European Union (EU) Country -`details.is_eu` will return `true` if the country is a member of the European Union (EU), as supplied by the `eu.json` file. +`details.is_eu` will return `true` if the country is a member of the European Union (EU) +, as defined by `DEFAULT_EU_COUNTRIES_LIST` within `countriesData.rb`. ```ruby is_eu = details.is_eu # false ``` It is possible to change the file by setting the `eu_countries` setting when creating the `IPinfo` object. -The file must be a `.json` file with the [following structure](lib/ipinfo/eu.json). - ##### Country Flag -`details.country_flag` will return `emoji` and `unicode` of a country's flag, as supplied by the `eu.json` file. +`details.country_flag` will return `emoji` and `unicode` of a country's flag, as defined by +`DEFAULT_COUNTRIES_FLAG_LIST` within `countriesData.rb`. ```ruby country_flag = details.country_flag # {"emoji"=>"🇺🇸", "unicode"=>"U+1F1FA U+1F1F8"} country_flag_emoji = details.country_flag['emoji'] # 🇺🇸 country_flag_unicode = details.country_flag['unicode'] # U+1F1FA U+1F1F8 @@ -135,36 +137,34 @@ country_flag = details.country_flag_url # {"https://cdn.ipinfo.io/static/images/countries-flags/US.svg"} ``` ##### Country Currency -`details.country_currency` will return `code` and `symbol` of a country's currency, as supplied by the `currency.json` file. +`details.country_currency` will return `code` and `symbol` of a country's currency, as defined by +`DEFAULT_COUNTRIES_CURRENCIES_LIST` within `countriesData.rb`. ```ruby country_currency = details.country_currency # {"code"=>"USD", "symbol"=>"$"} country_currency_code = details.country_currency['code'] # USD country_currency_symbol = details.country_currency['symbol'] # $ ``` It is possible to change the file by setting the `countries_currencies` setting when creating the `IPinfo` object. -The file must be a `.json` file with the [following structure](lib/ipinfo/currency.json). - ##### Continent -`details.continent` will return `code` and `name` of the continent, as supplied by the `continent.json` file. +`details.continent` will return `code` and `name` of the continent, as defined by +`DEFAULT_CONTINENT_LIST` within `countriesData.rb`. ```ruby continent = details.continent # {"code"=>"NA", "name"=>"North America"} continent_code = details.continent['code'] # NA continent_name = details.continent['name'] # North America ``` It is possible to change the file by setting the `continents` setting when creating the `IPinfo` object. -The file must be a `.json` file with the [following structure](lib/ipinfo/continent.json). - #### IP Address `details.ip_address` will return the `IPAddr` object from the [Ruby Standard Library](https://ruby-doc.org/stdlib-2.5.1/libdoc/ipaddr/rdoc/IPAddr.html). `details.ip` will still return a string. @@ -271,17 +271,15 @@ When looking up an IP address, the response object includes a `details.country_name` attribute which includes the country name based on American English. It is possible to return the country name in other languages by setting the `countries` setting when creating the `IPinfo` object. -The file must be a `.json` file with the following structure: - ``` { - "BD": "Bangladesh", - "BE": "Belgium", - "BF": "Burkina Faso", - "BG": "Bulgaria" + "BD" => "Bangladesh", + "BE" => "Belgium", + "BF" => "Burkina Faso", + "BG" => "Bulgaria" ... } ``` ### Other Libraries