//! Example: Enterprise Domain Filtering (FR-026)
//!
//! Demonstrates using EmploymentPolicy with domain and issuer constraints
//! to verify employment at a specific organization.
//!
//! # Use Case
//!
//! An enterprise application needs to verify:
//! 1. The user is currently employed at a specific company (domain)
//! 2. The credential was issued by a trusted issuer DID
//!
//! # Running
//!
//! ```bash
//! cargo run --example enterprise_domain_filter --features employment-policy
//! ```

use lastid_sdk::{EmploymentField, EmploymentPolicy, EmploymentStatus, PolicyBuilder};

fn main() {
    println!("=== Enterprise Domain Filtering Example ===\n");

    // Example 1: Filter by employer domain only
    println!("1. Employment at Specific Domain");
    let policy = EmploymentPolicy::new()
        .with_employer_domain("acme-corp.com")
        .with_status(EmploymentStatus::Current)
        .with_callback("https://example.com/callback");

    let request = policy.clone().to_request().unwrap();
    let constraints = request.constraints.unwrap();
    println!(
        "   Employer Domain: {}",
        constraints.get("employerDomain").unwrap()
    );
    println!(
        "   Status: {}",
        constraints.get("employmentStatus").unwrap()
    );
    println!();

    // Example 2: Filter by issuer DID (trusted credential issuer)
    println!("2. Employment from Trusted Issuer");
    let policy = EmploymentPolicy::new()
        .with_issuer_did("did:lastid:acme-corp-hr")
        .with_status(EmploymentStatus::Current)
        .with_callback("https://example.com/callback");

    let request = policy.clone().to_request().unwrap();
    let constraints = request.constraints.unwrap();
    println!("   Issuer DID: {}", constraints.get("iss").unwrap());
    println!();

    // Example 3: Filter by employer DID (credential subject's employer)
    println!("3. Employment with Employer DID");
    let policy = EmploymentPolicy::new()
        .with_employer_did("did:lastid:acme-corp")
        .with_status(EmploymentStatus::Current)
        .with_fields(&[EmploymentField::Company, EmploymentField::Title])
        .with_callback("https://example.com/callback");

    let request = policy.clone().to_request().unwrap();
    let constraints = request.constraints.unwrap();
    println!(
        "   Employer DID: {}",
        constraints.get("employer_did").unwrap()
    );
    println!("   Fields: {:?}", request.required_fields);
    println!();

    // Example 4: Combined constraints - domain + issuer
    println!("4. Full Enterprise Verification");
    let policy = EmploymentPolicy::new()
        .with_employer_domain("enterprise.com")
        .with_issuer_did("did:lastid:enterprise-hr-system")
        .with_status(EmploymentStatus::Current)
        .with_fields(&[
            EmploymentField::Company,
            EmploymentField::Title,
            EmploymentField::Department,
        ])
        .with_callback("https://example.com/callback");

    let request = policy.to_request().unwrap();
    let constraints = request.constraints.unwrap();
    println!("   Complete enterprise verification:");
    println!(
        "     Domain: {}",
        constraints.get("employerDomain").unwrap()
    );
    println!("     Issuer: {}", constraints.get("iss").unwrap());
    println!(
        "     Status: {}",
        constraints.get("employmentStatus").unwrap()
    );
    println!("     Fields: {:?}", request.required_fields);

    println!("\n=== Enterprise Domain Filtering Example Complete ===");
}
