/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomSignedDataSerializer">A delegate to serialize custom signed data JSON objects.</param> /// <param name="CustomSignedValueSerializer">A delegate to serialize custom signed value JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <SignedData> CustomSignedDataSerializer = null, CustomJObjectSerializerDelegate <SignedValue> CustomSignedValueSerializer = null) { var JSON = JSONObject.Create( new JProperty("encoding_method", EncodingMethod.ToString()), EncodingMethodVersion.HasValue ? new JProperty("encoding_method_version", EncodingMethodVersion.ToString()) : null, PublicKey.HasValue ? new JProperty("public_key", PublicKey.ToString()) : null, SignedValues.SafeAny() ? new JProperty("signed_values", new JArray(SignedValues.Select(signedValue => signedValue.ToJSON(CustomSignedValueSerializer)))) : null, URL.IsNotNullOrEmpty() ? new JProperty("url", URL) : null ); return(CustomSignedDataSerializer != null ? CustomSignedDataSerializer(this, JSON) : JSON); }
/// <summary> /// A charging period consists of a start timestamp and an enumeration of possible values that influence this period. /// </summary> /// <param name="EncodingMethod">The name of the encoding used in the SignedData field.</param> /// <param name="SignedValues">An enumeration of signed values.</param> /// /// <param name="EncodingMethodVersion">Version of the encoding method (when applicable).</param> /// <param name="PublicKey">The public key used to sign the data, base64 encoded.</param> /// <param name="URL">URL that can be shown to an electric vehicle driver.</param> public SignedData(EncodingMethod EncodingMethod, IEnumerable <SignedValue> SignedValues, Int32?EncodingMethodVersion = null, PublicKey?PublicKey = null, String URL = null) { if (!SignedValues.SafeAny()) { throw new ArgumentNullException(nameof(SignedValues), "The given enumeration of signed values must not be null or empty!"); } this.EncodingMethod = EncodingMethod; this.SignedValues = SignedValues.Distinct(); this.EncodingMethodVersion = EncodingMethodVersion; this.PublicKey = PublicKey; this.URL = URL; }