Ejemplo n.º 1
0
        public static List <PCOBatch> GetBatches(bool importing, DateTime?updatedAfter, string apiEndPoint)
        {
            // Create variables to store the results
            var dataItems     = new List <PCOData>();
            var includedItems = new List <PCOData>();

            // Set the endpoint if not passed from parameter
            apiEndPoint = apiEndPoint ?? "https://api.planningcenteronline.com/giving/v2/batches?include=owner&per_page=100";

            // Query Planning Center for people
            if (PCOGetItems(apiEndPoint, dataItems, includedItems, updatedAfter,
                            !importing, "", ""))
            {
                // Create variable to store the people
                var batches = new List <PCOBatch>();

                // Loop through each item in the result of api call
                foreach (var item in dataItems)
                {
                    // Create the person record
                    var batch = new PCOBatch(item);
                    if (batch != null)
                    {
                        // Add to list of results
                        batches.Add(batch);
                    }
                }

                // return the list of people
                return(batches);
            }

            // An error occurred trying to query people so return null
            return(null);
        }
Ejemplo n.º 2
0
        public static FinancialBatch Translate(PCOBatch inputBatch)
        {
            var financialBatch = new Core.Model.FinancialBatch();

            financialBatch.Id        = inputBatch.id;
            financialBatch.StartDate = inputBatch.created_at;
            financialBatch.Name      = inputBatch.description;

            if (inputBatch.committed_at.HasValue)
            {
                financialBatch.Status = BatchStatus.Closed;
            }
            else
            {
                financialBatch.Status = BatchStatus.Open;
            }

            financialBatch.CreatedDateTime   = inputBatch.created_at;
            financialBatch.ModifiedDateTime  = inputBatch.updated_at;
            financialBatch.CreatedByPersonId = inputBatch.ownerId;

            return(financialBatch);
        }