Skip to content

Commit

Permalink
Create DeletedMetadata model from response body metadata. Fixes #82
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalvarma05 committed Oct 6, 2017
1 parent aa4a05f commit f8ab4d3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Dropbox/Dropbox.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace Kunnu\Dropbox;

use Kunnu\Dropbox\Models\DeletedMetadata;
use Kunnu\Dropbox\Models\File;
use Kunnu\Dropbox\Models\Account;
use Kunnu\Dropbox\Models\Thumbnail;
Expand Down Expand Up @@ -502,7 +504,7 @@ public function createFolder($path, $autorename = false)
*
* @param string $path Path to file/folder to delete
*
* @return \Kunnu\Dropbox\Models\DeletedMetadata|\Kunnu\Dropbox\Models\FileMetadata|\Kunnu\Dropbox\Models\FolderMetadata
* @return \Kunnu\Dropbox\Models\DeletedMetadata
*
* @throws \Kunnu\Dropbox\Exceptions\DropboxClientException
*
Expand All @@ -518,8 +520,14 @@ public function delete($path)

//Delete
$response = $this->postToAPI('/files/delete_v2', ['path' => $path]);
$body = $response->getDecodedBody();

return $this->makeModelFromResponse($response);
//Response doesn't have Metadata
if (!isset($body['metadata']) || !is_array($body['metadata'])) {
throw new DropboxClientException("Invalid Response.");
}

return new DeletedMetadata($body['metadata']);
}

/**
Expand Down

0 comments on commit f8ab4d3

Please sign in to comment.