예제 #1
0
        public async Task <FdaLabelSearchResults> SearchAsync(FdaLabelSearchOptions fdaLabelSearchOptions, PagingSortingOptions pagingOptions = null, string joiner = "AND")
        {
            if (pagingOptions == null)
            {
                pagingOptions = new PagingSortingOptions();
            }

            var parameterDictionary = new ParameterDictionary
            {
                { "search", fdaLabelSearchOptions.ToQuery(joiner) }
            };

            if (pagingOptions.Limit != 0)
            {
                parameterDictionary.Add("limit", pagingOptions.Limit.ToString());
            }
            if (pagingOptions.Skip != 0)
            {
                parameterDictionary.Add("skip", pagingOptions.Skip.ToString());
            }

            if (!string.IsNullOrEmpty(_apiKey))
            {
                parameterDictionary.Add("api_key", _apiKey);
            }

            var json = await GetAsync($"/drug/label.json?{parameterDictionary.ToQueryString()}");


            return(FdaLabelSearchResults.FromJson(json));
        }