def documentation(collection, operation=nil)
data = {}
request(:get, "/docs/#{collection}") do |body|
document = Nokogiri::XML(body)
if operation
data[:operation] = operation
data[:description] = document.xpath('/docs/collection/operations/operation[@name = "'+operation+'"]/description').first.text.strip
return false unless data[:description]
data[:params] = []
(document/"/docs/collection/operations/operation[@name='#{operation}']/parameter").each do |param|
data[:params] << {
:name => param['name'],
:required => param['type'] == 'optional',
:type => (param/'class').text
}
end
else
data[:description] = (document/'/docs/collection/description').text
data[:collection] = collection
data[:operations] = (document/"/docs/collection/operations/operation").collect{ |o| o['name'] }
end
end
return Documentation.new(self, data)
end