internal static OAuth2PermissionGrant DeserializeOAuth2PermissionGrant(JsonElement element)
        {
            Optional <string>      odataType   = default;
            Optional <string>      clientId    = default;
            Optional <string>      objectId    = default;
            Optional <ConsentType> consentType = default;
            Optional <string>      principalId = default;
            Optional <string>      resourceId  = default;
            Optional <string>      scope       = default;
            Optional <string>      startTime   = default;
            Optional <string>      expiryTime  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("clientId"))
                {
                    clientId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("consentType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    consentType = new ConsentType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("principalId"))
                {
                    principalId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("scope"))
                {
                    scope = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    startTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expiryTime"))
                {
                    expiryTime = property.Value.GetString();
                    continue;
                }
            }
            return(new OAuth2PermissionGrant(odataType.Value, clientId.Value, objectId.Value, Optional.ToNullable(consentType), principalId.Value, resourceId.Value, scope.Value, startTime.Value, expiryTime.Value));
        }
        internal static OAuth2PermissionGrant DeserializeOAuth2PermissionGrant(JsonElement element)
        {
            string      odataType   = default;
            string      clientId    = default;
            string      objectId    = default;
            ConsentType?consentType = default;
            string      principalId = default;
            string      resourceId  = default;
            string      scope       = default;
            string      startTime   = default;
            string      expiryTime  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("odata.type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("clientId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    clientId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("consentType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    consentType = new ConsentType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("principalId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    principalId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("scope"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    scope = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    startTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expiryTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    expiryTime = property.Value.GetString();
                    continue;
                }
            }
            return(new OAuth2PermissionGrant(odataType, clientId, objectId, consentType, principalId, resourceId, scope, startTime, expiryTime));
        }