@@ 515-532 (lines=18) @@ | ||
512 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-delete |
|
513 | * |
|
514 | */ |
|
515 | public function delete($path) |
|
516 | { |
|
517 | //Path cannot be null |
|
518 | if (is_null($path)) { |
|
519 | throw new DropboxClientException("Path cannot be null."); |
|
520 | } |
|
521 | ||
522 | //Delete |
|
523 | $response = $this->postToAPI('/files/delete_v2', ['path' => $path]); |
|
524 | $body = $response->getDecodedBody(); |
|
525 | ||
526 | //Response doesn't have Metadata |
|
527 | if (!isset($body['metadata']) || !is_array($body['metadata'])) { |
|
528 | throw new DropboxClientException("Invalid Response."); |
|
529 | } |
|
530 | ||
531 | return new DeletedMetadata($body['metadata']); |
|
532 | } |
|
533 | ||
534 | /** |
|
535 | * Move a file or folder to a different location |
|
@@ 716-733 (lines=18) @@ | ||
713 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-save_url |
|
714 | * |
|
715 | */ |
|
716 | public function saveUrl($path, $url) |
|
717 | { |
|
718 | //Path and URL cannot be null |
|
719 | if (is_null($path) || is_null($url)) { |
|
720 | throw new DropboxClientException("Path and URL cannot be null."); |
|
721 | } |
|
722 | ||
723 | //Save URL |
|
724 | $response = $this->postToAPI('/files/save_url', ['path' => $path, 'url' => $url]); |
|
725 | $body = $response->getDecodedBody(); |
|
726 | ||
727 | if (!isset($body['async_job_id'])) { |
|
728 | throw new DropboxClientException("Could not retrieve Async Job ID."); |
|
729 | } |
|
730 | ||
731 | //Return the Async Job ID |
|
732 | return $body['async_job_id']; |
|
733 | } |
|
734 | ||
735 | /** |
|
736 | * Save a specified URL into a file in user's Dropbox |