/// <summary> /// Fetch a list of files and folders at the specified 'path'. /// </summary> /// <param name="path"></param> /// <param name="offset"></param> /// <param name="limit"></param> /// <param name="sortBy"></param> /// <param name="sortDirection"></param> /// <param name="fileType"></param> /// <param name="onlyWritable"></param> /// <param name="additional"></param> /// <returns></returns> public async Task <DataModel <FilesModel> > ListAsync(string path, int offset = 0, int limit = 0, SortBy sortBy = SortBy.Name, SortDirection sortDirection = SortDirection.Ascending, string fileType = "all", bool onlyWritable = false, string[] additional = null) { if (String.IsNullOrWhiteSpace(path)) { throw new ArgumentException($"Argument cannot be null, empty or whitespace.", nameof(path)); } _logger.LogDebug($"Making HTTP request to fetch a list"); if (String.IsNullOrWhiteSpace(_sid)) { await AuthenticateAsync(); } var values = new Dictionary <string, string>() { { "api", "SYNO.FileStation.List" }, { "version", "2" }, { "method", "list" }, { "_sid", _sid }, { "offset", $"{offset}" }, { "limit", $"{limit}" }, { "sort_by", sortBy.GetValue() }, { "sort_direction", sortDirection.GetValue() }, { "onlywritable", $"{onlyWritable}" }, { "additional", $"[\"{String.Join("\",\"", additional ?? new string [0])}\"]" }, { "action", "list" }, { "check_dir", "true" }, { "filetype", fileType }, { "folder_path", path }, }; var form = new FormUrlEncodedContent(values); var response = await _client.PostAsync(Path("entry"), form); return(await HandleResponseAsync <FilesModel>(response)); }
public void AddToRequest(RestRequest restRequest) { restRequest.AddQueryParameterIfNotEmpty("domain_ids", DomainIds); restRequest.AddQueryParameterIfNotEmpty("lang", Lang); restRequest.AddQueryParameterIfNotEmpty("event_id", EventIds); restRequest.AddQueryParameterIfNotEmpty("attraction_ids", AttractionIds); restRequest.AddQueryParameterIfNotEmpty("category_ids", CategoryIds); restRequest.AddQueryParameterIfNotEmpty("subcategory_ids", SubCategoryIds); restRequest.AddQueryParameterIfNotEmpty("event_name", EventName); restRequest.AddQueryParameterIfNotEmpty("country_ids", CountryIds); restRequest.AddQueryParameterIfNotEmpty("postal_code", PostalCode); restRequest.AddQueryParameterIfNotEmpty("lat", Latitude); restRequest.AddQueryParameterIfNotEmpty("long", Longitude); restRequest.AddQueryParameterIfNotEmpty("radius", RadiusInKm); restRequest.AddQueryParameterIfNotEmpty("eventdate_from", EventDateFrom); restRequest.AddQueryParameterIfNotEmpty("eventdate_to", EventDateTo); restRequest.AddQueryParameterIfNotEmpty("onsaledate_from", OnSaleDateFrom); restRequest.AddQueryParameterIfNotEmpty("onsaledate_to", OnSaleDateTo); restRequest.AddQueryParameterIfNotEmpty("offsaledate_from", OffSaleDateFrom); restRequest.AddQueryParameterIfNotEmpty("offsaledate_to", OffSaleDateTo); restRequest.AddQueryParameterIfNotEmpty("min_price", MinPrice); restRequest.AddQueryParameterIfNotEmpty("max_price", MaxPrice); restRequest.AddQueryParameterIfNotEmpty("price_excl_fees", PriceExcludingFees); restRequest.AddQueryParameterIfNotEmpty("is_seats_available", IsSeatsAvailable); restRequest.AddQueryParameterIfNotEmpty("is_not_cancelled", IsNotCancelled); restRequest.AddQueryParameterIfNotEmpty("is_not_package", IsNotPackage); restRequest.AddQueryParameterIfNotEmpty("include_external_events", IncludeExternalEvents); restRequest.AddQueryParameterIfNotEmpty("sort_by", SortBy.GetValue()); restRequest.AddQueryParameterIfNotEmpty("order", Order.GetValue()); restRequest.AddQueryParameterIfNotEmpty("start", _start); restRequest.AddQueryParameterIfNotEmpty("rows", _rows); }