1<?php 2/* 3 * Copyright 2014 Google Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 * use this file except in compliance with the License. You may obtain a copy of 7 * the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18namespace Google\Service\Gmail\Resource; 19 20use Google\Service\Gmail\BatchDeleteMessagesRequest; 21use Google\Service\Gmail\BatchModifyMessagesRequest; 22use Google\Service\Gmail\ListMessagesResponse; 23use Google\Service\Gmail\Message; 24use Google\Service\Gmail\ModifyMessageRequest; 25 26/** 27 * The "messages" collection of methods. 28 * Typical usage is: 29 * <code> 30 * $gmailService = new Google\Service\Gmail(...); 31 * $messages = $gmailService->messages; 32 * </code> 33 */ 34class UsersMessages extends \Google\Service\Resource 35{ 36 /** 37 * Deletes many messages by message ID. Provides no guarantees that messages 38 * were not already deleted or even existed at all. (messages.batchDelete) 39 * 40 * @param string $userId The user's email address. The special value `me` can be 41 * used to indicate the authenticated user. 42 * @param BatchDeleteMessagesRequest $postBody 43 * @param array $optParams Optional parameters. 44 */ 45 public function batchDelete($userId, BatchDeleteMessagesRequest $postBody, $optParams = []) 46 { 47 $params = ['userId' => $userId, 'postBody' => $postBody]; 48 $params = array_merge($params, $optParams); 49 return $this->call('batchDelete', [$params]); 50 } 51 /** 52 * Modifies the labels on the specified messages. (messages.batchModify) 53 * 54 * @param string $userId The user's email address. The special value `me` can be 55 * used to indicate the authenticated user. 56 * @param BatchModifyMessagesRequest $postBody 57 * @param array $optParams Optional parameters. 58 */ 59 public function batchModify($userId, BatchModifyMessagesRequest $postBody, $optParams = []) 60 { 61 $params = ['userId' => $userId, 'postBody' => $postBody]; 62 $params = array_merge($params, $optParams); 63 return $this->call('batchModify', [$params]); 64 } 65 /** 66 * Immediately and permanently deletes the specified message. This operation 67 * cannot be undone. Prefer `messages.trash` instead. (messages.delete) 68 * 69 * @param string $userId The user's email address. The special value `me` can be 70 * used to indicate the authenticated user. 71 * @param string $id The ID of the message to delete. 72 * @param array $optParams Optional parameters. 73 */ 74 public function delete($userId, $id, $optParams = []) 75 { 76 $params = ['userId' => $userId, 'id' => $id]; 77 $params = array_merge($params, $optParams); 78 return $this->call('delete', [$params]); 79 } 80 /** 81 * Gets the specified message. (messages.get) 82 * 83 * @param string $userId The user's email address. The special value `me` can be 84 * used to indicate the authenticated user. 85 * @param string $id The ID of the message to retrieve. This ID is usually 86 * retrieved using `messages.list`. The ID is also contained in the result when 87 * a message is inserted (`messages.insert`) or imported (`messages.import`). 88 * @param array $optParams Optional parameters. 89 * 90 * @opt_param string format The format to return the message in. 91 * @opt_param string metadataHeaders When given and format is `METADATA`, only 92 * include headers specified. 93 * @return Message 94 */ 95 public function get($userId, $id, $optParams = []) 96 { 97 $params = ['userId' => $userId, 'id' => $id]; 98 $params = array_merge($params, $optParams); 99 return $this->call('get', [$params], Message::class); 100 } 101 /** 102 * Imports a message into only this user's mailbox, with standard email delivery 103 * scanning and classification similar to receiving via SMTP. This method 104 * doesn't perform SPF checks, so it might not work for some spam messages, such 105 * as those attempting to perform domain spoofing. This method does not send a 106 * message. Note: This function doesn't trigger forwarding rules or filters set 107 * up by the user. (messages.import) 108 * 109 * @param string $userId The user's email address. The special value `me` can be 110 * used to indicate the authenticated user. 111 * @param Message $postBody 112 * @param array $optParams Optional parameters. 113 * 114 * @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and 115 * only visible in Google Vault to a Vault administrator. Only used for G Suite 116 * accounts. 117 * @opt_param string internalDateSource Source for Gmail's internal date of the 118 * message. 119 * @opt_param bool neverMarkSpam Ignore the Gmail spam classifier decision and 120 * never mark this email as SPAM in the mailbox. 121 * @opt_param bool processForCalendar Process calendar invites in the email and 122 * add any extracted meetings to the Google Calendar for this user. 123 * @return Message 124 */ 125 public function import($userId, Message $postBody, $optParams = []) 126 { 127 $params = ['userId' => $userId, 'postBody' => $postBody]; 128 $params = array_merge($params, $optParams); 129 return $this->call('import', [$params], Message::class); 130 } 131 /** 132 * Directly inserts a message into only this user's mailbox similar to `IMAP 133 * APPEND`, bypassing most scanning and classification. Does not send a message. 134 * (messages.insert) 135 * 136 * @param string $userId The user's email address. The special value `me` can be 137 * used to indicate the authenticated user. 138 * @param Message $postBody 139 * @param array $optParams Optional parameters. 140 * 141 * @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and 142 * only visible in Google Vault to a Vault administrator. Only used for G Suite 143 * accounts. 144 * @opt_param string internalDateSource Source for Gmail's internal date of the 145 * message. 146 * @return Message 147 */ 148 public function insert($userId, Message $postBody, $optParams = []) 149 { 150 $params = ['userId' => $userId, 'postBody' => $postBody]; 151 $params = array_merge($params, $optParams); 152 return $this->call('insert', [$params], Message::class); 153 } 154 /** 155 * Lists the messages in the user's mailbox. (messages.listUsersMessages) 156 * 157 * @param string $userId The user's email address. The special value `me` can be 158 * used to indicate the authenticated user. 159 * @param array $optParams Optional parameters. 160 * 161 * @opt_param bool includeSpamTrash Include messages from `SPAM` and `TRASH` in 162 * the results. 163 * @opt_param string labelIds Only return messages with labels that match all of 164 * the specified label IDs. 165 * @opt_param string maxResults Maximum number of messages to return. This field 166 * defaults to 100. The maximum allowed value for this field is 500. 167 * @opt_param string pageToken Page token to retrieve a specific page of results 168 * in the list. 169 * @opt_param string q Only return messages matching the specified query. 170 * Supports the same query format as the Gmail search box. For example, 171 * `"from:someuser@example.com rfc822msgid: is:unread"`. Parameter cannot be 172 * used when accessing the api using the gmail.metadata scope. 173 * @return ListMessagesResponse 174 */ 175 public function listUsersMessages($userId, $optParams = []) 176 { 177 $params = ['userId' => $userId]; 178 $params = array_merge($params, $optParams); 179 return $this->call('list', [$params], ListMessagesResponse::class); 180 } 181 /** 182 * Modifies the labels on the specified message. (messages.modify) 183 * 184 * @param string $userId The user's email address. The special value `me` can be 185 * used to indicate the authenticated user. 186 * @param string $id The ID of the message to modify. 187 * @param ModifyMessageRequest $postBody 188 * @param array $optParams Optional parameters. 189 * @return Message 190 */ 191 public function modify($userId, $id, ModifyMessageRequest $postBody, $optParams = []) 192 { 193 $params = ['userId' => $userId, 'id' => $id, 'postBody' => $postBody]; 194 $params = array_merge($params, $optParams); 195 return $this->call('modify', [$params], Message::class); 196 } 197 /** 198 * Sends the specified message to the recipients in the `To`, `Cc`, and `Bcc` 199 * headers. (messages.send) 200 * 201 * @param string $userId The user's email address. The special value `me` can be 202 * used to indicate the authenticated user. 203 * @param Message $postBody 204 * @param array $optParams Optional parameters. 205 * @return Message 206 */ 207 public function send($userId, Message $postBody, $optParams = []) 208 { 209 $params = ['userId' => $userId, 'postBody' => $postBody]; 210 $params = array_merge($params, $optParams); 211 return $this->call('send', [$params], Message::class); 212 } 213 /** 214 * Moves the specified message to the trash. (messages.trash) 215 * 216 * @param string $userId The user's email address. The special value `me` can be 217 * used to indicate the authenticated user. 218 * @param string $id The ID of the message to Trash. 219 * @param array $optParams Optional parameters. 220 * @return Message 221 */ 222 public function trash($userId, $id, $optParams = []) 223 { 224 $params = ['userId' => $userId, 'id' => $id]; 225 $params = array_merge($params, $optParams); 226 return $this->call('trash', [$params], Message::class); 227 } 228 /** 229 * Removes the specified message from the trash. (messages.untrash) 230 * 231 * @param string $userId The user's email address. The special value `me` can be 232 * used to indicate the authenticated user. 233 * @param string $id The ID of the message to remove from Trash. 234 * @param array $optParams Optional parameters. 235 * @return Message 236 */ 237 public function untrash($userId, $id, $optParams = []) 238 { 239 $params = ['userId' => $userId, 'id' => $id]; 240 $params = array_merge($params, $optParams); 241 return $this->call('untrash', [$params], Message::class); 242 } 243} 244 245// Adding a class alias for backwards compatibility with the previous class name. 246class_alias(UsersMessages::class, 'Google_Service_Gmail_Resource_UsersMessages'); 247