public async Task <SendDataResetPasswordResponse> SendDataResetPasswordAsync(SendDataResetPasswordRequest sendDataResetPasswordRequest) { //--- verifica se o request é válido ValidateRequestObject(sendDataResetPasswordRequest); //--- recupera o id do cliente pelo email GetUserIdAndSessionIdByEmailResponse getUserIdAndSessionIdByEmailResponse = _userSqlRepository.GetUserIdAndSessionIdByEmail(new GetUserIdAndSessionIdByEmailRequest(sendDataResetPasswordRequest.Email)); //--- cria o objeto de request para a api da clearsale SendDataResetPasswordClearSaleRequest sendDataResetPasswordClearSaleRequest = new SendDataResetPasswordClearSaleRequest { Code = getUserIdAndSessionIdByEmailResponse.UserId == 0 ? "" : getUserIdAndSessionIdByEmailResponse.UserId.ToString(), SessionId = getUserIdAndSessionIdByEmailResponse.SessionId }; //--- valida se o id do cliente e a sessionid foram passadas ValidateString(sendDataResetPasswordClearSaleRequest.Code, "Code"); ValidateString(sendDataResetPasswordClearSaleRequest.SessionId, "SessionId"); //--- verifica se esta setado para enviar os dados para o clearsale CanSendDataResetPasswordClearSale(); //--- envia para o clearsale e retorna com o resultado SendDataResetPasswordResponse sendDataResetPasswordResponse = await _clearSaleProxy.SendDataResetPasswordAsync(sendDataResetPasswordClearSaleRequest); return(sendDataResetPasswordResponse); }
public async Task <SendDataResetPasswordResponse> SendDataResetPasswordAsync(SendDataResetPasswordClearSaleRequest sendDataResetPasswordClearSaleRequest) { //--- obter o token await GetToken(); //--- converter o objeto para json string sendDataResetPasswordClearSaleRequestJson = JsonConvert.SerializeObject(sendDataResetPasswordClearSaleRequest); //--- post BaseResponse sendDataResetPasswordResponseJson = await HttpPostAsync($"{_urlApiAccountClearSale}/ResetPassword", sendDataResetPasswordClearSaleRequestJson, AuthenticationResponse, "SendDataResetPasswordAsync"); //--- deserializa o json para o o objeto de retorno SendDataResetPasswordResponse sendDataResetPasswordResponse = JsonConvert.DeserializeObject <SendDataResetPasswordResponse> (sendDataResetPasswordResponseJson.Contents); //--- retorna return(sendDataResetPasswordResponse); }