Class: OxfordDictionary::Request
- Inherits:
-
Object
- Object
- OxfordDictionary::Request
- Defined in:
- lib/oxford_dictionary/request.rb
Constant Summary collapse
- BASE_URL =
'https://od-api.oxforddictionaries.com/api/v2'.freeze
Instance Method Summary collapse
- #get(uri:) ⇒ Object
-
#initialize(app_id:, app_key:) ⇒ Request
constructor
A new instance of Request.
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 |