Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Mail\Application\Contract; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Contract for Email Context Association Service. |
| 13 | * |
| 14 | * Automatically detects, associates, caches, and unlinks CRM records |
| 15 | * (Company, Contact, Process, Subprocess) from viewing email messages in Webmail. |
| 16 | * |
| 17 | * @package App\Modules\Mail\Application\Contract |
| 18 | */ |
| 19 | interface EmailContextAssociationServiceInterface |
| 20 | { |
| 21 | /** |
| 22 | * Resolves existing or automatically detects and links CRM associations for an email message. |
| 23 | * |
| 24 | * @param int $mailboxId Client mailbox primary key. |
| 25 | * @param string $folder Mail folder name (e.g. 'INBOX'). |
| 26 | * @param string $uid Message unique identifier. |
| 27 | * @param int $userId Authenticated user ID. |
| 28 | * @param bool $forceRefresh Whether to re-scan and re-match entities. |
| 29 | * @return array{ |
| 30 | * company: ?array{id: int, name: string, url: string}, |
| 31 | * contact: ?array{id: int, name: string, email: string, url: string}, |
| 32 | * process: ?array{id: int, type: string, name: string, url: string}, |
| 33 | * subprocess: ?array{id: int, type: string, name: string, url: string}, |
| 34 | * email_record_id: ?int, |
| 35 | * has_associations: bool |
| 36 | * } |
| 37 | */ |
| 38 | public function detectAndAssociate( |
| 39 | int $mailboxId, |
| 40 | string $folder, |
| 41 | string $uid, |
| 42 | int $userId, |
| 43 | bool $forceRefresh = false |
| 44 | ): array; |
| 45 | |
| 46 | /** |
| 47 | * Unlinks a specific CRM relation type (or all) from the email record. |
| 48 | * |
| 49 | * @param int $mailboxId Mailbox ID. |
| 50 | * @param string $folder Mail folder. |
| 51 | * @param string $uid Message UID. |
| 52 | * @param string $relationType Relation to unlink ('company', 'contact', 'process', 'subprocess', 'all'). |
| 53 | * @param int $userId Authenticated user ID. |
| 54 | * @return array{ |
| 55 | * company: ?array{id: int, name: string, url: string}, |
| 56 | * contact: ?array{id: int, name: string, email: string, url: string}, |
| 57 | * process: ?array{id: int, type: string, name: string, url: string}, |
| 58 | * subprocess: ?array{id: int, type: string, name: string, url: string}, |
| 59 | * email_record_id: ?int, |
| 60 | * has_associations: bool |
| 61 | * } |
| 62 | */ |
| 63 | public function unlinkRelation( |
| 64 | int $mailboxId, |
| 65 | string $folder, |
| 66 | string $uid, |
| 67 | string $relationType, |
| 68 | int $userId |
| 69 | ): array; |
| 70 | } |