Exemple #1
0
        public static void RetrievePaymentList(DateTime startDate, DateTime endDate, FileInfo excelFile)
        {
            var client        = CreateClient();
            var paymentclient = new PaymentsApi(client.HttpChannel);

            if (excelFile == null)
            {
                var list = paymentclient.RetrievePaymentsBetween(startDate, endDate);
                if (!list.Any())
                {
                    Console.WriteLine("No payments found for the dates entered");
                }

                foreach (var item in list)
                {
                    Console.WriteLine("#{0} £{1} ({2}) paid to account {3} on {4:dd/MM/yyyy}", item.PaymentRef, item.Net, item.PaymentType, item.Account, item.PaymentDate);
                    Console.WriteLine("Full report: {0}", item.Url);
                    Console.WriteLine();
                }
            }
            else
            {
                var excelData = paymentclient.RetrievePaymentsBetween(startDate, endDate, 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 RetrievePaymentList(DateTime startDate, DateTime endDate, FileInfo excelFile)
        {
            var client = CreateClient();
            var paymentclient = new PaymentsApi(client.HttpChannel);
            if (excelFile == null)
            {
                var list = paymentclient.RetrievePaymentsBetween(startDate, endDate);
                if (!list.Any())
                    Console.WriteLine("No payments found for the dates entered");

                foreach (var item in list)
                {
                    Console.WriteLine("#{0} £{1} ({2}) paid to account {3} on {4:dd/MM/yyyy}", item.PaymentRef, item.Net, item.PaymentType, item.Account, item.PaymentDate);
                    Console.WriteLine("Full report: {0}", item.Url);
                    Console.WriteLine();
                }
            }
            else
            {
                var excelData = paymentclient.RetrievePaymentsBetween(startDate, endDate, DataFileFormat.excel);

                using (var fs = new FileStream(excelFile.FullName, FileMode.Create))
                {
                    fs.Write(excelData, 0, excelData.Length);
                    fs.Close();
                }
                Console.WriteLine("Saved!");
            }
        }
        public void GetPaymentListAndDownloadSeveralPayments()
        {
            var clientConfiguration = GetDefaultDataClientConfiguration()
                                      .With((clientConfig) => clientConfig.WireDataFormat         = WireDataFormat.Json)
                                      .With((clientConfig) => clientConfig.IsZipSupportedByClient = true);

            var client        = new JustGivingDataClient(clientConfiguration);
            var paymentClient = new PaymentsApi(client.HttpChannel);

            int       count            = 0;
            const int numberToDownload = 10;

            var payments = paymentClient.RetrievePaymentsBetween(new DateTime(2012, 06, 01), new DateTime(2012, 06, 30));

            foreach (var payment in payments)
            {
                if (count >= numberToDownload)
                {
                    break;
                }
                var report = client.Payment.RetrieveReport <Payment>(payment.PaymentRef);

                Assert.That(report, Is.Not.Null);
                count++;
            }
        }
        public void GetPaymentListAndDownloadSeveralPayments()
        {
            var clientConfiguration = GetDefaultDataClientConfiguration()
                .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json)
                .With((clientConfig) => clientConfig.IsZipSupportedByClient = true);

            var client = new JustGivingDataClient(clientConfiguration);
            var paymentClient = new PaymentsApi(client.HttpChannel);

            int count = 0;
            const int numberToDownload = 10;

            var payments = paymentClient.RetrievePaymentsBetween(new DateTime(2012, 06, 01), new DateTime(2012, 06, 30));
            foreach(var payment in payments)
            {
                if (count >= numberToDownload) break;
                var report = client.Payment.RetrieveReport<Payment>(payment.PaymentRef);

                Assert.That(report, Is.Not.Null);
                count++;
            }
        }