Exemplo n.º 1
0
        public void GetCompanyFilingsInfo_InvalidRegulatorCode(string name)
        {
            RunInitSql(name, "ConnectionStringFilings");

            GetCompanyFilingsInfo request = PrepareRequest <GetCompanyFilingsInfo>(name);

            GetCompanyFilingsInfoResponse response = Post <GetCompanyFilingsInfo, GetCompanyFilingsInfoResponse>("GetCompanyFilingsInfo", request);

            RunFinalizeSql(name, "ConnectionStringFilings");

            Assert.AreEqual(response.Success, true, "GetCompanyFilingsInfo call failed");
            Assert.AreEqual(response.Payload.Filings.Count, 0, "Non-empty list of companies returned for invalid regulator code");
        }
Exemplo n.º 2
0
        public void GetCompanyFilingsInfo_Success(string name)
        {
            RunInitSql(name, "ConnectionStringFilings");

            GetCompanyFilingsInfo request = PrepareRequest <GetCompanyFilingsInfo>(name);

            GetCompanyFilingsInfoResponse response = Post <GetCompanyFilingsInfo, GetCompanyFilingsInfoResponse>("GetCompanyFilingsInfo", request);

            RunFinalizeSql(name, "ConnectionStringFilings");

            Assert.AreEqual(response.Success, true, "GetCompanyFilingsInfo call failed");
            Assert.Greater(response.Payload.Filings.Count, 0, "Empty filings list returned");
        }
Exemplo n.º 3
0
        public void GetCompanyFilingsInfo_10K_Success(string name)
        {
            RunInitSql(name, "ConnectionStringFilings");

            GetCompanyFilingsInfo request = PrepareRequest <GetCompanyFilingsInfo>(name);

            GetCompanyFilingsInfoResponse response = Post <GetCompanyFilingsInfo, GetCompanyFilingsInfoResponse>("GetCompanyFilingsInfo", request);

            RunFinalizeSql(name, "ConnectionStringFilings");

            Assert.AreEqual(response.Success, true, "GetCompanyFilingsInfo call failed");
            Assert.Greater(response.Payload.Filings.Count, 0, "Empty filings list returned");
            Assert.IsNotEmpty(response.Payload.Filings.Where(r => r.Type == "10-K"), "Reports of type 10-K were not returned");
        }
Exemplo n.º 4
0
        public void GetCompanyFilingsInfo_InvalidSession(string name)
        {
            RunInitSql(name, "ConnectionStringFilings");

            GetCompanyFilingsInfo request = PrepareRequest <GetCompanyFilingsInfo>(name);

            request.SessionToken = Guid.NewGuid().ToString();

            GetCompanyFilingsInfoResponse response = Post <GetCompanyFilingsInfo, GetCompanyFilingsInfoResponse>("GetCompanyFilingsInfo", request);

            RunFinalizeSql(name, "ConnectionStringFilings");

            Assert.AreEqual(response.Success, false, "GetCompanyFilingsInfo succeeded with invalid session");
            Assert.AreEqual(response.Payload.Filings.Count, 0, "Filings list is not empty");
            Assert.IsNotEmpty(response.Errors, "Errors are empty in the response");
            Assert.AreEqual(response.Errors[0].Code, EErrorCodes.InvalidSession, "Incorrect error code returned");
        }
        public GetCompanyFilingsInfoResponse PostGetCompanyFilingsInfo(GetCompanyFilingsInfo request)
        {
            var response = Post <GetCompanyFilingsInfo, GetCompanyFilingsInfoResponse>("GetCompanyFilingsInfo", request);

            return(response);
        }
        public object Any(GetCompanyFilingsInfo request)
        {
            DateTime dtStart = DateTime.UtcNow;

            _logger.Log(EErrorType.Info, " ****** Call start: GetCompanyFilingsInfo");
            GetCompanyFilingsInfoResponse response = new GetCompanyFilingsInfoResponse();

            TransferHeader(request, response);

            EErrorCodes valSession = ValidateSession(request.SessionToken);

            if (valSession == EErrorCodes.Success)
            {
                try
                {
                    Interfaces.DAL.GetCompanyFilingsInfoParams infoParams = new Interfaces.DAL.GetCompanyFilingsInfoParams();
                    infoParams.CompanyCode   = request.CompanyCode;
                    infoParams.PeriodEnd     = request.PeriodEnd != null ? (DateTime)request.PeriodEnd : infoParams.PeriodEnd;
                    infoParams.PeriodStart   = request.PeriodStart != null ? (DateTime)request.PeriodStart : infoParams.PeriodStart;
                    infoParams.RegulatorCode = request.RegulatorCode;
                    foreach (var t in request.Types)
                    {
                        infoParams.Types.Add(t);
                    }

                    Interfaces.DAL.GetCompanyFilingsInfoResult dalResult = _dal.GetCompanyFilingsInfo(infoParams);
                    foreach (var f in dalResult.Filings)
                    {
                        DTO.CompanyFilingInfo cfi = new DTO.CompanyFilingInfo();
                        cfi.Name        = f.Name;
                        cfi.PeriodEnd   = f.PeriodEnd;
                        cfi.PeriodStart = f.PeriodStart;
                        cfi.Submitted   = f.Submitted;
                        cfi.Type        = f.Type;

                        response.Payload.Filings.Add(cfi);
                    }
                    response.Payload.CompanyCode   = request.CompanyCode;
                    response.Payload.RegulatorCode = request.RegulatorCode;
                    response.Success = true;
                }
                catch (Exception ex)
                {
                    _logger.Log(ex);
                    response.Success = false;
                    response.Errors.Add(new Error()
                    {
                        Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unpexcted error: {0}", ex.Message)
                    });
                }
            }
            else
            {
                response.Success = false;
                response.Errors.Add(new Error()
                {
                    Code = EErrorCodes.InvalidSession, Type = EErrorType.Error, Message = string.Format("Invalid session")
                });
            }

            DateTime dtEnd = DateTime.UtcNow;

            _logger.Log(EErrorType.Info, string.Format(" ****** Call end: GetCompanyFilingsInfo\tTime:{0}", dtEnd - dtStart));

            return(response);
        }