| @@ 86-99 (lines=14) @@ | ||
| 83 | * |
|
| 84 | * @return StreamInterface |
|
| 85 | */ |
|
| 86 | public function getFile(string $fileId) |
|
| 87 | { |
|
| 88 | if (empty($fileId)) { |
|
| 89 | throw new InvalidArgumentException('FileID can not be empty'); |
|
| 90 | } |
|
| 91 | ||
| 92 | $response = $this->httpGet(sprintf('/files/%s', $fileId)); |
|
| 93 | ||
| 94 | if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { |
|
| 95 | $this->handleErrors($response); |
|
| 96 | } |
|
| 97 | ||
| 98 | return $response->getBody(); |
|
| 99 | } |
|
| 100 | ||
| 101 | /** |
|
| 102 | * Gets a public link for a file that can be accessed without logging into Mattermost. |
|
| @@ 108-121 (lines=14) @@ | ||
| 105 | * |
|
| 106 | * @return string |
|
| 107 | */ |
|
| 108 | public function getFileLink(string $fileId) |
|
| 109 | { |
|
| 110 | if (empty($fileId)) { |
|
| 111 | throw new InvalidArgumentException('FileID can not be empty'); |
|
| 112 | } |
|
| 113 | ||
| 114 | $response = $this->httpGet(sprintf('/files/%s/link', $fileId)); |
|
| 115 | ||
| 116 | if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { |
|
| 117 | $this->handleErrors($response); |
|
| 118 | } |
|
| 119 | ||
| 120 | return $response->getBody()->getContents(); |
|
| 121 | } |
|
| 122 | } |
|
| 123 | ||