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\Blogger\Resource;
19
20use Google\Service\Blogger\Post;
21use Google\Service\Blogger\PostList;
22
23/**
24 * The "posts" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $bloggerService = new Google\Service\Blogger(...);
28 *   $posts = $bloggerService->posts;
29 *  </code>
30 */
31class Posts extends \Google\Service\Resource
32{
33  /**
34   * Deletes a post by blog id and post id. (posts.delete)
35   *
36   * @param string $blogId
37   * @param string $postId
38   * @param array $optParams Optional parameters.
39   */
40  public function delete($blogId, $postId, $optParams = [])
41  {
42    $params = ['blogId' => $blogId, 'postId' => $postId];
43    $params = array_merge($params, $optParams);
44    return $this->call('delete', [$params]);
45  }
46  /**
47   * Gets a post by blog id and post id (posts.get)
48   *
49   * @param string $blogId
50   * @param string $postId
51   * @param array $optParams Optional parameters.
52   *
53   * @opt_param bool fetchBody
54   * @opt_param bool fetchImages
55   * @opt_param string maxComments
56   * @opt_param string view
57   * @return Post
58   */
59  public function get($blogId, $postId, $optParams = [])
60  {
61    $params = ['blogId' => $blogId, 'postId' => $postId];
62    $params = array_merge($params, $optParams);
63    return $this->call('get', [$params], Post::class);
64  }
65  /**
66   * Gets a post by path. (posts.getByPath)
67   *
68   * @param string $blogId
69   * @param string $path
70   * @param array $optParams Optional parameters.
71   *
72   * @opt_param string maxComments
73   * @opt_param string view
74   * @return Post
75   */
76  public function getByPath($blogId, $path, $optParams = [])
77  {
78    $params = ['blogId' => $blogId, 'path' => $path];
79    $params = array_merge($params, $optParams);
80    return $this->call('getByPath', [$params], Post::class);
81  }
82  /**
83   * Inserts a post. (posts.insert)
84   *
85   * @param string $blogId
86   * @param Post $postBody
87   * @param array $optParams Optional parameters.
88   *
89   * @opt_param bool fetchBody
90   * @opt_param bool fetchImages
91   * @opt_param bool isDraft
92   * @return Post
93   */
94  public function insert($blogId, Post $postBody, $optParams = [])
95  {
96    $params = ['blogId' => $blogId, 'postBody' => $postBody];
97    $params = array_merge($params, $optParams);
98    return $this->call('insert', [$params], Post::class);
99  }
100  /**
101   * Lists posts. (posts.listPosts)
102   *
103   * @param string $blogId
104   * @param array $optParams Optional parameters.
105   *
106   * @opt_param string endDate
107   * @opt_param bool fetchBodies
108   * @opt_param bool fetchImages
109   * @opt_param string labels
110   * @opt_param string maxResults
111   * @opt_param string orderBy
112   * @opt_param string pageToken
113   * @opt_param string startDate
114   * @opt_param string status
115   * @opt_param string view
116   * @return PostList
117   */
118  public function listPosts($blogId, $optParams = [])
119  {
120    $params = ['blogId' => $blogId];
121    $params = array_merge($params, $optParams);
122    return $this->call('list', [$params], PostList::class);
123  }
124  /**
125   * Patches a post. (posts.patch)
126   *
127   * @param string $blogId
128   * @param string $postId
129   * @param Post $postBody
130   * @param array $optParams Optional parameters.
131   *
132   * @opt_param bool fetchBody
133   * @opt_param bool fetchImages
134   * @opt_param string maxComments
135   * @opt_param bool publish
136   * @opt_param bool revert
137   * @return Post
138   */
139  public function patch($blogId, $postId, Post $postBody, $optParams = [])
140  {
141    $params = ['blogId' => $blogId, 'postId' => $postId, 'postBody' => $postBody];
142    $params = array_merge($params, $optParams);
143    return $this->call('patch', [$params], Post::class);
144  }
145  /**
146   * Publishes a post. (posts.publish)
147   *
148   * @param string $blogId
149   * @param string $postId
150   * @param array $optParams Optional parameters.
151   *
152   * @opt_param string publishDate
153   * @return Post
154   */
155  public function publish($blogId, $postId, $optParams = [])
156  {
157    $params = ['blogId' => $blogId, 'postId' => $postId];
158    $params = array_merge($params, $optParams);
159    return $this->call('publish', [$params], Post::class);
160  }
161  /**
162   * Reverts a published or scheduled post to draft state. (posts.revert)
163   *
164   * @param string $blogId
165   * @param string $postId
166   * @param array $optParams Optional parameters.
167   * @return Post
168   */
169  public function revert($blogId, $postId, $optParams = [])
170  {
171    $params = ['blogId' => $blogId, 'postId' => $postId];
172    $params = array_merge($params, $optParams);
173    return $this->call('revert', [$params], Post::class);
174  }
175  /**
176   * Searches for posts matching given query terms in the specified blog.
177   * (posts.search)
178   *
179   * @param string $blogId
180   * @param string $q
181   * @param array $optParams Optional parameters.
182   *
183   * @opt_param bool fetchBodies
184   * @opt_param string orderBy
185   * @return PostList
186   */
187  public function search($blogId, $q, $optParams = [])
188  {
189    $params = ['blogId' => $blogId, 'q' => $q];
190    $params = array_merge($params, $optParams);
191    return $this->call('search', [$params], PostList::class);
192  }
193  /**
194   * Updates a post by blog id and post id. (posts.update)
195   *
196   * @param string $blogId
197   * @param string $postId
198   * @param Post $postBody
199   * @param array $optParams Optional parameters.
200   *
201   * @opt_param bool fetchBody
202   * @opt_param bool fetchImages
203   * @opt_param string maxComments
204   * @opt_param bool publish
205   * @opt_param bool revert
206   * @return Post
207   */
208  public function update($blogId, $postId, Post $postBody, $optParams = [])
209  {
210    $params = ['blogId' => $blogId, 'postId' => $postId, 'postBody' => $postBody];
211    $params = array_merge($params, $optParams);
212    return $this->call('update', [$params], Post::class);
213  }
214}
215
216// Adding a class alias for backwards compatibility with the previous class name.
217class_alias(Posts::class, 'Google_Service_Blogger_Resource_Posts');
218