<?php
if (!defined('ABSPATH')) exit;

function asana_automator_tag_on_section_entry($config, $token, $task) {
    $tag_gid = trim($config['tag_gid'] ?? '');
    if (!$tag_gid || empty($task['gid'])) return;

    wp_remote_post("https://app.asana.com/api/1.0/tasks/{$task['gid']}/addTag", [
        'headers' => [
            'Authorization' => 'Bearer ' . $token,
            'Content-Type' => 'application/json'
        ],
        'body' => json_encode(['tag' => $tag_gid])
    ]);
}
