@@ -11,6 +11,7 @@ import dev.arcade.core.ExcludeMissing
1111import dev.arcade.core.JsonField
1212import dev.arcade.core.JsonMissing
1313import dev.arcade.core.JsonValue
14+ import dev.arcade.core.checkKnown
1415import dev.arcade.core.toImmutable
1516import dev.arcade.errors.ArcadeInvalidDataException
1617import java.util.Collections
@@ -1683,6 +1684,7 @@ private constructor(
16831684 private val clientId: JsonField <String >,
16841685 private val clientSecret: JsonField <ClientSecret >,
16851686 private val redirectUri: JsonField <String >,
1687+ private val supportedScopes: JsonField <List <String >>,
16861688 private val additionalProperties: MutableMap <String , JsonValue >,
16871689 ) {
16881690
@@ -1700,7 +1702,17 @@ private constructor(
17001702 @JsonProperty(" redirect_uri" )
17011703 @ExcludeMissing
17021704 redirectUri: JsonField <String > = JsonMissing .of(),
1703- ) : this (authorizationUrl, clientId, clientSecret, redirectUri, mutableMapOf ())
1705+ @JsonProperty(" supported_scopes" )
1706+ @ExcludeMissing
1707+ supportedScopes: JsonField <List <String >> = JsonMissing .of(),
1708+ ) : this (
1709+ authorizationUrl,
1710+ clientId,
1711+ clientSecret,
1712+ redirectUri,
1713+ supportedScopes,
1714+ mutableMapOf (),
1715+ )
17041716
17051717 /* *
17061718 * @throws ArcadeInvalidDataException if the JSON field has an unexpected type (e.g. if
@@ -1727,6 +1739,13 @@ private constructor(
17271739 */
17281740 fun redirectUri (): Optional <String > = redirectUri.getOptional(" redirect_uri" )
17291741
1742+ /* *
1743+ * @throws ArcadeInvalidDataException if the JSON field has an unexpected type (e.g. if
1744+ * the server responded with an unexpected value).
1745+ */
1746+ fun supportedScopes (): Optional <List <String >> =
1747+ supportedScopes.getOptional(" supported_scopes" )
1748+
17301749 /* *
17311750 * Returns the raw JSON value of [authorizationUrl].
17321751 *
@@ -1765,6 +1784,16 @@ private constructor(
17651784 @ExcludeMissing
17661785 fun _redirectUri (): JsonField <String > = redirectUri
17671786
1787+ /* *
1788+ * Returns the raw JSON value of [supportedScopes].
1789+ *
1790+ * Unlike [supportedScopes], this method doesn't throw if the JSON field has an
1791+ * unexpected type.
1792+ */
1793+ @JsonProperty(" supported_scopes" )
1794+ @ExcludeMissing
1795+ fun _supportedScopes (): JsonField <List <String >> = supportedScopes
1796+
17681797 @JsonAnySetter
17691798 private fun putAdditionalProperty (key : String , value : JsonValue ) {
17701799 additionalProperties.put(key, value)
@@ -1790,6 +1819,7 @@ private constructor(
17901819 private var clientId: JsonField <String > = JsonMissing .of()
17911820 private var clientSecret: JsonField <ClientSecret > = JsonMissing .of()
17921821 private var redirectUri: JsonField <String > = JsonMissing .of()
1822+ private var supportedScopes: JsonField <MutableList <String >>? = null
17931823 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
17941824
17951825 @JvmSynthetic
@@ -1798,6 +1828,7 @@ private constructor(
17981828 clientId = oauth2.clientId
17991829 clientSecret = oauth2.clientSecret
18001830 redirectUri = oauth2.redirectUri
1831+ supportedScopes = oauth2.supportedScopes.map { it.toMutableList() }
18011832 additionalProperties = oauth2.additionalProperties.toMutableMap()
18021833 }
18031834
@@ -1853,6 +1884,32 @@ private constructor(
18531884 this .redirectUri = redirectUri
18541885 }
18551886
1887+ fun supportedScopes (supportedScopes : List <String >) =
1888+ supportedScopes(JsonField .of(supportedScopes))
1889+
1890+ /* *
1891+ * Sets [Builder.supportedScopes] to an arbitrary JSON value.
1892+ *
1893+ * You should usually call [Builder.supportedScopes] with a well-typed
1894+ * `List<String>` value instead. This method is primarily for setting the field to
1895+ * an undocumented or not yet supported value.
1896+ */
1897+ fun supportedScopes (supportedScopes : JsonField <List <String >>) = apply {
1898+ this .supportedScopes = supportedScopes.map { it.toMutableList() }
1899+ }
1900+
1901+ /* *
1902+ * Adds a single [String] to [supportedScopes].
1903+ *
1904+ * @throws IllegalStateException if the field was previously set to a non-list.
1905+ */
1906+ fun addSupportedScope (supportedScope : String ) = apply {
1907+ supportedScopes =
1908+ (supportedScopes ? : JsonField .of(mutableListOf ())).also {
1909+ checkKnown(" supportedScopes" , it).add(supportedScope)
1910+ }
1911+ }
1912+
18561913 fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
18571914 this .additionalProperties.clear()
18581915 putAllAdditionalProperties(additionalProperties)
@@ -1886,6 +1943,7 @@ private constructor(
18861943 clientId,
18871944 clientSecret,
18881945 redirectUri,
1946+ (supportedScopes ? : JsonMissing .of()).map { it.toImmutable() },
18891947 additionalProperties.toMutableMap(),
18901948 )
18911949 }
@@ -1901,6 +1959,7 @@ private constructor(
19011959 clientId()
19021960 clientSecret().ifPresent { it.validate() }
19031961 redirectUri()
1962+ supportedScopes()
19041963 validated = true
19051964 }
19061965
@@ -1923,7 +1982,8 @@ private constructor(
19231982 (if (authorizationUrl.asKnown().isPresent) 1 else 0 ) +
19241983 (if (clientId.asKnown().isPresent) 1 else 0 ) +
19251984 (clientSecret.asKnown().getOrNull()?.validity() ? : 0 ) +
1926- (if (redirectUri.asKnown().isPresent) 1 else 0 )
1985+ (if (redirectUri.asKnown().isPresent) 1 else 0 ) +
1986+ (supportedScopes.asKnown().getOrNull()?.size ? : 0 )
19271987
19281988 class ClientSecret
19291989 @JsonCreator(mode = JsonCreator .Mode .DISABLED )
@@ -2342,6 +2402,7 @@ private constructor(
23422402 clientId == other.clientId &&
23432403 clientSecret == other.clientSecret &&
23442404 redirectUri == other.redirectUri &&
2405+ supportedScopes == other.supportedScopes &&
23452406 additionalProperties == other.additionalProperties
23462407 }
23472408
@@ -2351,14 +2412,15 @@ private constructor(
23512412 clientId,
23522413 clientSecret,
23532414 redirectUri,
2415+ supportedScopes,
23542416 additionalProperties,
23552417 )
23562418 }
23572419
23582420 override fun hashCode (): Int = hashCode
23592421
23602422 override fun toString () =
2361- " Oauth2{authorizationUrl=$authorizationUrl , clientId=$clientId , clientSecret=$clientSecret , redirectUri=$redirectUri , additionalProperties=$additionalProperties }"
2423+ " Oauth2{authorizationUrl=$authorizationUrl , clientId=$clientId , clientSecret=$clientSecret , redirectUri=$redirectUri , supportedScopes= $supportedScopes , additionalProperties=$additionalProperties }"
23622424 }
23632425
23642426 class Secrets
0 commit comments