/**
 * Workflow Case Manager Types
 *
 * Type definitions for internal workflow cases created via the WorkflowCaseManager.
 * All workflow cases use PORTAL_NOTIFICATION origin (visible to CS team only, not customers).
 */

/**
 * Base parameters shared across all workflow cases
 */
export interface BaseWorkflowCaseParams {
  /** Salesforce Account ID */
  accountId: string;
  /** Optional Opportunity ID to link the case */
  opportunityId?: string;
  /** Case priority - defaults to Medium if not specified */
  priority?: "High" | "Medium" | "Low";
}

/**
 * Order placement notification case
 * Created when a customer places an order via the portal
 */
export interface OrderPlacedCaseParams extends BaseWorkflowCaseParams {
  /** Salesforce Order ID */
  orderId: string;
  /** Order type (e.g., "Internet", "SIM") */
  orderType: string;
  /** Whether a new Opportunity was created for this order */
  opportunityCreated: boolean;
}

/**
 * Internet eligibility check request case
 * Created when a customer requests an internet availability check
 */
export interface EligibilityCheckCaseParams extends BaseWorkflowCaseParams {
  /** Service address to check */
  address: {
    address1?: string;
    address2?: string;
    city?: string;
    state?: string;
    postcode?: string;
    country?: string;
  };
  /** Whether a new Opportunity was created for this request */
  opportunityCreated: boolean;
}

/**
 * Internet cancellation request case
 * Created when a customer requests to cancel their internet service
 */
export interface InternetCancellationCaseParams extends BaseWorkflowCaseParams {
  /** WHMCS subscription/service ID */
  subscriptionId: number;
  /** Selected cancellation month (e.g., "2024-03") */
  cancellationMonth: string;
  /** Calculated service end date */
  serviceEndDate: string;
  /** Optional customer comments */
  comments?: string;
}

/**
 * SIM cancellation request case
 * Created when a customer requests to cancel their SIM service
 */
export interface SimCancellationCaseParams extends BaseWorkflowCaseParams {
  /** SIM account number */
  simAccount: string;
  /** SIM serial number (ICCID) */
  iccid: string;
  /** WHMCS subscription/service ID */
  subscriptionId: number;
  /** Selected cancellation month (e.g., "2024-03") */
  cancellationMonth: string;
  /** Calculated service end date */
  serviceEndDate: string;
  /** Optional customer comments */
  comments?: string;
}

/**
 * ID verification case (CRITICAL)
 * Created when a customer submits ID documents for verification.
 * Returns the case ID which is needed to attach the uploaded file.
 */
export interface IdVerificationCaseParams {
  /** Salesforce Account ID */
  accountId: string;
  /** Uploaded document filename */
  filename: string;
  /** Document MIME type */
  mimeType: string;
  /** Document size in bytes */
  sizeBytes: number;
}

/**
 * Result of a workflow case creation attempt
 */
export interface WorkflowCaseResult {
  /** Whether the case was created successfully */
  success: boolean;
  /** Salesforce Case ID (if successful) */
  caseId?: string;
  /** Salesforce Case Number (if successful) */
  caseNumber?: string;
  /** Error message (if failed) */
  error?: string;
}
