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