import { Controller, Get } from '@nestjs/common';
import { MarcadeoService } from './marcadeo.service';

/**
 * Marcadeo integration status. The actual provisioning (advertiser, campaign,
 * publisher, coupon) happens inside the real app flows — campaign create and
 * affiliate approval — not via a test endpoint.
 */
@Controller('marcadeo')
export class MarcadeoController {
  constructor(private marcadeo: MarcadeoService) {}

  /** Is Marcadeo configured, and does the token work? */
  @Get('status')
  async status() {
    if (!this.marcadeo.configured()) {
      return { configured: false };
    }
    const r = await this.marcadeo.ping();
    return { configured: true, connected: r.ok, error: r.error };
  }
}
