Module: Cb::ResponseValidator

Defined in:
lib/cb/utils/validator.rb

Class Method Summary collapse

Class Method Details

.validate(response) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/cb/utils/validator.rb', line 8

def validate(response)
  body = response.response.body rescue nil
  return Hash.new if !body

  if response.code != 200
    return Hash.new if body.include?('<!DOCTYPE html')
  end
  
  try_parse_json(body) || try_parse_xml(body) || {}
end