Ejemplo n.º 1
0
        public async Task <object> novaGetWarehouses(string refCity)
        {
            if (refCity == null)
            {
                refCity = "";
            }

            var request = new NovaCitiesRequest()
            {
                calledMethod     = "getWarehouses",
                modelName        = "AddressGeneral",
                apiKey           = apiKeyNovaPoshta,
                methodProperties = new NovaProps()
                {
                    CityRef = refCity
                }
            };

            var jsonRequest = await Task.Run(() => JsonConvert.SerializeObject(request));

            var httpContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
            var response    = await client.PostAsync(novaRef, httpContent);

            string value = await response.Content.ReadAsStringAsync();

            return(value);
        }
Ejemplo n.º 2
0
        public async Task <object> novaFindCitites(string cityKeyWord)
        {
            if (cityKeyWord == null)
            {
                cityKeyWord = "";
            }

            cityKeyWord = cityKeyWord.ToLower();

            var request = new NovaCitiesRequest()
            {
                calledMethod     = "getCities",
                modelName        = "Address",
                apiKey           = apiKeyNovaPoshta,
                methodProperties = new NovaProps()
                {
                    FindByString = cityKeyWord,
                    Limit        = 20
                }
            };
            var jsonRequest = await Task.Run(() => JsonConvert.SerializeObject(request));

            var httpContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
            var response    = await client.PostAsync(novaRef, httpContent);

            string value = await response.Content.ReadAsStringAsync();

            return(value);
        }