Method: FacebookAds::APIRequest#create_response

Defined in:
lib/facebook_ads/api_request.rb

#create_response(status, headers, body) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/facebook_ads/api_request.rb', line 49

def create_response(status, headers, body)
  api_response = APIResponse.new(status, headers, body)

  if status.to_i >= 500
    raise ServerError.new(api_response)
  elsif status.to_i >= 400
    raise ClientError.new(api_response)
  end

  (callback ? callback[api_response] : api_response).tap do |result|
    batch_proxy.set_result(result) if batch_proxy
  end
end