[e3d4e0a] | 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 |
|
---|
| 18 | namespace Google\Service\Gmail\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Gmail\BatchDeleteMessagesRequest;
|
---|
| 21 | use Google\Service\Gmail\BatchModifyMessagesRequest;
|
---|
| 22 | use Google\Service\Gmail\ListMessagesResponse;
|
---|
| 23 | use Google\Service\Gmail\Message;
|
---|
| 24 | use 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->users_messages;
|
---|
| 32 | * </code>
|
---|
| 33 | */
|
---|
| 34 | class 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 | * @throws \Google\Service\Exception
|
---|
| 45 | */
|
---|
| 46 | public function batchDelete($userId, BatchDeleteMessagesRequest $postBody, $optParams = [])
|
---|
| 47 | {
|
---|
| 48 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 49 | $params = array_merge($params, $optParams);
|
---|
| 50 | return $this->call('batchDelete', [$params]);
|
---|
| 51 | }
|
---|
| 52 | /**
|
---|
| 53 | * Modifies the labels on the specified messages. (messages.batchModify)
|
---|
| 54 | *
|
---|
| 55 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 56 | * used to indicate the authenticated user.
|
---|
| 57 | * @param BatchModifyMessagesRequest $postBody
|
---|
| 58 | * @param array $optParams Optional parameters.
|
---|
| 59 | * @throws \Google\Service\Exception
|
---|
| 60 | */
|
---|
| 61 | public function batchModify($userId, BatchModifyMessagesRequest $postBody, $optParams = [])
|
---|
| 62 | {
|
---|
| 63 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 64 | $params = array_merge($params, $optParams);
|
---|
| 65 | return $this->call('batchModify', [$params]);
|
---|
| 66 | }
|
---|
| 67 | /**
|
---|
| 68 | * Immediately and permanently deletes the specified message. This operation
|
---|
| 69 | * cannot be undone. Prefer `messages.trash` instead. (messages.delete)
|
---|
| 70 | *
|
---|
| 71 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 72 | * used to indicate the authenticated user.
|
---|
| 73 | * @param string $id The ID of the message to delete.
|
---|
| 74 | * @param array $optParams Optional parameters.
|
---|
| 75 | * @throws \Google\Service\Exception
|
---|
| 76 | */
|
---|
| 77 | public function delete($userId, $id, $optParams = [])
|
---|
| 78 | {
|
---|
| 79 | $params = ['userId' => $userId, 'id' => $id];
|
---|
| 80 | $params = array_merge($params, $optParams);
|
---|
| 81 | return $this->call('delete', [$params]);
|
---|
| 82 | }
|
---|
| 83 | /**
|
---|
| 84 | * Gets the specified message. (messages.get)
|
---|
| 85 | *
|
---|
| 86 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 87 | * used to indicate the authenticated user.
|
---|
| 88 | * @param string $id The ID of the message to retrieve. This ID is usually
|
---|
| 89 | * retrieved using `messages.list`. The ID is also contained in the result when
|
---|
| 90 | * a message is inserted (`messages.insert`) or imported (`messages.import`).
|
---|
| 91 | * @param array $optParams Optional parameters.
|
---|
| 92 | *
|
---|
| 93 | * @opt_param string format The format to return the message in.
|
---|
| 94 | * @opt_param string metadataHeaders When given and format is `METADATA`, only
|
---|
| 95 | * include headers specified.
|
---|
| 96 | * @return Message
|
---|
| 97 | * @throws \Google\Service\Exception
|
---|
| 98 | */
|
---|
| 99 | public function get($userId, $id, $optParams = [])
|
---|
| 100 | {
|
---|
| 101 | $params = ['userId' => $userId, 'id' => $id];
|
---|
| 102 | $params = array_merge($params, $optParams);
|
---|
| 103 | return $this->call('get', [$params], Message::class);
|
---|
| 104 | }
|
---|
| 105 | /**
|
---|
| 106 | * Imports a message into only this user's mailbox, with standard email delivery
|
---|
| 107 | * scanning and classification similar to receiving via SMTP. This method
|
---|
| 108 | * doesn't perform SPF checks, so it might not work for some spam messages, such
|
---|
| 109 | * as those attempting to perform domain spoofing. This method does not send a
|
---|
| 110 | * message. (messages.import)
|
---|
| 111 | *
|
---|
| 112 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 113 | * used to indicate the authenticated user.
|
---|
| 114 | * @param Message $postBody
|
---|
| 115 | * @param array $optParams Optional parameters.
|
---|
| 116 | *
|
---|
| 117 | * @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and
|
---|
| 118 | * only visible in Google Vault to a Vault administrator. Only used for Google
|
---|
| 119 | * Workspace accounts.
|
---|
| 120 | * @opt_param string internalDateSource Source for Gmail's internal date of the
|
---|
| 121 | * message.
|
---|
| 122 | * @opt_param bool neverMarkSpam Ignore the Gmail spam classifier decision and
|
---|
| 123 | * never mark this email as SPAM in the mailbox.
|
---|
| 124 | * @opt_param bool processForCalendar Process calendar invites in the email and
|
---|
| 125 | * add any extracted meetings to the Google Calendar for this user.
|
---|
| 126 | * @return Message
|
---|
| 127 | * @throws \Google\Service\Exception
|
---|
| 128 | */
|
---|
| 129 | public function import($userId, Message $postBody, $optParams = [])
|
---|
| 130 | {
|
---|
| 131 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 132 | $params = array_merge($params, $optParams);
|
---|
| 133 | return $this->call('import', [$params], Message::class);
|
---|
| 134 | }
|
---|
| 135 | /**
|
---|
| 136 | * Directly inserts a message into only this user's mailbox similar to `IMAP
|
---|
| 137 | * APPEND`, bypassing most scanning and classification. Does not send a message.
|
---|
| 138 | * (messages.insert)
|
---|
| 139 | *
|
---|
| 140 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 141 | * used to indicate the authenticated user.
|
---|
| 142 | * @param Message $postBody
|
---|
| 143 | * @param array $optParams Optional parameters.
|
---|
| 144 | *
|
---|
| 145 | * @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and
|
---|
| 146 | * only visible in Google Vault to a Vault administrator. Only used for Google
|
---|
| 147 | * Workspace accounts.
|
---|
| 148 | * @opt_param string internalDateSource Source for Gmail's internal date of the
|
---|
| 149 | * message.
|
---|
| 150 | * @return Message
|
---|
| 151 | * @throws \Google\Service\Exception
|
---|
| 152 | */
|
---|
| 153 | public function insert($userId, Message $postBody, $optParams = [])
|
---|
| 154 | {
|
---|
| 155 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 156 | $params = array_merge($params, $optParams);
|
---|
| 157 | return $this->call('insert', [$params], Message::class);
|
---|
| 158 | }
|
---|
| 159 | /**
|
---|
| 160 | * Lists the messages in the user's mailbox. (messages.listUsersMessages)
|
---|
| 161 | *
|
---|
| 162 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 163 | * used to indicate the authenticated user.
|
---|
| 164 | * @param array $optParams Optional parameters.
|
---|
| 165 | *
|
---|
| 166 | * @opt_param bool includeSpamTrash Include messages from `SPAM` and `TRASH` in
|
---|
| 167 | * the results.
|
---|
| 168 | * @opt_param string labelIds Only return messages with labels that match all of
|
---|
| 169 | * the specified label IDs. Messages in a thread might have labels that other
|
---|
| 170 | * messages in the same thread don't have. To learn more, see [Manage labels on
|
---|
| 171 | * messages and threads](https://developers.google.com/gmail/api/guides/labels#m
|
---|
| 172 | * anage_labels_on_messages_threads).
|
---|
| 173 | * @opt_param string maxResults Maximum number of messages to return. This field
|
---|
| 174 | * defaults to 100. The maximum allowed value for this field is 500.
|
---|
| 175 | * @opt_param string pageToken Page token to retrieve a specific page of results
|
---|
| 176 | * in the list.
|
---|
| 177 | * @opt_param string q Only return messages matching the specified query.
|
---|
| 178 | * Supports the same query format as the Gmail search box. For example,
|
---|
| 179 | * `"from:someuser@example.com rfc822msgid: is:unread"`. Parameter cannot be
|
---|
| 180 | * used when accessing the api using the gmail.metadata scope.
|
---|
| 181 | * @return ListMessagesResponse
|
---|
| 182 | * @throws \Google\Service\Exception
|
---|
| 183 | */
|
---|
| 184 | public function listUsersMessages($userId, $optParams = [])
|
---|
| 185 | {
|
---|
| 186 | $params = ['userId' => $userId];
|
---|
| 187 | $params = array_merge($params, $optParams);
|
---|
| 188 | return $this->call('list', [$params], ListMessagesResponse::class);
|
---|
| 189 | }
|
---|
| 190 | /**
|
---|
| 191 | * Modifies the labels on the specified message. (messages.modify)
|
---|
| 192 | *
|
---|
| 193 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 194 | * used to indicate the authenticated user.
|
---|
| 195 | * @param string $id The ID of the message to modify.
|
---|
| 196 | * @param ModifyMessageRequest $postBody
|
---|
| 197 | * @param array $optParams Optional parameters.
|
---|
| 198 | * @return Message
|
---|
| 199 | * @throws \Google\Service\Exception
|
---|
| 200 | */
|
---|
| 201 | public function modify($userId, $id, ModifyMessageRequest $postBody, $optParams = [])
|
---|
| 202 | {
|
---|
| 203 | $params = ['userId' => $userId, 'id' => $id, 'postBody' => $postBody];
|
---|
| 204 | $params = array_merge($params, $optParams);
|
---|
| 205 | return $this->call('modify', [$params], Message::class);
|
---|
| 206 | }
|
---|
| 207 | /**
|
---|
| 208 | * Sends the specified message to the recipients in the `To`, `Cc`, and `Bcc`
|
---|
| 209 | * headers. For example usage, see [Sending
|
---|
| 210 | * email](https://developers.google.com/gmail/api/guides/sending).
|
---|
| 211 | * (messages.send)
|
---|
| 212 | *
|
---|
| 213 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 214 | * used to indicate the authenticated user.
|
---|
| 215 | * @param Message $postBody
|
---|
| 216 | * @param array $optParams Optional parameters.
|
---|
| 217 | * @return Message
|
---|
| 218 | * @throws \Google\Service\Exception
|
---|
| 219 | */
|
---|
| 220 | public function send($userId, Message $postBody, $optParams = [])
|
---|
| 221 | {
|
---|
| 222 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 223 | $params = array_merge($params, $optParams);
|
---|
| 224 | return $this->call('send', [$params], Message::class);
|
---|
| 225 | }
|
---|
| 226 | /**
|
---|
| 227 | * Moves the specified message to the trash. (messages.trash)
|
---|
| 228 | *
|
---|
| 229 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 230 | * used to indicate the authenticated user.
|
---|
| 231 | * @param string $id The ID of the message to Trash.
|
---|
| 232 | * @param array $optParams Optional parameters.
|
---|
| 233 | * @return Message
|
---|
| 234 | * @throws \Google\Service\Exception
|
---|
| 235 | */
|
---|
| 236 | public function trash($userId, $id, $optParams = [])
|
---|
| 237 | {
|
---|
| 238 | $params = ['userId' => $userId, 'id' => $id];
|
---|
| 239 | $params = array_merge($params, $optParams);
|
---|
| 240 | return $this->call('trash', [$params], Message::class);
|
---|
| 241 | }
|
---|
| 242 | /**
|
---|
| 243 | * Removes the specified message from the trash. (messages.untrash)
|
---|
| 244 | *
|
---|
| 245 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 246 | * used to indicate the authenticated user.
|
---|
| 247 | * @param string $id The ID of the message to remove from Trash.
|
---|
| 248 | * @param array $optParams Optional parameters.
|
---|
| 249 | * @return Message
|
---|
| 250 | * @throws \Google\Service\Exception
|
---|
| 251 | */
|
---|
| 252 | public function untrash($userId, $id, $optParams = [])
|
---|
| 253 | {
|
---|
| 254 | $params = ['userId' => $userId, 'id' => $id];
|
---|
| 255 | $params = array_merge($params, $optParams);
|
---|
| 256 | return $this->call('untrash', [$params], Message::class);
|
---|
| 257 | }
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 261 | class_alias(UsersMessages::class, 'Google_Service_Gmail_Resource_UsersMessages');
|
---|