Class: Bingo::BingoClient

Inherits:
Object
  • Object
show all
Defined in:
lib/bingo.rb

Constant Summary collapse

API_ENDPOINT =
"https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_key, logger = ::Logger.new('/dev/null')) ⇒ BingoClient

Returns a new instance of BingoClient.



16
17
18
19
20
# File 'lib/bingo.rb', line 16

def initialize(, logger = ::Logger.new('/dev/null'))
  @user = ''
  @account_key = 
  @logger = logger
end

Instance Attribute Details

#account_keyObject (readonly)

Returns the value of attribute account_key.



14
15
16
# File 'lib/bingo.rb', line 14

def 
  @account_key
end

#loggerObject (readonly)

Returns the value of attribute logger.



14
15
16
# File 'lib/bingo.rb', line 14

def logger
  @logger
end

#userObject (readonly)

Returns the value of attribute user.



14
15
16
# File 'lib/bingo.rb', line 14

def user
  @user
end

Instance Method Details

#search(query, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/bingo.rb', line 22

def search(query, options = {})
  response = perform_search(query, options)
  json = JSON.parse(response.body)
  json["d"]["results"]
end