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\YouTube\Resource;
19
20use Google\Service\YouTube\Comment;
21use Google\Service\YouTube\CommentListResponse;
22
23/**
24 * The "comments" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $youtubeService = new Google\Service\YouTube(...);
28 *   $comments = $youtubeService->comments;
29 *  </code>
30 */
31class Comments extends \Google\Service\Resource
32{
33  /**
34   * Deletes a resource. (comments.delete)
35   *
36   * @param string $id
37   * @param array $optParams Optional parameters.
38   */
39  public function delete($id, $optParams = [])
40  {
41    $params = ['id' => $id];
42    $params = array_merge($params, $optParams);
43    return $this->call('delete', [$params]);
44  }
45  /**
46   * Inserts a new resource into this collection. (comments.insert)
47   *
48   * @param string|array $part The *part* parameter identifies the properties that
49   * the API response will include. Set the parameter value to snippet. The
50   * snippet part has a quota cost of 2 units.
51   * @param Comment $postBody
52   * @param array $optParams Optional parameters.
53   * @return Comment
54   */
55  public function insert($part, Comment $postBody, $optParams = [])
56  {
57    $params = ['part' => $part, 'postBody' => $postBody];
58    $params = array_merge($params, $optParams);
59    return $this->call('insert', [$params], Comment::class);
60  }
61  /**
62   * Retrieves a list of resources, possibly filtered. (comments.listComments)
63   *
64   * @param string|array $part The *part* parameter specifies a comma-separated
65   * list of one or more comment resource properties that the API response will
66   * include.
67   * @param array $optParams Optional parameters.
68   *
69   * @opt_param string id Returns the comments with the given IDs for One
70   * Platform.
71   * @opt_param string maxResults The *maxResults* parameter specifies the maximum
72   * number of items that should be returned in the result set.
73   * @opt_param string pageToken The *pageToken* parameter identifies a specific
74   * page in the result set that should be returned. In an API response, the
75   * nextPageToken and prevPageToken properties identify other pages that could be
76   * retrieved.
77   * @opt_param string parentId Returns replies to the specified comment. Note,
78   * currently YouTube features only one level of replies (ie replies to top level
79   * comments). However replies to replies may be supported in the future.
80   * @opt_param string textFormat The requested text format for the returned
81   * comments.
82   * @return CommentListResponse
83   */
84  public function listComments($part, $optParams = [])
85  {
86    $params = ['part' => $part];
87    $params = array_merge($params, $optParams);
88    return $this->call('list', [$params], CommentListResponse::class);
89  }
90  /**
91   * Expresses the caller's opinion that one or more comments should be flagged as
92   * spam. (comments.markAsSpam)
93   *
94   * @param string|array $id Flags the comments with the given IDs as spam in the
95   * caller's opinion.
96   * @param array $optParams Optional parameters.
97   */
98  public function markAsSpam($id, $optParams = [])
99  {
100    $params = ['id' => $id];
101    $params = array_merge($params, $optParams);
102    return $this->call('markAsSpam', [$params]);
103  }
104  /**
105   * Sets the moderation status of one or more comments.
106   * (comments.setModerationStatus)
107   *
108   * @param string|array $id Modifies the moderation status of the comments with
109   * the given IDs
110   * @param string $moderationStatus Specifies the requested moderation status.
111   * Note, comments can be in statuses, which are not available through this call.
112   * For example, this call does not allow to mark a comment as 'likely spam'.
113   * Valid values: MODERATION_STATUS_PUBLISHED, MODERATION_STATUS_HELD_FOR_REVIEW,
114   * MODERATION_STATUS_REJECTED.
115   * @param array $optParams Optional parameters.
116   *
117   * @opt_param bool banAuthor If set to true the author of the comment gets added
118   * to the ban list. This means all future comments of the author will
119   * autmomatically be rejected. Only valid in combination with STATUS_REJECTED.
120   */
121  public function setModerationStatus($id, $moderationStatus, $optParams = [])
122  {
123    $params = ['id' => $id, 'moderationStatus' => $moderationStatus];
124    $params = array_merge($params, $optParams);
125    return $this->call('setModerationStatus', [$params]);
126  }
127  /**
128   * Updates an existing resource. (comments.update)
129   *
130   * @param string|array $part The *part* parameter identifies the properties that
131   * the API response will include. You must at least include the snippet part in
132   * the parameter value since that part contains all of the properties that the
133   * API request can update.
134   * @param Comment $postBody
135   * @param array $optParams Optional parameters.
136   * @return Comment
137   */
138  public function update($part, Comment $postBody, $optParams = [])
139  {
140    $params = ['part' => $part, 'postBody' => $postBody];
141    $params = array_merge($params, $optParams);
142    return $this->call('update', [$params], Comment::class);
143  }
144}
145
146// Adding a class alias for backwards compatibility with the previous class name.
147class_alias(Comments::class, 'Google_Service_YouTube_Resource_Comments');
148