public async Task <CookAppUserDto> VerifyCookAppUserByVerifyCode(string phone, string code) { CookAppUserDto result = null; var client = _clientFactory.CreateClient("zk-backend"); var jsonStr = JsonConvert.SerializeObject(new { userName = phone, code }); var content = new StringContent(jsonStr); content.Headers.ContentType = new MediaTypeHeaderValue("application/json");//x-www-form-urlencoded content.Headers.Add("gooiosapikey", _config.UserServiceHeaderValue); var response = await client.PostAsync($"{_config.UserServiceRootUrl}api/cookappuser/verifybycode/v1", content); var contentJson = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { result = JsonConvert.DeserializeObject <CookAppUserDto>(contentJson); } else { result = null; } return(result); }
public async Task <CookAppUserDto> GetUser(string idOrUserName) { CookAppUserDto result = null; var client = _clientFactory.CreateClient("zk-backend"); //content.Headers.ContentType = new MediaTypeHeaderValue("application/json");//x-www-form-urlencoded //content.Headers.Add("gooiosapikey", _config.UserServiceHeaderValue); client.DefaultRequestHeaders.Add("gooiosapikey", _config.UserServiceHeaderValue); var response = await client.GetAsync($"{_config.UserServiceRootUrl}api/cookappuser/v1?idOrUserName=" + idOrUserName); var contentJson = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { result = JsonConvert.DeserializeObject <CookAppUserDto>(contentJson); } else { result = null; } return(result); }