@@ -31,6 +31,7 @@ private constructor(
3131 private val expiryDate: JsonField <OffsetDateTime >,
3232 private val filters: JsonField <List <Filter >>,
3333 private val maximumInitialBalance: JsonField <Double >,
34+ private val metadata: JsonField <Metadata >,
3435 private val perUnitCostBasis: JsonField <String >,
3536 private val status: JsonField <Status >,
3637 private val additionalProperties: MutableMap <String , JsonValue >,
@@ -52,6 +53,7 @@ private constructor(
5253 @JsonProperty(" maximum_initial_balance" )
5354 @ExcludeMissing
5455 maximumInitialBalance: JsonField <Double > = JsonMissing .of(),
56+ @JsonProperty(" metadata" ) @ExcludeMissing metadata: JsonField <Metadata > = JsonMissing .of(),
5557 @JsonProperty(" per_unit_cost_basis" )
5658 @ExcludeMissing
5759 perUnitCostBasis: JsonField <String > = JsonMissing .of(),
@@ -63,6 +65,7 @@ private constructor(
6365 expiryDate,
6466 filters,
6567 maximumInitialBalance,
68+ metadata,
6669 perUnitCostBasis,
6770 status,
6871 mutableMapOf (),
@@ -105,6 +108,16 @@ private constructor(
105108 fun maximumInitialBalance (): Optional <Double > =
106109 maximumInitialBalance.getOptional(" maximum_initial_balance" )
107110
111+ /* *
112+ * User specified key-value pairs for the resource. If not present, this defaults to an empty
113+ * dictionary. Individual keys can be removed by setting the value to `null`, and the entire
114+ * metadata mapping can be cleared by setting `metadata` to `null`.
115+ *
116+ * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly
117+ * missing or null (e.g. if the server responded with an unexpected value).
118+ */
119+ fun metadata (): Metadata = metadata.getRequired(" metadata" )
120+
108121 /* *
109122 * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server
110123 * responded with an unexpected value).
@@ -166,6 +179,13 @@ private constructor(
166179 @ExcludeMissing
167180 fun _maximumInitialBalance (): JsonField <Double > = maximumInitialBalance
168181
182+ /* *
183+ * Returns the raw JSON value of [metadata].
184+ *
185+ * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type.
186+ */
187+ @JsonProperty(" metadata" ) @ExcludeMissing fun _metadata (): JsonField <Metadata > = metadata
188+
169189 /* *
170190 * Returns the raw JSON value of [perUnitCostBasis].
171191 *
@@ -208,6 +228,7 @@ private constructor(
208228 * .expiryDate()
209229 * .filters()
210230 * .maximumInitialBalance()
231+ * .metadata()
211232 * .perUnitCostBasis()
212233 * .status()
213234 * ```
@@ -224,6 +245,7 @@ private constructor(
224245 private var expiryDate: JsonField <OffsetDateTime >? = null
225246 private var filters: JsonField <MutableList <Filter >>? = null
226247 private var maximumInitialBalance: JsonField <Double >? = null
248+ private var metadata: JsonField <Metadata >? = null
227249 private var perUnitCostBasis: JsonField <String >? = null
228250 private var status: JsonField <Status >? = null
229251 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
@@ -236,6 +258,7 @@ private constructor(
236258 expiryDate = creditBlockRetrieveResponse.expiryDate
237259 filters = creditBlockRetrieveResponse.filters.map { it.toMutableList() }
238260 maximumInitialBalance = creditBlockRetrieveResponse.maximumInitialBalance
261+ metadata = creditBlockRetrieveResponse.metadata
239262 perUnitCostBasis = creditBlockRetrieveResponse.perUnitCostBasis
240263 status = creditBlockRetrieveResponse.status
241264 additionalProperties = creditBlockRetrieveResponse.additionalProperties.toMutableMap()
@@ -349,6 +372,22 @@ private constructor(
349372 this .maximumInitialBalance = maximumInitialBalance
350373 }
351374
375+ /* *
376+ * User specified key-value pairs for the resource. If not present, this defaults to an
377+ * empty dictionary. Individual keys can be removed by setting the value to `null`, and the
378+ * entire metadata mapping can be cleared by setting `metadata` to `null`.
379+ */
380+ fun metadata (metadata : Metadata ) = metadata(JsonField .of(metadata))
381+
382+ /* *
383+ * Sets [Builder.metadata] to an arbitrary JSON value.
384+ *
385+ * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead.
386+ * This method is primarily for setting the field to an undocumented or not yet supported
387+ * value.
388+ */
389+ fun metadata (metadata : JsonField <Metadata >) = apply { this .metadata = metadata }
390+
352391 fun perUnitCostBasis (perUnitCostBasis : String? ) =
353392 perUnitCostBasis(JsonField .ofNullable(perUnitCostBasis))
354393
@@ -409,6 +448,7 @@ private constructor(
409448 * .expiryDate()
410449 * .filters()
411450 * .maximumInitialBalance()
451+ * .metadata()
412452 * .perUnitCostBasis()
413453 * .status()
414454 * ```
@@ -423,6 +463,7 @@ private constructor(
423463 checkRequired(" expiryDate" , expiryDate),
424464 checkRequired(" filters" , filters).map { it.toImmutable() },
425465 checkRequired(" maximumInitialBalance" , maximumInitialBalance),
466+ checkRequired(" metadata" , metadata),
426467 checkRequired(" perUnitCostBasis" , perUnitCostBasis),
427468 checkRequired(" status" , status),
428469 additionalProperties.toMutableMap(),
@@ -442,6 +483,7 @@ private constructor(
442483 expiryDate()
443484 filters().forEach { it.validate() }
444485 maximumInitialBalance()
486+ metadata().validate()
445487 perUnitCostBasis()
446488 status().validate()
447489 validated = true
@@ -468,6 +510,7 @@ private constructor(
468510 (if (expiryDate.asKnown().isPresent) 1 else 0 ) +
469511 (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ? : 0 ) +
470512 (if (maximumInitialBalance.asKnown().isPresent) 1 else 0 ) +
513+ (metadata.asKnown().getOrNull()?.validity() ? : 0 ) +
471514 (if (perUnitCostBasis.asKnown().isPresent) 1 else 0 ) +
472515 (status.asKnown().getOrNull()?.validity() ? : 0 )
473516
@@ -1001,6 +1044,110 @@ private constructor(
10011044 " Filter{field=$field , operator=$operator , values=$values , additionalProperties=$additionalProperties }"
10021045 }
10031046
1047+ /* *
1048+ * User specified key-value pairs for the resource. If not present, this defaults to an empty
1049+ * dictionary. Individual keys can be removed by setting the value to `null`, and the entire
1050+ * metadata mapping can be cleared by setting `metadata` to `null`.
1051+ */
1052+ class Metadata
1053+ @JsonCreator
1054+ private constructor (
1055+ @com.fasterxml.jackson.annotation.JsonValue
1056+ private val additionalProperties: Map <String , JsonValue >
1057+ ) {
1058+
1059+ @JsonAnyGetter
1060+ @ExcludeMissing
1061+ fun _additionalProperties (): Map <String , JsonValue > = additionalProperties
1062+
1063+ fun toBuilder () = Builder ().from(this )
1064+
1065+ companion object {
1066+
1067+ /* * Returns a mutable builder for constructing an instance of [Metadata]. */
1068+ @JvmStatic fun builder () = Builder ()
1069+ }
1070+
1071+ /* * A builder for [Metadata]. */
1072+ class Builder internal constructor() {
1073+
1074+ private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
1075+
1076+ @JvmSynthetic
1077+ internal fun from (metadata : Metadata ) = apply {
1078+ additionalProperties = metadata.additionalProperties.toMutableMap()
1079+ }
1080+
1081+ fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
1082+ this .additionalProperties.clear()
1083+ putAllAdditionalProperties(additionalProperties)
1084+ }
1085+
1086+ fun putAdditionalProperty (key : String , value : JsonValue ) = apply {
1087+ additionalProperties.put(key, value)
1088+ }
1089+
1090+ fun putAllAdditionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
1091+ this .additionalProperties.putAll(additionalProperties)
1092+ }
1093+
1094+ fun removeAdditionalProperty (key : String ) = apply { additionalProperties.remove(key) }
1095+
1096+ fun removeAllAdditionalProperties (keys : Set <String >) = apply {
1097+ keys.forEach(::removeAdditionalProperty)
1098+ }
1099+
1100+ /* *
1101+ * Returns an immutable instance of [Metadata].
1102+ *
1103+ * Further updates to this [Builder] will not mutate the returned instance.
1104+ */
1105+ fun build (): Metadata = Metadata (additionalProperties.toImmutable())
1106+ }
1107+
1108+ private var validated: Boolean = false
1109+
1110+ fun validate (): Metadata = apply {
1111+ if (validated) {
1112+ return @apply
1113+ }
1114+
1115+ validated = true
1116+ }
1117+
1118+ fun isValid (): Boolean =
1119+ try {
1120+ validate()
1121+ true
1122+ } catch (e: OrbInvalidDataException ) {
1123+ false
1124+ }
1125+
1126+ /* *
1127+ * Returns a score indicating how many valid values are contained in this object
1128+ * recursively.
1129+ *
1130+ * Used for best match union deserialization.
1131+ */
1132+ @JvmSynthetic
1133+ internal fun validity (): Int =
1134+ additionalProperties.count { (_, value) -> ! value.isNull() && ! value.isMissing() }
1135+
1136+ override fun equals (other : Any? ): Boolean {
1137+ if (this == = other) {
1138+ return true
1139+ }
1140+
1141+ return other is Metadata && additionalProperties == other.additionalProperties
1142+ }
1143+
1144+ private val hashCode: Int by lazy { Objects .hash(additionalProperties) }
1145+
1146+ override fun hashCode (): Int = hashCode
1147+
1148+ override fun toString () = " Metadata{additionalProperties=$additionalProperties }"
1149+ }
1150+
10041151 class Status @JsonCreator private constructor(private val value : JsonField <String >) : Enum {
10051152
10061153 /* *
@@ -1137,6 +1284,7 @@ private constructor(
11371284 expiryDate == other.expiryDate &&
11381285 filters == other.filters &&
11391286 maximumInitialBalance == other.maximumInitialBalance &&
1287+ metadata == other.metadata &&
11401288 perUnitCostBasis == other.perUnitCostBasis &&
11411289 status == other.status &&
11421290 additionalProperties == other.additionalProperties
@@ -1150,6 +1298,7 @@ private constructor(
11501298 expiryDate,
11511299 filters,
11521300 maximumInitialBalance,
1301+ metadata,
11531302 perUnitCostBasis,
11541303 status,
11551304 additionalProperties,
@@ -1159,5 +1308,5 @@ private constructor(
11591308 override fun hashCode (): Int = hashCode
11601309
11611310 override fun toString () =
1162- " CreditBlockRetrieveResponse{id=$id , balance=$balance , effectiveDate=$effectiveDate , expiryDate=$expiryDate , filters=$filters , maximumInitialBalance=$maximumInitialBalance , perUnitCostBasis=$perUnitCostBasis , status=$status , additionalProperties=$additionalProperties }"
1311+ " CreditBlockRetrieveResponse{id=$id , balance=$balance , effectiveDate=$effectiveDate , expiryDate=$expiryDate , filters=$filters , maximumInitialBalance=$maximumInitialBalance , metadata= $metadata , perUnitCostBasis=$perUnitCostBasis , status=$status , additionalProperties=$additionalProperties }"
11631312}
0 commit comments