1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the zibios/wrike-php-library package. |
5
|
|
|
* |
6
|
|
|
* (c) Zbigniew Ślązak |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Zibios\WrikePhpLibrary\Resource\Traits; |
13
|
|
|
|
14
|
|
|
use Zibios\WrikePhpLibrary\Enum\Api\RequestMethodEnum; |
15
|
|
|
use Zibios\WrikePhpLibrary\Enum\Api\ResourceMethodEnum; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Download Trait. |
19
|
|
|
*/ |
20
|
|
|
trait DownloadTrait |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @param string $id |
24
|
|
|
* @param array|null $params |
25
|
|
|
* |
26
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ServerErrorException |
27
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ResourceNotFoundException |
28
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ParameterRequiredException |
29
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAuthorizedException |
30
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAllowedException |
31
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidRequestException |
32
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidParameterException |
33
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ApiException |
34
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\AccessForbiddenException |
35
|
|
|
* @throws \LogicException |
36
|
|
|
* @throws \InvalidArgumentException |
37
|
|
|
* @throws \Exception |
38
|
|
|
* |
39
|
|
|
* @return mixed |
40
|
|
|
*/ |
41
|
2 |
|
public function download($id, array $params = []) |
42
|
|
|
{ |
43
|
2 |
|
return $this->executeRequest( |
44
|
2 |
|
RequestMethodEnum::GET, |
45
|
2 |
|
ResourceMethodEnum::DOWNLOAD, |
46
|
|
|
$params, |
47
|
|
|
$id |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $requestMethod |
53
|
|
|
* @param string $requestScope |
54
|
|
|
* @param array $params |
55
|
|
|
* @param string|array $id |
56
|
|
|
* |
57
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ServerErrorException |
58
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ResourceNotFoundException |
59
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ParameterRequiredException |
60
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAuthorizedException |
61
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAllowedException |
62
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidRequestException |
63
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidParameterException |
64
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\ApiException |
65
|
|
|
* @throws \Zibios\WrikePhpLibrary\Exception\Api\AccessForbiddenException |
66
|
|
|
* @throws \LogicException |
67
|
|
|
* @throws \InvalidArgumentException |
68
|
|
|
* @throws \Exception |
69
|
|
|
* |
70
|
|
|
* @return mixed |
71
|
|
|
*/ |
72
|
|
|
abstract protected function executeRequest( |
73
|
|
|
$requestMethod, |
74
|
|
|
$requestScope, |
75
|
|
|
array $params, |
76
|
|
|
$id |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|