<?php

namespace App\Campaigns\Manager\Editing;

use App\Models\Campaign;
use App\Models\CampaignPlatformEntity;

/**
 * Sends one approved patch to one platform object.
 *
 * Only the fields in the patch are sent, by their platform names. A writer
 * never posts the stored settings snapshot back, because that snapshot is a
 * projection of what was read and not a body any platform will accept.
 */
interface EntityWriter
{
    /**
     * @param  array<string, mixed>  $patch  manager field names to new values
     */
    public function write(Campaign $campaign, CampaignPlatformEntity $entity, array $patch, string $actor): void;

    /**
     * What this object has spent and shown over its whole life, read now.
     *
     * @return array{spend: float, impressions: int}
     */
    public function delivery(Campaign $campaign, CampaignPlatformEntity $entity, string $actor): array;

    /**
     * Remove the object from the platform.
     *
     * @return bool true when it is gone, false when the platform only marked it for deletion
     */
    public function delete(Campaign $campaign, CampaignPlatformEntity $entity, string $actor): bool;

    /**
     * Make a paused copy beside the object, under the same parent.
     *
     * @return string the copy's platform id
     */
    public function duplicate(Campaign $campaign, CampaignPlatformEntity $entity, string $actor): string;
}
