Class: JishoAPI::Client

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

Constant Summary collapse

URI =
'https://jisho.org/api/v1/search/words'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



11
# File 'lib/jisho_api/client.rb', line 11

def initialize; end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/jisho_api/client.rb', line 7

def response
  @response
end

Instance Method Details

#make_request(params: {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jisho_api/client.rb', line 13

def make_request(params: {})
  params.merge!(keyword: query) unless params.key?(:keyword)
  params.merge!(page: page) unless params.key?(:page)

  invalidate_cached_response!

  self.response = connection.get do |req|
    req.params = params
  end

  handle_response
end