public void RemoveAccountAlerts_InvalidSessionToken(string name) { RunInitSql(name, "ConnectionStringAlerts"); // getting alerts to obtain IDs GetAccountAlerts getAlertsReq = new GetAccountAlerts() { AccountKey = ConfigurationManager.AppSettings["AccountKey"], SessionToken = ConfigurationManager.AppSettings["SessionToken"], RequestID = Guid.NewGuid().ToString() }; GetAccountAlertsResponse getAlertsResp = Post <GetAccountAlerts, GetAccountAlertsResponse>("GetAccountAlerts", getAlertsReq); // setting proper IDs RemoveAccountAlerts request = PrepareRequest <RemoveAccountAlerts>(name); request.SubscriptionIds.AddRange(getAlertsResp.Payload.Alerts.Select(x => x.ID)); RemoveAccountAlertsResponse response = Post <RemoveAccountAlerts, RemoveAccountAlertsResponse>("RemoveAccountAlerts", request); RunFinalizeSql(name, "ConnectionStringAlerts"); Assert.AreEqual(response.Success, false, "RemoveAccountAlerts succeeded unexpectedly"); Assert.IsNotNull(response.Errors.FirstOrDefault(e => e.Type == Interfaces.EErrorType.Error), "Errors are empty"); Assert.AreEqual(response.Errors[0].Code, Interfaces.EErrorCodes.InvalidSession, "Wrong error code returned"); }
public void RemoveAccountAlerts_Success(string name) { RunInitSql(name, "ConnectionStringAlerts"); // getting alerts to obtain IDs GetAccountAlerts getAlertsReq = new GetAccountAlerts() { AccountKey = ConfigurationManager.AppSettings["AccountKey"], SessionToken = ConfigurationManager.AppSettings["SessionToken"], RequestID = Guid.NewGuid().ToString() }; GetAccountAlertsResponse getAlertsResp = Post <GetAccountAlerts, GetAccountAlertsResponse>("GetAccountAlerts", getAlertsReq); // setting proper IDs RemoveAccountAlerts request = PrepareRequest <RemoveAccountAlerts>(name); request.SubscriptionIds.AddRange(getAlertsResp.Payload.Alerts.Select(x => x.ID)); RemoveAccountAlertsResponse response = Post <RemoveAccountAlerts, RemoveAccountAlertsResponse>("RemoveAccountAlerts", request); RunFinalizeSql(name, "ConnectionStringAlerts"); Assert.AreEqual(response.Success, true, "RemoveAccountAlerts failed unexpectedly"); }
public object Any(RemoveAccountAlerts request) { RemoveAccountAlertsResponse response = new RemoveAccountAlertsResponse(); TransferHeader(request, response); try { if (IsValidSessionToken(request)) { var remSubParams = _dal.CreateRemoveAccountSubscrParams(); foreach (var s in request.SubscriptionIds) { remSubParams.SubscriptionIds.Add(s); } var remSeqResult = _dal.RemoveAlertSubscription(remSubParams); if (remSeqResult.Success) { response.Success = true; } else { response.Success = false; response.Errors.AddRange(remSeqResult.Errors); } } else { response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.InvalidSession, Type = EErrorType.Error, Message = "Invalid session token" }); } } catch (Exception ex) { response.Success = false; response.Errors.Add(new Interfaces.Error() { Code = Interfaces.EErrorCodes.GeneralError, Type = Interfaces.EErrorType.Error, Message = ex.Message }); } return(response); }
public RemoveAccountAlertsResponse PostRemoveAccountAlerts(RemoveAccountAlerts request) { RemoveAccountAlertsResponse response = Post <RemoveAccountAlerts, RemoveAccountAlertsResponse>("RemoveAccountAlerts", request); return(response); }