Sha256: 080edb703857daad5e04a3eaafcca35d1d3f8ae9665544e74dc3b79bd9690893

Contents?: true

Size: 1008 Bytes

Versions: 10

Compression:

Stored size: 1008 Bytes

Contents

require 'geocoder/lookups/base'
require "geocoder/results/melissa_street"

module Geocoder::Lookup
  class MelissaStreet < Base

    def name
      "MelissaStreet"
    end

    def results(query)
      return [] unless doc = fetch_data(query)

      if doc["TransmissionResults"] == "GE05"
        raise_error(Geocoder::InvalidApiKey) ||
          Geocoder.log(:warn, "Melissa service error: invalid API key.")
      end

      return doc["Records"]
    end

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

    def base_query_url(query)
      "#{protocol}://address.melissadata.net/v3/WEB/GlobalAddress/doGlobalAddress?"
    end

    def query_url_params(query)
      params = {
        id: configuration.api_key,
        format: "JSON",
        a1: query.sanitized_text,
        loc: query.options[:city],
        admarea: query.options[:state],
        postal: query.options[:postal],
        ctry: query.options[:country]
      }
      params.merge(super)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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