1 | <?php |
||
11 | class Download extends AbstractApi |
||
12 | { |
||
13 | /** @var string */ |
||
14 | protected $package = 'all.zip'; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $copyDestination = '/tmp'; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $branch; |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | public function execute() |
||
26 | { |
||
27 | $path = sprintf( |
||
28 | "project/%s/download/%s?key=%s", |
||
29 | $this->client->getProjectIdentifier(), |
||
30 | $this->package, |
||
31 | $this->client->getProjectApiKey() |
||
32 | ); |
||
33 | if (null !== $this->branch) { |
||
34 | $path = sprintf('%s&branch=%s', $path, $this->branch); |
||
35 | } |
||
36 | $request = $this->client->getHttpClient()->get($path); |
||
37 | $response = $request |
||
38 | ->setResponseBody($this->copyDestination.DIRECTORY_SEPARATOR.$this->package) |
||
39 | ->send(); |
||
40 | |||
41 | return $response->getBody(true); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param string $package |
||
46 | * |
||
47 | * @return Download |
||
48 | */ |
||
49 | public function setPackage($package) |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getPackage() |
||
63 | |||
64 | /** |
||
65 | * @param string $dest |
||
66 | * |
||
67 | * @return Download |
||
68 | */ |
||
69 | public function setCopyDestination($dest) |
||
75 | |||
76 | /** |
||
77 | * @return string |
||
78 | */ |
||
79 | public function getCopyDestination() |
||
83 | |||
84 | /** |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getBranch() |
||
91 | |||
92 | /** |
||
93 | * @param string $branch |
||
94 | * |
||
95 | * @return Download |
||
96 | */ |
||
97 | public function setBranch($branch) |
||
103 | } |
||
104 |