diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..d5a323c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,9 @@ -# Change Log \ No newline at end of file +# Change Log + +## 15.1.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `dart38` and `flutter332` support to runtime models +* Add `gif` support to `ImageFormat` enum +* Add `upsertDocument` support to `Databases` service +* Add `sequence` support to `Document` model diff --git a/README.md b/README.md index 1c5d4cd..382a055 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/docs/databases.md b/docs/databases.md index 5ca5264..acca9fc 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -623,7 +623,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** ### Parameters @@ -638,7 +640,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** ### Parameters @@ -647,14 +651,16 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | -| documents | array | Array of document data as JSON objects. May contain partial documents. | [] | +| documents | array | Array of document data as JSON objects. May contain partial documents. | | ```http request PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. ** ### Parameters @@ -670,7 +676,9 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Bulk delete documents using queries, if no queries are passed then all documents are deleted. ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Bulk delete documents using queries, if no queries are passed then all documents are deleted. ** ### Parameters @@ -697,6 +705,25 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | +```http request +PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} +``` + +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| documentId | string | **Required** Document ID. | | +| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} | +| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + ```http request PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` @@ -729,6 +756,42 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | documentId | string | **Required** Document ID. | | +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement +``` + +** Decrement a specific attribute of a document by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| documentId | string | **Required** Document ID. | | +| attribute | string | **Required** Attribute key. | | +| value | number | Value to decrement the attribute by. The value must be a number. | 1 | +| min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment +``` + +** Increment a specific attribute of a document by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| documentId | string | **Required** Document ID. | | +| attribute | string | **Required** Attribute key. | | +| value | number | Value to increment the attribute by. The value must be a number. | 1 | +| max | number | Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. | | + + ```http request GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes ``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 8726b37..bf1ee3f 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -5,9 +5,8 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setKey('') // Your secret API key - ->setJWT(''); // Your secret JSON Web Token + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 96008e2..bc05f67 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -5,6 +5,7 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID ->setKey(''); // Your secret API key $databases = new Databases($client); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..40e14af --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + min: null // optional +); \ No newline at end of file diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..fb61d87 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + max: null // optional +); \ No newline at end of file diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..6cff829 --- /dev/null +++ b/docs/examples/databases/upsert-document.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$databases = new Databases($client); + +$result = $databases->upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: [], + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 7b9459e..d9f9efd 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,5 +13,5 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [] // optional + documents: [] ); \ No newline at end of file diff --git a/docs/tokens.md b/docs/tokens.md index ba4c5df..ca3d831 100644 --- a/docs/tokens.md +++ b/docs/tokens.md @@ -20,7 +20,7 @@ GET https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId} POST https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId} ``` -** Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter. ** +** Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. ** ### Parameters diff --git a/docs/users.md b/docs/users.md index 89c3cba..a31ac8c 100644 --- a/docs/users.md +++ b/docs/users.md @@ -509,7 +509,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/targets | Field Name | Type | Description | Default | | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType | [] | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 27f8cca..4288210 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/15.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/15.1.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '15.0.0', + 'x-sdk-version'=> '15.1.0', ]; /** diff --git a/src/Appwrite/Enums/BuildRuntime.php b/src/Appwrite/Enums/BuildRuntime.php index 0c0936a..4fea891 100644 --- a/src/Appwrite/Enums/BuildRuntime.php +++ b/src/Appwrite/Enums/BuildRuntime.php @@ -43,6 +43,7 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $DART31; private static BuildRuntime $DART33; private static BuildRuntime $DART35; + private static BuildRuntime $DART38; private static BuildRuntime $DOTNET60; private static BuildRuntime $DOTNET70; private static BuildRuntime $DOTNET80; @@ -69,6 +70,7 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $FLUTTER324; private static BuildRuntime $FLUTTER327; private static BuildRuntime $FLUTTER329; + private static BuildRuntime $FLUTTER332; private string $value; @@ -346,6 +348,13 @@ public static function DART35(): BuildRuntime } return self::$DART35; } + public static function DART38(): BuildRuntime + { + if (!isset(self::$DART38)) { + self::$DART38 = new BuildRuntime('dart-3.8'); + } + return self::$DART38; + } public static function DOTNET60(): BuildRuntime { if (!isset(self::$DOTNET60)) { @@ -528,4 +537,11 @@ public static function FLUTTER329(): BuildRuntime } return self::$FLUTTER329; } + public static function FLUTTER332(): BuildRuntime + { + if (!isset(self::$FLUTTER332)) { + self::$FLUTTER332 = new BuildRuntime('flutter-3.32'); + } + return self::$FLUTTER332; + } } \ No newline at end of file diff --git a/src/Appwrite/Enums/ImageFormat.php b/src/Appwrite/Enums/ImageFormat.php index 0ea7a98..8cb2ce6 100644 --- a/src/Appwrite/Enums/ImageFormat.php +++ b/src/Appwrite/Enums/ImageFormat.php @@ -12,6 +12,7 @@ class ImageFormat implements JsonSerializable private static ImageFormat $WEBP; private static ImageFormat $HEIC; private static ImageFormat $AVIF; + private static ImageFormat $GIF; private string $value; @@ -72,4 +73,11 @@ public static function AVIF(): ImageFormat } return self::$AVIF; } + public static function GIF(): ImageFormat + { + if (!isset(self::$GIF)) { + self::$GIF = new ImageFormat('gif'); + } + return self::$GIF; + } } \ No newline at end of file diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php index f29a4d2..a210be9 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -43,6 +43,7 @@ class Runtime implements JsonSerializable private static Runtime $DART31; private static Runtime $DART33; private static Runtime $DART35; + private static Runtime $DART38; private static Runtime $DOTNET60; private static Runtime $DOTNET70; private static Runtime $DOTNET80; @@ -69,6 +70,7 @@ class Runtime implements JsonSerializable private static Runtime $FLUTTER324; private static Runtime $FLUTTER327; private static Runtime $FLUTTER329; + private static Runtime $FLUTTER332; private string $value; @@ -346,6 +348,13 @@ public static function DART35(): Runtime } return self::$DART35; } + public static function DART38(): Runtime + { + if (!isset(self::$DART38)) { + self::$DART38 = new Runtime('dart-3.8'); + } + return self::$DART38; + } public static function DOTNET60(): Runtime { if (!isset(self::$DOTNET60)) { @@ -528,4 +537,11 @@ public static function FLUTTER329(): Runtime } return self::$FLUTTER329; } + public static function FLUTTER332(): Runtime + { + if (!isset(self::$FLUTTER332)) { + self::$FLUTTER332 = new Runtime('flutter-3.32'); + } + return self::$FLUTTER332; + } } \ No newline at end of file diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 66b293c..19cfdbd 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -1535,6 +1535,10 @@ public function createDocument(string $databaseId, string $collectionId, string } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Create new Documents. Before using this route, you should create a new * collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1571,6 +1575,10 @@ public function createDocuments(string $databaseId, string $collectionId, array } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Create or update Documents. Before using this route, you should create a * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1579,11 +1587,11 @@ public function createDocuments(string $databaseId, string $collectionId, array * * @param string $databaseId * @param string $collectionId - * @param ?array $documents + * @param array $documents * @throws AppwriteException * @return array */ - public function upsertDocuments(string $databaseId, string $collectionId, ?array $documents = null): array + public function upsertDocuments(string $databaseId, string $collectionId, array $documents): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1594,10 +1602,7 @@ public function upsertDocuments(string $databaseId, string $collectionId, ?array $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; - - if (!is_null($documents)) { - $apiParams['documents'] = $documents; - } + $apiParams['documents'] = $documents; $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1611,6 +1616,10 @@ public function upsertDocuments(string $databaseId, string $collectionId, ?array } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Update all documents that match your queries, if no queries are submitted * then all documents are updated. You can pass only specific fields to be * updated. @@ -1654,6 +1663,10 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Bulk delete documents using queries, if no queries are passed then all * documents are deleted. * @@ -1728,6 +1741,53 @@ public function getDocument(string $databaseId, string $collectionId, string $do ); } + /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * + * Create or update a Document. Before using this route, you should create a + * new collection resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $collectionId + * @param string $documentId + * @param array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{documentId}'], + [$databaseId, $collectionId, $documentId], + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['documentId'] = $documentId; + $apiParams['data'] = $data; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. @@ -1805,6 +1865,96 @@ public function deleteDocument(string $databaseId, string $collectionId, string ); } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param string $databaseId + * @param string $collectionId + * @param string $documentId + * @param string $attribute + * @param ?float $value + * @param ?float $min + * @throws AppwriteException + * @return array + */ + public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], + [$databaseId, $collectionId, $documentId, $attribute], + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['documentId'] = $documentId; + $apiParams['attribute'] = $attribute; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param string $databaseId + * @param string $collectionId + * @param string $documentId + * @param string $attribute + * @param ?float $value + * @param ?float $max + * @throws AppwriteException + * @return array + */ + public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], + [$databaseId, $collectionId, $documentId, $attribute], + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['documentId'] = $documentId; + $apiParams['attribute'] = $attribute; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * List indexes in the collection. * diff --git a/src/Appwrite/Services/Tokens.php b/src/Appwrite/Services/Tokens.php index 4811f4a..572321a 100644 --- a/src/Appwrite/Services/Tokens.php +++ b/src/Appwrite/Services/Tokens.php @@ -52,7 +52,7 @@ public function list(string $bucketId, string $fileId, ?array $queries = null): /** * Create a new token. A token is linked to a file. Token can be passed as a - * header or request get parameter. + * request URL search parameter. * * @param string $bucketId * @param string $fileId diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index d8ecfd5..e870542 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -867,6 +867,7 @@ public function testMethodCreateDocument(): void { $data = array( "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, "\$collectionId" => "5e5ea5c15117e", "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -921,7 +922,8 @@ public function testMethodUpsertDocuments(): void { $response = $this->databases->upsertDocuments( "", - "" + "", + array() ); $this->assertSame($data, $response); @@ -969,6 +971,7 @@ public function testMethodGetDocument(): void { $data = array( "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, "\$collectionId" => "5e5ea5c15117e", "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -989,10 +992,37 @@ public function testMethodGetDocument(): void { $this->assertSame($data, $response); } + public function testMethodUpsertDocument(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->upsertDocument( + "", + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateDocument(): void { $data = array( "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, "\$collectionId" => "5e5ea5c15117e", "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -1031,6 +1061,58 @@ public function testMethodDeleteDocument(): void { $this->assertSame($data, $response); } + public function testMethodDecrementDocumentAttribute(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->decrementDocumentAttribute( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodIncrementDocumentAttribute(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->incrementDocumentAttribute( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodListIndexes(): void { $data = array(