|
| 1 | +// File generated from our OpenAPI spec by Stainless. |
| 2 | + |
| 3 | +package com.inty.api.models.api.v1.users.profile |
| 4 | + |
| 5 | +import com.fasterxml.jackson.annotation.JsonAnyGetter |
| 6 | +import com.fasterxml.jackson.annotation.JsonAnySetter |
| 7 | +import com.fasterxml.jackson.annotation.JsonCreator |
| 8 | +import com.fasterxml.jackson.annotation.JsonProperty |
| 9 | +import com.inty.api.core.ExcludeMissing |
| 10 | +import com.inty.api.core.JsonField |
| 11 | +import com.inty.api.core.JsonMissing |
| 12 | +import com.inty.api.core.JsonValue |
| 13 | +import com.inty.api.errors.IntyInvalidDataException |
| 14 | +import java.util.Collections |
| 15 | +import java.util.Objects |
| 16 | + |
| 17 | +class ProfileMeResponse |
| 18 | +@JsonCreator(mode = JsonCreator.Mode.DISABLED) |
| 19 | +private constructor( |
| 20 | + private val code: JsonField<Long>, |
| 21 | + private val data: JsonField<User>, |
| 22 | + private val message: JsonField<String>, |
| 23 | + private val additionalProperties: MutableMap<String, JsonValue>, |
| 24 | +) { |
| 25 | + |
| 26 | + @JsonCreator |
| 27 | + private constructor( |
| 28 | + @JsonProperty("code") @ExcludeMissing code: JsonField<Long> = JsonMissing.of(), |
| 29 | + @JsonProperty("data") @ExcludeMissing data: JsonField<User> = JsonMissing.of(), |
| 30 | + @JsonProperty("message") @ExcludeMissing message: JsonField<String> = JsonMissing.of(), |
| 31 | + ) : this(code, data, message, mutableMapOf()) |
| 32 | + |
| 33 | + /** |
| 34 | + * @throws IntyInvalidDataException if the JSON field has an unexpected type (e.g. if the server |
| 35 | + * responded with an unexpected value). |
| 36 | + */ |
| 37 | + fun code(): Long? = code.getNullable("code") |
| 38 | + |
| 39 | + /** |
| 40 | + * 返回给客户端的用户信息 |
| 41 | + * |
| 42 | + * @throws IntyInvalidDataException if the JSON field has an unexpected type (e.g. if the server |
| 43 | + * responded with an unexpected value). |
| 44 | + */ |
| 45 | + fun data(): User? = data.getNullable("data") |
| 46 | + |
| 47 | + /** |
| 48 | + * @throws IntyInvalidDataException if the JSON field has an unexpected type (e.g. if the server |
| 49 | + * responded with an unexpected value). |
| 50 | + */ |
| 51 | + fun message(): String? = message.getNullable("message") |
| 52 | + |
| 53 | + /** |
| 54 | + * Returns the raw JSON value of [code]. |
| 55 | + * |
| 56 | + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. |
| 57 | + */ |
| 58 | + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField<Long> = code |
| 59 | + |
| 60 | + /** |
| 61 | + * Returns the raw JSON value of [data]. |
| 62 | + * |
| 63 | + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. |
| 64 | + */ |
| 65 | + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField<User> = data |
| 66 | + |
| 67 | + /** |
| 68 | + * Returns the raw JSON value of [message]. |
| 69 | + * |
| 70 | + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. |
| 71 | + */ |
| 72 | + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField<String> = message |
| 73 | + |
| 74 | + @JsonAnySetter |
| 75 | + private fun putAdditionalProperty(key: String, value: JsonValue) { |
| 76 | + additionalProperties.put(key, value) |
| 77 | + } |
| 78 | + |
| 79 | + @JsonAnyGetter |
| 80 | + @ExcludeMissing |
| 81 | + fun _additionalProperties(): Map<String, JsonValue> = |
| 82 | + Collections.unmodifiableMap(additionalProperties) |
| 83 | + |
| 84 | + fun toBuilder() = Builder().from(this) |
| 85 | + |
| 86 | + companion object { |
| 87 | + |
| 88 | + /** Returns a mutable builder for constructing an instance of [ProfileMeResponse]. */ |
| 89 | + fun builder() = Builder() |
| 90 | + } |
| 91 | + |
| 92 | + /** A builder for [ProfileMeResponse]. */ |
| 93 | + class Builder internal constructor() { |
| 94 | + |
| 95 | + private var code: JsonField<Long> = JsonMissing.of() |
| 96 | + private var data: JsonField<User> = JsonMissing.of() |
| 97 | + private var message: JsonField<String> = JsonMissing.of() |
| 98 | + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() |
| 99 | + |
| 100 | + internal fun from(profileMeResponse: ProfileMeResponse) = apply { |
| 101 | + code = profileMeResponse.code |
| 102 | + data = profileMeResponse.data |
| 103 | + message = profileMeResponse.message |
| 104 | + additionalProperties = profileMeResponse.additionalProperties.toMutableMap() |
| 105 | + } |
| 106 | + |
| 107 | + fun code(code: Long) = code(JsonField.of(code)) |
| 108 | + |
| 109 | + /** |
| 110 | + * Sets [Builder.code] to an arbitrary JSON value. |
| 111 | + * |
| 112 | + * You should usually call [Builder.code] with a well-typed [Long] value instead. This |
| 113 | + * method is primarily for setting the field to an undocumented or not yet supported value. |
| 114 | + */ |
| 115 | + fun code(code: JsonField<Long>) = apply { this.code = code } |
| 116 | + |
| 117 | + /** 返回给客户端的用户信息 */ |
| 118 | + fun data(data: User?) = data(JsonField.ofNullable(data)) |
| 119 | + |
| 120 | + /** |
| 121 | + * Sets [Builder.data] to an arbitrary JSON value. |
| 122 | + * |
| 123 | + * You should usually call [Builder.data] with a well-typed [User] value instead. This |
| 124 | + * method is primarily for setting the field to an undocumented or not yet supported value. |
| 125 | + */ |
| 126 | + fun data(data: JsonField<User>) = apply { this.data = data } |
| 127 | + |
| 128 | + fun message(message: String) = message(JsonField.of(message)) |
| 129 | + |
| 130 | + /** |
| 131 | + * Sets [Builder.message] to an arbitrary JSON value. |
| 132 | + * |
| 133 | + * You should usually call [Builder.message] with a well-typed [String] value instead. This |
| 134 | + * method is primarily for setting the field to an undocumented or not yet supported value. |
| 135 | + */ |
| 136 | + fun message(message: JsonField<String>) = apply { this.message = message } |
| 137 | + |
| 138 | + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { |
| 139 | + this.additionalProperties.clear() |
| 140 | + putAllAdditionalProperties(additionalProperties) |
| 141 | + } |
| 142 | + |
| 143 | + fun putAdditionalProperty(key: String, value: JsonValue) = apply { |
| 144 | + additionalProperties.put(key, value) |
| 145 | + } |
| 146 | + |
| 147 | + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { |
| 148 | + this.additionalProperties.putAll(additionalProperties) |
| 149 | + } |
| 150 | + |
| 151 | + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } |
| 152 | + |
| 153 | + fun removeAllAdditionalProperties(keys: Set<String>) = apply { |
| 154 | + keys.forEach(::removeAdditionalProperty) |
| 155 | + } |
| 156 | + |
| 157 | + /** |
| 158 | + * Returns an immutable instance of [ProfileMeResponse]. |
| 159 | + * |
| 160 | + * Further updates to this [Builder] will not mutate the returned instance. |
| 161 | + */ |
| 162 | + fun build(): ProfileMeResponse = |
| 163 | + ProfileMeResponse(code, data, message, additionalProperties.toMutableMap()) |
| 164 | + } |
| 165 | + |
| 166 | + private var validated: Boolean = false |
| 167 | + |
| 168 | + fun validate(): ProfileMeResponse = apply { |
| 169 | + if (validated) { |
| 170 | + return@apply |
| 171 | + } |
| 172 | + |
| 173 | + code() |
| 174 | + data()?.validate() |
| 175 | + message() |
| 176 | + validated = true |
| 177 | + } |
| 178 | + |
| 179 | + fun isValid(): Boolean = |
| 180 | + try { |
| 181 | + validate() |
| 182 | + true |
| 183 | + } catch (e: IntyInvalidDataException) { |
| 184 | + false |
| 185 | + } |
| 186 | + |
| 187 | + /** |
| 188 | + * Returns a score indicating how many valid values are contained in this object recursively. |
| 189 | + * |
| 190 | + * Used for best match union deserialization. |
| 191 | + */ |
| 192 | + internal fun validity(): Int = |
| 193 | + (if (code.asKnown() == null) 0 else 1) + |
| 194 | + (data.asKnown()?.validity() ?: 0) + |
| 195 | + (if (message.asKnown() == null) 0 else 1) |
| 196 | + |
| 197 | + override fun equals(other: Any?): Boolean { |
| 198 | + if (this === other) { |
| 199 | + return true |
| 200 | + } |
| 201 | + |
| 202 | + return other is ProfileMeResponse && |
| 203 | + code == other.code && |
| 204 | + data == other.data && |
| 205 | + message == other.message && |
| 206 | + additionalProperties == other.additionalProperties |
| 207 | + } |
| 208 | + |
| 209 | + private val hashCode: Int by lazy { Objects.hash(code, data, message, additionalProperties) } |
| 210 | + |
| 211 | + override fun hashCode(): Int = hashCode |
| 212 | + |
| 213 | + override fun toString() = |
| 214 | + "ProfileMeResponse{code=$code, data=$data, message=$message, additionalProperties=$additionalProperties}" |
| 215 | +} |
0 commit comments