TWILIO_SENDSMS::define_action()

Define and register the action by pushing it into the Automator object


Source

File: src/integrations/twilio/actions/twilio-sendsms.php

	public function define_action() {

		$number_field_args    = array(
			'option_code' => $this->action_meta,
			'input_type'  => 'text',
			'label'       => esc_attr__( 'To', 'uncanny-automator' ),
			'description' => __( 'Separate multiple phone numbers with a comma', 'uncanny-automator' ),
			'required'    => true,
			'tokens'      => true,
		);

		$body_field_args = array(
			'option_code' => 'SMSBODY',
			'input_type'  => 'textarea',
			'label'       => esc_attr__( 'Body', 'uncanny-automator' ),
			'required'    => true,
			'tokens'      => true,
			'supports_tinymce' => false
		);

		$action = array(
			'author'             => Automator()->get_author_name( $this->action_code ),
			'support_link'       => Automator()->get_author_support_link( $this->action_code, 'integration/twilio/' ),
			'is_pro'             => false,
			'requires_user'      => false,
			'integration'        => self::$integration,
			'code'               => $this->action_code,
			'sentence'           => sprintf( __( 'Send an SMS message to {{a number:%1$s}}', 'uncanny-automator' ), $this->action_meta ),
			'select_option_name' => __( 'Send an SMS message to {{a number}}', 'uncanny-automator' ),
			'priority'           => 10,
			'accepted_args'      => 1,
			'execution_function' => array( $this, 'twilio_send_sms' ),
			'options_group'      => [
				$this->action_meta => [
					Automator()->helpers->recipe->field->text( $number_field_args ),
					Automator()->helpers->recipe->field->text( $body_field_args ),
				],
			],
		);

		Automator()->register->action( $action );
	}