From ccd991d3484b66308e6a22262db89a0b451cf3d7 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 2 Dec 2023 11:11:30 +0100 Subject: [PATCH] Add metadata property to CaptureRequest --- .../Models/Capture/Request/CaptureRequest.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Mollie.Api/Models/Capture/Request/CaptureRequest.cs b/src/Mollie.Api/Models/Capture/Request/CaptureRequest.cs index 66f8d28f..45202f66 100644 --- a/src/Mollie.Api/Models/Capture/Request/CaptureRequest.cs +++ b/src/Mollie.Api/Models/Capture/Request/CaptureRequest.cs @@ -1,4 +1,7 @@ -namespace Mollie.Api.Models.Capture.Request { +using Mollie.Api.JsonConverters; +using Newtonsoft.Json; + +namespace Mollie.Api.Models.Capture.Request { public class CaptureRequest { /// /// The amount to capture. @@ -9,5 +12,21 @@ public class CaptureRequest { /// The description of the capture you are creating. /// public string Description { get; set; } + + /// + /// Provide any data you like, for example a string or a JSON object. We will save the data alongside the capture. + /// Whenever you fetch the capture with our API, we will also include the metadata. You can use up to + /// approximately 1kB. + /// + [JsonConverter(typeof(RawJsonConverter))] + public string Metadata { get; set; } + + public void SetMetadata(object metadataObj, JsonSerializerSettings jsonSerializerSettings = null) { + this.Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); + } + + public override string ToString() { + return $"Amount: {this.Amount} Description: {this.Description}"; + } } } \ No newline at end of file