import type { Brand, BrandPatch, NewBrand } from '../domain/brand.js';
import type { BrandRepository } from '../domain/ports.js';

export class GetBrandBySlug {
  constructor(private readonly brands: BrandRepository) {}

  async execute(slug: string): Promise<Brand | undefined> {
    return this.brands.findBySlug(slug);
  }
}

export class ListBrands {
  constructor(private readonly brands: BrandRepository) {}

  async execute(): Promise<Brand[]> {
    return this.brands.list();
  }
}

export class CreateBrand {
  constructor(private readonly brands: BrandRepository) {}

  async execute(input: NewBrand): Promise<Brand> {
    return this.brands.create(input);
  }
}

export class UpdateBrand {
  constructor(private readonly brands: BrandRepository) {}

  async execute(id: string, patch: BrandPatch): Promise<Brand | undefined> {
    return this.brands.update(id, patch);
  }
}
