/**
 * Mock for @binect/js library
 */

export class BinectApiError extends Error {
  status: number;
  response?: unknown;

  constructor(message: string, status: number, response?: unknown) {
    super(message);
    this.name = 'BinectApiError';
    this.status = status;
    this.response = response;
  }
}

export class BinectAuthError extends Error {
  constructor(message: string) {
    super(message);
    this.name = 'BinectAuthError';
  }
}

export const EnvelopeType = {
  DINLANG: 'DINLANG',
  C4: 'C4',
} as const;

export const FrankingType = {
  UNSPECIFIED: 'UNSPECIFIED',
  STANDARD_FRANKING: 'STANDARD_FRANKING',
  DV_FRANKING: 'DV_FRANKING',
} as const;

// Mock document response
const mockDocument = {
  id: 123,
  filename: 'test.pdf',
  numberOfPages: 2,
  status: { code: 2, text: 'shippable' },
  documentType: 'LETTER',
  letter: {
    letterType: 'LetterData',
    letterData: {
      recipientAddress: 'Test Address',
      price: { priceBeforeTax: 100, priceAfterTax: 119, unit: 'EUROCENT', taxInPercent: 19 },
      international: false,
      options: { simplex: false, color: false },
    },
  },
};

// Mock account response
const mockAccount = {
  id: 1,
  email: 'test@example.com',
};

export class BinectClient {
  documents = {
    upload: jest.fn().mockResolvedValue(mockDocument),
  };

  accounts = {
    get: jest.fn().mockResolvedValue(mockAccount),
  };

  constructor(_config: { username: string; password: string }) {
    // Store config if needed for tests
  }
}

export type Document = typeof mockDocument;

export interface DocumentUploadOptions {
  content: string;
  filename: string;
  simplex?: boolean;
  color?: boolean;
  envelope?: string;
  franking?: string;
}
