class DictionaryAPI::DictionaryAPI::Client

Constants

BASE_URL

Public Instance Methods

execute(path, options = {}) click to toggle source
# File lib/dictionary_api/client.rb, line 9
def execute(path, options = {})
  response = HTTPClient.post(BASE_URL + path, options)  
  self.check_errors(response)
end

Protected Instance Methods

check_errors(response) click to toggle source
# File lib/dictionary_api/client.rb, line 16
def check_errors(response)
  case response.code
  when 200 then response
  when 401 then raise 'Invalid API key'
  when 402 then raise 'API key blocked'
  when 403 then raise 'Daily limit of requests is exceeded'
  when 413 then raise 'Text too long'
  when 501 then raise 'Translate direction is not supported'
  end
end