<?php

namespace Uncanny_Automator;

class KONNECTZ_IT_SENDWEBHOOK {

	use Recipe\Actions;

	use Recipe\Webhooks;

	public function __construct() {

		$this->setup_action();
	}

	/**
	 * Setting up Webhook trigger
	 *
	 * @return void
	 */
	protected function setup_action() {

		$this->set_integration( 'KONNECTZ_IT' );

		$this->set_action_code( 'KONNECTZ_IT_SENDWEBHOOK' );

		$this->set_action_meta( 'KONNECTZ_IT_SENDWEBHOOK_META' );

		$this->set_author( 'Uncanny Automator' );

		$this->set_support_link(
			Automator()->get_author_support_link(
				$this->get_action_code(),
				'knowledge-base/send-data-to-a-webhook/?utm_source=uncanny-automator&utm_medium=in-plugin&utm_content=automator-send-data-to-webhook-help-button'
			)
		);

		$this->set_requires_user( false );

		/* translators: Action - Uncanny Automator */
		$this->set_sentence(
			sprintf(
			/* translators: Trigger sentence */
				esc_attr_x( 'Send data to KonnectzIT {{webhook:%1$s}}', 'Konnectz It', 'uncanny-automator' ),
				$this->get_action_meta()
			)
		);

		/* translators: Action - Uncanny Automator */
		$this->set_readable_sentence(
			esc_attr_x( 'Send data to KonnectzIT {{webhook}}', 'Konnectz It', 'uncanny-automator' )
		);

		$this->set_options_group(
			Automator()->send_webhook->fields->options_group(
				$this->get_action_meta()
			)
		);

		$this->set_buttons(
			Automator()->send_webhook->fields->buttons(
				$this->get_action_meta(),
				$this->get_support_link()
			)
		);

		$this->set_background_processing( true );

		$this->register_action();
	}
}
