GCALENDAR_REMOVEATTENDEE::process_action( int $user_id, array $action_data, int $recipe_id, array $args,  $parsed )

Process the action.


Parameters Parameters

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)

$args

(Required)

$parsed

(Required)


Top ↑

Return Return

(Uncanny_Automatorvoid.)


Source Source

File: src/integrations/google-calendar/actions/gcalendar-removeattendee.php

	protected function process_action( $user_id, $action_data, $recipe_id, $args, $parsed ) {

		$calendar_id    = isset( $parsed[ $this->get_formatted_code( 'calendar_id' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'calendar_id' ) ] ) : null;
		$event_id       = isset( $parsed[ $this->get_formatted_code( 'event_id' ) ] ) ? sanitize_text_field( $parsed[ $this->get_formatted_code( 'event_id' ) ] ) : null;
		$attendee_email = isset( $parsed[ $this->get_action_meta() ] ) ? sanitize_text_field( $parsed[ $this->get_action_meta() ] ) : null;

		$helper = Automator()->helpers->recipe->google_calendar->options;

		try {

			$body = array(
				'access_token'   => $helper->get_client(),
				'action'         => 'remove_attendee',
				'calendar_id'    => $calendar_id,
				'event_id'       => $event_id,
				'attendee_email' => $attendee_email,
			);

			$helper->api_call( $body, $action_data );

			Automator()->complete->action( $user_id, $action_data, $recipe_id );

		} catch ( \Exception $e ) {

			$action_data['complete_with_errors'] = true;

			Automator()->complete->action( $user_id, $action_data, $recipe_id, $e->getMessage() );

		}

		return true;

	}