示例#1
0
        /// <summary>
        /// Retorna informações de todos estados do Brasil
        /// </summary>
        /// <returns></returns>
        public async Task <IBGEResponse> IBGE_UF()
        {
            string baseUrl = $"{BASE_URL}/ibge/uf/v1";

            var response = await Client.GetAsync(baseUrl);

            await EnsureSuccess(response, baseUrl);

            var json = await response.Content.ReadAsStringAsync();

            var ibgeResponse = new IBGEResponse()
            {
                IBGEs        = JsonConvert.DeserializeObject <IEnumerable <IBGE> >(json),
                CalledURL    = baseUrl,
                JsonResponse = json
            };

            return(ibgeResponse);
        }
示例#2
0
        /// <summary>
        /// Busca as informações de um um estado a partir da sigla(UF) ou código
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public async Task <IBGEResponse> IBGE_UF(string code)
        {
            string baseUrl = $"{BASE_URL}/ibge/uf/v1/{code}";

            var response = await Client.GetAsync(baseUrl);

            await EnsureSuccess(response, baseUrl);

            var json = await response.Content.ReadAsStringAsync();

            var ibgeResponse = new IBGEResponse()
            {
                IBGEs        = new List <IBGE>(),
                CalledURL    = baseUrl,
                JsonResponse = json
            };

            (ibgeResponse.IBGEs as List <IBGE>).Add(JsonConvert.DeserializeObject <IBGE>(json));

            return(ibgeResponse);
        }