@@ 523-540 (lines=18) @@ | ||
520 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-delete |
|
521 | * |
|
522 | */ |
|
523 | public function delete($path) |
|
524 | { |
|
525 | //Path cannot be null |
|
526 | if (is_null($path)) { |
|
527 | throw new DropboxClientException("Path cannot be null."); |
|
528 | } |
|
529 | ||
530 | //Delete |
|
531 | $response = $this->postToAPI('/files/delete_v2', ['path' => $path]); |
|
532 | $body = $response->getDecodedBody(); |
|
533 | ||
534 | //Response doesn't have Metadata |
|
535 | if (!isset($body['metadata']) || !is_array($body['metadata'])) { |
|
536 | throw new DropboxClientException("Invalid Response."); |
|
537 | } |
|
538 | ||
539 | return new DeletedMetadata($body['metadata']); |
|
540 | } |
|
541 | ||
542 | /** |
|
543 | * Move a file or folder to a different location |
|
@@ 724-741 (lines=18) @@ | ||
721 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-save_url |
|
722 | * |
|
723 | */ |
|
724 | public function saveUrl($path, $url) |
|
725 | { |
|
726 | //Path and URL cannot be null |
|
727 | if (is_null($path) || is_null($url)) { |
|
728 | throw new DropboxClientException("Path and URL cannot be null."); |
|
729 | } |
|
730 | ||
731 | //Save URL |
|
732 | $response = $this->postToAPI('/files/save_url', ['path' => $path, 'url' => $url]); |
|
733 | $body = $response->getDecodedBody(); |
|
734 | ||
735 | if (!isset($body['async_job_id'])) { |
|
736 | throw new DropboxClientException("Could not retrieve Async Job ID."); |
|
737 | } |
|
738 | ||
739 | //Return the Async Job ID |
|
740 | return $body['async_job_id']; |
|
741 | } |
|
742 | ||
743 | /** |
|
744 | * Save a specified URL into a file in user's Dropbox |