public void Arrange() { _configuration = new PaymentsEventsApiConfiguration { ApiBaseUrl = "some-url/", ClientToken = "super_secure_token" }; _transfer = new AccountTransfer { TransferId = 1, SenderAccountId = 666, ReceiverAccountId = 777, Type = TransferType.Levy, RequiredPaymentId = Guid.NewGuid(), Amount = 888 }; _httpClient = new Mock <SecureHttpClient>(MockBehavior.Strict); _httpClient.Setup(c => c.GetAsync(It.IsAny <string>())) .Returns(Task.FromResult(JsonConvert.SerializeObject(new PageOfResults <AccountTransfer> { PageNumber = 1, TotalNumberOfPages = 2, Items = new[] { _transfer } }))); _client = new Client.PaymentsEventsApiClient(_configuration, _httpClient.Object); }
public async Task TestMethod1() { const string apiBaseUrl = "https://beta-payments.apprenticeships.sfa.bis.gov.uk/"; string clientToken = File.ReadAllText(@"C:\tokens\PaymentsEventsApi_PROD.txt"); //use https://stackoverflow.com/questions/10667012/getting-downloads-folder-in-c? const string outputPath = @"C:\Users\phil\Downloads\"; var config = new PaymentsEventsApiConfiguration { ApiBaseUrl = apiBaseUrl, ClientToken = clientToken }; var client = new PaymentsEventsApiClient(config); //todo: could provide employeraccountid & prn to reduce volumes! //var sinceEventId = 1747413 - 1; //try azure db with and withoug mars //do web sites write to datalockstatus? //point to live? nah, db set up pain //recheck logs for exceptions - search by apprenticeshipid? when error occured? //could bring in SelectManyAsync //var datalockEvents = Data.SinceEventIds().SelectMany(async since => await client.GetDataLockEvents(since)); var pageStartIds = Data.SinceEventIds(Data.Ids); Console.WriteLine("Page start ids:"); Console.WriteLine(string.Join(",", pageStartIds.Select(i => i.ToString()))); List <DataLockEvent> datalockEvents = new List <DataLockEvent>(); foreach (var since in pageStartIds) { // var page = await Retries.CallWithRetryAsync<PageOfResults<DataLockEvent>>(c => client.GetDataLockEvents(since)); Console.WriteLine($"Fetching page @ {since}"); var page = await Retries.CallWithRetryAsync(() => client.GetDataLockEvents(since)); datalockEvents = datalockEvents.Concat(page.Items).Where(id => Data.Ids.Contains(id.Id)).ToList(); } var path = outputPath + "1_payment_event.json"; Console.WriteLine($"Generating {path}"); var newPage = new PageOfResults <DataLockEvent> { Items = datalockEvents.ToArray(), PageNumber = 1, TotalNumberOfPages = 1 }; var pageJson = JsonConvert.SerializeObject(newPage); File.WriteAllText(path, pageJson); }
public void Arrange() { _configuration = new PaymentsEventsApiConfiguration { ApiBaseUrl = "some-url/", ClientToken = "super_secure_token" }; _httpClient = new Mock<SecureHttpClient>(); _httpClient.Setup(c => c.GetAsync( "some-url/api/v2/payments/statistics")) .ReturnsAsync(JsonConvert.SerializeObject(new PaymentStatistics() { TotalNumberOfPayments = 500, TotalNumberOfPaymentsWithRequiredPayment = 470 })); _client = new Client.PaymentsEventsApiClient(_configuration, _httpClient.Object); }
public void Arrange() { _configuration = new PaymentsEventsApiConfiguration { ApiBaseUrl = "some-url/", ClientToken = "super_secure_token" }; _periodEnd1 = new PeriodEnd { Id = "1617-R01", CalendarPeriod = new CalendarPeriod { Month = 9, Year = 2016 }, ReferenceData = new ReferenceDataDetails { AccountDataValidAt = new DateTime(2016, 9, 1), CommitmentDataValidAt = new DateTime(2016, 9, 2) }, CompletionDateTime = new DateTime(2016, 10, 3), Links = new PeriodEndLinks { PaymentsForPeriod = "some-other-url" } }; _httpClient = new Mock <SecureHttpClient>(); _httpClient.Setup(c => c.GetAsync(It.IsAny <string>())) .Returns(Task.FromResult(JsonConvert.SerializeObject(new[] { _periodEnd1 }))); _client = new Client.PaymentsEventsApiClient(_configuration, _httpClient.Object); }
public void Arrange() { _configuration = new PaymentsEventsApiConfiguration { ApiBaseUrl = "some-url/", ClientToken = "super_secure_token" }; _dasPayment = new Payment { Id = Guid.NewGuid().ToString(), Ukprn = 123456, Uln = 987654, EmployerAccountId = "ACC001", ApprenticeshipId = 918273, DeliveryPeriod = new CalendarPeriod { Month = 8, Year = 2017 }, CollectionPeriod = new NamedCalendarPeriod { Month = 9, Year = 2017 }, EvidenceSubmittedOn = new DateTime(2017, 10, 1), EmployerAccountVersion = "A", ApprenticeshipVersion = "B", FundingSource = FundingSource.Levy, FundingAccountId = 69, TransactionType = TransactionType.Learning, Amount = 1234.56m, StandardCode = 25, ContractType = ContractType.ContractWithEmployer }; _nonDasPayment = new Payment { Id = Guid.NewGuid().ToString(), Ukprn = 654321, Uln = 987654, DeliveryPeriod = new CalendarPeriod { Month = 8, Year = 2017 }, CollectionPeriod = new NamedCalendarPeriod { Month = 9, Year = 2017 }, EvidenceSubmittedOn = new DateTime(2017, 10, 1), FundingSource = FundingSource.CoInvestedSfa, TransactionType = TransactionType.Learning, Amount = 987.65m, FrameworkCode = 550, ProgrammeType = 20, PathwayCode = 6, ContractType = ContractType.ContractWithSfa }; _httpClient = new Mock <SecureHttpClient>(); _httpClient.Setup(c => c.GetAsync(It.IsAny <string>())) .Returns(Task.FromResult(JsonConvert.SerializeObject(new PageOfResults <Payment> { PageNumber = 1, TotalNumberOfPages = 2, Items = new[] { _dasPayment, _nonDasPayment } }))); _client = new Client.PaymentsEventsApiClient(_configuration, _httpClient.Object); }
public void Arrange() { _configuration = new PaymentsEventsApiConfiguration { ApiBaseUrl = "some-url/", ClientToken = "super_secure_token" }; _dataLockEvent = new DataLockEvent { Id = 1, ProcessDateTime = new DateTime(2017, 2, 8, 9, 10, 11), IlrFileName = "ILR-123456", Ukprn = 123456, Uln = 987654, LearnRefNumber = "Lrn1", AimSeqNumber = 1, PriceEpisodeIdentifier = "25-27-01/05/2017", ApprenticeshipId = 1, EmployerAccountId = 123, EventSource = EventSource.Submission, HasErrors = true, IlrStartDate = new DateTime(2017, 5, 1), IlrStandardCode = 27, IlrTrainingPrice = 12000m, IlrEndpointAssessorPrice = 3000m, Errors = new [] { new DataLockEventError { ErrorCode = "Err15", SystemDescription = "Mismatch on price." } }, Periods = new [] { new DataLockEventPeriod { ApprenticeshipVersion = "1-019", Period = new NamedCalendarPeriod { Id = "1617-R09", Month = 4, Year = 2017 }, IsPayable = false, TransactionType = TransactionType.Learning }, new DataLockEventPeriod { ApprenticeshipVersion = "1-019", Period = new NamedCalendarPeriod { Id = "1617-R10", Month = 5, Year = 2017 }, IsPayable = false } }, Apprenticeships = new [] { new DataLockEventApprenticeship { Version = "19", StartDate = new DateTime(2017, 5, 1), StandardCode = 27, NegotiatedPrice = 17500m, EffectiveDate = new DateTime(2017, 5, 1) } } }; _httpClient = new Mock <SecureHttpClient>(); _httpClient.Setup(c => c.GetAsync(It.IsAny <string>())) .Returns(Task.FromResult(JsonConvert.SerializeObject(new PageOfResults <DataLockEvent> { PageNumber = 1, TotalNumberOfPages = 2, Items = new[] { _dataLockEvent } }))); _client = new Client.PaymentsEventsApiClient(_configuration, _httpClient.Object); }
public void Arrange() { _configuration = new PaymentsEventsApiConfiguration { ApiBaseUrl = "some-url/", ClientToken = "super_secure_token" }; _submissionStandardEvent = new SubmissionEvent { Id = 1, IlrFileName = "ILR-123456", FileDateTime = new DateTime(2017, 2, 10, 8, 55, 23), SubmittedDateTime = new DateTime(2017, 2, 10, 8, 59, 13), ComponentVersionNumber = 1, Ukprn = 123456, Uln = 987654, StandardCode = 27, ActualStartDate = new DateTime(2017, 4, 1), PlannedEndDate = new DateTime(2018, 5, 1), TrainingPrice = 12000m, EndpointAssessorPrice = 3000m, NiNumber = "AB12345C", ApprenticeshipId = 1, AcademicYear = "1617", EmployerReferenceNumber = 123456, EPAOrgId = "EPACodeI" }; _submissionFrameworkEvent = new SubmissionEvent { Id = 1, IlrFileName = "ILR-123456", FileDateTime = new DateTime(2017, 2, 10, 8, 55, 23), SubmittedDateTime = new DateTime(2017, 2, 10, 8, 59, 13), ComponentVersionNumber = 1, Ukprn = 123456, Uln = 987654321, ProgrammeType = 20, FrameworkCode = 550, PathwayCode = 6, ActualStartDate = new DateTime(2017, 4, 1), PlannedEndDate = new DateTime(2018, 5, 1), TrainingPrice = 6000m, EndpointAssessorPrice = 1500m, NiNumber = "AB12345C", ApprenticeshipId = 9, AcademicYear = "1617", EmployerReferenceNumber = 123456, EPAOrgId = "EPACodeI" }; _httpClient = new Mock <SecureHttpClient>(); _httpClient.Setup(c => c.GetAsync(It.IsAny <string>())) .Returns(Task.FromResult(JsonConvert.SerializeObject(new PageOfResults <SubmissionEvent> { PageNumber = 1, TotalNumberOfPages = 2, Items = new[] { _submissionStandardEvent, _submissionFrameworkEvent } }))); _client = new Client.PaymentsEventsApiClient(_configuration, _httpClient.Object); }