Class: Qubell::APICall
- Inherits:
-
Object
- Object
- Qubell::APICall
- Defined in:
- lib/qubell/api_call.rb
Overview
Implements Qubell API HTTP call helpers
Class Method Summary collapse
Class Method Details
.handle_error(code) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/qubell/api_call.rb', line 35 def self.handle_error(code) case code when 400 then raise Qubell::ExecutionError when 401 then raise Qubell::AuthenticationError when 403 then raise Qubell::PermissionsDeniedError when 404 then raise Qubell::ResourceUnavaliable when 409 then raise Qubell::WorkflowError else raise Qubell::BaseError, code end end |
.handle_response(response) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/qubell/api_call.rb', line 22 def self.handle_response(response) if response.code == 200 case response.headers[:content_type] when 'application/json' then JSON.parse(response, symbolize_names: true) when 'application/x-yaml' then YAML.load response else response.empty? ? nil : response end else handle_error(response.code) end end |