Sha256: ea72a13796ba004e7f0f75ecb6c08a20311d74df73a0bcaef24282b6ba6bc3c1

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

module Ratis

  class LocationTypeAhead

    def self.where(conditions={})
      search_text = conditions.delete(:search)
      app_id      = conditions.delete(:app_id) || 'WEB'

      raise ArgumentError.new('You must provide some search text') unless search_text

      Ratis.all_conditions_used? conditions

      response = Request.get 'Locationtypeahead', {'Appid' => app_id,
                                                   'Search' => search_text.downcase}

      return "" unless response.success?

      response_code = response.to_hash[:locationtypeahead_response][:responsecode]
      locations     = response.to_array :locationtypeahead_response, :items, :item

      locations.map do |location_hash|
        Ratis::LocationTypeAheadItem.new(location_hash.merge(responsecode: response_code))
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ratis-3.4.3 lib/ratis/location_type_ahead.rb
ratis-3.4.2 lib/ratis/location_type_ahead.rb
ratis-3.4.1 lib/ratis/location_type_ahead.rb