Skip to content

Commit 81e04fd

Browse files
author
stlc-bot
committed
Build SDK
Stainless-Generated-From: 00239b9
1 parent 36070fc commit 81e04fd

10 files changed

Lines changed: 1992 additions & 2 deletions

File tree

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package io.imagekit.models.webhooks
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 io.imagekit.core.ExcludeMissing
10+
import io.imagekit.core.JsonField
11+
import io.imagekit.core.JsonMissing
12+
import io.imagekit.core.JsonValue
13+
import io.imagekit.core.checkRequired
14+
import io.imagekit.errors.ImageKitInvalidDataException
15+
import io.imagekit.models.files.Folder
16+
import java.time.OffsetDateTime
17+
import java.util.Collections
18+
import java.util.Objects
19+
import kotlin.jvm.optionals.getOrNull
20+
21+
/** Triggered when a folder is created. */
22+
class FolderCreateEvent
23+
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
24+
private constructor(
25+
private val id: JsonField<String>,
26+
private val type: JsonField<String>,
27+
private val createdAt: JsonField<OffsetDateTime>,
28+
private val data: JsonField<Folder>,
29+
private val additionalProperties: MutableMap<String, JsonValue>,
30+
) {
31+
32+
@JsonCreator
33+
private constructor(
34+
@JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(),
35+
@JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(),
36+
@JsonProperty("created_at")
37+
@ExcludeMissing
38+
createdAt: JsonField<OffsetDateTime> = JsonMissing.of(),
39+
@JsonProperty("data") @ExcludeMissing data: JsonField<Folder> = JsonMissing.of(),
40+
) : this(id, type, createdAt, data, mutableMapOf())
41+
42+
fun toBaseWebhookEvent(): BaseWebhookEvent =
43+
BaseWebhookEvent.builder().id(id).type(type).build()
44+
45+
/**
46+
* Unique identifier for the event.
47+
*
48+
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
49+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
50+
*/
51+
fun id(): String = id.getRequired("id")
52+
53+
/**
54+
* The type of webhook event.
55+
*
56+
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
57+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
58+
*/
59+
fun type(): String = type.getRequired("type")
60+
61+
/**
62+
* Timestamp of when the event occurred in ISO8601 format.
63+
*
64+
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
65+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
66+
*/
67+
fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at")
68+
69+
/**
70+
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
71+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
72+
*/
73+
fun data(): Folder = data.getRequired("data")
74+
75+
/**
76+
* Returns the raw JSON value of [id].
77+
*
78+
* Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
79+
*/
80+
@JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id
81+
82+
/**
83+
* Returns the raw JSON value of [type].
84+
*
85+
* Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
86+
*/
87+
@JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type
88+
89+
/**
90+
* Returns the raw JSON value of [createdAt].
91+
*
92+
* Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
93+
*/
94+
@JsonProperty("created_at")
95+
@ExcludeMissing
96+
fun _createdAt(): JsonField<OffsetDateTime> = createdAt
97+
98+
/**
99+
* Returns the raw JSON value of [data].
100+
*
101+
* Unlike [data], this method doesn't throw if the JSON field has an unexpected type.
102+
*/
103+
@JsonProperty("data") @ExcludeMissing fun _data(): JsonField<Folder> = data
104+
105+
@JsonAnySetter
106+
private fun putAdditionalProperty(key: String, value: JsonValue) {
107+
additionalProperties.put(key, value)
108+
}
109+
110+
@JsonAnyGetter
111+
@ExcludeMissing
112+
fun _additionalProperties(): Map<String, JsonValue> =
113+
Collections.unmodifiableMap(additionalProperties)
114+
115+
fun toBuilder() = Builder().from(this)
116+
117+
companion object {
118+
119+
/**
120+
* Returns a mutable builder for constructing an instance of [FolderCreateEvent].
121+
*
122+
* The following fields are required:
123+
* ```java
124+
* .id()
125+
* .type()
126+
* .createdAt()
127+
* .data()
128+
* ```
129+
*/
130+
@JvmStatic fun builder() = Builder()
131+
}
132+
133+
/** A builder for [FolderCreateEvent]. */
134+
class Builder internal constructor() {
135+
136+
private var id: JsonField<String>? = null
137+
private var type: JsonField<String>? = null
138+
private var createdAt: JsonField<OffsetDateTime>? = null
139+
private var data: JsonField<Folder>? = null
140+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
141+
142+
@JvmSynthetic
143+
internal fun from(folderCreateEvent: FolderCreateEvent) = apply {
144+
id = folderCreateEvent.id
145+
type = folderCreateEvent.type
146+
createdAt = folderCreateEvent.createdAt
147+
data = folderCreateEvent.data
148+
additionalProperties = folderCreateEvent.additionalProperties.toMutableMap()
149+
}
150+
151+
/** Unique identifier for the event. */
152+
fun id(id: String) = id(JsonField.of(id))
153+
154+
/**
155+
* Sets [Builder.id] to an arbitrary JSON value.
156+
*
157+
* You should usually call [Builder.id] with a well-typed [String] value instead. This
158+
* method is primarily for setting the field to an undocumented or not yet supported value.
159+
*/
160+
fun id(id: JsonField<String>) = apply { this.id = id }
161+
162+
/** The type of webhook event. */
163+
fun type(type: String) = type(JsonField.of(type))
164+
165+
/**
166+
* Sets [Builder.type] to an arbitrary JSON value.
167+
*
168+
* You should usually call [Builder.type] with a well-typed [String] value instead. This
169+
* method is primarily for setting the field to an undocumented or not yet supported value.
170+
*/
171+
fun type(type: JsonField<String>) = apply { this.type = type }
172+
173+
/** Timestamp of when the event occurred in ISO8601 format. */
174+
fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))
175+
176+
/**
177+
* Sets [Builder.createdAt] to an arbitrary JSON value.
178+
*
179+
* You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value
180+
* instead. This method is primarily for setting the field to an undocumented or not yet
181+
* supported value.
182+
*/
183+
fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt }
184+
185+
fun data(data: Folder) = data(JsonField.of(data))
186+
187+
/**
188+
* Sets [Builder.data] to an arbitrary JSON value.
189+
*
190+
* You should usually call [Builder.data] with a well-typed [Folder] value instead. This
191+
* method is primarily for setting the field to an undocumented or not yet supported value.
192+
*/
193+
fun data(data: JsonField<Folder>) = apply { this.data = data }
194+
195+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
196+
this.additionalProperties.clear()
197+
putAllAdditionalProperties(additionalProperties)
198+
}
199+
200+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
201+
additionalProperties.put(key, value)
202+
}
203+
204+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
205+
this.additionalProperties.putAll(additionalProperties)
206+
}
207+
208+
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
209+
210+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
211+
keys.forEach(::removeAdditionalProperty)
212+
}
213+
214+
/**
215+
* Returns an immutable instance of [FolderCreateEvent].
216+
*
217+
* Further updates to this [Builder] will not mutate the returned instance.
218+
*
219+
* The following fields are required:
220+
* ```java
221+
* .id()
222+
* .type()
223+
* .createdAt()
224+
* .data()
225+
* ```
226+
*
227+
* @throws IllegalStateException if any required field is unset.
228+
*/
229+
fun build(): FolderCreateEvent =
230+
FolderCreateEvent(
231+
checkRequired("id", id),
232+
checkRequired("type", type),
233+
checkRequired("createdAt", createdAt),
234+
checkRequired("data", data),
235+
additionalProperties.toMutableMap(),
236+
)
237+
}
238+
239+
private var validated: Boolean = false
240+
241+
/**
242+
* Validates that the types of all values in this object match their expected types recursively.
243+
*
244+
* This method is _not_ forwards compatible with new types from the API for existing fields.
245+
*
246+
* @throws ImageKitInvalidDataException if any value type in this object doesn't match its
247+
* expected type.
248+
*/
249+
fun validate(): FolderCreateEvent = apply {
250+
if (validated) {
251+
return@apply
252+
}
253+
254+
id()
255+
type()
256+
createdAt()
257+
data().validate()
258+
validated = true
259+
}
260+
261+
fun isValid(): Boolean =
262+
try {
263+
validate()
264+
true
265+
} catch (e: ImageKitInvalidDataException) {
266+
false
267+
}
268+
269+
/**
270+
* Returns a score indicating how many valid values are contained in this object recursively.
271+
*
272+
* Used for best match union deserialization.
273+
*/
274+
@JvmSynthetic
275+
internal fun validity(): Int =
276+
(if (id.asKnown().isPresent) 1 else 0) +
277+
(if (type.asKnown().isPresent) 1 else 0) +
278+
(if (createdAt.asKnown().isPresent) 1 else 0) +
279+
(data.asKnown().getOrNull()?.validity() ?: 0)
280+
281+
override fun equals(other: Any?): Boolean {
282+
if (this === other) {
283+
return true
284+
}
285+
286+
return other is FolderCreateEvent &&
287+
id == other.id &&
288+
type == other.type &&
289+
createdAt == other.createdAt &&
290+
data == other.data &&
291+
additionalProperties == other.additionalProperties
292+
}
293+
294+
private val hashCode: Int by lazy {
295+
Objects.hash(id, type, createdAt, data, additionalProperties)
296+
}
297+
298+
override fun hashCode(): Int = hashCode
299+
300+
override fun toString() =
301+
"FolderCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}"
302+
}

0 commit comments

Comments
 (0)