Sha256: db7236c608ca0884962d44b8be23b66f7c375d1258e925d3db91550aaf6741e3

Contents?: true

Size: 533 Bytes

Versions: 2

Compression:

Stored size: 533 Bytes

Contents

module AutocompleteService
  include HttpRestClient

  VEHICLE_AUTOCOMPLETE_URL = "#{BASE_URL}/UsedCarWS/UsedCarWS/Autocomplete".freeze

  def lookup_autocomplete(query_params = {})
    begin
      response = HTTParty.get(VEHICLE_AUTOCOMPLETE_URL, headers: headers, query: query_params)
      process_response(JSON.parse(response), :transformer)
    rescue => e
      [{ error: e.to_s }, 500]
    end
  end

  def transformer(response)
    return [] unless response && response['autocomplete']
    response['autocomplete']
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blackbook_client-1.0.0 lib/autocomplete_service.rb
blackbook_client-0.2.1 lib/autocomplete_service.rb