<?php

namespace SugarCalendarBookings\Integrations;

use SugarCalendarBookings\Integrations\OAuthRelay\OAuthConnectionModel;

/**
 * Webhook subscription lifecycle capability.
 *
 * Contract for integrations that own a provider-side webhook/subscription
 * resource and need to tear it down when the underlying OAuth connection
 * is removed. Implementations are resolved by provider slug via
 * {@see IntegrationCapabilityRegistry} so disconnect call-sites stay
 * provider-agnostic.
 *
 * @since 1.5.0
 */
interface WebhookSubscriptionLifecycleInterface extends IntegrationCapabilityInterface {

	/**
	 * Tear down the provider-side subscription tied to the given connection.
	 *
	 * Called immediately before the connection row is removed from the
	 * database. Implementations should treat already-gone subscriptions as
	 * success and must not throw.
	 *
	 * @since 1.5.0
	 *
	 * @param OAuthConnectionModel $connection Connection being disconnected.
	 */
	public function unregister( OAuthConnectionModel $connection ): void;
}
