|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 Expedia, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +/** |
| 17 | + * |
| 18 | + * Please note: |
| 19 | + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 20 | + * Do not edit this file manually. |
| 21 | + * |
| 22 | + */ |
| 23 | + |
| 24 | +@file:Suppress( |
| 25 | + "ArrayInDataClass", |
| 26 | + "EnumEntryName", |
| 27 | + "RemoveRedundantQualifierName", |
| 28 | + "UnusedImport" |
| 29 | +) |
| 30 | + |
| 31 | +package com.expediagroup.sdk.rapid.models |
| 32 | + |
| 33 | +import com.expediagroup.sdk.core.model.exception.client.PropertyConstraintViolationException |
| 34 | +import com.expediagroup.sdk.rapid.models.Address1 |
| 35 | +import com.fasterxml.jackson.annotation.JsonProperty |
| 36 | +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator |
| 37 | +import javax.validation.Valid |
| 38 | +import javax.validation.Validation |
| 39 | + |
| 40 | +/** |
| 41 | + * Additional sensitive (PII) data about a traveler that should only be submitted in cases where it is necessary to clarify the identity of the traveler. |
| 42 | + * @param middleName Middle name of room guest. Max 60 characters. Special characters (\"<\", \">\", \"(\", \")\", and \"&\") entered in this field will be re-encoded. |
| 43 | + * @param dateOfBirth The date of birth of room guest, in ISO 8601 format (YYYY-MM-DD). |
| 44 | + * @param address |
| 45 | + */ |
| 46 | +data class CreateItineraryRequestRoomSensitiveTravelerDetails( |
| 47 | + // Middle name of room guest. Max 60 characters. Special characters (\"<\", \">\", \"(\", \")\", and \"&\") entered in this field will be re-encoded. |
| 48 | + @JsonProperty("middle_name") |
| 49 | + @field:Valid |
| 50 | + val middleName: kotlin.String? = null, |
| 51 | + // The date of birth of room guest, in ISO 8601 format (YYYY-MM-DD). |
| 52 | + @JsonProperty("date_of_birth") |
| 53 | + @field:Valid |
| 54 | + val dateOfBirth: kotlin.String? = null, |
| 55 | + @JsonProperty("address") |
| 56 | + @field:Valid |
| 57 | + val address: Address1? = null |
| 58 | +) { |
| 59 | + companion object { |
| 60 | + @JvmStatic |
| 61 | + fun builder() = Builder() |
| 62 | + } |
| 63 | + |
| 64 | + class Builder( |
| 65 | + private var middleName: kotlin.String? = null, |
| 66 | + private var dateOfBirth: kotlin.String? = null, |
| 67 | + private var address: Address1? = null |
| 68 | + ) { |
| 69 | + fun middleName(middleName: kotlin.String?) = apply { this.middleName = middleName } |
| 70 | + |
| 71 | + fun dateOfBirth(dateOfBirth: kotlin.String?) = apply { this.dateOfBirth = dateOfBirth } |
| 72 | + |
| 73 | + fun address(address: Address1?) = apply { this.address = address } |
| 74 | + |
| 75 | + fun build(): CreateItineraryRequestRoomSensitiveTravelerDetails { |
| 76 | + val instance = |
| 77 | + CreateItineraryRequestRoomSensitiveTravelerDetails( |
| 78 | + middleName = middleName, |
| 79 | + dateOfBirth = dateOfBirth, |
| 80 | + address = address |
| 81 | + ) |
| 82 | + |
| 83 | + validate(instance) |
| 84 | + |
| 85 | + return instance |
| 86 | + } |
| 87 | + |
| 88 | + private fun validate(instance: CreateItineraryRequestRoomSensitiveTravelerDetails) { |
| 89 | + val validator = |
| 90 | + Validation |
| 91 | + .byDefaultProvider() |
| 92 | + .configure() |
| 93 | + .messageInterpolator(ParameterMessageInterpolator()) |
| 94 | + .buildValidatorFactory() |
| 95 | + .validator |
| 96 | + |
| 97 | + val violations = validator.validate(instance) |
| 98 | + |
| 99 | + if (violations.isNotEmpty()) { |
| 100 | + throw PropertyConstraintViolationException( |
| 101 | + constraintViolations = violations.map { "${it.propertyPath}: ${it.message}" } |
| 102 | + ) |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + fun toBuilder() = |
| 108 | + Builder( |
| 109 | + middleName = middleName, |
| 110 | + dateOfBirth = dateOfBirth, |
| 111 | + address = address |
| 112 | + ) |
| 113 | +} |
0 commit comments