Class: OxfordDictionary::Request

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

Constant Summary collapse

BASE_URL =
'https://od-api.oxforddictionaries.com/api/v2'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app_id:, app_key:) ⇒ Request

Returns a new instance of Request.



7
8
9
10
# File 'lib/oxford_dictionary/request.rb', line 7

def initialize(app_id:, app_key:)
  @app_id = app_id
  @app_key = app_key
end

Instance Method Details

#get(uri:) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/oxford_dictionary/request.rb', line 12

def get(uri:)
  uri = URI("#{BASE_URL}/#{uri}")

  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |https|
    https.request(request_object(uri))
  end
end