class MedlineplusRuby::API::Request
MedlinePlus Connect is rate limited to 100 req/minute. Once this limit is
reached, service will not be restored for 300 seconds, or whenever the request rate falls below 100/min, whichever is longer.
Constants
- API_URI
Base location from which to make
API
requests.
Attributes
response_payload[R]
Object to handle resulting response body.
Public Class Methods
build()
click to toggle source
# File lib/medlineplus_ruby/api/request.rb, line 19 def self.build new ResponsePayload.new end
new(response_payload_handler)
click to toggle source
# File lib/medlineplus_ruby/api/request.rb, line 23 def initialize(response_payload_handler) @response_payload = response_payload_handler end
Public Instance Methods
get_request(req_params = {})
click to toggle source
# File lib/medlineplus_ruby/api/request.rb, line 27 def get_request(req_params = {}) response = RestClient.get API_URI, { params: req_params } # TODO: Check for failures and/or rate limitations, and return an # appropriate response. Provide an error message, or extract something # meaningful from the response if provided. Note: it appears as though # the National Library of Medicine has no such rate limitation at this # time. raise MedlineplusRuby::Error, MedlineplusRuby::API::ResponseMessage::ERROR_NO_RESPONSE if response.nil? || response.empty? @response_payload.respond response.body end