// Contract Templates - FX Swap, Letter of Credit, etc.

import { contractFabricService } from './contract-fabric.service';
import { ContractTemplateType } from '@/shared/types';

export class ContractTemplatesService {
  /**
   * Create FX Swap contract
   */
  async createFxSwapContract(
    sovereignBankId: string,
    parameters: {
      baseCurrency: string;
      quoteCurrency: string;
      spotAmount: string;
      forwardAmount: string;
      forwardDate: Date;
    },
    signatories: string[]
  ) {
    return await contractFabricService.createContract(
      sovereignBankId,
      ContractTemplateType.FX_SWAP,
      parameters,
      signatories
    );
  }

  /**
   * Create Letter of Credit contract (UCP 600)
   */
  async createLetterOfCreditContract(
    sovereignBankId: string,
    parameters: {
      applicantBankId: string;
      beneficiaryBankId: string;
      amount: string;
      currencyCode: string;
      expiryDate: Date;
      documents: Record<string, unknown>;
    },
    signatories: string[]
  ) {
    return await contractFabricService.createContract(
      sovereignBankId,
      ContractTemplateType.LETTER_OF_CREDIT,
      parameters,
      signatories
    );
  }

  /**
   * Create Sovereign Guarantee contract (URDG 758)
   */
  async createSovereignGuaranteeContract(
    sovereignBankId: string,
    parameters: {
      guarantorBankId: string;
      beneficiaryBankId: string;
      amount: string;
      currencyCode: string;
      expiryDate: Date;
    },
    signatories: string[]
  ) {
    return await contractFabricService.createContract(
      sovereignBankId,
      ContractTemplateType.SOVEREIGN_GUARANTEE,
      parameters,
      signatories
    );
  }
}

export const contractTemplatesService = new ContractTemplatesService();

