/**
 * @description Validates request parameters for Docusign composite envelopes
 * @author Paul Huliganga
 * @date 2026-02-25
 */
global with sharing class DocusignEnvelopeRequestHandler {
    
    /**
     * @description Validates composite envelope request parameters
     * @param req Request object to validate
     * @throws IllegalArgumentException if validation fails
     */
    public static void validateRequest(DocusignEnvelopeRequest req) {
        if (req.templateIds == null || req.templateIds.isEmpty()) {
            throw new IllegalArgumentException('At least one template ID is required');
        }
        
        if (req.templateIds.size() > 14) {
            throw new IllegalArgumentException('Maximum 14 templates allowed per envelope');
        }
        
        if (String.isBlank(req.recordId)) {
            throw new IllegalArgumentException('Salesforce record ID is required');
        }
        
        for (String templateId : req.templateIds) {
            if (String.isBlank(templateId)) {
                throw new IllegalArgumentException('Template ID cannot be blank');
            }
        }
    }
}
