[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\Draft;
|
---|
| 21 | use Google\Service\Gmail\ListDraftsResponse;
|
---|
| 22 | use Google\Service\Gmail\Message;
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * The "drafts" collection of methods.
|
---|
| 26 | * Typical usage is:
|
---|
| 27 | * <code>
|
---|
| 28 | * $gmailService = new Google\Service\Gmail(...);
|
---|
| 29 | * $drafts = $gmailService->users_drafts;
|
---|
| 30 | * </code>
|
---|
| 31 | */
|
---|
| 32 | class UsersDrafts extends \Google\Service\Resource
|
---|
| 33 | {
|
---|
| 34 | /**
|
---|
| 35 | * Creates a new draft with the `DRAFT` label. (drafts.create)
|
---|
| 36 | *
|
---|
| 37 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 38 | * used to indicate the authenticated user.
|
---|
| 39 | * @param Draft $postBody
|
---|
| 40 | * @param array $optParams Optional parameters.
|
---|
| 41 | * @return Draft
|
---|
| 42 | * @throws \Google\Service\Exception
|
---|
| 43 | */
|
---|
| 44 | public function create($userId, Draft $postBody, $optParams = [])
|
---|
| 45 | {
|
---|
| 46 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 47 | $params = array_merge($params, $optParams);
|
---|
| 48 | return $this->call('create', [$params], Draft::class);
|
---|
| 49 | }
|
---|
| 50 | /**
|
---|
| 51 | * Immediately and permanently deletes the specified draft. Does not simply
|
---|
| 52 | * trash it. (drafts.delete)
|
---|
| 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 string $id The ID of the draft to delete.
|
---|
| 57 | * @param array $optParams Optional parameters.
|
---|
| 58 | * @throws \Google\Service\Exception
|
---|
| 59 | */
|
---|
| 60 | public function delete($userId, $id, $optParams = [])
|
---|
| 61 | {
|
---|
| 62 | $params = ['userId' => $userId, 'id' => $id];
|
---|
| 63 | $params = array_merge($params, $optParams);
|
---|
| 64 | return $this->call('delete', [$params]);
|
---|
| 65 | }
|
---|
| 66 | /**
|
---|
| 67 | * Gets the specified draft. (drafts.get)
|
---|
| 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 draft to retrieve.
|
---|
| 72 | * @param array $optParams Optional parameters.
|
---|
| 73 | *
|
---|
| 74 | * @opt_param string format The format to return the draft in.
|
---|
| 75 | * @return Draft
|
---|
| 76 | * @throws \Google\Service\Exception
|
---|
| 77 | */
|
---|
| 78 | public function get($userId, $id, $optParams = [])
|
---|
| 79 | {
|
---|
| 80 | $params = ['userId' => $userId, 'id' => $id];
|
---|
| 81 | $params = array_merge($params, $optParams);
|
---|
| 82 | return $this->call('get', [$params], Draft::class);
|
---|
| 83 | }
|
---|
| 84 | /**
|
---|
| 85 | * Lists the drafts in the user's mailbox. (drafts.listUsersDrafts)
|
---|
| 86 | *
|
---|
| 87 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 88 | * used to indicate the authenticated user.
|
---|
| 89 | * @param array $optParams Optional parameters.
|
---|
| 90 | *
|
---|
| 91 | * @opt_param bool includeSpamTrash Include drafts from `SPAM` and `TRASH` in
|
---|
| 92 | * the results.
|
---|
| 93 | * @opt_param string maxResults Maximum number of drafts to return. This field
|
---|
| 94 | * defaults to 100. The maximum allowed value for this field is 500.
|
---|
| 95 | * @opt_param string pageToken Page token to retrieve a specific page of results
|
---|
| 96 | * in the list.
|
---|
| 97 | * @opt_param string q Only return draft messages matching the specified query.
|
---|
| 98 | * Supports the same query format as the Gmail search box. For example,
|
---|
| 99 | * `"from:someuser@example.com rfc822msgid: is:unread"`.
|
---|
| 100 | * @return ListDraftsResponse
|
---|
| 101 | * @throws \Google\Service\Exception
|
---|
| 102 | */
|
---|
| 103 | public function listUsersDrafts($userId, $optParams = [])
|
---|
| 104 | {
|
---|
| 105 | $params = ['userId' => $userId];
|
---|
| 106 | $params = array_merge($params, $optParams);
|
---|
| 107 | return $this->call('list', [$params], ListDraftsResponse::class);
|
---|
| 108 | }
|
---|
| 109 | /**
|
---|
| 110 | * Sends the specified, existing draft to the recipients in the `To`, `Cc`, and
|
---|
| 111 | * `Bcc` headers. (drafts.send)
|
---|
| 112 | *
|
---|
| 113 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 114 | * used to indicate the authenticated user.
|
---|
| 115 | * @param Draft $postBody
|
---|
| 116 | * @param array $optParams Optional parameters.
|
---|
| 117 | * @return Message
|
---|
| 118 | * @throws \Google\Service\Exception
|
---|
| 119 | */
|
---|
| 120 | public function send($userId, Draft $postBody, $optParams = [])
|
---|
| 121 | {
|
---|
| 122 | $params = ['userId' => $userId, 'postBody' => $postBody];
|
---|
| 123 | $params = array_merge($params, $optParams);
|
---|
| 124 | return $this->call('send', [$params], Message::class);
|
---|
| 125 | }
|
---|
| 126 | /**
|
---|
| 127 | * Replaces a draft's content. (drafts.update)
|
---|
| 128 | *
|
---|
| 129 | * @param string $userId The user's email address. The special value `me` can be
|
---|
| 130 | * used to indicate the authenticated user.
|
---|
| 131 | * @param string $id The ID of the draft to update.
|
---|
| 132 | * @param Draft $postBody
|
---|
| 133 | * @param array $optParams Optional parameters.
|
---|
| 134 | * @return Draft
|
---|
| 135 | * @throws \Google\Service\Exception
|
---|
| 136 | */
|
---|
| 137 | public function update($userId, $id, Draft $postBody, $optParams = [])
|
---|
| 138 | {
|
---|
| 139 | $params = ['userId' => $userId, 'id' => $id, 'postBody' => $postBody];
|
---|
| 140 | $params = array_merge($params, $optParams);
|
---|
| 141 | return $this->call('update', [$params], Draft::class);
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 146 | class_alias(UsersDrafts::class, 'Google_Service_Gmail_Resource_UsersDrafts');
|
---|