import type { ProductVendor } from '../../../store/models';

export interface VendorConfig {
  id: string;
  vendor_key: string;
  vendor_type: string;
  name: string;
  description: string;
  app_url: string;
  status: 'active' | 'inactive';
  metadata: Record<string, any>;
}

export interface FulfillOrderParams {
  checkoutSessionId: string;
  productCode: string;
  customerId: string;
  quantity: number;
  invoiceId: string;
  amount: string;
  currency: string;

  description: string;
  userInfo: {
    userDid: string;
    email: string;
    description?: string;
  };
  deliveryParams: {
    blockletMetaUrl: string;
    customParams?: Record<string, any>;
  };

  customParams?: Record<string, any>;
}

export interface OrderDetails {
  productCode: string;
  customerId: string;
  amount: string;
  currency: string;
  quantity: number;
  invoiceId: string;
  customParams?: Record<string, any>;
}

export interface InstallationInfo {
  appId: string;
  appUrl: string;
  adminUrl: string;
  status: 'installing' | 'completed' | 'failed';
  estimatedCompletionTime: string;
}

export interface FulfillOrderResult {
  orderId: string;
  status: 'pending' | 'processing' | 'completed' | 'failed';
  serviceUrl?: string;
  estimatedTime?: number;
  message: string;
  vendorOrderId?: string;
  progress?: number;
  orderDetails?: OrderDetails;
  installationInfo?: InstallationInfo;
}

export interface ReturnRequestParams {
  orderId: string;
  vendorOrderId?: string;
  reason: string;
  customParams?: Record<string, any>;
}

export interface ReturnRequestResult {
  code: string;
  message?: string;
  data?: Record<string, any>;
}

export interface RefundRequestParams {
  orderId: string;
  amount: string;
  livemode: number;
  contract: string;
  chainType: string;
  chainApiHost: string;
  reason?: string;
}

export interface RefundRequestResult {
  code?: string;
  message?: string;
  data?: Record<string, any>;
}

export interface CheckOrderStatusParams extends Record<string, any> {}

export interface CheckOrderStatusResult {
  status: 'processing' | 'completed' | 'failed';
}

export interface VendorAdapter {
  fulfillOrder(params: FulfillOrderParams): Promise<FulfillOrderResult>;
  requestReturn(params: ReturnRequestParams): Promise<ReturnRequestResult>;
  requestRefund(params: RefundRequestParams): Promise<RefundRequestResult>;
  checkOrderStatus(params: CheckOrderStatusParams): Promise<CheckOrderStatusResult>;
  getOrder(vendor: ProductVendor, orderId: string, option?: Record<string, any>): Promise<any>;
  getOrderStatus(vendor: ProductVendor, orderId: string, option?: Record<string, any>): Promise<any>;
  connectTest(): Promise<any>;
}
