Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding restore commands #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": ">=5.4.0",
"guzzlehttp/guzzle": "~4.2.2",
"guzzlehttp/guzzle": "^5.3|^6.0",
"adammbalogh/key-value-store": "~0.5.1"
},
"require-dev": {
Expand Down
43 changes: 43 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,28 @@ if ($response instanceof SuccessResponse) {
}
```


#### Restore Folder Command

✔ Extended Request

```php
<?php
use AdammBalogh\Box\Command\Content;
use AdammBalogh\Box\Factory\ResponseFactory;
use AdammBalogh\Box\GuzzleHttp\Message\SuccessResponse;
use AdammBalogh\Box\GuzzleHttp\Message\ErrorResponse;

$command = new Content\Folder\RestoreFolder('folderId');
$response = ResponseFactory::getResponse($contentClient, $command);

if ($response instanceof SuccessResponse) {
# ...
} elseif ($response instanceof ErrorResponse) {
# ...
}
```

#### Get Folder Info Command

```php
Expand Down Expand Up @@ -449,6 +471,27 @@ if ($response instanceof SuccessResponse) {
}
```

#### Restore File Command

✔ Extended Request

```php
<?php
use AdammBalogh\Box\Command\Content;
use AdammBalogh\Box\Factory\ResponseFactory;
use AdammBalogh\Box\GuzzleHttp\Message\SuccessResponse;
use AdammBalogh\Box\GuzzleHttp\Message\ErrorResponse;

$command = new Content\File\RestoreFile('fileId');
$response = ResponseFactory::getResponse($contentClient, $command);

if ($response instanceof SuccessResponse) {
# ...
} elseif ($response instanceof ErrorResponse) {
# ...
}
```

#### Download File Command

✔ Extended Request
Expand Down
24 changes: 24 additions & 0 deletions src/Command/Content/File/RestoreFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php namespace AdammBalogh\Box\Command\Content\File;

use AdammBalogh\Box\Command\AbstractCommand;
use AdammBalogh\Box\GuzzleHttp\Message\PostRequest;
use AdammBalogh\Box\Request\ExtendedRequest;
use GuzzleHttp\Post\PostBody;

class RestoreFile extends AbstractCommand
{

/**
* RestoreFile constructor.
* @param $fileId
* @param ExtendedRequest|null $extendedRequest
*/
public function __construct($fileId, ExtendedRequest $extendedRequest = null)
{
$this->request = new PostRequest("files/{$fileId}");

if ($extendedRequest) {
$this->request->setRawJsonBody($extendedRequest->getPostBodyFields());
}
}
}
22 changes: 22 additions & 0 deletions src/Command/Content/Folder/RestoreFolder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php namespace AdammBalogh\Box\Command\Content\Folder;

use AdammBalogh\Box\Command\AbstractCommand;
use AdammBalogh\Box\GuzzleHttp\Message\PostRequest;
use AdammBalogh\Box\Request\ExtendedRequest;
use GuzzleHttp\Post\PostBody;

class RestoreFolder extends AbstractCommand
{
/**
* @param string $folderId
* @param ExtendedRequest|null $extendedRequest
*/
public function __construct($folderId, ExtendedRequest $extendedRequest = null)
{
$this->request = new PostRequest("folders/{$folderId}");

if ($extendedRequest) {
$this->request->setRawJsonBody($extendedRequest->getPostBodyFields());
}
}
}