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\HangoutsChat\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\HangoutsChat\Media as MediaModel;
|
---|
21 | use Google\Service\HangoutsChat\UploadAttachmentRequest;
|
---|
22 | use Google\Service\HangoutsChat\UploadAttachmentResponse;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * The "media" collection of methods.
|
---|
26 | * Typical usage is:
|
---|
27 | * <code>
|
---|
28 | * $chatService = new Google\Service\HangoutsChat(...);
|
---|
29 | * $media = $chatService->media;
|
---|
30 | * </code>
|
---|
31 | */
|
---|
32 | class Media extends \Google\Service\Resource
|
---|
33 | {
|
---|
34 | /**
|
---|
35 | * Downloads media. Download is supported on the URI
|
---|
36 | * `/v1/media/{+name}?alt=media`. (media.download)
|
---|
37 | *
|
---|
38 | * @param string $resourceName Name of the media that is being downloaded. See
|
---|
39 | * ReadRequest.resource_name.
|
---|
40 | * @param array $optParams Optional parameters.
|
---|
41 | * @return MediaModel
|
---|
42 | * @throws \Google\Service\Exception
|
---|
43 | */
|
---|
44 | public function download($resourceName, $optParams = [])
|
---|
45 | {
|
---|
46 | $params = ['resourceName' => $resourceName];
|
---|
47 | $params = array_merge($params, $optParams);
|
---|
48 | return $this->call('download', [$params], MediaModel::class);
|
---|
49 | }
|
---|
50 | /**
|
---|
51 | * Uploads an attachment. For an example, see [Upload media as a file
|
---|
52 | * attachment](https://developers.google.com/workspace/chat/upload-media-
|
---|
53 | * attachments). Requires user
|
---|
54 | * [authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
55 | * authorize-chat-user). You can upload attachments up to 200 MB. Certain file
|
---|
56 | * types aren't supported. For details, see [File types blocked by Google Chat](
|
---|
57 | * https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#F
|
---|
58 | * ile%20types%20blocked%20in%20Google%20Chat). (media.upload)
|
---|
59 | *
|
---|
60 | * @param string $parent Required. Resource name of the Chat space in which the
|
---|
61 | * attachment is uploaded. Format "spaces/{space}".
|
---|
62 | * @param UploadAttachmentRequest $postBody
|
---|
63 | * @param array $optParams Optional parameters.
|
---|
64 | * @return UploadAttachmentResponse
|
---|
65 | * @throws \Google\Service\Exception
|
---|
66 | */
|
---|
67 | public function upload($parent, UploadAttachmentRequest $postBody, $optParams = [])
|
---|
68 | {
|
---|
69 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
70 | $params = array_merge($params, $optParams);
|
---|
71 | return $this->call('upload', [$params], UploadAttachmentResponse::class);
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
76 | class_alias(Media::class, 'Google_Service_HangoutsChat_Resource_Media');
|
---|