import { Body, Controller, Inject, Post } from '@nestjs/common';
import { TagsManagerService, UpdateRule } from './tags-manager.service';

type UpdateParams = {
  userApiKey: string;
  updateRules: UpdateRule[];
};

@Controller('tags-manager')
export class TagsManagerController {
  constructor(
    @Inject('TAG_MANAGER_SERVICE')
    private tagsManagerService: TagsManagerService,
  ) {}

  @Post('/update')
  async update(@Body() params: UpdateParams): Promise<any> {
    return await this.tagsManagerService.updateTags(
      params.userApiKey,
      params.updateRules,
    );
  }
}
