added a method to check validity of Httparty response before JSON decoding