pdk-script 1.3.0-alpha.0

PDK Script
Documentation
// Copyright 2023 Salesforce, Inc. All rights reserved.

use crate::Value;

/// Binding for the top-level `authentication` variable.
pub trait AuthenticationBinding {
    /// Returns the `authentication.clientId` value.
    fn client_id(&self) -> Option<String>;

    /// Returns the `authentication.clientName` value.
    fn client_name(&self) -> Option<String>;

    /// Returns the `authentication.principal` value.
    fn principal(&self) -> Option<String>;

    /// Returns the `authentication.properties` value.
    fn properties(&self) -> Option<Value>;
}

impl<K: AuthenticationBinding> AuthenticationBinding for Option<K> {
    fn client_id(&self) -> Option<String> {
        self.as_ref().and_then(K::client_id)
    }

    fn client_name(&self) -> Option<String> {
        self.as_ref().and_then(K::client_name)
    }

    fn principal(&self) -> Option<String> {
        self.as_ref().and_then(K::principal)
    }

    fn properties(&self) -> Option<Value> {
        self.as_ref().and_then(K::properties)
    }
}