Skip to content

Commit

Permalink
Merge b04cf88 into 9089e72
Browse files Browse the repository at this point in the history
  • Loading branch information
muxamilian committed Dec 18, 2016
2 parents 9089e72 + b04cf88 commit 38ee83d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/locomotive/coal/resources/concerns/request.rb
@@ -1,3 +1,5 @@
require 'json'

module Locomotive::Coal::Resources
module Concerns

Expand Down Expand Up @@ -31,7 +33,7 @@ def do_request(action, endpoint, parameters = {}, raw = false)
end

if response.success?
raw ? response : response.body
raw ? response : _parse_response_body(response.body)
else
raise Locomotive::Coal::Error.from_response(response)
end
Expand All @@ -46,6 +48,13 @@ def without_authentication(&block)

private

def _parse_response_body response_body
if response_body.is_a? String
response_body = JSON.parse(response_body)
end
response_body
end

def _do_request(action, endpoint, parameters)
# compatibility with v2.5.x
parameters = parameters.merge(auth_token: credentials[:token]) if _token
Expand Down

0 comments on commit 38ee83d

Please sign in to comment.