From f51fbfa43ee1c3226ca523ed613a59423fceaaff Mon Sep 17 00:00:00 2001 From: Mohamed Radwan Date: Tue, 21 Feb 2023 17:20:48 +0200 Subject: [PATCH 1/2] adding snipping attribute to mail --- src/Services/Message/Mail.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Services/Message/Mail.php b/src/Services/Message/Mail.php index 34dbdc6..bd2b8a4 100644 --- a/src/Services/Message/Mail.php +++ b/src/Services/Message/Mail.php @@ -71,6 +71,11 @@ class Mail extends GmailConnection public $parts; + /** + * @var + */ + public $snippet; + /** * @var Google_Service_Gmail */ @@ -130,6 +135,7 @@ protected function setMessage(\Google_Service_Gmail_Message $message) $this->threadId = $message->getThreadId(); $this->historyId = $message->getHistoryId(); $this->payload = $message->getPayload(); + $this->snippet = $message->getSnippet(); if ($this->payload) { $this->parts = collect($this->payload->getParts()); } @@ -231,6 +237,18 @@ public function getReplyTo() return $this->getFrom($replyTo ? $replyTo : $this->getHeader('From')); } + /** + * Returns the Snippet from the email + * + * @return string + */ + public function getSnippet() + { + + + return $this->snippet; + } + /** * Returns array of name and email of each recipient * @@ -407,7 +425,6 @@ public function getPlainTextBody($raw = false) public function getBody($type = 'text/plain') { $parts = $this->getAllParts($this->parts); - try { if (!$parts->isEmpty()) { foreach ($parts as $part) { From f4af7e957c29dc580a613ff3b621973c4b781430 Mon Sep 17 00:00:00 2001 From: Mohamed Radwan Date: Tue, 21 Feb 2023 19:42:42 +0200 Subject: [PATCH 2/2] added getLabel to HasLabel Trait --- src/Traits/HasLabels.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Traits/HasLabels.php b/src/Traits/HasLabels.php index b4e40f5..1df36ea 100644 --- a/src/Traits/HasLabels.php +++ b/src/Traits/HasLabels.php @@ -56,4 +56,18 @@ public function firstOrCreateLabel($userEmail, $newLabel) return $service->users_labels->create($userEmail, $newLabel); } + + /** + * List the labels in the user's mailbox. + * + * @param $userEmail + * + * @return \Google\Service\Gmail\Label + */ + public function getLabel($userEmail, $id) + { + $service = new Google_Service_Gmail($this); + + return $service->users_labels->get($userEmail, $id); + } } \ No newline at end of file