Example #1
0
        public JObject ToJSON()

        => JSONObject.Create(
            new JProperty("timestamp", Timestamp.ToIso8601()),
            new JProperty("meterValue", MeterValue),
            new JProperty("meterId", MeterId.ToString()),
            new JProperty("evseId", EVSEId.ToString()),
            new JProperty("userId", UserId),
            new JProperty("publicKey", PublicKey.Fingerprint.ToHexString()),
            new JProperty("lastSignature", lastSignature),
            new JProperty("signature", Signature)
            );
Example #2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomSessionSerializer">A delegate to serialize custom session JSON objects.</param>
        /// <param name="CustomCDRTokenSerializer">A delegate to serialize custom charge detail record token JSON objects.</param>
        /// <param name="CustomEnergyMeterSerializer">A delegate to serialize custom energy meter JSON objects.</param>
        /// <param name="CustomTransparencySoftwareSerializer">A delegate to serialize custom transparency software JSON objects.</param>
        /// <param name="CustomChargingPeriodSerializer">A delegate to serialize custom charging period JSON objects.</param>
        /// <param name="CustomCDRDimensionSerializer">A delegate to serialize custom charge detail record dimension JSON objects.</param>
        /// <param name="CustomPriceSerializer">A delegate to serialize custom price JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <Session> CustomSessionSerializer         = null,
                              CustomJObjectSerializerDelegate <CDRToken> CustomCDRTokenSerializer       = null,
                              CustomJObjectSerializerDelegate <EnergyMeter> CustomEnergyMeterSerializer = null,
                              CustomJObjectSerializerDelegate <TransparencySoftware> CustomTransparencySoftwareSerializer = null,
                              CustomJObjectSerializerDelegate <ChargingPeriod> CustomChargingPeriodSerializer             = null,
                              CustomJObjectSerializerDelegate <CDRDimension> CustomCDRDimensionSerializer = null,
                              CustomJObjectSerializerDelegate <Price> CustomPriceSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("country_code", CountryCode.ToString()),
                new JProperty("party_id", PartyId.ToString()),
                new JProperty("id", Id.ToString()),

                new JProperty("start_date_time", Start.ToIso8601()),

                End.HasValue
                               ? new JProperty("end_date_time", End.Value.ToIso8601())
                               : null,

                new JProperty("kwh", kWh),

                new JProperty("cdr_token", CDRToken.ToJSON(CustomCDRTokenSerializer)),
                new JProperty("auth_method", AuthMethod.ToString()),

                AuthorizationReference.HasValue
                               ? new JProperty("authorization_reference", AuthorizationReference.ToString())
                               : null,

                new JProperty("location_id", LocationId.ToString()),
                new JProperty("evse_uid", EVSEUId.ToString()),
                new JProperty("connector_id", ConnectorId.ToString()),

                MeterId.HasValue
                               ? new JProperty("meter_id", MeterId.ToString())
                               : null,

                EnergyMeter != null
                               ? new JProperty("energy_meter", EnergyMeter.ToJSON(CustomEnergyMeterSerializer))
                               : null,

                TransparencySoftwares.SafeAny()
                               ? new JProperty("transparency_softwares", new JArray(TransparencySoftwares.Select(software => software.ToJSON(CustomTransparencySoftwareSerializer))))
                               : null,

                new JProperty("currency", Currency.ToString()),

                ChargingPeriods.SafeAny()
                               ? new JProperty("charging_periods", new JArray(ChargingPeriods.Select(chargingPeriod => chargingPeriod.ToJSON(CustomChargingPeriodSerializer,
                                                                                                                                             CustomCDRDimensionSerializer))))
                               : null,

                TotalCosts.HasValue
                               ? new JProperty("total_cost", TotalCosts.Value.ToJSON(CustomPriceSerializer))
                               : null,

                new JProperty("status", Status.ToString()),


                new JProperty("last_updated", LastUpdated.ToIso8601())

                );

            return(CustomSessionSerializer != null
                       ? CustomSessionSerializer(this, JSON)
                       : JSON);
        }