Ejemplo n.º 1
0
        /// <summary>
        /// Verifies companies of the given nips
        /// </summary>
        /// <param name="nips">Comma separted Nips</param>
        /// <returns></returns>
        public async Task <EntryListResponse> VerifyCompanies(string nips, DateTime date)
        {
            string            currentDate = DateTime.Now.ToString(_dateFormat);
            EntryListResponse entities    = null;
            string            content;
            string            getCompaniesByNipUrl = string.Format("{0}/{1}?date={2}", _getCompaniesByNipMethodUrl, nips, currentDate);

            HttpResponseMessage responseMsg = _httpClient.GetAsync(getCompaniesByNipUrl).GetAwaiter().GetResult();

            if (responseMsg.IsSuccessStatusCode)
            {
                content = await responseMsg.Content.ReadAsStringAsync();

                entities = JsonConvert.DeserializeObject <EntryListResponse>(content);
            }
            else
            {
                content = await responseMsg.Content.ReadAsStringAsync();

                var exception = JsonConvert.DeserializeObject <WebServiceModel.Exception>(content);
                throw new WhiteListClientException(exception);
            }



            return(entities);
        }
Ejemplo n.º 2
0
        public void TestSingleTooLongNipCompany()
        {
            string nipToCheck = "123456789190";

            EntryListResponse eLR = _client.VerifyCompanies(nipToCheck, DateTime.Now).GetAwaiter().GetResult();
            Assert.IsTrue(DTHelper.IsItToday(eLR.Result.RequestDateTime));
            Assert.IsNotNull(eLR.Result.RequestId);
            Assert.IsNotEmpty(eLR.Result.RequestId);

            Assert.AreEqual(nipToCheck, eLR.Result.Entries[0].Identifier);
            Assert.AreEqual("WL-113", eLR.Result.Entries[0].Error.Code);
        }
Ejemplo n.º 3
0
        public void TestSingleWithIncorrectCharsNipCompany()
        {
            List<string> nipsToCheck = new List<string>() { "1w34567890", "1 23456789" };

            foreach (var nipToCheck in nipsToCheck)
            {
                EntryListResponse eLR = _client.VerifyCompanies(nipToCheck, DateTime.Now).GetAwaiter().GetResult();
                Assert.IsTrue(DTHelper.IsItToday(eLR.Result.RequestDateTime));
                Assert.IsNotNull(eLR.Result.RequestId);
                Assert.IsNotEmpty(eLR.Result.RequestId);

                Assert.AreEqual(nipToCheck, eLR.Result.Entries[0].Identifier);
                Assert.AreEqual("WL-114", eLR.Result.Entries[0].Error.Code);
            }
        }
        private Dictionary <string, WhiteListVerResult> VerifyChunkOfCompanies(List <InputCompany> chunkOfCompaies, string nipsInString, DateTime dateOfRequest, bool verifyBankAccount)
        {
            EntryListResponse content = null;
            Dictionary <string, WhiteListVerResult> result = new Dictionary <string, WhiteListVerResult>();
            WhiteListVerResult tempWhiteListVerResult      = null;

            content = _whiteListClient.VerifyCompanies(nipsInString, dateOfRequest).GetAwaiter().GetResult();

            foreach (var companyToVerify in chunkOfCompaies)
            {
                tempWhiteListVerResult = ExtractResultForCompanyFromResponse(verifyBankAccount, content, companyToVerify);
                result.Add(companyToVerify.ID, tempWhiteListVerResult);
            }

            return(result);
        }
Ejemplo n.º 5
0
 private void MapEntryListResponse(EntryListResponse entryListResponse)
 {
     if (entryListResponse.Result.Entries != null && entryListResponse.Result.Entries.Count != 0)
     {
         entryListResponse.Result.Entries
         .ForEach(entry =>
         {
             if (entry.Subjects != null && entry.Subjects.Count > 0)
             {
                 entry.Subjects
                 .ForEach(subject => subject.AccountNumbers
                          .ForEach(accountNumber => subject.BankAccountNumbers.Add(new AccountNumber {
                     Number = accountNumber
                 })));
             }
         });
     }
 }
        private WhiteListVerResult ExtractResultForCompanyFromResponse(bool verifyBankAccount, EntryListResponse content, InputCompany companyToVerify)
        {
            WhiteListVerResult tempWhiteListVerResult = new WhiteListVerResult()
            {
                Nip = companyToVerify.NIP,
                VerificationDate = DateTime.Now.ToString()
            };

            if (companyToVerify.BankAccountNumber is null || companyToVerify.FormatErrors.Contains(InputCompanyFormatError.BankAccountFormatError))
            {
                tempWhiteListVerResult.GivenAccountNumber = string.Empty;
            }