Sha256: 18dfda414d8ddd67f8d11537aa275967fabb154c25e651a80a7cc3d591011d06

Contents?: true

Size: 876 Bytes

Versions: 11

Compression:

Stored size: 876 Bytes

Contents

# encoding: utf-8

require 'geocoder/lookups/base'
require 'geocoder/results/abstract_api'

module Geocoder::Lookup
  class AbstractApi < Base

    def name
      "Abstract API"
    end

    def required_api_key_parts
      ['api_key']
    end

    def supported_protocols
      [:https]
    end

    private # ---------------------------------------------------------------

    def base_query_url(query)
      "#{protocol}://ipgeolocation.abstractapi.com/v1/?"
    end

    def query_url_params(query)
      params = {api_key: configuration.api_key}

      ip_address = query.sanitized_text
      if ip_address.is_a?(String) && ip_address.length > 0
        params[:ip_address] = ip_address
      end

      params.merge(super)
    end

    def results(query, reverse = false)
      if doc = fetch_data(query)
        [doc]
      else
        []
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
geocoder-1.8.3 lib/geocoder/lookups/abstract_api.rb
geocoder-1.8.2 lib/geocoder/lookups/abstract_api.rb
geocoder-1.8.1 lib/geocoder/lookups/abstract_api.rb
geocoder-1.8.0 lib/geocoder/lookups/abstract_api.rb
geocoder-1.7.5 lib/geocoder/lookups/abstract_api.rb
geocoder-1.7.4 lib/geocoder/lookups/abstract_api.rb
geocoder-1.7.3 lib/geocoder/lookups/abstract_api.rb
geocoder-1.7.2 lib/geocoder/lookups/abstract_api.rb
geocoder-1.7.1 lib/geocoder/lookups/abstract_api.rb
geocoder-1.7.0 lib/geocoder/lookups/abstract_api.rb
geocoder-1.6.7 lib/geocoder/lookups/abstract_api.rb