class FHIR::ClientReply

Public Instance Methods

response_format() click to toggle source
# File lib/ext/client_reply.rb, line 4
def response_format
  doc = Nokogiri::XML(self.body)
  if doc.errors.empty?
    FHIR::Formats::ResourceFormat::RESOURCE_XML
  else
    begin
      JSON.parse(self.body)
      FHIR::Formats::ResourceFormat::RESOURCE_JSON
    rescue JSON::ParserError => e
      raise "Failed to detect response format: #{self.body}"
    end
  end
end