lib/catalogcat/client.rb in bearcat-1.5.3 vs lib/catalogcat/client.rb in bearcat-1.5.4
- old
+ new
@@ -9,31 +9,18 @@
require mod
include "Catalogcat::Client::#{mname}".constantize
end
# Override Footrest connection to use Token authorization
- # rubocop:disable Naming/AccessorMethodName
def set_connection(config)
super
- connection.builder.insert(Footrest::RaiseFootrestErrors, ExtendedRaiseFootrestErrors)
- connection.builder.delete(Footrest::RaiseFootrestErrors)
connection.headers[:authorization].sub! 'Bearer', 'Token'
end
- # rubocop:enable Naming/AccessorMethodName
# Override Footrest request for ApiArray support
def request(method, &block)
response = connection.send(method, &block)
- raise Footrest::HttpError::ErrorBase, response if response.status >= 400
Catalogcat::ApiArray.process_response(response, self)
- end
- end
-
- class ExtendedRaiseFootrestErrors < Footrest::RaiseFootrestErrors
- def on_complete(response)
- super
- key = response[:status].to_i
- raise ERROR_MAP[key.floor(-2)], response if key >= 400
end
end
end