├── LICENSE ├── README.md ├── composer.json └── src ├── Exception ├── DropboxException.php └── NoTokenException.php ├── Operation ├── AbstractOperation.php ├── Files │ ├── Copy.php │ ├── CopyReference │ │ ├── Get.php │ │ └── Save.php │ ├── CreateFolder.php │ ├── Delete.php │ ├── Download.php │ ├── GetMetadata.php │ ├── GetPreview.php │ ├── GetTemporaryLink.php │ ├── GetThumbnail.php │ ├── ListFolder │ │ ├── GetLatestCursor.php │ │ ├── ListFolder.php │ │ ├── ListFolderContinue.php │ │ └── Longpoll.php │ ├── ListRevisions.php │ ├── Move.php │ ├── PermanentlyDelete.php │ ├── Restore.php │ ├── SaveUrl │ │ ├── CheckJobStatus.php │ │ └── SaveURL.php │ ├── Search.php │ ├── Upload.php │ └── UploadSession │ │ ├── Append.php │ │ ├── Finish.php │ │ └── Start.php └── Users │ ├── GetAccount.php │ ├── GetAccountBatch.php │ ├── GetCurrentAccount.php │ └── GetSpaceUsage.php ├── OperationKind ├── ContentDownloadOperation.php ├── ContentUploadAbstractOperation.php ├── RPCOperation.php ├── SingleArgumentRPCOperation.php └── SourceDestRPCOperation.php ├── Options ├── Builder │ ├── GetMetadataOptions.php │ ├── GetThumbnailOptions.php │ ├── ListFolderOptions.php │ ├── ListRevisionsOptions.php │ ├── LongpollOptions.php │ ├── SearchOptions.php │ ├── UploadOptions.php │ └── UploadSession │ │ └── UploadSessionActiveOptions.php ├── Mixins │ ├── AutoRenameTrait.php │ ├── ClientModifiedTrait.php │ ├── CloseTrait.php │ ├── IncludeDeletedTrait.php │ ├── IncludeHasExplicitSharedMembersTrait.php │ ├── IncludeMediaInfoTrait.php │ ├── LimitTrait.php │ ├── MaxResultsTrait.php │ ├── MuteTrait.php │ ├── RecursiveTrait.php │ ├── SearchModeTrait.php │ ├── StartTrait.php │ ├── ThumbnailFormatTrait.php │ ├── ThumbnailSizeTrait.php │ ├── TimeoutTrait.php │ └── WriteModeTrait.php ├── Option.php └── Options.php ├── Parameters ├── AbstractParameter.php ├── CommitInfo.php ├── SearchMode.php ├── ThumbnailFormat.php ├── ThumbnailSize.php ├── UploadSessionCursor.php └── WriteMode.php ├── Response └── ResponseAttribute.php └── Util.php /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 Arturas Molcanovas 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Percentage of issues still open](http://isitmaintained.com/badge/open/alorel/dropbox-v2-php.svg)](http://isitmaintained.com/project/alorel/dropbox-v2-php "Percentage of issues still open") 2 | [![Build Status](https://travis-ci.org/Alorel/dropbox-v2-php.svg?branch=master)](https://travis-ci.org/Alorel/dropbox-v2-php) 3 | [![codecov](https://codecov.io/gh/Alorel/dropbox-v2-php/branch/master/graph/badge.svg)](https://codecov.io/gh/Alorel/dropbox-v2-php) 4 | [![Dependency Status](https://www.versioneye.com/user/projects/5756bd6b7757a0004a1de150/badge.svg)](https://www.versioneye.com/user/projects/5756bd6b7757a0004a1de150) 5 | 6 | [![Latest Stable Version](https://poser.pugx.org/alorel/dropbox-v2-php/v/stable)](https://packagist.org/packages/alorel/dropbox-v2-php) 7 | [![Total Downloads](https://poser.pugx.org/alorel/dropbox-v2-php/downloads)](https://packagist.org/packages/alorel/dropbox-v2-php) 8 | [![License](https://poser.pugx.org/alorel/dropbox-v2-php/license)](https://packagist.org/packages/alorel/dropbox-v2-php) 9 | 10 | 11 | Tested with PHP 5.6-7.1 and HHVM 3.18. See the [CI builds](https://travis-ci.org/Alorel/dropbox-v2-php/builds) page for the most accurate, up-to-date version list. 12 | 13 | ---------- 14 | 15 | # Maintainer(s) needed! 16 | 17 | [10 Feb 2017] Unfortunately, I do not have time to maintain this SDK. I do not expect it to become out-of-date in terms of functionality for at least another year, but it won't be adding any new functionality. Please [open an issue](https://github.com/Alorel/dropbox-v2-php/issues) if you're interested. 18 | 19 | ----- 20 | 21 | A PHP SDK for Dropbox's v2 API. If you haven't tried Dropbox out yet, [do](https://db.tt/u56WHf8q "referral link") - it's great! 22 | 23 | # Table of Contents 24 | 25 | 1. [Installation](#installation) 26 | 1. [Usage](#usage) 27 | 1. [Supported API operations](#supported-api-operations) 28 | 1. [API Documentation](#api-documentation) 29 | 30 | # Installation 31 | 32 | Installation is only available via [Composer](https://getcomposer.org/). 33 | 34 | ## Quick version: 35 | 36 | ```sh 37 | composer require alorel/dropbox-v2-php 38 | ``` 39 | 40 | ## More informed version: 41 | 42 | The package is still in its `0.x` development stage, therefore adding it as a `^` dependency, e.g. `"alorel/dropbox-v2-php":"^0.1"` will severely limit the amount of updates you receive, as, per [semver](http://semver.org/#spec-item-4) specification, `0.2` is allowed to be backwards-incompatible with `0.1`. While I definitely cannot guarantee **full** backwards compatibility if you fiddle with protected methods and derive your own subclasses, I do guarantee that the public API will remain backwards-compatible, therefore, if you only use the `raw` methods in your application e.g. 43 | 44 | ```php 45 | $options = new UploadOptions(); //set your options 46 | (new Upload())->raw('/file.txt', 'data', $options); 47 | ``` 48 | 49 | You can safely add the following as a dependency in your composer.json: 50 | 51 | ```json 52 | { 53 | "require": { 54 | "alorel/dropbox-v2-php": ">=0.4 <1.0" 55 | } 56 | } 57 | ``` 58 | 59 | Additionally, `composer outdated` is a useful command to know during the `0.x` development stage! 60 | 61 | # Usage 62 | 63 | Every Dropbox API operation is located in the [\Alorel\Dropbox\Operation](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.3.3/docs/master/Alorel/Dropbox/Operation.html) namespace and is a class named after the API endpoint. There are a few exceptions to this, however, e.g. the class for `https://content.dropboxapi.com/2/files/upload_session/start` is `\Alorel\Dropbox\Operation\Files\UploadSession\Start`. 64 | 65 | All operation classes inherit the AbstractOperation constructor: 66 | 67 | ```php 68 | /** 69 | * Operation constructor. 70 | * 71 | * @param bool $async Whether requests should be asynchronous 72 | * @param string $accessToken Our access token 73 | */ 74 | public function __construct($async = null, string $accessToken = null) {} 75 | 76 | ``` 77 | The first parameter is a boolean determining whether operations should run synchronously or asynchronously (defaults to synchronous), the second is the access token created when the user authorises your application. Both can have default values set via [AbstractOperation::setDefaultToken()](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.3.3/docs/master/Alorel/Dropbox/Operation/AbstractOperation.html#method_setDefaultToken) and [AbstractOperation::setDefaultAsync()](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.3.3/docs/master/Alorel/Dropbox/Operation/AbstractOperation.html#method_setDefaultAsync) respectively. 78 | 79 | Currently the only supported way of making requests is with the respective operation class' `raw` method, which will return an instance of `PromiseInterface` when operating in asynchronous mode or an instance of `ResponseInterface` if operating in synchronous mode. See [guzzlephp.org](http://guzzlephp.org/) for more information on promises and responses. 80 | 81 | In future releases I will be adding 'management' classes that will automatically format the response. 82 | 83 | # Supported API Operations 84 | 85 | Unless specified otherwise, any operation that is not currently supported will be added in a future release. 86 | 87 | ## Files 88 | All except: 89 | 90 | - [ ] /alpha/get_metadata | *In Beta/Alpha on Dropbox - will implement once stable* 91 | - [ ] /alpha/upload | *In Beta/Alpha on Dropbox - will implement once stable* 92 | - [ ] /properties/add | *In Beta/Alpha on Dropbox - will implement once stable* 93 | - [ ] /properties/overwrite | *In Beta/Alpha on Dropbox - will implement once stable* 94 | - [ ] /properties/remove | *In Beta/Alpha on Dropbox - will implement once stable* 95 | - [ ] /properties/template/get | *In Beta/Alpha on Dropbox - will implement once stable* 96 | - [ ] /properties/template/list | *In Beta/Alpha on Dropbox - will implement once stable* 97 | - [ ] /properties/update | *In Beta/Alpha on Dropbox - will implement once stable* 98 | 99 | ## Users 100 | 101 | All 102 | 103 | # API Documentation 104 | 105 | [0.4](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.4/docs/master/index.html) | 106 | [0.3.3](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.3.3/docs/master/index.html) | 107 | [0.2](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.2/docs/master/index.html) | 108 | [0.1.1](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.1.1/docs/master/index.html) | 109 | [0.1](https://cdn.rawgit.com/Alorel/dropbox-v2-php/0.1/docs/master/index.html) 110 | 111 | ---------- 112 | 113 | # Links 114 | 115 | - [Changelog](https://github.com/Alorel/dropbox-v2-php/releases) 116 | - [Dropbox HTTP API docs](https://www.dropbox.com/developers/documentation/http/documentation) (this library is merely a HTTP request wrapper) 117 | - [Dropbox API explorer](https://dropbox.github.io/dropbox-api-v2-explorer) 118 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alorel/dropbox-v2-php", 3 | "description": "A PHP SDK for Dropbox's v2 API", 4 | "prefer-stable": true, 5 | "type": "library", 6 | "license": "Apache-2.0", 7 | "homepage": "https://github.com/Alorel/dropbox-v2-php", 8 | "keywords": [ 9 | "PHP", 10 | "Dropbox", 11 | "API", 12 | "SDK" 13 | ], 14 | "authors": [ 15 | { 16 | "name": "Art", 17 | "email": "a.molcanovas@gmail.com", 18 | "role": "Developer", 19 | "homepage": "https://github.com/Alorel" 20 | } 21 | ], 22 | "support": { 23 | "issues": "https://github.com/Alorel/dropbox-v2-php/issues" 24 | }, 25 | "require": { 26 | "guzzlehttp/guzzle": "^6.0", 27 | "guzzlehttp/psr7": "^1.0", 28 | "aloframework/common": "^1.3 || ^2.0" 29 | }, 30 | "autoload": { 31 | "psr-4": { 32 | "Alorel\\Dropbox\\": "src" 33 | } 34 | }, 35 | "require-dev": { 36 | "raveren/kint": "^1.0", 37 | "alorel/phpunit-auto-rerun": "^0.1", 38 | "phpunit/phpunit": "^5.0", 39 | "ramsey/uuid": "^3.5" 40 | }, 41 | "extra": { 42 | "branch-alias": { 43 | "dev-dev-retriable-tests": "0.3-dev" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Exception/DropboxException.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Exception; 20 | 21 | /** 22 | * Exception wrapper 23 | * 24 | * @author Art 25 | */ 26 | abstract class DropboxException extends \Exception { 27 | 28 | /** 29 | * Code for when the API key is not provided 30 | * 31 | * @var int 32 | */ 33 | const NO_TOKEN = 1; 34 | } -------------------------------------------------------------------------------- /src/Exception/NoTokenException.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Exception; 20 | 21 | /** 22 | * Exception for when the API key is not provided 23 | * 24 | * @author Art 25 | */ 26 | class NoTokenException extends DropboxException { 27 | 28 | /** 29 | * NoTokenException constructor. 30 | * 31 | * @author Art 32 | */ 33 | public function __construct() { 34 | parent::__construct('The API token must be set either via the constructor or the static setDefaultToken() ' 35 | . 'method', 36 | self::NO_TOKEN); 37 | } 38 | } -------------------------------------------------------------------------------- /src/Operation/AbstractOperation.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation; 20 | 21 | use AloFramework\Common\Alo; 22 | use Alorel\Dropbox\Exception\NoTokenException; 23 | use GuzzleHttp\Client; 24 | use GuzzleHttp\Psr7\Request; 25 | 26 | /** 27 | * The most abstract operation wrapper 28 | * 29 | * @author Art 30 | */ 31 | abstract class AbstractOperation { 32 | 33 | /** 34 | * Dropbox API version 35 | * 36 | * @var int 37 | */ 38 | const API_VERSION = 2; 39 | 40 | /** 41 | * The access token 42 | * 43 | * @var string 44 | */ 45 | private $token; 46 | 47 | /** 48 | * Method to call when sending requests. This will be either send or sendAsync. 49 | * 50 | * @var callable 51 | * @see Client::send() 52 | * @see Client::sendAsync() 53 | */ 54 | private $sendCallable; 55 | 56 | /** 57 | * The client that will send requests 58 | * 59 | * @var \GuzzleHttp\Client 60 | */ 61 | private static $client; 62 | 63 | /** 64 | * The default access token to use across requests 65 | * 66 | * @var string 67 | */ 68 | private static $defaultToken = null; 69 | 70 | /** 71 | * The default behaviour - sync or async 72 | * 73 | * @var bool 74 | */ 75 | private static $defaultAsync = false; 76 | 77 | /** 78 | * Whether we're operating in async mode 79 | * 80 | * @var bool 81 | */ 82 | private $async; 83 | 84 | /** 85 | * Operation constructor. 86 | * 87 | * @author Art 88 | * 89 | * @param bool $async Whether requests should be asynchronous 90 | * @param string $accessToken Our access token 91 | * 92 | * @throws NoTokenException If $accessToken is not provided and the {@link AbstractOperation::$defaultToken default token} hasn't been set via {@link AbstractOperation::setDefaultToken() setDefaultToken()} 93 | */ 94 | public function __construct($async = null, $accessToken = null) { 95 | $this->token = Alo::ifnull($accessToken, self::$defaultToken, true); 96 | if (!$this->token) { 97 | throw new NoTokenException(); 98 | } 99 | 100 | if (!self::$client) { 101 | self::$client = new Client(); 102 | } 103 | 104 | $this->setAsync((bool)(Alo::ifnull($async, self::$defaultAsync, true))); 105 | } 106 | 107 | /** 108 | * Sets the default token to use with the constructor 109 | * 110 | * @author Art 111 | * 112 | * @param string $token The token 113 | */ 114 | public static final function setDefaultToken($token) { 115 | self::$defaultToken = $token; 116 | } 117 | 118 | /** 119 | * Returns the Guzzle callable 120 | * 121 | * @author Art 122 | * @return callable 123 | */ 124 | protected function getSendCallable() { 125 | return $this->sendCallable; 126 | } 127 | 128 | /** 129 | * Return whether we're operating in async mode 130 | * 131 | * @author Art 132 | * @return boolean 133 | */ 134 | public function isAsync() { 135 | return $this->async; 136 | } 137 | 138 | /** 139 | * Sets the sync/async operation mode 140 | * 141 | * @author Art 142 | * 143 | * @param bool $async true to perform operations in async mode, false to perform them in sync 144 | * 145 | * @return self 146 | */ 147 | public final function setAsync($async) { 148 | $this->async = $async; 149 | $this->sendCallable = [self::$client, $this->async ? 'sendAsync' : 'send']; 150 | 151 | return $this; 152 | } 153 | 154 | /** 155 | * Sets the default $async value for the constructor 156 | * 157 | * @author Art 158 | * 159 | * @param bool $async The default async value 160 | */ 161 | static final function setDefaultAsync($async) { 162 | self::$defaultAsync = $async; 163 | } 164 | 165 | /** 166 | * Return our token 167 | * 168 | * @author Art 169 | * @return string 170 | */ 171 | protected function getToken() { 172 | return $this->token; 173 | } 174 | 175 | /** 176 | * Send our request 177 | * 178 | * @author Art 179 | * 180 | * @param string $httpMethod The HTTP method to use (GET, POST etc) 181 | * @param string $url The URL to call. This is automatically prepended with https:// in this method 182 | * @param array $options Request options 183 | * 184 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 185 | * async is set to true and the 186 | * request interface if it is 187 | * set to false 188 | * @throws \GuzzleHttp\Exception\ClientException 189 | */ 190 | protected final function sendAbstract($httpMethod, $url, array $options = []) { 191 | return call_user_func( 192 | $this->sendCallable, 193 | new Request( 194 | $httpMethod, 195 | 'https://' . $url, 196 | array_merge( 197 | ['authorization' => 'Bearer ' . $this->token], 198 | Alo::ifnull($options['headers'], [], true) 199 | ), 200 | Alo::nullget($options['body'])) 201 | ); 202 | } 203 | } -------------------------------------------------------------------------------- /src/Operation/Files/Copy.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\SourceDestRPCOperation; 22 | 23 | /** 24 | * The Copy operation 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-copy 28 | */ 29 | class Copy extends SourceDestRPCOperation { 30 | 31 | } -------------------------------------------------------------------------------- /src/Operation/Files/CopyReference/Get.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\CopyReference; 20 | 21 | use Alorel\Dropbox\OperationKind\SingleArgumentRPCOperation; 22 | 23 | /** 24 | * Get a copy reference to a file or folder. This reference string can be used to save that file or folder to 25 | * another user's Dropbox by passing it to copy_reference/save. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get 29 | */ 30 | class Get extends SingleArgumentRPCOperation { 31 | 32 | } -------------------------------------------------------------------------------- /src/Operation/Files/CopyReference/Save.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\CopyReference; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Option as O; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * Save a copy reference returned by copy_reference/get to the user's Dropbox. 27 | * 28 | * @author Art 29 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-save 30 | */ 31 | class Save extends RPCOperation { 32 | 33 | /** 34 | * Perform the operation, returning a promise or raw response object 35 | * 36 | * @author Art 37 | * 38 | * @param string $destPath Path in the user's Dropbox that is the destination. 39 | * @param string $copyReference A copy reference returned by copy_reference/get. 40 | * 41 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 42 | * async is set to true and the 43 | * request interface if it is 44 | * set to false 45 | * @throws \GuzzleHttp\Exception\ClientException 46 | */ 47 | public function raw($destPath, $copyReference) { 48 | return $this->send('files/copy_reference/save', 49 | $destPath, 50 | new Options([O::COPY_REFERENCE => $copyReference])); 51 | } 52 | } -------------------------------------------------------------------------------- /src/Operation/Files/CreateFolder.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\SingleArgumentRPCOperation; 22 | 23 | /** 24 | * Create a folder at a given path. 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder 28 | */ 29 | class CreateFolder extends SingleArgumentRPCOperation { 30 | 31 | } -------------------------------------------------------------------------------- /src/Operation/Files/Delete.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\SingleArgumentRPCOperation; 22 | 23 | /** 24 | * The delete operation 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-delete 28 | */ 29 | class Delete extends SingleArgumentRPCOperation { 30 | 31 | } -------------------------------------------------------------------------------- /src/Operation/Files/Download.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentDownloadOperation; 22 | 23 | /** 24 | * Download a file 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-download 28 | */ 29 | class Download extends ContentDownloadOperation { 30 | 31 | /** 32 | * Perform the operation, returning a promise or raw response object 33 | * 34 | * @author Art 35 | * 36 | * @param string $path Path to the file on Dropbox 37 | * 38 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 39 | * async is set to true and the 40 | * request interface if it is 41 | * set to false 42 | * @throws \GuzzleHttp\Exception\ClientException 43 | */ 44 | public function raw($path) { 45 | return $this->send('download', $path); 46 | } 47 | } -------------------------------------------------------------------------------- /src/Operation/Files/GetMetadata.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Builder\GetMetadataOptions; 23 | 24 | /** 25 | * The get_metadata operation 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata 29 | */ 30 | class GetMetadata extends RPCOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $path Path to the file 38 | * @param GetMetadataOptions|null $options Additional options 39 | * 40 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 41 | * async is set to true and the 42 | * request interface if it is 43 | * set to false 44 | * @throws \GuzzleHttp\Exception\ClientException 45 | */ 46 | public function raw($path, GetMetadataOptions $options = null) { 47 | return $this->send('files/get_metadata', $path, $options); 48 | } 49 | } -------------------------------------------------------------------------------- /src/Operation/Files/GetPreview.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentDownloadOperation; 22 | 23 | /** 24 | * Get a preview for a file. Currently previews are only generated for the files with the following extensions: 25 | * .doc, .docx, .docm, .ppt, .pps, .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-get_preview 29 | */ 30 | class GetPreview extends ContentDownloadOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $path Path to the file on Dropbox 38 | * 39 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 40 | * async is set to true and the 41 | * request interface if it is 42 | * set to false 43 | * @throws \GuzzleHttp\Exception\ClientException 44 | */ 45 | public function raw($path) { 46 | return $this->send('get_preview', $path); 47 | } 48 | } -------------------------------------------------------------------------------- /src/Operation/Files/GetTemporaryLink.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\SingleArgumentRPCOperation; 22 | 23 | /** 24 | * Get a temporary link to stream content of a file. This link will expire in four hours and afterwards you will 25 | * get 410 Gone. Content-Type of the link is determined automatically by the file's mime type. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link 29 | */ 30 | class GetTemporaryLink extends SingleArgumentRPCOperation { 31 | 32 | } -------------------------------------------------------------------------------- /src/Operation/Files/GetThumbnail.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentDownloadOperation; 22 | use Alorel\Dropbox\Options\Builder\GetThumbnailOptions; 23 | 24 | /** 25 | * Get the file's thumbnail 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail 29 | */ 30 | class GetThumbnail extends ContentDownloadOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $path Path to the file on Dropbox 38 | * @param GetThumbnailOptions|null $opts Additional options 39 | * 40 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 41 | * async is set to true and the 42 | * request interface if it is 43 | * set to false 44 | * @throws \GuzzleHttp\Exception\ClientException 45 | */ 46 | public function raw($path, GetThumbnailOptions $opts = null) { 47 | return $this->send('get_thumbnail', $path, $opts); 48 | } 49 | } -------------------------------------------------------------------------------- /src/Operation/Files/ListFolder/GetLatestCursor.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\ListFolder; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Builder\ListFolderOptions; 23 | 24 | /** 25 | * A way to quickly get a cursor for the folder's state. Unlike list_folder, list_folder/get_latest_cursor 26 | * doesn't return any entries. This endpoint is for app which only needs to know about new files and 27 | * modifications and doesn't need to know about files that already exist in Dropbox. 28 | * 29 | * @author Art 30 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-get_latest_cursor 31 | */ 32 | class GetLatestCursor extends RPCOperation { 33 | 34 | /** 35 | * Perform the operation, returning a promise or raw response object 36 | * 37 | * @author Art 38 | * 39 | * @param string $path Path to the folder 40 | * @param ListFolderOptions|null $options Additional options 41 | * 42 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 43 | * async is set to true and the 44 | * request interface if it is 45 | * set to false 46 | * @throws \GuzzleHttp\Exception\ClientException 47 | */ 48 | public function raw($path = '', ListFolderOptions $options = null) { 49 | return $this->send('files/list_folder/get_latest_cursor', $path, $options); 50 | } 51 | } -------------------------------------------------------------------------------- /src/Operation/Files/ListFolder/ListFolder.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\ListFolder; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Builder\ListFolderOptions; 23 | 24 | /** 25 | * Returns the contents of a folder. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder 29 | */ 30 | class ListFolder extends RPCOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $path Path to the folder 38 | * @param ListFolderOptions|null $options Additional options 39 | * 40 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 41 | * async is set to true and the 42 | * request interface if it is 43 | * set to false 44 | * @throws \GuzzleHttp\Exception\ClientException 45 | */ 46 | public function raw($path = '', ListFolderOptions $options = null) { 47 | return $this->send('files/list_folder', $path, $options); 48 | } 49 | } -------------------------------------------------------------------------------- /src/Operation/Files/ListFolder/ListFolderContinue.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\ListFolder; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\OperationKind\RPCOperation; 23 | 24 | /** 25 | * Once a cursor has been retrieved from list_folder, use this to paginate through all files and retrieve updates 26 | * to the folder. 27 | * 28 | * @author Art 29 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue 30 | */ 31 | class ListFolderContinue extends AbstractOperation { 32 | 33 | /** 34 | * Perform the operation, returning a promise or raw response object 35 | * 36 | * @author Art 37 | * 38 | * @param string $cursor The cursor returned by {@link ListFolder} 39 | * 40 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 41 | * async is set to true and the 42 | * request interface if it is 43 | * set to false 44 | * @throws \GuzzleHttp\Exception\ClientException 45 | */ 46 | public function raw($cursor) { 47 | return $this->sendAbstract( 48 | 'POST', 49 | RPCOperation::HOST . '/' . self::API_VERSION . '/files/list_folder/continue', 50 | [ 51 | 'headers' => ['Content-Type' => 'application/json'], 52 | 'body' => json_encode(['cursor' => $cursor]) 53 | ] 54 | ); 55 | } 56 | } -------------------------------------------------------------------------------- /src/Operation/Files/ListFolder/Longpoll.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\ListFolder; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\Options\Builder\LongpollOptions; 23 | use Alorel\Dropbox\Options\Option as O; 24 | use GuzzleHttp\Psr7\Request; 25 | 26 | /** 27 | * A longpoll endpoint to wait for changes on an account. In conjunction with list_folder/continue, this call 28 | * gives you a low-latency way to monitor an account for file changes. The connection will block until there are 29 | * changes available or a timeout occurs. This endpoint is useful mostly for client-side apps. 30 | * 31 | * @author Art 32 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-longpoll 33 | */ 34 | class Longpoll extends AbstractOperation { 35 | 36 | /** 37 | * The host for this operation 38 | * 39 | * @var string 40 | */ 41 | const HOST = 'notify.dropboxapi.com'; 42 | 43 | /** 44 | * Perform the operation, returning a promise or raw response object 45 | * 46 | * @author Art 47 | * 48 | * @param string $cursor The cursor returned by {@link ListFolder} 49 | * @param LongpollOptions $opts Additional options 50 | * 51 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 52 | * async is set to true and the 53 | * request interface if it is 54 | * set to false 55 | * @throws \GuzzleHttp\Exception\ClientException 56 | */ 57 | public function raw($cursor, LongpollOptions $opts = null) { 58 | $body = [O::CURSOR => $cursor]; 59 | if ($opts) { 60 | $body = array_merge($body, $opts->toArray()); 61 | } 62 | 63 | return call_user_func( 64 | $this->getSendCallable(), 65 | new Request( 66 | 'POST', 67 | 'https://' . self::HOST . '/' . self::API_VERSION . '/files/list_folder/longpoll', 68 | ['Content-Type' => 'application/json'], 69 | json_encode($body) 70 | ) 71 | ); 72 | } 73 | } -------------------------------------------------------------------------------- /src/Operation/Files/ListRevisions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Builder\ListRevisionsOptions; 23 | 24 | /** 25 | * Return revisions of a file 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_revisions 29 | */ 30 | class ListRevisions extends RPCOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $path Path to the file 38 | * @param ListRevisionsOptions|null $options Additional options 39 | * 40 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 41 | * async is set to true and the 42 | * request interface if it is 43 | * set to false 44 | * @throws \GuzzleHttp\Exception\ClientException 45 | */ 46 | public function raw($path, ListRevisionsOptions $options = null) { 47 | return $this->send('files/list_revisions', $path, $options); 48 | } 49 | } -------------------------------------------------------------------------------- /src/Operation/Files/Move.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\SourceDestRPCOperation; 22 | 23 | /** 24 | * The Move operation 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-move 28 | */ 29 | class Move extends SourceDestRPCOperation { 30 | 31 | } -------------------------------------------------------------------------------- /src/Operation/Files/PermanentlyDelete.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\SingleArgumentRPCOperation; 22 | 23 | /** 24 | * The permanently_delete operation 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-permanently_delete 28 | */ 29 | class PermanentlyDelete extends SingleArgumentRPCOperation { 30 | 31 | } -------------------------------------------------------------------------------- /src/Operation/Files/Restore.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * Restore a file to a specific revision 27 | * 28 | * @author Art 29 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-restore 30 | */ 31 | class Restore extends RPCOperation { 32 | 33 | /** 34 | * Perform the operation, returning a promise or raw response object 35 | * 36 | * @author Art 37 | * 38 | * @param string $path Path to the folder 39 | * @param string $revision The revision you want to restore to 40 | * 41 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 42 | * async is set to true and the 43 | * request interface if it is 44 | * set to false 45 | * @throws \GuzzleHttp\Exception\ClientException 46 | */ 47 | public function raw($path, $revision) { 48 | return $this->send('files/restore', $path, new Options([Option::REVISION => $revision])); 49 | } 50 | } -------------------------------------------------------------------------------- /src/Operation/Files/SaveUrl/CheckJobStatus.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\SaveUrl; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | 24 | /** 25 | * Check the status of a save_url job. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-save_url-check_job_status 29 | */ 30 | class CheckJobStatus extends RPCOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $jobID The asynchronous job ID 38 | * 39 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 40 | * async is set to true and the 41 | * request interface if it is 42 | * set to false 43 | * @throws \GuzzleHttp\Exception\ClientException 44 | */ 45 | public function raw($jobID) { 46 | return $this->send('files/save_url/check_job_status', 47 | [ 48 | Option::ASYNC_JOB_ID => $jobID 49 | ]); 50 | } 51 | } -------------------------------------------------------------------------------- /src/Operation/Files/SaveUrl/SaveURL.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\SaveUrl; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * Save a specified URL into a file in user's Dropbox. If the given path already exists, the file will be renamed 27 | * to avoid the conflict (e.g. myfile (1).txt). 28 | * 29 | * @author Art 30 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-save_url 31 | */ 32 | class SaveURL extends RPCOperation { 33 | 34 | /** 35 | * Perform the operation, returning a promise or raw response object 36 | * 37 | * @author Art 38 | * 39 | * @param string $path Path to save to 40 | * @param string $url 41 | * 42 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 43 | * async is set to true and the 44 | * request interface if it is 45 | * set to false 46 | * @throws \GuzzleHttp\Exception\ClientException 47 | */ 48 | public function raw($path, $url) { 49 | return $this->send('files/save_url', $path, new Options([Option::URL => $url])); 50 | } 51 | } -------------------------------------------------------------------------------- /src/Operation/Files/Search.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Builder\SearchOptions; 23 | use Alorel\Dropbox\Options\Option; 24 | use Alorel\Dropbox\Options\Options; 25 | 26 | /** 27 | * Searches for files and folders. Note: Recent changes may not immediately be reflected in search results due to 28 | * a short delay in indexing. 29 | * 30 | * @author Art 31 | * 32 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-search 33 | */ 34 | class Search extends RPCOperation { 35 | 36 | /** 37 | * Perform the operation, returning a promise or raw response object 38 | * 39 | * @author Art 40 | * 41 | * @param string $query The search query 42 | * @param string $path The folder to search 43 | * @param SearchOptions|null $options Additional options 44 | * 45 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 46 | * async is set to true and the 47 | * request interface if it is 48 | * set to false 49 | * @throws \GuzzleHttp\Exception\ClientException 50 | */ 51 | public function raw($query, $path = '', SearchOptions $options = null) { 52 | return $this->send( 53 | 'files/search', 54 | $path, 55 | Options::merge([Option::QUERY => $query], $options) 56 | ); 57 | } 58 | } -------------------------------------------------------------------------------- /src/Operation/Files/Upload.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentUploadAbstractOperation; 22 | use Alorel\Dropbox\Options\Builder\UploadOptions; 23 | 24 | /** 25 | * Create a new file with the contents provided in the request. Do not use this to upload a file larger than 26 | * 150 MB. Instead, create an upload session with upload_session/start. 27 | * 28 | * @author Art 29 | * @see \Alorel\Dropbox\Operation\Files\UploadSession\Start 30 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload 31 | */ 32 | class Upload extends ContentUploadAbstractOperation { 33 | 34 | /** 35 | * Perform the operation, returning a promise or raw response object 36 | * 37 | * @author Art 38 | * 39 | * @param string $path The path to upload the file to 40 | * @param string|resource|\Psr\Http\Message\StreamInterface $data The file contents. Can be a string, a fopen() 41 | * resource or an instance of StreamInterface 42 | * @param UploadOptions|null $options Any additional options 43 | * 44 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 45 | * async is set to true and the 46 | * request interface if it is 47 | * set to false 48 | * @throws \GuzzleHttp\Exception\ClientException 49 | */ 50 | public function raw($path, $data, UploadOptions $options = null) { 51 | return $this->send('upload', $path, $data, $options); 52 | } 53 | } -------------------------------------------------------------------------------- /src/Operation/Files/UploadSession/Append.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\UploadSession; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentUploadAbstractOperation; 22 | use Alorel\Dropbox\Options\Builder\UploadSession\UploadSessionActiveOptions; 23 | use Alorel\Dropbox\Options\Option; 24 | use Alorel\Dropbox\Options\Options; 25 | use Alorel\Dropbox\Parameters\UploadSessionCursor; 26 | 27 | /** 28 | * Append more data to an upload session. When the parameter close is set, this call will close the session. A 29 | * single request should not upload more than 150 MB of file contents. 30 | * 31 | * @author Art 32 | */ 33 | class Append extends ContentUploadAbstractOperation { 34 | 35 | /** 36 | * Perform the operation, returning a promise or raw response object 37 | * 38 | * @author Art 39 | * 40 | * @param string|resource|\Psr\Http\Message\StreamInterface $data The file contents. Can be a string, a fopen() 41 | * @param UploadSessionCursor $cursor The upload session cursor 42 | * @param UploadSessionActiveOptions|null $options Additional operation options 43 | * 44 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 45 | * async is set to true and the 46 | * request interface if it is 47 | * set to false 48 | * @throws \GuzzleHttp\Exception\ClientException 49 | */ 50 | public function raw($data, UploadSessionCursor $cursor, UploadSessionActiveOptions $options = null) { 51 | return $this->send('upload_session/append_v2', 52 | null, 53 | $data, 54 | Options::merge( 55 | $options, 56 | [Option::CURSOR => $cursor] 57 | )); 58 | } 59 | } -------------------------------------------------------------------------------- /src/Operation/Files/UploadSession/Finish.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\UploadSession; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentUploadAbstractOperation; 22 | use Alorel\Dropbox\Options\Option as O; 23 | use Alorel\Dropbox\Options\Options; 24 | use Alorel\Dropbox\Parameters\CommitInfo; 25 | use Alorel\Dropbox\Parameters\UploadSessionCursor; 26 | 27 | /** 28 | * Finish an upload session and save the uploaded data to the given file path. A single request should not upload 29 | * more than 150 MB of file contents. 30 | * 31 | * @author Art 32 | */ 33 | class Finish extends ContentUploadAbstractOperation { 34 | 35 | /** 36 | * Perform the operation, returning a promise or raw response object 37 | * 38 | * @author Art 39 | * 40 | * @param string|resource|\Psr\Http\Message\StreamInterface $data The file contents. Can be a string, a fopen() 41 | * resource or an instance of StreamInterface 42 | * @param UploadSessionCursor $cursor The upload session cursor 43 | * @param CommitInfo $commitInfo Final info, such as path and options 44 | * available to the regular upload 45 | * operation 46 | * 47 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 48 | * async is set to true and the 49 | * request interface if it is 50 | * set to false 51 | * @throws \GuzzleHttp\Exception\ClientException 52 | */ 53 | public function raw($data, UploadSessionCursor $cursor, CommitInfo $commitInfo) { 54 | return $this->send('upload_session/finish', 55 | null, 56 | $data, 57 | new Options([ 58 | O::CURSOR => $cursor, 59 | O::COMMIT_INFO => $commitInfo 60 | ])); 61 | } 62 | } -------------------------------------------------------------------------------- /src/Operation/Files/UploadSession/Start.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Files\UploadSession; 20 | 21 | use Alorel\Dropbox\OperationKind\ContentUploadAbstractOperation; 22 | use Alorel\Dropbox\Options\Builder\UploadSession\UploadSessionActiveOptions; 23 | 24 | /** 25 | * Upload sessions allow you to upload a single file using multiple requests. This call starts a new upload 26 | * session with the given data. You can then use upload_session/append to add more data and upload_session/finish 27 | * to save all the data to a file in Dropbox. 28 | *

29 | * A single request should not upload more than 150 MB of file contents. 30 | * 31 | * @author Art 32 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start 33 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2 34 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish 35 | * @see Append 36 | * @see Finish 37 | */ 38 | class Start extends ContentUploadAbstractOperation { 39 | 40 | /** 41 | * Perform the operation, returning a promise or raw response object 42 | * 43 | * @author Art 44 | * 45 | * @param UploadSessionActiveOptions|null $options Additional options 46 | * 47 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 48 | * async is set to true and the 49 | * request interface if it is 50 | * set to false 51 | * @throws \GuzzleHttp\Exception\ClientException 52 | */ 53 | public function raw(UploadSessionActiveOptions $options = null) { 54 | return $this->send('upload_session/start', null, null, $options); 55 | } 56 | } -------------------------------------------------------------------------------- /src/Operation/Users/GetAccount.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Users; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | 24 | /** 25 | * Get information about a user's account. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#users-get_account 29 | */ 30 | class GetAccount extends RPCOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string $accountID The ID of the account we're grabbing 38 | * 39 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 40 | * async is set to true and the 41 | * request interface if it is 42 | * set to false 43 | * @throws \GuzzleHttp\Exception\ClientException 44 | */ 45 | public function raw($accountID) { 46 | if (stripos($accountID, 'dbid:') !== 0) { 47 | $accountID = 'dbid:' . $accountID; 48 | } 49 | 50 | return $this->send('users/get_account', 51 | [ 52 | Option::ACCOUNT_ID => $accountID 53 | ]); 54 | } 55 | } -------------------------------------------------------------------------------- /src/Operation/Users/GetAccountBatch.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Users; 20 | 21 | use Alorel\Dropbox\OperationKind\RPCOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | 24 | /** 25 | *Get information about multiple user accounts. At most 300 accounts may be queried per request. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#users-get_account_batch 29 | */ 30 | class GetAccountBatch extends RPCOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * 37 | * @param string[] $accountIDs The ID of the account we're grabbing. Unlike with {@link GetAccount}, you need to include the "dbid:" prefix with this method 38 | * 39 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 40 | * async is set to true and the 41 | * request interface if it is 42 | * set to false 43 | * @throws \GuzzleHttp\Exception\ClientException 44 | */ 45 | public function raw(...$accountIDs) { 46 | 47 | return $this->send('users/get_account_batch', 48 | [ 49 | Option::ACCOUNT_IDS => $accountIDs 50 | ]); 51 | } 52 | } -------------------------------------------------------------------------------- /src/Operation/Users/GetCurrentAccount.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Users; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\OperationKind\RPCOperation; 23 | 24 | /** 25 | * Get information about the current user's account. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account 29 | */ 30 | class GetCurrentAccount extends AbstractOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 37 | * async is set to true and the 38 | * request interface if it is 39 | * set to false 40 | * @throws \GuzzleHttp\Exception\ClientException 41 | */ 42 | public function raw() { 43 | return $this->sendAbstract( 44 | 'POST', 45 | RPCOperation::HOST . '/' . self::API_VERSION . '/users/get_current_account' 46 | ); 47 | } 48 | } -------------------------------------------------------------------------------- /src/Operation/Users/GetSpaceUsage.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Operation\Users; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\OperationKind\RPCOperation; 23 | 24 | /** 25 | * Get the space usage information for the current user's account. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#users-get_space_usage 29 | */ 30 | class GetSpaceUsage extends AbstractOperation { 31 | 32 | /** 33 | * Perform the operation, returning a promise or raw response object 34 | * 35 | * @author Art 36 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 37 | * async is set to true and the 38 | * request interface if it is 39 | * set to false 40 | * @throws \GuzzleHttp\Exception\ClientException 41 | */ 42 | public function raw() { 43 | return $this->sendAbstract( 44 | 'POST', 45 | RPCOperation::HOST . '/' . self::API_VERSION . '/users/get_space_usage' 46 | ); 47 | } 48 | } -------------------------------------------------------------------------------- /src/OperationKind/ContentDownloadOperation.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\OperationKind; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * Abstraction for content downloads 27 | * 28 | * @author Art 29 | */ 30 | class ContentDownloadOperation extends AbstractOperation { 31 | 32 | /** 33 | * The host for this set of operations 34 | * 35 | * @var string 36 | */ 37 | const HOST = 'content.dropboxapi.com'; 38 | 39 | /** 40 | * Send our request 41 | * 42 | * @author Art 43 | * 44 | * @param string $url Endpoint URL 45 | * @param string $path Path to the target 46 | * @param Options|null $opts Any additional options 47 | * 48 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 49 | * async is set to true and the 50 | * request interface if it is 51 | * set to false 52 | * @throws \GuzzleHttp\Exception\ClientException 53 | */ 54 | public function send($url, $path, Options $opts = null) { 55 | $params = [ 56 | Option::PATH => $path 57 | ]; 58 | 59 | if ($opts) { 60 | $params = array_merge($params, $opts->toArray()); 61 | } 62 | 63 | return $this->sendAbstract( 64 | 'POST', 65 | self::HOST . '/' . self::API_VERSION . '/files/' . $url, 66 | ['headers' => ['Dropbox-API-Arg' => json_encode($params)]] 67 | ); 68 | } 69 | } -------------------------------------------------------------------------------- /src/OperationKind/ContentUploadAbstractOperation.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\OperationKind; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * A wrapper for the ContentUpload group of operations 27 | * 28 | * @author Art 29 | * @see https://www.dropbox.com/developers/documentation/http/documentation#formats 30 | */ 31 | abstract class ContentUploadAbstractOperation extends AbstractOperation { 32 | 33 | /** 34 | * The hostname for these operations 35 | * 36 | * @var string 37 | */ 38 | const HOST = 'content.dropboxapi.com'; 39 | 40 | /** 41 | * Send the request 42 | * 43 | * @author Art 44 | * 45 | * @param string $url The URL to send to. This will be prepended 46 | * with the HOST, API version and "files/" 47 | * @param string $path The path to upload the file to 48 | * @param string|resource|\Psr\Http\Message\StreamInterface $body The file contents. Can be a string, a fopen() 49 | * resource or an instance of StreamInterface 50 | * @param \Alorel\Dropbox\Options\Options|null $opts Any additional, operation-specific options 51 | * 52 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 53 | * async is set to true and the 54 | * request interface if it is 55 | * set to false 56 | * @throws \GuzzleHttp\Exception\ClientException 57 | * @see ContentUploadOperation::HOST 58 | * @see Operation::API_VERSION 59 | */ 60 | protected function send($url, $path, $body, Options $opts = null) { 61 | $headers = [ 62 | 'Content-Type' => 'application/octet-stream', 63 | 'Dropbox-API-Arg' => [] 64 | ]; 65 | $arg = &$headers['Dropbox-API-Arg']; 66 | 67 | if ($path) { 68 | $arg[Option::PATH] = $path; 69 | } 70 | 71 | if ($opts) { 72 | $arg = array_merge($arg, $opts->toArray()); 73 | } 74 | 75 | $arg = $arg ? json_encode($arg) : '{}'; 76 | 77 | $params = [ 78 | 'headers' => $headers 79 | ]; 80 | if ($body !== null) { 81 | $params['body'] = $body; 82 | } 83 | 84 | return $this->sendAbstract('POST', 85 | self::HOST . '/' . self::API_VERSION . '/files/' . $url, 86 | $params); 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/OperationKind/RPCOperation.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\OperationKind; 20 | 21 | use Alorel\Dropbox\Operation\AbstractOperation; 22 | use Alorel\Dropbox\Options\Option; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * Wrapper for RPC endpoints 27 | * 28 | * @author Art 29 | */ 30 | class RPCOperation extends AbstractOperation { 31 | 32 | /** 33 | * The hostname for these requests 34 | * 35 | * @var string 36 | */ 37 | const HOST = 'api.dropboxapi.com'; 38 | 39 | /** 40 | * Send the request 41 | * 42 | * @author Art 43 | * 44 | * @param string $url The URL to send to. This will be prepended with the HOST and API version 45 | * @param array|string $path The paths involved. Will be a string for most operations or an array for 46 | * move/copy operations 47 | * @param Options|null $options Additional options 48 | * 49 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 50 | * async is set to true and the 51 | * request interface if it is 52 | * set to false 53 | * @throws \GuzzleHttp\Exception\ClientException 54 | */ 55 | protected function send($url, $path, Options $options = null) { 56 | $body = is_array($path) ? $path : [ 57 | Option::PATH => $path 58 | ]; 59 | if ($options) { 60 | $body = array_merge($body, $options->toArray()); 61 | } 62 | 63 | return $this->sendAbstract( 64 | 'POST', 65 | self::HOST . '/' . self::API_VERSION . '/' . $url, 66 | [ 67 | 'headers' => ['Content-Type' => 'application/json'], 68 | 'body' => json_encode($body) 69 | ] 70 | ); 71 | } 72 | } -------------------------------------------------------------------------------- /src/OperationKind/SingleArgumentRPCOperation.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\OperationKind; 20 | 21 | use Alorel\Dropbox\Operation\Files\CopyReference\Get; 22 | use Alorel\Dropbox\Operation\Files\CreateFolder; 23 | use Alorel\Dropbox\Operation\Files\Delete; 24 | use Alorel\Dropbox\Operation\Files\GetPreview; 25 | use Alorel\Dropbox\Operation\Files\GetTemporaryLink; 26 | use Alorel\Dropbox\Operation\Files\PermanentlyDelete; 27 | 28 | /** 29 | * A subtype of RPC that only accepts a single argument 30 | * 31 | * @author Art 32 | */ 33 | class SingleArgumentRPCOperation extends RPCOperation { 34 | 35 | /** 36 | * Class to URL mapping 37 | * 38 | * @var string[] 39 | */ 40 | private static $map = [ 41 | Delete::class => 'files/delete', 42 | PermanentlyDelete::class => 'files/permanently_delete', 43 | Get::class => 'files/copy_reference/get', 44 | CreateFolder::class => 'files/create_folder', 45 | GetPreview::class => 'files/get_preview', 46 | GetTemporaryLink::class => 'files/get_temporary_link' 47 | ]; 48 | 49 | /** 50 | * Perform the operation, returning a promise or raw response object 51 | * 52 | * @author Art 53 | * 54 | * @param string $path The path operate on 55 | * 56 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 57 | * async is set to true and the 58 | * request interface if it is 59 | * set to false 60 | * @throws \GuzzleHttp\Exception\ClientException 61 | */ 62 | public function raw($path) { 63 | return $this->send(self::$map[get_class($this)], $path); 64 | } 65 | } -------------------------------------------------------------------------------- /src/OperationKind/SourceDestRPCOperation.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\OperationKind; 20 | 21 | use Alorel\Dropbox\Operation\Files\Copy; 22 | use Alorel\Dropbox\Operation\Files\Move; 23 | use Alorel\Dropbox\Options\Option as O; 24 | 25 | /** 26 | * A subtype of RPC that only needs a source path and a destination path 27 | * 28 | * @author Art 29 | */ 30 | class SourceDestRPCOperation extends RPCOperation { 31 | 32 | /** 33 | * Class to URL mapping 34 | * 35 | * @var string[] 36 | */ 37 | private static $map = [ 38 | Move::class => 'files/move', 39 | Copy::class => 'files/copy' 40 | ]; 41 | 42 | /** 43 | * Perform the operation, returning a promise or raw response object 44 | * 45 | * @author Art 46 | * 47 | * @param string $from The source path 48 | * @param string $to The destination path 49 | * 50 | * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if 51 | * async is set to true and the 52 | * request interface if it is 53 | * set to false 54 | * @throws \GuzzleHttp\Exception\ClientException 55 | */ 56 | public function raw($from, $to) { 57 | return $this->send(self::$map[get_class($this)], 58 | [ 59 | O::PATH_SRC => $from, 60 | O::PATH_DEST => $to 61 | ]); 62 | } 63 | } -------------------------------------------------------------------------------- /src/Options/Builder/GetMetadataOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\IncludeDeletedTrait; 22 | use Alorel\Dropbox\Options\Mixins\IncludeHasExplicitSharedMembersTrait; 23 | use Alorel\Dropbox\Options\Mixins\IncludeMediaInfoTrait; 24 | use Alorel\Dropbox\Options\Options; 25 | 26 | /** 27 | * Additional options for the GetMetadata operation 28 | * 29 | * @author Art 30 | * @see \Alorel\Dropbox\Operation\Files\GetMetadata 31 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata 32 | */ 33 | class GetMetadataOptions extends Options { 34 | use IncludeDeletedTrait; 35 | use IncludeHasExplicitSharedMembersTrait; 36 | use IncludeMediaInfoTrait; 37 | } -------------------------------------------------------------------------------- /src/Options/Builder/GetThumbnailOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\ThumbnailFormatTrait; 22 | use Alorel\Dropbox\Options\Mixins\ThumbnailSizeTrait; 23 | use Alorel\Dropbox\Options\Options; 24 | 25 | /** 26 | * Options for the get_thumbnail operation 27 | * 28 | * @author Art 29 | */ 30 | class GetThumbnailOptions extends Options { 31 | use ThumbnailSizeTrait; 32 | use ThumbnailFormatTrait; 33 | } -------------------------------------------------------------------------------- /src/Options/Builder/ListFolderOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\RecursiveTrait; 22 | 23 | /** 24 | * Additional options for the ListFolder operation 25 | * 26 | * @author Art 27 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder 28 | */ 29 | class ListFolderOptions extends GetMetadataOptions { 30 | use RecursiveTrait; 31 | } -------------------------------------------------------------------------------- /src/Options/Builder/ListRevisionsOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\LimitTrait; 22 | use Alorel\Dropbox\Options\Options; 23 | 24 | /** 25 | * Additional options for the list_revisions operation 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-list_revisions 29 | */ 30 | class ListRevisionsOptions extends Options { 31 | use LimitTrait; 32 | } -------------------------------------------------------------------------------- /src/Options/Builder/LongpollOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\TimeoutTrait; 22 | use Alorel\Dropbox\Options\Options; 23 | 24 | /** 25 | * Options for the Longpoll operation 26 | * 27 | * @author Art 28 | * @see \Alorel\Dropbox\Operation\Files\ListFolder\Longpoll 29 | */ 30 | class LongpollOptions extends Options { 31 | use TimeoutTrait; 32 | } -------------------------------------------------------------------------------- /src/Options/Builder/SearchOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\MaxResultsTrait; 22 | use Alorel\Dropbox\Options\Mixins\SearchModeTrait; 23 | use Alorel\Dropbox\Options\Mixins\StartTrait; 24 | use Alorel\Dropbox\Options\Options; 25 | 26 | /** 27 | * Options for the search operation 28 | * 29 | * @author Art 30 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-search 31 | */ 32 | class SearchOptions extends Options { 33 | use StartTrait; 34 | use MaxResultsTrait; 35 | use SearchModeTrait; 36 | } -------------------------------------------------------------------------------- /src/Options/Builder/UploadOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder; 20 | 21 | use Alorel\Dropbox\Options\Mixins\AutoRenameTrait; 22 | use Alorel\Dropbox\Options\Mixins\ClientModifiedTrait; 23 | use Alorel\Dropbox\Options\Mixins\MuteTrait; 24 | use Alorel\Dropbox\Options\Mixins\WriteModeTrait; 25 | use Alorel\Dropbox\Options\Options; 26 | 27 | /** 28 | * Additional options for the Upload operation 29 | * 30 | * @author Art 31 | * @see \Alorel\Dropbox\Operation\Files\Upload 32 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload 33 | */ 34 | class UploadOptions extends Options { 35 | 36 | use WriteModeTrait; 37 | use AutoRenameTrait; 38 | use ClientModifiedTrait; 39 | use MuteTrait; 40 | } -------------------------------------------------------------------------------- /src/Options/Builder/UploadSession/UploadSessionActiveOptions.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Builder\UploadSession; 20 | 21 | use Alorel\Dropbox\Options\Mixins\CloseTrait; 22 | use Alorel\Dropbox\Options\Options; 23 | 24 | /** 25 | * Additional options for upload_session/start 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start 29 | * @see \Alorel\Dropbox\Operation\Files\UploadSession\Start 30 | */ 31 | class UploadSessionActiveOptions extends Options { 32 | 33 | use CloseTrait; 34 | } -------------------------------------------------------------------------------- /src/Options/Mixins/AutoRenameTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * If there's a conflict, as determined by mode, have the Dropbox server try to autorename the file to avoid 25 | * conflict. The default for this field is False. 26 | * 27 | * @author Art 28 | */ 29 | trait AutoRenameTrait { 30 | 31 | /** 32 | * If there's a conflict, as determined by mode, have the Dropbox server try to autorename the file to avoid 33 | * conflict. The default for this field is False. 34 | * 35 | * @author Art 36 | * 37 | * @param bool $set The setting 38 | * 39 | * @return self 40 | */ 41 | public function setAutoRename($set) { 42 | $this[Option::AUTO_RENAME] = $set; 43 | 44 | return $this; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Options/Mixins/ClientModifiedTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | use Alorel\Dropbox\Options\Options; 23 | use DateTimeInterface; 24 | 25 | /** 26 | * The value to store as the client_modified timestamp. Dropbox automatically records the time at which the file 27 | * was written to the Dropbox servers. It can also record an additional timestamp, provided by Dropbox desktop 28 | * clients, mobile clients, and API apps of when the file was actually created or modified 29 | * 30 | * @author Art 31 | */ 32 | trait ClientModifiedTrait { 33 | 34 | /** 35 | * The value to store as the client_modified timestamp. Dropbox automatically records the time at which the 36 | * file was written to the Dropbox servers. It can also record an additional timestamp, provided by Dropbox 37 | * desktop clients, mobile clients, and API apps of when the file was actually created or modified. 38 | * 39 | * @author Art 40 | * 41 | * @param DateTimeInterface $set The setting 42 | * 43 | * @return self 44 | */ 45 | public function setClientModified(DateTimeInterface $set) { 46 | $this[Option::CLIENT_MODIFIED] = $set->format(Options::DATETIME_FORMAT); 47 | 48 | return $this; 49 | } 50 | } -------------------------------------------------------------------------------- /src/Options/Mixins/CloseTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * If true, current session will be closed. You cannot do upload_session/append any more to current session The 25 | * default for this field is False. 26 | * 27 | * @author Art 28 | * @see \Alorel\Dropbox\Operation\Files\UploadSession\Append 29 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2 30 | */ 31 | trait CloseTrait { 32 | 33 | /** 34 | * If true, current session will be closed. You cannot do upload_session/append any more to current session The 35 | * default for this field is False. 36 | * 37 | * @author Art 38 | * 39 | * @param bool $set The switch 40 | * 41 | * @return self 42 | */ 43 | public function setClose($set) { 44 | $this[Option::CLOSE] = $set; 45 | 46 | return $this; 47 | } 48 | } -------------------------------------------------------------------------------- /src/Options/Mixins/IncludeDeletedTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * If true, DeletedMetadata will be returned for deleted file or folder, otherwise LookupError.not_found will be 25 | * returned. The default for this field is False. 26 | * 27 | * @author Art 28 | */ 29 | trait IncludeDeletedTrait { 30 | 31 | /** 32 | * If true, DeletedMetadata will be returned for deleted file or folder, otherwise LookupError.not_found will 33 | * be returned. The default for this field is False. 34 | * 35 | * @author Art 36 | * 37 | * @param bool $set The setting 38 | * 39 | * @return self 40 | */ 41 | public function setIncludeDeleted($set) { 42 | $this[Option::INCLUDE_DELETED] = $set; 43 | 44 | return $this; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Options/Mixins/IncludeHasExplicitSharedMembersTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * If true, the results will include a flag for each file indicating whether or not that file has any explicit 25 | * members. The default for this field is False. 26 | * 27 | * @author Art 28 | */ 29 | trait IncludeHasExplicitSharedMembersTrait { 30 | 31 | /** 32 | * If true, the results will include a flag for each file indicating whether or not that file has any explicit 33 | * members. The default for this field is False. 34 | * 35 | * @author Art 36 | * 37 | * @param bool $set The setting 38 | * 39 | * @return self 40 | */ 41 | public function setIncludeHasExplicitSharedMembers($set) { 42 | $this[Option::INCLUDE_HAS_EXPLICIT_SHARED_MEMBERS] = $set; 43 | 44 | return $this; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Options/Mixins/IncludeMediaInfoTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * If true, FileMetadata.media_info is set for photo and video. The default for this field is False. 25 | * 26 | * @author Art 27 | */ 28 | trait IncludeMediaInfoTrait { 29 | 30 | /** 31 | * If true, FileMetadata.media_info is set for photo and video. The default for this field is False. 32 | * 33 | * @author Art 34 | * 35 | * @param bool $set The setting 36 | * 37 | * @return self 38 | */ 39 | public function setIncludeMediaInfo($set) { 40 | $this[Option::INCLUDE_MEDIA_INFO] = $set; 41 | 42 | return $this; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Options/Mixins/LimitTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * The maximum number of entries returned. The default for this field is 10. 25 | * 26 | * @author Art 27 | */ 28 | trait LimitTrait { 29 | 30 | /** 31 | * The maximum number of entries returned. The default for this field is 10. 32 | * 33 | * @author Art 34 | * 35 | * @param int $set The setting 36 | * 37 | * @return self 38 | */ 39 | public function setLimit($set) { 40 | $this[Option::LIMIT] = $set; 41 | 42 | return $this; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Options/Mixins/MaxResultsTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * The maximum number of search results to return. The default for this field is 100. 25 | * 26 | * @author Art 27 | */ 28 | trait MaxResultsTrait { 29 | 30 | /** 31 | * The maximum number of search results to return. The default for this field is 100. 32 | * 33 | * @author Art 34 | * 35 | * @param int $set The max number of results 36 | * 37 | * @return self 38 | */ 39 | public function setMaxResults($set) { 40 | $this[Option::MAX_RESULTS] = $set; 41 | 42 | return $this; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Options/Mixins/MuteTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * Normally, users are made aware of any file modifications in their Dropbox account via notifications in the 25 | * client software. If true, this tells the clients that this modification shouldn't result in a user 26 | * notification. The default for this field is False. 27 | * 28 | * @author Art 29 | */ 30 | trait MuteTrait { 31 | 32 | /** 33 | * Normally, users are made aware of any file modifications in their Dropbox account via notifications in the 34 | * client software. If true, this tells the clients that this modification shouldn't result in a user 35 | * notification. The default for this field is False. 36 | * 37 | * @author Art 38 | * 39 | * @param bool $set The setting 40 | * 41 | * @return self 42 | */ 43 | public function setMute($set) { 44 | $this[Option::MUTE] = $set; 45 | 46 | return $this; 47 | } 48 | } -------------------------------------------------------------------------------- /src/Options/Mixins/RecursiveTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * If true, the operation will apply to all subfolders, too. The default value is false. 25 | * 26 | * @author Art 27 | */ 28 | trait RecursiveTrait { 29 | 30 | /** 31 | * If true, the operation will apply to all subfolders, too. The default value is false. 32 | * 33 | * @author Art 34 | * 35 | * @param bool $set The setting 36 | * 37 | * @return self 38 | */ 39 | public function setRecursive($set) { 40 | $this[Option::RECURSIVE] = $set; 41 | 42 | return $this; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Options/Mixins/SearchModeTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | use Alorel\Dropbox\Parameters\SearchMode; 23 | 24 | /** 25 | * The search mode (filename, filename_and_content, or deleted_filename). Note that searching file content is 26 | * only available for Dropbox Business accounts. The default for this union is filename. 27 | * 28 | * @author Art 29 | */ 30 | trait SearchModeTrait { 31 | 32 | /** 33 | * The search mode (filename, filename_and_content, or deleted_filename). Note that searching file content is 34 | * only available for Dropbox Business accounts. The default for this union is filename. 35 | * 36 | * @author Art 37 | * 38 | * @param SearchMode $set The search mode 39 | * 40 | * @return self 41 | */ 42 | public function setSearchMode(SearchMode $set) { 43 | $this[Option::MODE] = $set; 44 | 45 | return $this; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Options/Mixins/StartTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | 23 | /** 24 | * The starting index within the search results (used for paging). The default for this field is 0. 25 | * 26 | * @author Art 27 | */ 28 | trait StartTrait { 29 | 30 | /** 31 | * The starting index within the search results (used for paging). The default for this field is 0. 32 | * 33 | * @author Art 34 | * 35 | * @param int $start The start index 36 | * 37 | * @return self 38 | */ 39 | public function setStart($start) { 40 | $this[Option::START] = $start; 41 | 42 | return $this; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Options/Mixins/ThumbnailFormatTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | use Alorel\Dropbox\Parameters\ThumbnailFormat; 23 | 24 | /** 25 | * The format for the thumbnail image, jpeg (default) or png. For images that are photos, jpeg should be preferred, 26 | * while png is better for screenshots and digital arts. The default for this union is jpeg. 27 | * 28 | * @author Art 29 | */ 30 | trait ThumbnailFormatTrait { 31 | 32 | /** 33 | * The format for the thumbnail image, jpeg (default) or png. For images that are photos, jpeg should be preferred, 34 | * while png is better for screenshots and digital arts. The default for this union is jpeg. 35 | * 36 | * @author Art 37 | * 38 | * @param ThumbnailFormat $format The format 39 | * 40 | * @return self 41 | */ 42 | public function setThumbnailFormat(ThumbnailFormat $format) { 43 | $this[Option::FORMAT] = $format; 44 | 45 | return $this; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Options/Mixins/ThumbnailSizeTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | use Alorel\Dropbox\Parameters\ThumbnailSize; 23 | 24 | /** 25 | * The size for the thumbnail image. The default for this union is w64h64. 26 | * 27 | * @author Art 28 | */ 29 | trait ThumbnailSizeTrait { 30 | 31 | /** 32 | * The size for the thumbnail image. The default for this union is w64h64. 33 | * 34 | * @author Art 35 | * 36 | * @param ThumbnailSize $size The size 37 | * 38 | * @return self 39 | */ 40 | public function setThumbnailSize(ThumbnailSize $size) { 41 | $this[Option::SIZE] = $size; 42 | 43 | return $this; 44 | } 45 | } -------------------------------------------------------------------------------- /src/Options/Mixins/TimeoutTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /** 20 | * Created by PhpStorm. 21 | * User: Art 22 | * Date: 03/06/2016 23 | * Time: 23:26 24 | */ 25 | 26 | namespace Alorel\Dropbox\Options\Mixins; 27 | 28 | use Alorel\Dropbox\Options\Option; 29 | 30 | /** 31 | * A timeout in seconds. The request will block for at most this length of time, plus up to 90 seconds of random 32 | * jitter added to avoid the thundering herd problem. Care should be taken when using this parameter, as some 33 | * network infrastructure does not support long timeouts. The default for this field is 30. 34 | * 35 | * @author Art 36 | */ 37 | trait TimeoutTrait { 38 | 39 | /** 40 | * A timeout in seconds. The request will block for at most this length of time, plus up to 90 seconds of random 41 | * jitter added to avoid the thundering herd problem. Care should be taken when using this parameter, as some 42 | * network infrastructure does not support long timeouts. The default for this field is 30. 43 | * 44 | * @author Art 45 | * 46 | * @param int $timeout The timeout 47 | * 48 | * @return self 49 | */ 50 | public function setTimeout($timeout) { 51 | $this[Option::TIMEOUT] = $timeout; 52 | 53 | return $this; 54 | } 55 | } -------------------------------------------------------------------------------- /src/Options/Mixins/WriteModeTrait.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options\Mixins; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | use Alorel\Dropbox\Parameters\WriteMode; 23 | 24 | /** 25 | * Selects what to do if the file already exists. The default for this union is add. 26 | *

27 | * Your intent when writing a file to some path. This is used to determine what constitutes a conflict and what the 28 | * autorename strategy is. 29 | *

30 | * In some situations, the conflict behavior is identical: 31 | *
    32 | *
  1. If the target path doesn't contain anything, the file is always written; no conflict.
  2. 33 | *
  3. If the target path contains a folder, it's always a conflict.
  4. 34 | *
  5. If the target path contains a file with identical contents, nothing gets written; no conflict
  6. 35 | *
36 | * The conflict checking differs in the case where there's a file at the target path with contents different from 37 | * the contents you're trying to write 38 | * 39 | * @author Art 40 | */ 41 | trait WriteModeTrait { 42 | 43 | /** 44 | * Selects what to do if the file already exists. The default for this union is add. 45 | *

46 | * Your intent when writing a file to some path. This is used to determine what constitutes a conflict and what the 47 | * autorename strategy is. 48 | *

49 | * In some situations, the conflict behavior is identical: 50 | *
    51 | *
  1. If the target path doesn't contain anything, the file is always written; no conflict.
  2. 52 | *
  3. If the target path contains a folder, it's always a conflict.
  4. 53 | *
  5. If the target path contains a file with identical contents, nothing gets written; no conflict
  6. 54 | *
55 | * The conflict checking differs in the case where there's a file at the target path with contents different from 56 | * the contents you're trying to write 57 | * 58 | * @author Art 59 | * 60 | * @param WriteMode $set The write mode 61 | * 62 | * @return self 63 | */ 64 | public function setWriteMode(WriteMode $set) { 65 | $this[Option::MODE] = $set; 66 | 67 | return $this; 68 | } 69 | } -------------------------------------------------------------------------------- /src/Options/Option.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options; 20 | 21 | /** 22 | * Option names 23 | * 24 | * @author Art 25 | */ 26 | class Option { 27 | 28 | /** 29 | * A copy reference 30 | * 31 | * @var string 32 | */ 33 | const COPY_REFERENCE = 'copy_reference'; 34 | 35 | /** 36 | * Account ID 37 | * 38 | * @var string 39 | */ 40 | const ACCOUNT_ID = 'account_id'; 41 | 42 | /** 43 | * Account IDs 44 | * 45 | * @var string 46 | */ 47 | const ACCOUNT_IDS = 'account_ids'; 48 | 49 | /** 50 | * Start index 51 | * 52 | * @var string 53 | */ 54 | const START = 'start'; 55 | 56 | /** 57 | * The URL to work with 58 | * 59 | * @var string 60 | */ 61 | const URL = 'url'; 62 | 63 | /** 64 | * An asynchronous job ID 65 | * 66 | * @var string 67 | */ 68 | const ASYNC_JOB_ID = 'async_job_id'; 69 | 70 | /** 71 | * What we're searching for 72 | * 73 | * @var string 74 | */ 75 | const QUERY = 'query'; 76 | 77 | /** 78 | * Max # of results 79 | * 80 | * @var string 81 | */ 82 | const MAX_RESULTS = 'max_results'; 83 | 84 | /** 85 | * Image size 86 | * 87 | * @var string 88 | */ 89 | const SIZE = 'size'; 90 | 91 | /** 92 | * Session cursor 93 | * 94 | * @var string 95 | */ 96 | const CURSOR = 'cursor'; 97 | 98 | /** 99 | * Session commit information 100 | * 101 | * @var string 102 | */ 103 | const COMMIT_INFO = 'commit'; 104 | 105 | /** 106 | * Write mode 107 | * 108 | * @var string 109 | */ 110 | const MODE = 'mode'; 111 | 112 | /** 113 | * Mute change notifications 114 | * 115 | * @var string 116 | */ 117 | const MUTE = 'mute'; 118 | 119 | /** 120 | * File upload closing 121 | * 122 | * @var string 123 | */ 124 | const CLOSE = 'close'; 125 | 126 | /** 127 | * Client modified timestamp 128 | * 129 | * @var string 130 | */ 131 | const CLIENT_MODIFIED = 'client_modified'; 132 | 133 | /** 134 | * File renaming policy 135 | * 136 | * @var string 137 | */ 138 | const AUTO_RENAME = 'autorename'; 139 | 140 | /** 141 | * Recursion setting 142 | * 143 | * @var string 144 | */ 145 | const RECURSIVE = 'recursive'; 146 | 147 | /** 148 | * The timeout setting 149 | * 150 | * @var string 151 | */ 152 | const TIMEOUT = 'timeout'; 153 | 154 | /** 155 | * File format 156 | * 157 | * @var string 158 | */ 159 | const FORMAT = 'format'; 160 | 161 | /** 162 | * Whether to include deleted entries 163 | * 164 | * @var string 165 | */ 166 | const INCLUDE_DELETED = 'include_deleted'; 167 | 168 | /** 169 | * Whether to include media info 170 | * 171 | * @var string 172 | */ 173 | const INCLUDE_MEDIA_INFO = 'include_media_info'; 174 | 175 | /** 176 | * Whether to include the "has_explicit_shared_members" flag 177 | * 178 | * @var string 179 | */ 180 | const INCLUDE_HAS_EXPLICIT_SHARED_MEMBERS = 'include_has_explicit_shared_members'; 181 | 182 | /** 183 | * Result limit 184 | * 185 | * @var string 186 | */ 187 | const LIMIT = 'limit'; 188 | 189 | /** 190 | * The main target path 191 | * 192 | * @var string 193 | */ 194 | const PATH = 'path'; 195 | 196 | /** 197 | * The source path 198 | * 199 | * @var string 200 | */ 201 | const PATH_SRC = 'from_path'; 202 | 203 | /** 204 | * Destination path 205 | * 206 | * @var string 207 | */ 208 | const PATH_DEST = 'to_path'; 209 | 210 | /** 211 | * The upload session ID 212 | * 213 | * @var string 214 | */ 215 | const SESSION_ID = 'session_id'; 216 | 217 | /** 218 | * The session offset 219 | * 220 | * @var string 221 | */ 222 | const OFFSET = 'offset'; 223 | 224 | /** 225 | * Tags 226 | * 227 | * @var string 228 | */ 229 | const DOT_TAG = '.tag'; 230 | 231 | /** 232 | * File revision 233 | * 234 | * @var string 235 | */ 236 | const REVISION = 'rev'; 237 | 238 | /** 239 | * Update revision 240 | * 241 | * @var string 242 | */ 243 | const UPDATE = 'update'; 244 | } -------------------------------------------------------------------------------- /src/Options/Options.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Options; 20 | 21 | use AloFramework\Common\Alo; 22 | use Alorel\Dropbox\Util; 23 | use ArrayAccess; 24 | 25 | /** 26 | * Abstract options wrapper 27 | * 28 | * @author Art 29 | */ 30 | class Options implements ArrayAccess { 31 | 32 | /** 33 | * A Dropbox-friendly timestamp wrapper 34 | * 35 | * @var string 36 | */ 37 | const DATETIME_FORMAT = 'Y-m-d\TH:i:s\Z'; 38 | 39 | /** 40 | * The generated options 41 | * 42 | * @var array 43 | */ 44 | private $options; 45 | 46 | /** 47 | * Options constructor. 48 | * 49 | * @author Art 50 | * 51 | * @param array $defaults Default options 52 | */ 53 | public function __construct(array $defaults = []) { 54 | $this->options = Util::trimNulls($defaults); 55 | } 56 | 57 | /** 58 | * Whether a offset exists 59 | * 60 | * @author Art 61 | * @see http://php.net/manual/en/arrayaccess.offsetexists.php 62 | * 63 | * @param string $offset An offset to check for. 64 | * 65 | * @return boolean true on success or false on failure. The return value will be casted to boolean if 66 | * non-boolean was returned. 67 | */ 68 | public function offsetExists($offset) { 69 | return array_key_exists($offset, $this->options); 70 | } 71 | 72 | /** 73 | * Offset to retrieve 74 | * 75 | * @author Art 76 | * @see http://php.net/manual/en/arrayaccess.offsetget.php 77 | * 78 | * @param string $offset The offset to retrieve. 79 | * 80 | * @return mixed Can return all value types. 81 | */ 82 | public function offsetGet($offset) { 83 | return Alo::get($this->options[$offset]); 84 | } 85 | 86 | /** 87 | * Offset to set 88 | * 89 | * @author Art 90 | * @see http://php.net/manual/en/arrayaccess.offsetset.php 91 | * 92 | * @param string $offset The offset to assign the value to. 93 | * @param mixed $value The value to set. 94 | */ 95 | public function offsetSet($offset, $value) { 96 | $this->options[$offset] = $value; 97 | } 98 | 99 | /** 100 | * Offset to unset 101 | * 102 | * @author Art 103 | * @see http://php.net/manual/en/arrayaccess.offsetunset.php 104 | * 105 | * @param string $offset The offset to unset. 106 | */ 107 | public function offsetUnset($offset) { 108 | unset($this->options[$offset]); 109 | } 110 | 111 | /** 112 | * Create an Options object from a combination of configuration arrays and other option objects 113 | * 114 | * @author Art 115 | * 116 | * @param array ...$options The items to merge 117 | * 118 | * @return Options 119 | */ 120 | public static function merge(...$options) { 121 | $o = []; 122 | 123 | foreach ($options as $opt) { 124 | if ($opt instanceof Options) { 125 | $o = array_merge($o, $opt->toArray()); 126 | } elseif (is_array($opt)) { 127 | $o = array_merge($o, $opt); 128 | } 129 | } 130 | 131 | return new self(Util::trimNulls($o)); 132 | } 133 | 134 | /** 135 | * Return the generated options 136 | * 137 | * @author Art 138 | * @return array 139 | */ 140 | public function toArray() { 141 | return $this->options; 142 | } 143 | } -------------------------------------------------------------------------------- /src/Parameters/AbstractParameter.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Util; 22 | use JsonSerializable; 23 | 24 | /** 25 | * Topmost abstract parameter class 26 | * 27 | * @author Art 28 | */ 29 | abstract class AbstractParameter implements JsonSerializable { 30 | 31 | /** 32 | * Parameter arguments 33 | * 34 | * @var array 35 | */ 36 | private $args; 37 | 38 | /** 39 | * AbstractParameter constructor. 40 | * 41 | * @author Art 42 | * 43 | * @param array $args Arguments to set 44 | */ 45 | protected function __construct(array $args = []) { 46 | $this->args = Util::trimNulls($args); 47 | } 48 | 49 | /** 50 | * Sets an argument value 51 | * 52 | * @author Art 53 | * 54 | * @param string $key The argument 55 | * @param mixed $value The value 56 | * 57 | * @return self 58 | */ 59 | protected function setArg($key, $value) { 60 | if ($value !== null) { 61 | $this->args[$key] = $value; 62 | } 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Specify data which should be serialized to JSON 69 | * 70 | * @author Art 71 | * 72 | * @see http://php.net/manual/en/jsonserializable.jsonserialize.php 73 | * @return array data which can be serialized by json_encode, which is a value of any type other than 74 | * a resource. 75 | */ 76 | public function jsonSerialize() { 77 | return $this->args; 78 | } 79 | 80 | /** 81 | * A shorthand for JSON-encoding parameters 82 | * 83 | * @author Art 84 | * @return string 85 | * @uses json_encode() 86 | */ 87 | public function __toString() { 88 | return json_encode($this); 89 | } 90 | } -------------------------------------------------------------------------------- /src/Parameters/CommitInfo.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Options\Option as O; 22 | use Alorel\Dropbox\Options\Options; 23 | use DateTimeInterface; 24 | 25 | /** 26 | * Contains the path and other optional modifiers for the commit. 27 | * 28 | * @author Art 29 | */ 30 | class CommitInfo extends AbstractParameter { 31 | 32 | /** 33 | * CommitInfo constructor. 34 | * 35 | * @author Art 36 | * 37 | * @param string $path Path in the user's Dropbox to save the file. 38 | * @param WriteMode|null $writeMode Selects what to do if the file already exists. The default for 39 | * this union is add. 40 | * @param bool $autorename If there's a conflict, as determined by mode, have the Dropbox 41 | * server try to autorename the file to avoid conflict. The default 42 | * for this field is False. 43 | * @param bool $mute Normally, users are made aware of any file modifications in their 44 | * Dropbox account via notifications in the client software. If 45 | * true, this tells the clients that this modification shouldn't 46 | * result in a user notification. The default for this field is False. 47 | * @param DateTimeInterface|null $clientModified The value to store as the client_modified timestamp. Dropbox 48 | * automatically records the time at which the file was written to 49 | * the Dropbox servers. It can also record an additional timestamp, 50 | * provided by Dropbox desktop clients, mobile clients, and API apps 51 | * of when the file was actually created or modified. This field is 52 | * optional. 53 | * 54 | * @see WriteMode 55 | */ 56 | public function __construct($path, 57 | WriteMode $writeMode = null, 58 | $autorename = false, 59 | $mute = false, 60 | DateTimeInterface $clientModified = null) { 61 | parent::__construct([ 62 | O::PATH => $path, 63 | O::MODE => $writeMode, 64 | O::AUTO_RENAME => $autorename, 65 | O::CLIENT_MODIFIED => $clientModified ? 66 | $clientModified->format(Options::DATETIME_FORMAT) : null, 67 | O::MUTE => $mute 68 | ]); 69 | } 70 | } -------------------------------------------------------------------------------- /src/Parameters/SearchMode.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Options\Option as O; 22 | 23 | /** 24 | * What we're searching for

25 | * Note: Recent changes may not immediately be reflected in search results due to a short delay in indexing. 26 | * 27 | * @author Art 28 | * @see https://www.dropbox.com/developers/documentation/http/documentation#files-search 29 | */ 30 | class SearchMode extends AbstractParameter { 31 | 32 | /** 33 | * Search only existing file names 34 | * 35 | * @var string 36 | */ 37 | const TAG_FILENAME = 'filename'; 38 | 39 | /** 40 | * Search file names and their contents 41 | * 42 | * @var string 43 | */ 44 | const TAG_FILENAME_AND_CONTENT = 'filename_and_content'; 45 | 46 | /** 47 | * Deleted file names 48 | * 49 | * @var string 50 | */ 51 | const DELETED_FILENAME = 'deleted_filename'; 52 | 53 | /** 54 | * SearchMode constructor. 55 | * 56 | * @author Art 57 | * 58 | * @param string $tag The search mode 59 | */ 60 | protected function __construct($tag) { 61 | parent::__construct([O::DOT_TAG => $tag]); 62 | } 63 | 64 | /** 65 | * Search file and folder names. 66 | * 67 | * @author Art 68 | * @return SearchMode 69 | */ 70 | public static function filename() { 71 | return new self(self::TAG_FILENAME); 72 | } 73 | 74 | /** 75 | * Search file and folder names as well as file contents. 76 | * 77 | * @author Art 78 | * @return SearchMode 79 | */ 80 | public static function filenameAndContent() { 81 | return new self(self::TAG_FILENAME_AND_CONTENT); 82 | } 83 | 84 | /** 85 | * Search for deleted file and folder names. 86 | * 87 | * @author Art 88 | * @return SearchMode 89 | */ 90 | public static function deletedFilename() { 91 | return new self(self::DELETED_FILENAME); 92 | } 93 | } -------------------------------------------------------------------------------- /src/Parameters/ThumbnailFormat.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Options\Option as O; 22 | use ReflectionClass; 23 | 24 | /** 25 | * The format for the thumbnail image, jpeg (default) or png. For images that are photos, jpeg should be 26 | * preferred, while png is better for screenshots and digital arts. The default for this union is jpeg. 27 | * 28 | * @author Art 29 | */ 30 | class ThumbnailFormat extends AbstractParameter { 31 | 32 | /** 33 | * Dot jpg 34 | * 35 | * @var string 36 | */ 37 | const JPEG = 'jpeg'; 38 | 39 | /** 40 | * dot png 41 | * 42 | * @var string 43 | */ 44 | const PNG = 'png'; 45 | 46 | /** 47 | * ImageFormat constructor. 48 | * 49 | * @author Art 50 | * 51 | * @param string $format Image format 52 | */ 53 | protected function __construct($format) { 54 | parent::__construct([O::DOT_TAG => $format]); 55 | } 56 | 57 | /** 58 | * Set the image format to JPEG 59 | * 60 | * @author Art 61 | * @return self 62 | */ 63 | public static function jpeg() { 64 | return new self(static::JPEG); 65 | } 66 | 67 | /** 68 | * Set the image format to PNG 69 | * 70 | * @author Art 71 | * @return self 72 | */ 73 | public static function png() { 74 | return new self(static::PNG); 75 | } 76 | 77 | /** 78 | * Return the available formats 79 | * 80 | * @author Art 81 | * @return array 82 | */ 83 | public static function availableFormats() { 84 | return (new ReflectionClass(ThumbnailFormat::class))->getConstants(); 85 | } 86 | } -------------------------------------------------------------------------------- /src/Parameters/ThumbnailSize.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Options\Option; 22 | use ReflectionClass; 23 | 24 | /** 25 | * The size for the thumbnail image. The default for this union is 64x64. 26 | * 27 | * @author Art 28 | */ 29 | class ThumbnailSize extends AbstractParameter { 30 | 31 | /** 32 | * ThumbnailSize constructor. 33 | * 34 | * @author Art 35 | * 36 | * @param int $width Thumbnail width 37 | * @param int $height Thumbnail height 38 | */ 39 | public function __construct($width, $height) { 40 | parent::__construct([Option::DOT_TAG => 'w' . $width . 'h' . $height]); 41 | } 42 | 43 | /** 44 | * Make the size 32 pixels wide, 32 pixels height 45 | * 46 | * @author Art 47 | * @return self 48 | */ 49 | public static function w32h32() { 50 | return new self(32, 32); 51 | } 52 | 53 | /** 54 | * Make the size 64 pixels wide, 64 pixels high 55 | * 56 | * @author Art 57 | * @return self 58 | */ 59 | public static function w64h64() { 60 | return new self(64, 64); 61 | } 62 | 63 | /** 64 | * Make the size 128 pixels wide, 128 pixels high 65 | * 66 | * @author Art 67 | * @return self 68 | */ 69 | public static function w128h128() { 70 | return new self(128, 128); 71 | } 72 | 73 | /** 74 | * Make the size 640 pixels wide, 480 pixels high 75 | * 76 | * @author Art 77 | * @return self 78 | */ 79 | public static function w640h480() { 80 | return new self(640, 480); 81 | } 82 | 83 | /** 84 | * Make the size 1024 pixels wide, 768 pixels high 85 | * 86 | * @author Art 87 | * @return self 88 | */ 89 | public static function w1024h768() { 90 | return new self(1024, 768); 91 | } 92 | 93 | /** 94 | * Return a list ov available thumbnail sizes 95 | * 96 | * @author Art 97 | * @return array 98 | */ 99 | public static function availableSizes() { 100 | $r = []; 101 | foreach ((new ReflectionClass(ThumbnailSize::class))->getMethods() as $m) { 102 | if (preg_match('~^w[0-9]+h[0-9]+$~', $m->getName())) { 103 | $r[] = $m->getName(); 104 | } 105 | }; 106 | 107 | return $r; 108 | } 109 | } -------------------------------------------------------------------------------- /src/Parameters/UploadSessionCursor.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Options\Option as O; 22 | 23 | /** 24 | * Contains the upload session ID and the offset. 25 | * 26 | * @author Art 27 | */ 28 | class UploadSessionCursor extends AbstractParameter { 29 | 30 | /** 31 | * UploadSessionCursor constructor. 32 | * 33 | * @author Art 34 | * 35 | * @param string $sessionID The upload session ID (returned by upload_session/start). 36 | * @param int $offset The amount of data that has been uploaded so far. We use this to make sure upload 37 | * data isn't lost or duplicated in the event of a network error. 38 | */ 39 | public function __construct($sessionID, $offset = 0) { 40 | parent::__construct([ 41 | O::SESSION_ID => $sessionID, 42 | O::OFFSET => $offset 43 | ]); 44 | } 45 | 46 | /** 47 | * Sets the cursor offset 48 | * 49 | * @author Art 50 | * 51 | * @param int $offset The offset 52 | * 53 | * @return self 54 | */ 55 | public function setOffset($offset) { 56 | return $this->setArg(O::OFFSET, $offset); 57 | } 58 | } -------------------------------------------------------------------------------- /src/Parameters/WriteMode.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Parameters; 20 | 21 | use Alorel\Dropbox\Options\Option as O; 22 | 23 | /** 24 | * Selects what to do if the file already exists. The default for this union is add. 25 | *

26 | * Your intent when writing a file to some path. This is used to determine what constitutes a conflict and what the 27 | * autorename strategy is. 28 | *

29 | * In some situations, the conflict behavior is identical: 30 | *
    31 | *
  1. If the target path doesn't contain anything, the file is always written; no conflict.
  2. 32 | *
  3. If the target path contains a folder, it's always a conflict.
  4. 33 | *
  5. If the target path contains a file with identical contents, nothing gets written; no conflict
  6. 34 | *
35 | * The conflict checking differs in the case where there's a file at the target path with contents different from 36 | * the contents you're trying to write 37 | * 38 | * @author Art 39 | */ 40 | class WriteMode extends AbstractParameter { 41 | 42 | /** 43 | * Used by {@link WriteMode::add()} 44 | * 45 | * @var string 46 | */ 47 | const TAG_ADD = 'add'; 48 | 49 | /** 50 | * Used by {@link WriteMode::overwrite()} 51 | * 52 | * @var string 53 | */ 54 | const TAG_OVERWRITE = 'overwrite'; 55 | 56 | /** 57 | * Used by {@link WriteMode::update()} 58 | * 59 | * @var string 60 | */ 61 | const TAG_UPDATE = 'update'; 62 | 63 | /** 64 | * WriteMode constructor. 65 | * 66 | * @author Art 67 | * 68 | * @param string $tag The main write mode 69 | * @param string|null $rev The revision, if updating 70 | */ 71 | protected function __construct($tag, $rev = null) { 72 | parent::__construct([ 73 | O::DOT_TAG => $tag, 74 | O::UPDATE => $rev 75 | ]); 76 | } 77 | 78 | /** 79 | * Never overwrite the existing file. The autorename strategy is to append a number to the file name. For 80 | * example, "document.txt" might become "document (2).txt". 81 | * 82 | * @author Art 83 | * 84 | * @return self 85 | */ 86 | public static function add() { 87 | return new self(static::TAG_ADD); 88 | } 89 | 90 | /** 91 | * Always overwrite the existing file. The autorename strategy is the same as it is for add. 92 | * 93 | * @author Art 94 | * @return self 95 | */ 96 | public static function overwrite() { 97 | return new self(static::TAG_OVERWRITE); 98 | } 99 | 100 | /** 101 | * Overwrite if the given "rev" matches the existing file's "rev". The autorename strategy is to append the 102 | * string "conflicted copy" to the file name. For example, "document.txt" might become "document (conflicted 103 | * copy).txt" or "document (Panda's conflicted copy).txt". 104 | * 105 | * @author Art 106 | * 107 | * @param string $rev The "rev" from the description 108 | * 109 | * @return self 110 | */ 111 | public static function update($rev) { 112 | return new self(static::TAG_UPDATE, $rev); 113 | } 114 | } -------------------------------------------------------------------------------- /src/Response/ResponseAttribute.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox\Response; 20 | 21 | /** 22 | * Response attributes 23 | * 24 | * @author Art 25 | */ 26 | abstract class ResponseAttribute { 27 | 28 | /** 29 | * A copy reference 30 | * 31 | * @var string 32 | */ 33 | const COPY_REFERENCE = 'copy_reference'; 34 | 35 | /** 36 | * Metadata 37 | * 38 | * @var string 39 | */ 40 | const METADATA = 'metadata'; 41 | 42 | /** 43 | * A tag 44 | * 45 | * @var string 46 | */ 47 | const DOT_TAG = '.tag'; 48 | 49 | /** 50 | * The display path 51 | * 52 | * @var string 53 | */ 54 | const PATH_DISPLAY = 'path_display'; 55 | 56 | /** 57 | * The lowercase path 58 | * 59 | * @var string 60 | */ 61 | const PATH_LOWERCASE = 'path_lower'; 62 | 63 | /** 64 | * The client modified timestamp 65 | * 66 | * @var string 67 | */ 68 | const CLIENT_MODIFIED = 'client_modified'; 69 | 70 | /** 71 | * The item size 72 | * 73 | * @var string 74 | */ 75 | const SIZE = 'size'; 76 | 77 | /** 78 | * Whether the item has explicit shared members 79 | * 80 | * @var string 81 | */ 82 | const HAS_EXPLICIT_SHARED_MEMBERS = 'has_explicit_shared_members'; 83 | 84 | /** 85 | * The session ID 86 | * 87 | * @var string 88 | */ 89 | const SESSION_ID = 'session_id'; 90 | } -------------------------------------------------------------------------------- /src/Util.php: -------------------------------------------------------------------------------- 1 | 2016. 4 | * https://github.com/Alorel/dropbox-v2-php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Alorel\Dropbox; 20 | 21 | /** 22 | * Miscellaneous utilities 23 | * 24 | * @author Art 25 | */ 26 | class Util { 27 | 28 | /** 29 | * Trims nulls from the input 30 | * 31 | * @author Art 32 | * 33 | * @param array $in The input 34 | * 35 | * @return array The trimmed input 36 | */ 37 | public static function trimNulls(array $in) { 38 | foreach ($in as $k => $v) { 39 | if ($v === null) { 40 | unset($in[$k]); 41 | } 42 | } 43 | 44 | return $in; 45 | } 46 | } --------------------------------------------------------------------------------