Module: SharepointApi::Items
- Included in:
- SharepointApi
- Defined in:
- lib/sharepoint_api/items.rb
Defined Under Namespace
Classes: ItemUpdateError
Instance Method Summary collapse
- #fetch_content_types ⇒ Object
- #validate_update_list_item(path, field_name_field_value_pairs) ⇒ Object
Instance Method Details
#fetch_content_types ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sharepoint_api/items.rb', line 25 def fetch_content_types encoded_name = encode_path(library_name) response = site.query( :get, "Lists/GetByTitle('#{encoded_name}')/ContentTypes?" \ '$select=Name,StringId' ) response.map { |content_type| (content_type.data) } rescue Sharepoint::SharepointError => e log_as(__method__, e) nil end |
#validate_update_list_item(path, field_name_field_value_pairs) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sharepoint_api/items.rb', line 7 def validate_update_list_item(path, field_name_field_value_pairs) server_path = server_relative_path(path) uri = "GetFolderByServerRelativeUrl('#{server_path}')/ListItemAllFields/" \ 'ValidateUpdateListItem' form_values = field_name_field_value_pairs.map do |key, value| { 'FieldName' => key, 'FieldValue' => value } end body = { 'formValues' => form_values, 'bNewDocumentUpdate' => false } response = site.query(:post, uri, body.to_json, true) hoist_complex_errors!(response, uri, body) true rescue Sharepoint::SharepointError => e raise SharepointApi::SharepointError, e. end |