@@ -20,6 +20,7 @@ import com.lithic.api.core.JsonField
2020import com.lithic.api.core.JsonMissing
2121import com.lithic.api.core.JsonValue
2222import com.lithic.api.core.allMaxBy
23+ import com.lithic.api.core.checkRequired
2324import com.lithic.api.core.getOrThrow
2425import com.lithic.api.errors.LithicInvalidDataException
2526import java.util.Collections
@@ -256,18 +257,18 @@ private constructor(
256257 /* *
257258 * JWS object required for handoff to Apple's script.
258259 *
259- * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the
260- * server responded with an unexpected value).
260+ * @throws LithicInvalidDataException if the JSON field has an unexpected type or is
261+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
261262 */
262- fun jws (): Optional < WebPushProvisioningResponseJws > = jws.getOptional (" jws" )
263+ fun jws (): WebPushProvisioningResponseJws = jws.getRequired (" jws" )
263264
264265 /* *
265266 * A unique identifier for the JWS object.
266267 *
267- * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the
268- * server responded with an unexpected value).
268+ * @throws LithicInvalidDataException if the JSON field has an unexpected type or is
269+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
269270 */
270- fun state (): Optional < String > = state.getOptional (" state" )
271+ fun state (): String = state.getRequired (" state" )
271272
272273 /* *
273274 * Returns the raw JSON value of [jws].
@@ -302,15 +303,21 @@ private constructor(
302303 /* *
303304 * Returns a mutable builder for constructing an instance of
304305 * [AppleWebPushProvisioningResponse].
306+ *
307+ * The following fields are required:
308+ * ```java
309+ * .jws()
310+ * .state()
311+ * ```
305312 */
306313 @JvmStatic fun builder () = Builder ()
307314 }
308315
309316 /* * A builder for [AppleWebPushProvisioningResponse]. */
310317 class Builder internal constructor() {
311318
312- private var jws: JsonField <WebPushProvisioningResponseJws > = JsonMissing .of()
313- private var state: JsonField <String > = JsonMissing .of()
319+ private var jws: JsonField <WebPushProvisioningResponseJws >? = null
320+ private var state: JsonField <String >? = null
314321 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
315322
316323 @JvmSynthetic
@@ -369,9 +376,21 @@ private constructor(
369376 * Returns an immutable instance of [AppleWebPushProvisioningResponse].
370377 *
371378 * Further updates to this [Builder] will not mutate the returned instance.
379+ *
380+ * The following fields are required:
381+ * ```java
382+ * .jws()
383+ * .state()
384+ * ```
385+ *
386+ * @throws IllegalStateException if any required field is unset.
372387 */
373388 fun build (): AppleWebPushProvisioningResponse =
374- AppleWebPushProvisioningResponse (jws, state, additionalProperties.toMutableMap())
389+ AppleWebPushProvisioningResponse (
390+ checkRequired(" jws" , jws),
391+ checkRequired(" state" , state),
392+ additionalProperties.toMutableMap(),
393+ )
375394 }
376395
377396 private var validated: Boolean = false
@@ -381,7 +400,7 @@ private constructor(
381400 return @apply
382401 }
383402
384- jws().ifPresent { it. validate() }
403+ jws().validate()
385404 state()
386405 validated = true
387406 }
0 commit comments