private LocatedSignatureCount[] generateConstituencySignatures(Signatures_By_Constituency[] signaturesByConstituency, DateTime petitionRetrievalTimestamp)
        {
            List <LocatedSignatureCount> signatures     = new List <LocatedSignatureCount>();
            Dictionary <string, string>  constituencies = IdRetrieval.GetSubjectsDictionary("constituencyGroupOnsCode", logger);

            foreach (Signatures_By_Constituency constituency in signaturesByConstituency)
            {
                LocatedSignatureCount locatedSignatureCount = new LocatedSignatureCount();
                locatedSignatureCount.SignatureCount            = DeserializerHelper.GiveMeSingleIntegerValue(constituency.signature_count);
                locatedSignatureCount.SignatureCountRetrievedAt = DeserializerHelper.GiveMeSingleDateValue(petitionRetrievalTimestamp);
                if (constituencies.ContainsKey(constituency.ons_code))
                {
                    locatedSignatureCount.LocatedSignatureCountHasPlace = new Place()
                    {
                        Id = new Uri(constituencies[constituency.ons_code])
                    };
                    signatures.Add(locatedSignatureCount);
                }
                else
                {
                    logger.Warning($"Found signature on petition without matching constituency code - {constituency.ons_code}");
                }
            }
            return(signatures.ToArray());
        }
        private LocatedSignatureCount[] generateInternationalAreasSignatures(Signatures_By_Country[] signaturesByCountry, DateTime petitionRetrievalTimestamp)
        {
            List <LocatedSignatureCount> signatures  = new List <LocatedSignatureCount>();
            Dictionary <string, string>  countries   = IdRetrieval.GetSubjectsDictionary("countryGovRegisterId", logger);
            Dictionary <string, string>  territories = IdRetrieval.GetSubjectsDictionary("territoryGovRegisterId", logger);

            foreach (Signatures_By_Country country in signaturesByCountry)
            {
                LocatedSignatureCount locatedSignatureCount = new LocatedSignatureCount();
                locatedSignatureCount.SignatureCount            = DeserializerHelper.GiveMeSingleIntegerValue(country.signature_count);
                locatedSignatureCount.SignatureCountRetrievedAt = DeserializerHelper.GiveMeSingleDateValue(petitionRetrievalTimestamp);
                Place place = null;
                if (territories.ContainsKey(country.code))
                {
                    place = new Place()
                    {
                        Id = new Uri(territories[country.code])
                    }
                }
                ;
                else
                if (countries.ContainsKey(country.code))
                {
                    place = new Place()
                    {
                        Id = new Uri(countries[country.code])
                    }
                }
                ;
                if (place != null)
                {
                    locatedSignatureCount.LocatedSignatureCountHasPlace = place;
                    signatures.Add(locatedSignatureCount);
                }
                else
                {
                    logger.Warning($"Found signature on petition without matching international area code - {country.code}");
                }
            }
            return(signatures.ToArray());
        }
        private ThresholdAttainment[] generateThresholdAttainments(DateTime?moderatedAt, DateTime?respondedAt, DateTime?debatedAt)
        {
            List <ThresholdAttainment>  thresholdAttainments = new List <ThresholdAttainment>();
            Dictionary <string, string> thresholds           = IdRetrieval.GetSubjectsDictionary("thresholdName", logger);

            foreach (KeyValuePair <string, string> threshold in thresholds)
            {
                DateTime?timestamp = null;
                switch (threshold.Key.ToLower())
                {
                case "moderation":
                    timestamp = moderatedAt;
                    break;

                case "response":
                    timestamp = respondedAt;
                    break;

                case "debate":
                    timestamp = debatedAt;
                    break;
                }
                if (timestamp.HasValue)
                {
                    ThresholdAttainment thresholdAttainment = new ThresholdAttainment();
                    thresholdAttainment.Id = GenerateNewId();
                    thresholdAttainment.ThresholdAttainmentAt           = timestamp;
                    thresholdAttainment.ThresholdAttainmentHasThreshold = new Threshold()
                    {
                        Id = new Uri(threshold.Value)
                    };
                    thresholdAttainments.Add(thresholdAttainment);
                }
            }
            return(thresholdAttainments.ToArray());
        }