Google_Calendar_Helpers::get_user_info()

Method get_user_info.


Return Return

(array) The user info.


Source Source

File: src/integrations/google-calendar/helpers/google-calendar-helpers.php

	public function get_user_info() {

		$user_info = array(
			'avatar_uri' => '',
			'name'       => '',
			'email'      => '',
		);

		$transient_key = 'automator_google_calendar_user_info';

		$saved_user_info = get_transient( $transient_key );

		if ( false !== $saved_user_info ) {

			return $saved_user_info;

		}

		try {

			$user = $this->api_user_info();

			if ( empty( $user['data'] ) ) {
				return $user_info;
			}

			$user_info['name'] = $user['data']['name'];

			$user_info['avatar_uri'] = $user['data']['picture'];

			$user_info['email'] = $user['data']['email'];

			set_transient( $transient_key, $user_info, DAY_IN_SECONDS );

		} catch ( \Exception $e ) {

			return $user_info;

		}

		return $user_info;
	}