public async Task <string> GetItemAsync(string listName, int id, ApiRequestParameters parameters)
        {
            var path = BuildPathWithParams($"_api/web/lists/GetByTitle('{listName}')/items({id})", parameters);
            var json = await GetAsync(path);

            return(json);
        }
        private string BuildPathWithParams(string path, ApiRequestParameters parameters)
        {
            List <string> queryParameters = new List <string>();

            if (!string.IsNullOrEmpty(parameters.Select))
            {
                queryParameters.Add($"$select={parameters.Select}");
            }

            if (!string.IsNullOrEmpty(parameters.Expand))
            {
                queryParameters.Add($"$expand={parameters.Expand}");
            }

            if (parameters.Top != 100)
            {
                queryParameters.Add($"$top={parameters.Top}");
            }

            if (!queryParameters.Any())
            {
                return(path);
            }

            var result = $"{path}?{string.Join("&", queryParameters)}";

            return(result);
        }
        public async Task <string> GetItemsAsync(string listName, string digest, string camlQuery, ApiRequestParameters parameters)
        {
            var path = BuildPathWithParams($"_api/web/lists/GetByTitle('{listName}')/GetItems", parameters);
            var data = new { query = new { __metadata = new { type = "SP.CamlQuery" }, ViewXml = camlQuery } };

            var options = new JsonSerializerOptions
            {
                Encoder       = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
                WriteIndented = true
            };
            var dataJson = JsonSerializer.Serialize(data, options);
            var headers  = new Dictionary <string, string>()
            {
                ["X-RequestDigest"] = digest
            };
            string result = await PostAsync(path, dataJson, headers);

            return(result);
        }