class Sharepoint::List
Public Instance Methods
add_folder(path, attributes)
click to toggle source
# File lib/sharepoint-lists.rb, line 98 def add_folder path, attributes path = path.gsub(/\/*$/, '') # remove slashes at the end of the path site_url = "#{@site.protocol}://#{@site.server_url}/" action = "#{site_url}_vti_bin/listdata.svc/#{self.title}" path = root_folder.server_relative_url + '/' + path attributes['ContentTypeID'] ||= '0x01200059042D1A09191046851FA83D5B89816A' attributes['Path'] ||= path payload = VtiBin.translate_field_names(attributes).to_json # Create the item using _vti_bin api response = @site.query :post, action, payload, true do |curl| curl.headers['Slug'] = "#{path}/#{attributes['Title']}|0x0120" end response = JSON.parse response unless response['d'].nil? # Fetch the item we just created using the REST api item_id = response['d']['ID'] @site.query :get, "#{site_url}_api/#{__metadata['id']}/items(#{item_id})" else raise Sharepoint::DataError.new response, action, payload end end
add_item(attributes)
click to toggle source
# File lib/sharepoint-lists.rb, line 92 def add_item attributes attributes['__metadata'] ||= Hash.new attributes['__metadata']['type'] ||= list_item_entity_type_full_name @site.query :post, item_uri, attributes.to_json end
find_items(options = {})
click to toggle source
# File lib/sharepoint-lists.rb, line 84 def find_items options = {} @site.query :get, (make_item_filter options) end
item_count()
click to toggle source
# File lib/sharepoint-lists.rb, line 88 def item_count @site.query :get, "#{__metadata['id']}/ItemCount" end
Private Instance Methods
item_uri()
click to toggle source
# File lib/sharepoint-lists.rb, line 149 def item_uri url = @data['Items']['__deferred'] url = url['uri'] if url.class != String url end
make_item_filter(options = {})
click to toggle source
# File lib/sharepoint-lists.rb, line 155 def make_item_filter options = {} url = item_uri has_options = false options.each do |key,value| url += if has_options then '&' else '?' end url += "$#{key}=#{URI::encode value.to_s}" has_options = true end url end