<?php

namespace App\Campaigns\Publishing;

use App\Campaigns\Publisher;
use App\Models\CampaignAd;
use App\Models\CampaignAdSet;
use Illuminate\Support\Collection;

/**
 * Adding to a campaign that is already on the platform.
 *
 * Separate from {@see PlatformPublisher} because it is a capability rather than
 * part of publishing, and only Meta has it so far. Declaring these on the main
 * interface would mean Google and LinkedIn each carrying a method that throws,
 * which reads as an oversight rather than as the truth: nobody has written the
 * Google equivalent yet.
 *
 * {@see Publisher} checks for this interface and refuses by name - "adding an ad
 * set is not implemented for google yet" - which is something a buyer can act
 * on, unlike an exception from inside a publisher.
 *
 * Everything created here is created paused, for the same reason publishing is.
 * Adding an ad set to a live campaign is the one case where the parent is
 * already spending, so an ad set that arrived active would start spending
 * immediately and without anybody approving that it should.
 */
interface AddsToLiveCampaigns
{
    /**
     * Create one more ad set under a campaign that already exists, paused.
     *
     * The ad set row carries its own targeting, schedule and budget; what it
     * does not carry it reads from its campaign. The platform id comes back onto
     * the row.
     *
     * @return array<string,mixed> what was created, as the audit record and the
     *                             rollback instruction
     */
    public function addAdSet(CampaignAdSet $adSet, string $actor): array;

    /**
     * Create more ads inside an ad set that already exists, paused.
     *
     * One creative and one ad per row, exactly as publishing does, which is why
     * these arrive as rows rather than as copy: an ad that has been written,
     * had its asset uploaded and passed the gate is the same object whether it
     * goes out with the campaign or afterwards.
     *
     * @param  Collection<int, CampaignAd>  $ads
     * @return array<string,mixed>
     */
    public function addAds(CampaignAdSet $adSet, Collection $ads, string $actor): array;
}
