import { ApiProperty } from '@nestjs/swagger';
import { WebhookEventType } from '../enums/webhook-event-type.enum';

export class WebhookResponseDto {
  @ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440000' })
  id: string;

  @ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440001' })
  departmentId: string;

  @ApiProperty({ example: 'https://example.com/webhooks/events' })
  url: string;

  @ApiProperty({
    example: ['APPROVAL_REQUIRED', 'REQUEST_APPROVED'],
    enum: WebhookEventType,
    isArray: true,
  })
  events: WebhookEventType[];

  @ApiProperty({ example: true })
  isActive: boolean;

  @ApiProperty({ example: '2024-01-15T10:30:00Z' })
  createdAt: Date;

  @ApiProperty({ example: '2024-01-20T14:45:30Z' })
  updatedAt: Date;
}

export class WebhookTestResultDto {
  @ApiProperty({ example: true })
  success: boolean;

  @ApiProperty({ example: 200 })
  statusCode: number;

  @ApiProperty({ example: 'OK' })
  statusMessage: string;

  @ApiProperty({ example: 125 })
  responseTime: number;

  @ApiProperty({ example: null, nullable: true })
  error?: string;
}

export class WebhookLogEntryDto {
  @ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440000' })
  id: string;

  @ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440001' })
  webhookId: string;

  @ApiProperty({ example: 'APPROVAL_REQUIRED' })
  eventType: string;

  @ApiProperty({ example: { requestId: '123', status: 'PENDING' } })
  payload: Record<string, any>;

  @ApiProperty({ example: 200, nullable: true })
  responseStatus: number | null;

  @ApiProperty({ example: '{"status":"ok"}', nullable: true })
  responseBody: string | null;

  @ApiProperty({ example: 145, nullable: true })
  responseTime: number | null;

  @ApiProperty({ example: 0 })
  retryCount: number;

  @ApiProperty({ example: 'SUCCESS' })
  status: 'PENDING' | 'SUCCESS' | 'FAILED';

  @ApiProperty({ example: '2024-01-15T10:30:00Z' })
  createdAt: Date;
}
