public static void RetrieveSingleGiftAidPayment(int giftAidPaymentId, FileInfo excelFile) { var client = CreateClient(); var paymentClient = new PaymentsApi(client.HttpChannel); if (excelFile == null) { var paymentReport = paymentClient.RetrieveReport<GiftAidPayment>(giftAidPaymentId); foreach (var item in paymentReport.Donations) { Console.WriteLine("£{0} Gift Aid on {1:dd/MM/yyyy} from a donation of {2}", item.NetGiftAidAmount, item.Date, item.Amount); } } else { var excelData = paymentClient.RetrieveReport(giftAidPaymentId, DataFileFormat.excel); using (var fs = new FileStream(excelFile.FullName, FileMode.Create)) { fs.Write(excelData, 0, excelData.Length); fs.Close(); } Console.WriteLine("Saved!"); } }
public static void RetrieveSingleDonationPayment(int paymentId, FileInfo excelFile) { var client = CreateClient(); var paymentsClient = new PaymentsApi(client.HttpChannel); if (excelFile == null) { var paymentReport = paymentsClient.RetrieveReport<DonatoionPayment>(paymentId); foreach (var item in paymentReport.Donations) { Console.WriteLine("£{0} on {1:dd/MM/yyyy} from donor {2} {3} who said: '{4}'", item.Amount, item.Date, item.Donor.FirstName, item.Donor.LastName, item.MessageFromDonor); } } else { var excelData = paymentsClient.RetrieveReport(paymentId, DataFileFormat.excel); using (var fs = new FileStream(excelFile.FullName, FileMode.Create)) { fs.Write(excelData, 0, excelData.Length); fs.Close(); } Console.WriteLine("Saved!"); } }
public static void RetrieveSingleGiftAidPayment(int giftAidPaymentId, FileInfo excelFile) { var client = CreateClient(); var paymentClient = new PaymentsApi(client.HttpChannel); if (excelFile == null) { var paymentReport = paymentClient.RetrieveReport <GiftAidPayment>(giftAidPaymentId); foreach (var item in paymentReport.Donations) { Console.WriteLine("£{0} Gift Aid on {1:dd/MM/yyyy} from a donation of {2}", item.NetGiftAidAmount, item.Date, item.Amount); } } else { var excelData = paymentClient.RetrieveReport(giftAidPaymentId, DataFileFormat.excel); using (var fs = new FileStream(excelFile.FullName, FileMode.Create)) { fs.Write(excelData, 0, excelData.Length); fs.Close(); } Console.WriteLine("Saved!"); } }
public static void RetrieveSingleDonationPayment(int paymentId, FileInfo excelFile) { var client = CreateClient(); var paymentsClient = new PaymentsApi(client.HttpChannel); if (excelFile == null) { var paymentReport = paymentsClient.RetrieveReport <DonatoionPayment>(paymentId); foreach (var item in paymentReport.Donations) { Console.WriteLine("£{0} on {1:dd/MM/yyyy} from donor {2} {3} who said: '{4}'", item.Amount, item.Date, item.Donor.FirstName, item.Donor.LastName, item.MessageFromDonor); } } else { var excelData = paymentsClient.RetrieveReport(paymentId, DataFileFormat.excel); using (var fs = new FileStream(excelFile.FullName, FileMode.Create)) { fs.Write(excelData, 0, excelData.Length); fs.Close(); } Console.WriteLine("Saved!"); } }
public void AuthenticationSuccess_DoesNotReturnHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var payment = paymentClient.RetrieveReport <Payment>(_paymentId); Assert.That(payment.HttpStatusCode, Is.Not.EqualTo(HttpStatusCode.Unauthorized)); }
public void AuthenticationSuccess_DoesNotReturnHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var payment = paymentClient.RetrieveReport<Payment>(_paymentId); Assert.That(payment.HttpStatusCode, Is.Not.EqualTo(HttpStatusCode.Unauthorized)); }
public void AuthenticationFailure_ReturnsHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.Username = "") .With((clientConfig) => clientConfig.Password = ""); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var exception = Assert.Throws <ErrorResponseException>(() => paymentClient.RetrieveReport <Payment>(_paymentId)); Assert.That(exception.Message.Contains("401")); }
public void AuthenticationFailure_ReturnsHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.Username = "") .With((clientConfig) => clientConfig.Password = ""); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var exception = Assert.Throws<ErrorResponseException>(() => paymentClient.RetrieveReport<Payment>(_paymentId)); Assert.That(exception.Message.Contains("401")); }