Sha256: e633bb273610b9e7c99db086c17fe91a698c572fdd785dabf5d556778ebdf3c9

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

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

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

    private

    def response
      run('/revgeocode', options)
    end

    # NOTE: all options described in the documentation
    # https://api.regio.ee/documentation/#docs/reverse_geocode
    def default_options
      {
        apikey: Configuration.api_key,
        address_format: 'long_address',
        details: 'id,address,postcode,type,components,geometry,is_valid,is_complete',
        output_format: 'json',
        limit: 25
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
regio-0.2.0 lib/regio/reverse_geocode.rb