Class: DnB::Direct::Plus::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/dnb/direct/plus/match.rb

Class Method Summary collapse

Class Method Details

.cleanse_match(params = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dnb/direct/plus/match.rb', line 4

def self.cleanse_match(params = {})
    started_at = Time.now
  
    response = DnB::Direct::Plus.connection.get do |req|
        url = "/v1/search/typeahead?searchTerm=#{params[:term]}"
        url << "&countryISOAlpha2Code=#{params[:country]}" if params[:country]
        req.url url
        req.headers[:authorization] = "Bearer #{DnB::Direct::Plus.api_token}"
    end
    puts "== [TYPEAHEAD] Completed in #{((Time.now - started_at)*1000).round}ms".cyan.bold

    JSON.parse(response.body)
end