diff --git a/CHANGELOG.md b/CHANGELOG.md index b122126..d375d10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 17.4.0 + +* Add transaction support for Databases and TablesDB + ## 17.3.0 * Deprecate `createVerification` method in `Account` service diff --git a/docs/databases.md b/docs/databases.md index e97a483..35d4e4d 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -31,6 +31,87 @@ POST https://cloud.appwrite.io/v1/databases | enabled | boolean | Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. | 1 | +```http request +GET https://cloud.appwrite.io/v1/databases/transactions +``` + +** List transactions across all databases. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). | [] | + + +```http request +POST https://cloud.appwrite.io/v1/databases/transactions +``` + +** Create a new transaction. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| ttl | integer | Seconds before the transaction expires. | 300 | + + +```http request +GET https://cloud.appwrite.io/v1/databases/transactions/{transactionId} +``` + +** Get a transaction by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/transactions/{transactionId} +``` + +** Update a transaction, to either commit or roll back its operations. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | +| commit | boolean | Commit transaction? | | +| rollback | boolean | Rollback transaction? | | + + +```http request +DELETE https://cloud.appwrite.io/v1/databases/transactions/{transactionId} +``` + +** Delete a transaction by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/transactions/{transactionId}/operations +``` + +** Create multiple operations in a single transaction. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | +| operations | array | Array of staged operations. | [] | + + ```http request GET https://cloud.appwrite.io/v1/databases/{databaseId} ``` @@ -705,6 +786,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | 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. | [] | +| transactionId | string | Transaction ID to read uncommitted changes within the transaction. | | ```http request @@ -722,6 +804,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | documentId | string | Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | data | object | Document data as JSON object. | {} | | permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -737,6 +820,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. | | | documents | array | Array of documents data as JSON objects. | [] | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -753,6 +837,7 @@ 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. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -769,6 +854,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | collectionId | string | **Required** Collection ID. | | | data | object | Document data as JSON object. Include only attribute and value pairs to be updated. | {} | | 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. | [] | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -784,6 +870,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | 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. | [] | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -800,6 +887,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | documentId | string | **Required** Document 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. | [] | +| transactionId | string | Transaction ID to read uncommitted changes within the transaction. | | ```http request @@ -817,6 +905,7 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | 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). | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -834,6 +923,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | documentId | string | **Required** Document ID. | | | data | object | Document data as JSON object. Include only attribute and value pairs to be updated. | {} | | permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -849,6 +939,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | documentId | string | **Required** Document ID. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -867,6 +958,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | attribute | string | **Required** Attribute key. | | | value | number | Value to increment 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. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -885,6 +977,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | 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. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -926,7 +1019,7 @@ Attributes can be `key`, `fulltext`, and `unique`. ** GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes/{key} ``` -** Get index by ID. ** +** Get an index by its unique ID. ** ### Parameters diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 9f2e8f3..19d3cfb 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -21,5 +21,6 @@ $result = $databases->createDocument( 'age' => 30, 'isAdmin' => false ], - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index bc05f67..ced7a5a 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -13,5 +13,6 @@ $databases = new Databases($client); $result = $databases->createDocuments( databaseId: '', collectionId: '', - documents: [] + documents: [], + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md new file mode 100644 index 0000000..05038cb --- /dev/null +++ b/docs/examples/databases/create-operations.md @@ -0,0 +1,26 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createOperations( + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md new file mode 100644 index 0000000..ea6faf7 --- /dev/null +++ b/docs/examples/databases/create-transaction.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createTransaction( + ttl: 60 // optional +); \ No newline at end of file diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 6464a26..dfb1873 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -16,5 +16,6 @@ $result = $databases->decrementDocumentAttribute( documentId: '', attribute: '', value: null, // optional - min: null // optional + min: null, // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index def7f24..6e4d7aa 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -13,5 +13,6 @@ $databases = new Databases($client); $result = $databases->deleteDocument( databaseId: '', collectionId: '', - documentId: '' + documentId: '', + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 3552d85..3b2b0c7 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -13,5 +13,6 @@ $databases = new Databases($client); $result = $databases->deleteDocuments( databaseId: '', collectionId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md new file mode 100644 index 0000000..0559aac --- /dev/null +++ b/docs/examples/databases/delete-transaction.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->deleteTransaction( + transactionId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index a3204c5..834602d 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -14,5 +14,6 @@ $result = $databases->getDocument( databaseId: '', collectionId: '', documentId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md new file mode 100644 index 0000000..16ca28d --- /dev/null +++ b/docs/examples/databases/get-transaction.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->getTransaction( + transactionId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 9ad4bdf..63162d3 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -16,5 +16,6 @@ $result = $databases->incrementDocumentAttribute( documentId: '', attribute: '', value: null, // optional - max: null // optional + max: null, // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 07183ac..10dcc82 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -13,5 +13,6 @@ $databases = new Databases($client); $result = $databases->listDocuments( databaseId: '', collectionId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md new file mode 100644 index 0000000..858e905 --- /dev/null +++ b/docs/examples/databases/list-transactions.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->listTransactions( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index f1c8a34..d903252 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -15,5 +15,6 @@ $result = $databases->updateDocument( collectionId: '', documentId: '', data: [], // optional - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 51b4e18..7263246 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -14,5 +14,6 @@ $result = $databases->updateDocuments( databaseId: '', collectionId: '', data: [], // optional - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md new file mode 100644 index 0000000..750eb86 --- /dev/null +++ b/docs/examples/databases/update-transaction.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->updateTransaction( + transactionId: '', + commit: false, // optional + rollback: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 6cff829..6db7462 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -15,5 +15,6 @@ $result = $databases->upsertDocument( collectionId: '', documentId: '', data: [], - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index d9f9efd..06d3a31 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,5 +13,6 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [] + documents: [], + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 46aeeb3..51fc0d0 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -19,7 +19,7 @@ $result = $messaging->createPush( targets: [], // optional data: [], // optional action: '', // optional - image: '[ID1:ID2]', // optional + image: '', // optional icon: '', // optional sound: '', // optional color: '', // optional diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index e1df0b9..05a5178 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -19,7 +19,7 @@ $result = $messaging->updatePush( body: '', // optional data: [], // optional action: '', // optional - image: '[ID1:ID2]', // optional + image: '', // optional icon: '', // optional sound: '', // optional color: '', // optional diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md new file mode 100644 index 0000000..429a0bb --- /dev/null +++ b/docs/examples/tablesdb/create-operations.md @@ -0,0 +1,26 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createOperations( + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index fa5137b..873ecaf 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -21,5 +21,6 @@ $result = $tablesDB->createRow( 'age' => 30, 'isAdmin' => false ], - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 0114438..44c9c7d 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -13,5 +13,6 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createRows( databaseId: '', tableId: '', - rows: [] + rows: [], + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md new file mode 100644 index 0000000..3248818 --- /dev/null +++ b/docs/examples/tablesdb/create-transaction.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createTransaction( + ttl: 60 // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index a58bd71..ede258e 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -16,5 +16,6 @@ $result = $tablesDB->decrementRowColumn( rowId: '', column: '', value: null, // optional - min: null // optional + min: null, // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index 4ffc112..df87c50 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -13,5 +13,6 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->deleteRow( databaseId: '', tableId: '', - rowId: '' + rowId: '', + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 10a3c87..79ed607 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -13,5 +13,6 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->deleteRows( databaseId: '', tableId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md new file mode 100644 index 0000000..d165015 --- /dev/null +++ b/docs/examples/tablesdb/delete-transaction.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->deleteTransaction( + transactionId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 00ba9b6..4bbea55 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -14,5 +14,6 @@ $result = $tablesDB->getRow( databaseId: '', tableId: '', rowId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md new file mode 100644 index 0000000..146e7d1 --- /dev/null +++ b/docs/examples/tablesdb/get-transaction.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->getTransaction( + transactionId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index d72a1e3..66bf2e8 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -16,5 +16,6 @@ $result = $tablesDB->incrementRowColumn( rowId: '', column: '', value: null, // optional - max: null // optional + max: null, // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index c3b7137..5f8c9aa 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -13,5 +13,6 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->listRows( databaseId: '', tableId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md new file mode 100644 index 0000000..15095d6 --- /dev/null +++ b/docs/examples/tablesdb/list-transactions.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->listTransactions( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 70e5d15..c01eba8 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -15,5 +15,6 @@ $result = $tablesDB->updateRow( tableId: '', rowId: '', data: [], // optional - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 8a67628..681a9f0 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -14,5 +14,6 @@ $result = $tablesDB->updateRows( databaseId: '', tableId: '', data: [], // optional - queries: [] // optional + queries: [], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md new file mode 100644 index 0000000..fed3810 --- /dev/null +++ b/docs/examples/tablesdb/update-transaction.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateTransaction( + transactionId: '', + commit: false, // optional + rollback: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 235f0e5..bec3c0a 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -15,5 +15,6 @@ $result = $tablesDB->upsertRow( tableId: '', rowId: '', data: [], // optional - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index c1890f1..fb93df8 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -13,5 +13,6 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->upsertRows( databaseId: '', tableId: '', - rows: [] + rows: [], + transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 62d20c0..a155d3e 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -31,6 +31,87 @@ POST https://cloud.appwrite.io/v1/tablesdb | enabled | boolean | Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. | 1 | +```http request +GET https://cloud.appwrite.io/v1/tablesdb/transactions +``` + +** List transactions across all databases. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). | [] | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/transactions +``` + +** Create a new transaction. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| ttl | integer | Seconds before the transaction expires. | 300 | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/transactions/{transactionId} +``` + +** Get a transaction by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/transactions/{transactionId} +``` + +** Update a transaction, to either commit or roll back its operations. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | +| commit | boolean | Commit transaction? | | +| rollback | boolean | Rollback transaction? | | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/transactions/{transactionId} +``` + +** Delete a transaction by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/transactions/{transactionId}/operations +``` + +** Create multiple operations in a single transaction. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| transactionId | string | **Required** Transaction ID. | | +| operations | array | Array of staged operations. | [] | + + ```http request GET https://cloud.appwrite.io/v1/tablesdb/{databaseId} ``` @@ -769,6 +850,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | databaseId | string | **Required** Database ID. | | | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). | | | 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. | [] | +| transactionId | string | Transaction ID to read uncommitted changes within the transaction. | | ```http request @@ -786,6 +868,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | rowId | string | Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | data | object | Row data as JSON object. | {} | | permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -801,6 +884,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | databaseId | string | **Required** Database ID. | | | tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. | | | rows | array | Array of rows data as JSON objects. | [] | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -817,6 +901,7 @@ PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | databaseId | string | **Required** Database ID. | | | tableId | string | **Required** Table ID. | | | rows | array | Array of row data as JSON objects. May contain partial rows. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -833,6 +918,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | tableId | string | **Required** Table ID. | | | data | object | Row data as JSON object. Include only column and value pairs to be updated. | {} | | 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. | [] | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -848,6 +934,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | databaseId | string | **Required** Database ID. | | | tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | 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. | [] | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -864,6 +951,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ro | tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | rowId | string | **Required** Row 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. | [] | +| transactionId | string | Transaction ID to read uncommitted changes within the transaction. | | ```http request @@ -881,6 +969,7 @@ PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ro | rowId | string | **Required** Row ID. | | | data | object | Row data as JSON object. Include all required columns of the row 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). | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -898,6 +987,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ | rowId | string | **Required** Row ID. | | | data | object | Row data as JSON object. Include only columns and value pairs to be updated. | {} | | permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -913,6 +1003,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/ | databaseId | string | **Required** Database ID. | | | tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | rowId | string | **Required** Row ID. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -931,6 +1022,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ | column | string | **Required** Column key. | | | value | number | Value to increment the column by. The value must be a number. | 1 | | min | number | Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. | | +| transactionId | string | Transaction ID for staging the operation. | | ```http request @@ -949,4 +1041,5 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ | column | string | **Required** Column key. | | | value | number | Value to increment the column by. The value must be a number. | 1 | | max | number | Maximum value for the column. If the current value is greater than this value, an error will be thrown. | | +| transactionId | string | Transaction ID for staging the operation. | | diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 2c89cc5..2ebd173 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/17.3.0 ()', + 'user-agent' => 'AppwritePHPSDK/17.4.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '17.3.0', + 'x-sdk-version'=> '17.4.0', ]; /** diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 9c1b16e..7ecebe3 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -97,6 +97,199 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): ); } + /** + * List transactions across all databases. + * + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listTransactions(?array $queries = null): array + { + $apiPath = str_replace( + [], + [], + '/databases/transactions' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new transaction. + * + * @param ?int $ttl + * @throws AppwriteException + * @return array + */ + public function createTransaction(?int $ttl = null): array + { + $apiPath = str_replace( + [], + [], + '/databases/transactions' + ); + + $apiParams = []; + + if (!is_null($ttl)) { + $apiParams['ttl'] = $ttl; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a transaction by its unique ID. + * + * @param string $transactionId + * @throws AppwriteException + * @return array + */ + public function getTransaction(string $transactionId): array + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/databases/transactions/{transactionId}' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param string $transactionId + * @param ?bool $commit + * @param ?bool $rollback + * @throws AppwriteException + * @return array + */ + public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): array + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/databases/transactions/{transactionId}' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + if (!is_null($commit)) { + $apiParams['commit'] = $commit; + } + + if (!is_null($rollback)) { + $apiParams['rollback'] = $rollback; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a transaction by its unique ID. + * + * @param string $transactionId + * @throws AppwriteException + * @return string + */ + public function deleteTransaction(string $transactionId): string + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/databases/transactions/{transactionId}' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create multiple operations in a single transaction. + * + * @param string $transactionId + * @param ?array $operations + * @throws AppwriteException + * @return array + */ + public function createOperations(string $transactionId, ?array $operations = null): array + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/databases/transactions/{transactionId}/operations' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + if (!is_null($operations)) { + $apiParams['operations'] = $operations; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get a database by its unique ID. This endpoint response returns a JSON * object with the database metadata. @@ -1819,13 +2012,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti * @param string $databaseId * @param string $collectionId * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `listRows` instead. * @see TablesDB::listRows */ - public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null): array + public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1841,6 +2035,10 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; return $this->client->call( @@ -1862,13 +2060,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ * @param string $documentId * @param array $data * @param ?array $permissions + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `createRow` instead. * @see TablesDB::createRow */ - public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array + public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1886,6 +2085,10 @@ public function createDocument(string $databaseId, string $collectionId, string $apiParams['permissions'] = $permissions; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1906,13 +2109,14 @@ public function createDocument(string $databaseId, string $collectionId, string * @param string $databaseId * @param string $collectionId * @param array $documents + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `createRows` instead. * @see TablesDB::createRows */ - public function createDocuments(string $databaseId, string $collectionId, array $documents): array + public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1925,6 +2129,10 @@ public function createDocuments(string $databaseId, string $collectionId, array $apiParams['collectionId'] = $collectionId; $apiParams['documents'] = $documents; + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1946,13 +2154,14 @@ public function createDocuments(string $databaseId, string $collectionId, array * @param string $databaseId * @param string $collectionId * @param array $documents + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRows` instead. * @see TablesDB::upsertRows */ - public function upsertDocuments(string $databaseId, string $collectionId, array $documents): array + public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1965,6 +2174,10 @@ public function upsertDocuments(string $databaseId, string $collectionId, array $apiParams['collectionId'] = $collectionId; $apiParams['documents'] = $documents; + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1985,13 +2198,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array * @param string $collectionId * @param ?array $data * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `updateRows` instead. * @see TablesDB::updateRows */ - public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null): array + public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -2011,6 +2225,10 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2029,13 +2247,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array * @param string $databaseId * @param string $collectionId * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRows` instead. * @see TablesDB::deleteRows */ - public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null): array + public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -2051,6 +2270,10 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2070,13 +2293,14 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array * @param string $collectionId * @param string $documentId * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `getRow` instead. * @see TablesDB::getRow */ - public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null): array + public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -2093,6 +2317,10 @@ public function getDocument(string $databaseId, string $collectionId, string $do $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; return $this->client->call( @@ -2114,13 +2342,14 @@ public function getDocument(string $databaseId, string $collectionId, string $do * @param string $documentId * @param array $data * @param ?array $permissions + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRow` instead. * @see TablesDB::upsertRow */ - public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array + public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -2138,6 +2367,10 @@ public function upsertDocument(string $databaseId, string $collectionId, string $apiParams['permissions'] = $permissions; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2158,13 +2391,14 @@ public function upsertDocument(string $databaseId, string $collectionId, string * @param string $documentId * @param ?array $data * @param ?array $permissions + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `updateRow` instead. * @see TablesDB::updateRow */ - public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null): array + public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -2185,6 +2419,10 @@ public function updateDocument(string $databaseId, string $collectionId, string $apiParams['permissions'] = $permissions; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2202,13 +2440,14 @@ public function updateDocument(string $databaseId, string $collectionId, string * @param string $databaseId * @param string $collectionId * @param string $documentId + * @param ?string $transactionId * @throws AppwriteException * @return string * * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRow` instead. * @see TablesDB::deleteRow */ - public function deleteDocument(string $databaseId, string $collectionId, string $documentId): string + public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -2221,6 +2460,10 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiParams['collectionId'] = $collectionId; $apiParams['documentId'] = $documentId; + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2241,13 +2484,14 @@ public function deleteDocument(string $databaseId, string $collectionId, string * @param string $attribute * @param ?float $value * @param ?float $min + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `decrementRowColumn` instead. * @see TablesDB::decrementRowColumn */ - public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null): array + public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], @@ -2269,6 +2513,10 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio $apiParams['min'] = $min; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2289,13 +2537,14 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio * @param string $attribute * @param ?float $value * @param ?float $max + * @param ?string $transactionId * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `incrementRowColumn` instead. * @see TablesDB::incrementRowColumn */ - public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null): array + public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], @@ -2317,6 +2566,10 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio $apiParams['max'] = $max; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2419,7 +2672,7 @@ public function createIndex(string $databaseId, string $collectionId, string $ke } /** - * Get index by ID. + * Get an index by its unique ID. * * @param string $databaseId * @param string $collectionId diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php index 9d594a0..6a18ec4 100644 --- a/src/Appwrite/Services/TablesDb.php +++ b/src/Appwrite/Services/TablesDb.php @@ -91,6 +91,199 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): ); } + /** + * List transactions across all databases. + * + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listTransactions(?array $queries = null): array + { + $apiPath = str_replace( + [], + [], + '/tablesdb/transactions' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new transaction. + * + * @param ?int $ttl + * @throws AppwriteException + * @return array + */ + public function createTransaction(?int $ttl = null): array + { + $apiPath = str_replace( + [], + [], + '/tablesdb/transactions' + ); + + $apiParams = []; + + if (!is_null($ttl)) { + $apiParams['ttl'] = $ttl; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a transaction by its unique ID. + * + * @param string $transactionId + * @throws AppwriteException + * @return array + */ + public function getTransaction(string $transactionId): array + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/tablesdb/transactions/{transactionId}' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param string $transactionId + * @param ?bool $commit + * @param ?bool $rollback + * @throws AppwriteException + * @return array + */ + public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): array + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/tablesdb/transactions/{transactionId}' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + if (!is_null($commit)) { + $apiParams['commit'] = $commit; + } + + if (!is_null($rollback)) { + $apiParams['rollback'] = $rollback; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a transaction by its unique ID. + * + * @param string $transactionId + * @throws AppwriteException + * @return string + */ + public function deleteTransaction(string $transactionId): string + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/tablesdb/transactions/{transactionId}' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create multiple operations in a single transaction. + * + * @param string $transactionId + * @param ?array $operations + * @throws AppwriteException + * @return array + */ + public function createOperations(string $transactionId, ?array $operations = null): array + { + $apiPath = str_replace( + ['{transactionId}'], + [$transactionId], + '/tablesdb/transactions/{transactionId}/operations' + ); + + $apiParams = []; + $apiParams['transactionId'] = $transactionId; + + if (!is_null($operations)) { + $apiParams['operations'] = $operations; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get a database by its unique ID. This endpoint response returns a JSON * object with the database metadata. @@ -1850,10 +2043,11 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s * @param string $databaseId * @param string $tableId * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function listRows(string $databaseId, string $tableId, ?array $queries = null): array + public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1869,6 +2063,10 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; return $this->client->call( @@ -1890,10 +2088,11 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = * @param string $rowId * @param array $data * @param ?array $permissions + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null): array + public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1911,6 +2110,10 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar $apiParams['permissions'] = $permissions; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1931,10 +2134,11 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar * @param string $databaseId * @param string $tableId * @param array $rows + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function createRows(string $databaseId, string $tableId, array $rows): array + public function createRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1947,6 +2151,10 @@ public function createRows(string $databaseId, string $tableId, array $rows): ar $apiParams['tableId'] = $tableId; $apiParams['rows'] = $rows; + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1968,10 +2176,11 @@ public function createRows(string $databaseId, string $tableId, array $rows): ar * @param string $databaseId * @param string $tableId * @param array $rows + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function upsertRows(string $databaseId, string $tableId, array $rows): array + public function upsertRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1984,6 +2193,10 @@ public function upsertRows(string $databaseId, string $tableId, array $rows): ar $apiParams['tableId'] = $tableId; $apiParams['rows'] = $rows; + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2003,10 +2216,11 @@ public function upsertRows(string $databaseId, string $tableId, array $rows): ar * @param string $tableId * @param ?array $data * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null): array + public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -2026,6 +2240,10 @@ public function updateRows(string $databaseId, string $tableId, ?array $data = n $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2044,10 +2262,11 @@ public function updateRows(string $databaseId, string $tableId, ?array $data = n * @param string $databaseId * @param string $tableId * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function deleteRows(string $databaseId, string $tableId, ?array $queries = null): array + public function deleteRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -2063,6 +2282,10 @@ public function deleteRows(string $databaseId, string $tableId, ?array $queries $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2082,10 +2305,11 @@ public function deleteRows(string $databaseId, string $tableId, ?array $queries * @param string $tableId * @param string $rowId * @param ?array $queries + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null): array + public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], @@ -2102,6 +2326,10 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra $apiParams['queries'] = $queries; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; return $this->client->call( @@ -2123,10 +2351,11 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra * @param string $rowId * @param ?array $data * @param ?array $permissions + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null): array + public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], @@ -2147,6 +2376,10 @@ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?a $apiParams['permissions'] = $permissions; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2167,10 +2400,11 @@ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?a * @param string $rowId * @param ?array $data * @param ?array $permissions + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null): array + public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], @@ -2191,6 +2425,10 @@ public function updateRow(string $databaseId, string $tableId, string $rowId, ?a $apiParams['permissions'] = $permissions; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2208,10 +2446,11 @@ public function updateRow(string $databaseId, string $tableId, string $rowId, ?a * @param string $databaseId * @param string $tableId * @param string $rowId + * @param ?string $transactionId * @throws AppwriteException * @return string */ - public function deleteRow(string $databaseId, string $tableId, string $rowId): string + public function deleteRow(string $databaseId, string $tableId, string $rowId, ?string $transactionId = null): string { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], @@ -2224,6 +2463,10 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId): s $apiParams['tableId'] = $tableId; $apiParams['rowId'] = $rowId; + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2244,10 +2487,11 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId): s * @param string $column * @param ?float $value * @param ?float $min + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null): array + public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], @@ -2269,6 +2513,10 @@ public function decrementRowColumn(string $databaseId, string $tableId, string $ $apiParams['min'] = $min; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -2289,10 +2537,11 @@ public function decrementRowColumn(string $databaseId, string $tableId, string $ * @param string $column * @param ?float $value * @param ?float $max + * @param ?string $transactionId * @throws AppwriteException * @return array */ - public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null): array + public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], @@ -2314,6 +2563,10 @@ public function incrementRowColumn(string $databaseId, string $tableId, string $ $apiParams['max'] = $max; } + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index daa113b..8aa6a6b 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -56,6 +56,126 @@ public function testMethodCreate(): void { $this->assertSame($data, $response); } + public function testMethodListTransactions(): void { + + $data = array( + "total" => 5, + "transactions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->listTransactions( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTransaction(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createTransaction( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTransaction(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->getTransaction( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTransaction(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateTransaction( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteTransaction(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->deleteTransaction( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateOperations(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createOperations( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodGet(): void { $data = array( diff --git a/tests/Appwrite/Services/TablesDbTest.php b/tests/Appwrite/Services/TablesDbTest.php index 34c01d1..5b5d008 100644 --- a/tests/Appwrite/Services/TablesDbTest.php +++ b/tests/Appwrite/Services/TablesDbTest.php @@ -56,6 +56,126 @@ public function testMethodCreate(): void { $this->assertSame($data, $response); } + public function testMethodListTransactions(): void { + + $data = array( + "total" => 5, + "transactions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listTransactions( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTransaction(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createTransaction( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTransaction(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getTransaction( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTransaction(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateTransaction( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteTransaction(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteTransaction( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateOperations(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "status" => "pending", + "operations" => 5, + "expiresAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createOperations( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodGet(): void { $data = array(