/// <summary> /// Retrieve an ODItem for an item with a particular item-id /// </summary> /// <param name="itemReference"></param> /// <param name="itemRetrievalOptions"></param> /// <returns></returns> public async Task<ODItem> GetItemAsync(ODItemReference itemReference, ItemRetrievalOptions itemRetrievalOptions) { if (!itemReference.IsValid()) throw new ArgumentException("ItemReference was invalid. Requires either an ID or Path"); var queryParams = ODataOptionsToQueryString(itemRetrievalOptions); var serviceUri = UriForItemReference(itemReference, null, queryParams); return await DataModelForRequest<ODItem>(serviceUri, ApiConstants.HttpGet); }
/// <summary> /// Search for items matching a given search query /// </summary> /// <param name="rootItemReference"></param> /// <param name="searchQuery"></param> /// <param name="itemRetrievalOptions"></param> /// <returns></returns> public async Task<ODItemCollection> SearchForItemsAsync(ODItemReference rootItemReference, string searchQuery, ItemRetrievalOptions itemRetrievalOptions) { if (!rootItemReference.IsValid()) throw new ArgumentException("rootItemReference was invalid. Requires either an ID or Path"); if (null == searchQuery) throw new ArgumentNullException("searchQuery"); if (null == itemRetrievalOptions) throw new ArgumentNullException("itemRetrievalOptions"); var queryParams = ODataOptionsToQueryString(itemRetrievalOptions); queryParams.Add(ApiConstants.SearchQueryParameterKey, searchQuery); Uri serviceUri = UriForItemReference(rootItemReference, ApiConstants.SearchServiceAction, queryParams); var request = await CreateHttpRequestAsync(serviceUri, ApiConstants.HttpGet); return await DataModelForRequest<ODItemCollection>(request); }
/// <summary> /// Retrieve an ODItem for the root of the current user's OneDrive /// </summary> /// <param name="options"></param> /// <returns></returns> public async Task<ODItem> GetRootItemAsync(ItemRetrievalOptions options) { return await GetItemAsync(new ODItemReference { Id = ApiConstants.RootFolderItemId }, options); }