<?php

namespace App\ImportEmailBookings\Wizzair;

class Manager extends \App\ImportEmailBookings\ManagerAbstract
{

	protected function searchAllBookingEmails( ?\Engine\DateTime $oldestEmailDate=null ) :array
	{

		if ($oldestEmailDate) {
			$searchEmailSince = $oldestEmailDate->format('d-M-Y');
		} else {
			$searchEmailSince = \Engine\DateTime::create('-1 year')->format('d-M-Y'); // if no date provided - defaults to 1 year
		}

		$return = [];

		// import EN emails
		$emailsListIds = $this->filterEmailsListIds('SUBJECT "Your travel itinerary:" SINCE "' . $searchEmailSince . '"');
		$return = $return + array_fill_keys($emailsListIds, 'V01en');

		// import RO emails
		$emailsListIds = $this->filterEmailsListIds('SUBJECT "Itinerarul călătoriei:" SINCE "' . $searchEmailSince . '"');
		$return = $return + array_fill_keys($emailsListIds, 'V01ro');

		return $return;

	}

}
