diff --git a/lib/mailup.rb b/lib/mailup.rb index bcc57ec..966d510 100644 --- a/lib/mailup.rb +++ b/lib/mailup.rb @@ -168,6 +168,13 @@ def handle_response(response) # :nodoc: raise BadRequest.new response.parsed when 401 raise Unauthorized.new + when 403 + case response.body + when /Too many requests/i + raise TooManyRequests.new + else + raise ClientError.new response.parsed + end when 404 raise NotFound.new when 400...500 @@ -226,4 +233,4 @@ def stats end end -end \ No newline at end of file +end diff --git a/mailup.gemspec b/mailup.gemspec index 3166ad6..6fdf026 100644 --- a/mailup.gemspec +++ b/mailup.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |gem| gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_runtime_dependency 'oauth2', '~> 0.9', '>= 0.9.2' + gem.add_runtime_dependency 'oauth2', '~> 1.0' gem.add_development_dependency "rspec" gem.add_development_dependency "rake"