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