From c3fae72494e13c1a47618c9c0384af18a4549b9e Mon Sep 17 00:00:00 2001 From: Anton Maminov Date: Fri, 5 Apr 2024 12:22:26 +0300 Subject: [PATCH] add comments --- src/ipapi.cr | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ipapi.cr b/src/ipapi.cr index 9e7f8f2..01ac6e8 100644 --- a/src/ipapi.cr +++ b/src/ipapi.cr @@ -7,27 +7,27 @@ require "json" module Ipapi VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} - FIELDS = [ - "ip", - "city", - "region", - "region_code", - "country", - "country_name", - "continent_code", - "in_eu", - "postal", - "latitude", - "longitude", - "latlong", - "timezone", - "utc_offset", - "languages", - "country_calling_code", - "currency", - "asn", - "org", - ] + FIELDS = { + "ip" => "public (external) IP address (same as URL `ip`)", + "city" => "city name", + "region" => "region name (administrative division)", + "region_code" => "region code", + "country" => "country code (2 letter, ISO 3166-1 alpha-2)", + "country_name" => "short country name", + "continent_code" => "country code (2 letter, ISO 3166-1 alpha-2)", + "in_eu" => "whether IP address belongs to a country that is a member of the European Union (EU)", + "postal" => "postal code / zip code", + "latitude" => "latitude", + "longitude" => "longitude", + "latlong" => "comma separated latitude and longitude", + "timezone" => "timezone (IANA format i.e. “Area/Location”)", + "utc_offset" => "UTC offset (with daylight saving time) as `+HHMM` or `-HHMM` (`HH` is hours, `MM` is minutes)", + "languages" => "languages spoken (comma separated 2 or 3 letter ISO 639 code with optional hyphen separated country suffix)", + "country_calling_code" => "country calling code (dial in code, comma separated)", + "currency" => "currency code (ISO 4217)", + "asn" => "autonomous system number", + "org" => "organization name", + } class Client API_URL = "https://ipapi.co/" @@ -55,7 +55,7 @@ module Ipapi parse_locate_response(response) end - {% for field in FIELDS %} + {% for field, description in FIELDS %} def {{field.id}}(ip_address : String) : String url = "#{API_URL}#{ip_address}/{{field.id}}" url = url + "?key=#{@api_key}" if @api_key