Tribe__Events__Aggregator__API__Import::get( string $import_id,  $data = array() )

Gets the status (and possibly the results) of an import


Parameters

$import_id

(string) (Required) Event Aggregator import id


Top ↑

Return

(stdClass|WP_Error) A class containing the service response or a WP_Error if the service could not be reached.


Top ↑

Source

File: src/Tribe/Aggregator/API/Import.php

	public function get( $import_id, $data = array() ) {
		$response = $this->service->get_import( $import_id, $data );

		if ( is_wp_error( $response ) ) {

			/** @var WP_Error $response */
			if ( 'core:aggregator:http_request-limit' === $response->get_error_code() ) {
				$response = (object) array(
					'status'       => 'queued',
					'message_code' => 'queued',
					'message'      => tribe( 'events-aggregator.service' )->get_service_message( 'queued' ),
					'data'         => (object) array(
						'import_id' => $import_id,
					),
				);
			}

			return $response;
		}

		// let's try to use the localized version of the message if available
		if ( ! empty( $response->message_code ) ) {
			$default = ! empty( $response->message ) ? $response->message : $this->service->get_unknown_message();
			$message_args = is_array( $response->data ) ? $response->data : array();
			$response->message = $this->service->get_service_message( $response->message_code, $message_args, $default );
		}

		if ( 'success_import-complete' !== $response->message_code ) {
			return $response;
		}

		$events = array();

		foreach ( $response->data->events as $event ) {
			$events[] = $this->translate_json_to_event( $event );
		}

		return $events;
	}