@@ 11-53 (lines=43) @@ | ||
8 | * @author Julien Janvier <[email protected]> |
|
9 | * @see http://crowdin.net/page/api/delete-directory |
|
10 | */ |
|
11 | class DeleteDirectory extends AbstractApi |
|
12 | { |
|
13 | private $directory; |
|
14 | ||
15 | /** |
|
16 | * {@inheritdoc} |
|
17 | */ |
|
18 | public function execute() |
|
19 | { |
|
20 | if (null == $this->getDirectory()) { |
|
21 | throw new \InvalidArgumentException('There is no directory to delete.'); |
|
22 | } |
|
23 | ||
24 | $path = sprintf( |
|
25 | "project/%s/delete-directory?key=%s", |
|
26 | $this->client->getProjectIdentifier(), |
|
27 | $this->client->getProjectApiKey() |
|
28 | ); |
|
29 | ||
30 | $parameters = array_merge($this->parameters, array('name' => $this->getDirectory())); |
|
31 | ||
32 | $request = $this->client->getHttpClient()->post($path, array(), $parameters); |
|
33 | $response = $request->send(); |
|
34 | ||
35 | return $response->getBody(true); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * @param mixed $directory |
|
40 | */ |
|
41 | public function setDirectory($directory) |
|
42 | { |
|
43 | $this->directory = $directory; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @return mixed |
|
48 | */ |
|
49 | public function getDirectory() |
|
50 | { |
|
51 | return $this->directory; |
|
52 | } |
|
53 | } |
|
54 |
@@ 11-53 (lines=43) @@ | ||
8 | * @author Julien Janvier <[email protected]> |
|
9 | * @see http://crowdin.net/page/api/delete-file |
|
10 | */ |
|
11 | class DeleteFile extends AbstractApi |
|
12 | { |
|
13 | protected $file; |
|
14 | ||
15 | /** |
|
16 | * {@inheritdoc} |
|
17 | */ |
|
18 | public function execute() |
|
19 | { |
|
20 | if (null == $this->getFile()) { |
|
21 | throw new \InvalidArgumentException('There is no file to delete.'); |
|
22 | } |
|
23 | ||
24 | $path = sprintf( |
|
25 | "project/%s/delete-file?key=%s", |
|
26 | $this->client->getProjectIdentifier(), |
|
27 | $this->client->getProjectApiKey() |
|
28 | ); |
|
29 | ||
30 | $parameters = array_merge($this->parameters, array('file' => $this->getFile())); |
|
31 | ||
32 | $request = $this->client->getHttpClient()->post($path, array(), $parameters); |
|
33 | $response = $request->send(); |
|
34 | ||
35 | return $response->getBody(true); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * @param mixed $file |
|
40 | */ |
|
41 | public function setFile($file) |
|
42 | { |
|
43 | $this->file = $file; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @return mixed |
|
48 | */ |
|
49 | public function getFile() |
|
50 | { |
|
51 | return $this->file; |
|
52 | } |
|
53 | } |
|
54 |