Sha256: c30c967b79709cd300bef06aa12d291a46c6b7a59124f268df1d457730af573f

Contents?: true

Size: 636 Bytes

Versions: 6

Compression:

Stored size: 636 Bytes

Contents

# frozen_string_literal: true

module Regio
  class Gazetteer < Core
    def results
      raise Unprocessable, response[:message] if response[:message]

      response.merge(
        collection: response[:data]&.map { |result| transform(result) } || []
      )
    end

    private

    def response
      @response ||= run('/gazetteer', options)
    end

    # NOTE: all options described in the documentation
    # https://api.regio.ee/documentation/#docs/gazetteer
    def default_options
      {
        apikey: Configuration.api_key,
        address_format: 'long_address',
        output_format: 'json'
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
regio-0.3.5 lib/regio/gazetteer.rb
regio-0.3.4 lib/regio/gazetteer.rb
regio-0.3.3 lib/regio/gazetteer.rb
regio-0.3.2 lib/regio/gazetteer.rb
regio-0.3.1 lib/regio/gazetteer.rb
regio-0.3.0 lib/regio/gazetteer.rb