1<?php 2 3declare(strict_types=1); 4 5/** 6 * @author Kristian Lebold <kristian@lebold.info> 7 * 8 * Mail 9 * 10 * This code is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Affero General Public License, version 3, 12 * as published by the Free Software Foundation. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Affero General Public License for more details. 18 * 19 * You should have received a copy of the GNU Affero General Public License, version 3, 20 * along with this program. If not, see <http://www.gnu.org/licenses/> 21 * 22 */ 23 24namespace OCA\Mail\Service\ContactIntegration; 25 26use OCA\Mail\Service\ContactsIntegration; 27 28class ContactIntegrationService { 29 30 /** @var ContactsIntegration */ 31 private $contactsIntegration; 32 33 public function __construct(ContactsIntegration $ci) { 34 $this->contactsIntegration = $ci; 35 } 36 37 public function findMatches(string $mail): array { 38 $matches = $this->contactsIntegration->getContactsWithMail($mail); 39 return $matches; 40 } 41 42 public function addEMailToContact(string $uid, string $mail): ?array { 43 return $this->contactsIntegration->addEmailToContact($uid, $mail); 44 } 45 46 public function newContact(string $name, string $mail): ?array { 47 return $this->contactsIntegration->newContact($name, $mail); 48 } 49 50 public function autoComplete(string $term): array { 51 return $this->contactsIntegration->getContactsWithName($term); 52 } 53} 54