From d7208f12181996f74bb6935e6fd6156b0635279a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 10 Nov 2025 12:30:04 +0000 Subject: [PATCH 1/3] try fix file name --- CHANGELOG.md | 4 ++++ src/Appwrite/Client.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8727bf6..14a26e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 18.0.1 + +* Fix `TablesDB` service to use correct file name + ## 18.0.0 * Fix duplicate methods issue (e.g., `updateMFA` and `updateMfa`) causing build and runtime errors diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 618f616..28142f8 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/18.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/18.0.1 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '18.0.0', + 'x-sdk-version'=> '18.0.1', ]; /** From a28ae76794d5db6f706d5d7a6a30b5ffdb20b641 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 10 Nov 2025 12:36:34 +0000 Subject: [PATCH 2/3] caseignore --- src/Appwrite/Services/TablesDB.php | 2605 ++++++++++++++++++++++ tests/Appwrite/Services/TablesDBTest.php | 1487 ++++++++++++ 2 files changed, 4092 insertions(+) create mode 100644 src/Appwrite/Services/TablesDB.php create mode 100644 tests/Appwrite/Services/TablesDBTest.php diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php new file mode 100644 index 0000000..a0d9a89 --- /dev/null +++ b/src/Appwrite/Services/TablesDB.php @@ -0,0 +1,2605 @@ +client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Database. + * + * + * @param string $databaseId + * @param string $name + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function create(string $databaseId, string $name, ?bool $enabled = null): array + { + $apiPath = str_replace( + [], + [], + '/tablesdb' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['name'] = $name; + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * 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. + * + * @param string $databaseId + * @throws AppwriteException + * @return array + */ + public function get(string $databaseId): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a database by its unique ID. + * + * @param string $databaseId + * @param string $name + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function update(string $databaseId, string $name, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['name'] = $name; + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a database by its unique ID. Only API keys with with databases.write + * scope can delete a database. + * + * @param string $databaseId + * @throws AppwriteException + * @return string + */ + public function delete(string $databaseId): string + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a list of all tables that belong to the provided databaseId. You can + * use the search parameter to filter your results. + * + * @param string $databaseId + * @param ?array $queries + * @param ?string $search + * @param ?bool $total + * @throws AppwriteException + * @return array + */ + public function listTables(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}/tables' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($search)) { + $apiParams['search'] = $search; + } + + if (!is_null($total)) { + $apiParams['total'] = $total; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Table. Before using this route, you should create a new + * database resource using either a [server + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $name + * @param ?array $permissions + * @param ?bool $rowSecurity + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}/tables' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['name'] = $name; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($rowSecurity)) { + $apiParams['rowSecurity'] = $rowSecurity; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a table by its unique ID. This endpoint response returns a JSON object + * with the table metadata. + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return array + */ + public function getTable(string $databaseId, string $tableId): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a table by its unique ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $name + * @param ?array $permissions + * @param ?bool $rowSecurity + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function updateTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['name'] = $name; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($rowSecurity)) { + $apiParams['rowSecurity'] = $rowSecurity; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a table by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return string + */ + public function deleteTable(string $databaseId, string $tableId): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List columns in the table. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @param ?bool $total + * @throws AppwriteException + * @return array + */ + public function listColumns(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($total)) { + $apiParams['total'] = $total; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a boolean column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?bool $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a boolean column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?bool $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a date time column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an email column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an email column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an enumeration column. The `elements` param acts as a white-list of + * accepted values for this column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param array $elements + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['elements'] = $elements; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an enum column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param array $elements + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['elements'] = $elements; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a float column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?float $min + * @param ?float $max + * @param ?float $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a float column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?float $xdefault + * @param ?float $min + * @param ?float $max + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an integer column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?int $min + * @param ?int $max + * @param ?int $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an integer column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?int $xdefault + * @param ?int $min + * @param ?int $max + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create IP address column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an ip column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a geometric line column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?array $xdefault + * @throws AppwriteException + * @return array + */ + public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a line column. Changing the `default` value will not update already + * existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?array $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a geometric point column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?array $xdefault + * @throws AppwriteException + * @return array + */ + public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a point column. Changing the `default` value will not update already + * existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?array $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a geometric polygon column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?array $xdefault + * @throws AppwriteException + * @return array + */ + public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a polygon column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?array $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param string $databaseId + * @param string $tableId + * @param string $relatedTableId + * @param RelationshipType $type + * @param ?bool $twoWay + * @param ?string $key + * @param ?string $twoWayKey + * @param ?RelationMutate $onDelete + * @throws AppwriteException + * @return array + */ + public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['relatedTableId'] = $relatedTableId; + $apiParams['type'] = $type; + + if (!is_null($twoWay)) { + $apiParams['twoWay'] = $twoWay; + } + + if (!is_null($key)) { + $apiParams['key'] = $key; + } + + if (!is_null($twoWayKey)) { + $apiParams['twoWayKey'] = $twoWayKey; + } + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a string column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param int $size + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @param ?bool $encrypt + * @throws AppwriteException + * @return array + */ + public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['size'] = $size; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + if (!is_null($encrypt)) { + $apiParams['encrypt'] = $encrypt; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a string column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?int $size + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($size)) { + $apiParams['size'] = $size; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a URL column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an url column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get column by ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return array + */ + public function getColumn(string $databaseId, string $tableId, string $key): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Deletes a column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return string + */ + public function deleteColumn(string $databaseId, string $tableId, string $key): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param ?RelationMutate $onDelete + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List indexes on the table. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @param ?bool $total + * @throws AppwriteException + * @return array + */ + public function listIndexes(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/indexes' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($total)) { + $apiParams['total'] = $total; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Creates an index on the columns listed. Your index should include all the + * columns you will query in a single request. + * Type can be `key`, `fulltext`, or `unique`. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param IndexType $type + * @param array $columns + * @param ?array $orders + * @param ?array $lengths + * @throws AppwriteException + * @return array + */ + public function createIndex(string $databaseId, string $tableId, string $key, IndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/indexes' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['type'] = $type; + $apiParams['columns'] = $columns; + + if (!is_null($orders)) { + $apiParams['orders'] = $orders; + } + + if (!is_null($lengths)) { + $apiParams['lengths'] = $lengths; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get index by ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return array + */ + public function getIndex(string $databaseId, string $tableId, string $key): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete an index. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return string + */ + public function deleteIndex(string $databaseId, string $tableId, string $key): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a list of all the user's rows in a given table. You can use the query + * params to filter your results. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @param ?string $transactionId + * @param ?bool $total + * @throws AppwriteException + * @return array + */ + public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + if (!is_null($total)) { + $apiParams['total'] = $total; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Row. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['data'] = $data; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create new Rows. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) + * API or directly from your database console. + * + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rows'] = $rows; + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create or update Rows. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) + * API or directly from your database console. + * + * + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rows'] = $rows; + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update all rows that match your queries, if no queries are submitted then + * all rows are updated. You can pass only specific fields to be updated. + * + * @param string $databaseId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Bulk delete rows using queries, if no queries are passed then all rows are + * deleted. + * + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object + * with the row data. + * + * @param string $databaseId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create or update a Row. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only + * specific fields that will get updated. + * + * @param string $databaseId + * @param string $tableId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a row by its unique ID. + * + * @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 $transactionId = null): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}', '{column}'], + [$databaseId, $tableId, $rowId, $column], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['column'] = $column; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Increment a specific column of a row by a given value. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @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, ?string $transactionId = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}', '{column}'], + [$databaseId, $tableId, $rowId, $column], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['column'] = $column; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($transactionId)) { + $apiParams['transactionId'] = $transactionId; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php new file mode 100644 index 0000000..5b5d008 --- /dev/null +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -0,0 +1,1487 @@ +client = Mockery::mock(Client::class); + $this->tablesDB = new TablesDB($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "databases" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->list( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true, + "type" => "legacy",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->create( + "", + "" + ); + + $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( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true, + "type" => "legacy",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->get( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true, + "type" => "legacy",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->update( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->delete( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListTables(): void { + + $data = array( + "total" => 5, + "tables" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listTables( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createTable( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getTable( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateTable( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteTable(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteTable( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListColumns(): void { + + $data = array( + "total" => 5, + "columns" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listColumns( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBooleanColumn(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->createBooleanColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateBooleanColumn(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->updateBooleanColumn( + "", + "", + "", + true, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateDatetimeColumn(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createDatetimeColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateDatetimeColumn(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateDatetimeColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmailColumn(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createEmailColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmailColumn(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateEmailColumn( + "", + "", + "", + true, + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEnumColumn(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createEnumColumn( + "", + "", + "", + array(), + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEnumColumn(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateEnumColumn( + "", + "", + "", + array(), + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateFloatColumn(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->createFloatColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateFloatColumn(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->updateFloatColumn( + "", + "", + "", + true, + 1.0 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIntegerColumn(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->createIntegerColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIntegerColumn(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->updateIntegerColumn( + "", + "", + "", + true, + 1 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIpColumn(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createIpColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIpColumn(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateIpColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateLineColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->createLineColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateLineColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->updateLineColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePointColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->createPointColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePointColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->updatePointColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePolygonColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->createPolygonColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePolygonColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "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->updatePolygonColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRelationshipColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createRelationshipColumn( + "", + "", + "", + "oneToOne" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateStringColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createStringColumn( + "", + "", + "", + 1, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateStringColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateStringColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateUrlColumn(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createUrlColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateUrlColumn(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateUrlColumn( + "", + "", + "", + true, + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetColumn(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteColumn(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRelationshipColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListIndexes(): void { + + $data = array( + "total" => 5, + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listIndexes( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIndex(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "columns" => array(), + "lengths" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createIndex( + "", + "", + "", + "key", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetIndex(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "columns" => array(), + "lengths" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getIndex( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteIndex(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteIndex( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "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->tablesDB->createRow( + "", + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createRows( + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpsertRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->upsertRows( + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "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->tablesDB->getRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpsertRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "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->tablesDB->upsertRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "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->tablesDB->updateRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteRow(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDecrementRowColumn(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "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->tablesDB->decrementRowColumn( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodIncrementRowColumn(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "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->tablesDB->incrementRowColumn( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + +} From 19bc7211cda77b20525f2903b99038d6f4a0ef09 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 10 Nov 2025 12:44:06 +0000 Subject: [PATCH 3/3] remove file --- .github/ISSUE_TEMPLATE/bug.yaml | 82 - .github/ISSUE_TEMPLATE/documentation.yaml | 32 - .github/ISSUE_TEMPLATE/feature.yaml | 40 - .github/workflows/autoclose.yml | 11 - src/Appwrite/Services/TablesDb.php | 2605 --------------------- tests/Appwrite/Services/TablesDbTest.php | 1487 ------------ 6 files changed, 4257 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug.yaml delete mode 100644 .github/ISSUE_TEMPLATE/documentation.yaml delete mode 100644 .github/ISSUE_TEMPLATE/feature.yaml delete mode 100644 .github/workflows/autoclose.yml delete mode 100644 src/Appwrite/Services/TablesDb.php delete mode 100644 tests/Appwrite/Services/TablesDbTest.php diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml deleted file mode 100644 index f97c941..0000000 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: "🐛 Bug Report" -description: "Submit a bug report to help us improve" -title: "🐛 Bug Report: " -labels: [bug] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out our bug report form 🙏 - - type: textarea - id: steps-to-reproduce - validations: - required: true - attributes: - label: "👟 Reproduction steps" - description: "How do you trigger this bug? Please walk us through it step by step." - placeholder: "When I ..." - - type: textarea - id: expected-behavior - validations: - required: true - attributes: - label: "👍 Expected behavior" - description: "What did you think would happen?" - placeholder: "It should ..." - - type: textarea - id: actual-behavior - validations: - required: true - attributes: - label: "👎 Actual Behavior" - description: "What did actually happen? Add screenshots, if applicable." - placeholder: "It actually ..." - - type: dropdown - id: appwrite-version - attributes: - label: "🎲 Appwrite version" - description: "What version of Appwrite are you running?" - options: - - Version 0.10.x - - Version 0.9.x - - Version 0.8.x - - Version 0.7.x - - Version 0.6.x - - Different version (specify in environment) - validations: - required: true - - type: dropdown - id: operating-system - attributes: - label: "💻 Operating system" - description: "What OS is your server / device running on?" - options: - - Linux - - MacOS - - Windows - - Something else - validations: - required: true - - type: textarea - id: enviromnemt - validations: - required: false - attributes: - label: "🧱 Your Environment" - description: "Is your environment customized in any way?" - placeholder: "I use Cloudflare for ..." - - type: checkboxes - id: no-duplicate-issues - attributes: - label: "👀 Have you spent some time to check if this issue has been raised before?" - description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" - options: - - label: "I checked and didn't find similar issue" - required: true - - type: checkboxes - id: read-code-of-conduct - attributes: - label: "🏢 Have you read the Code of Conduct?" - options: - - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" - required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation.yaml b/.github/ISSUE_TEMPLATE/documentation.yaml deleted file mode 100644 index c2f829d..0000000 --- a/.github/ISSUE_TEMPLATE/documentation.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: "📚 Documentation" -description: "Report an issue related to documentation" -title: "📚 Documentation: " -labels: [documentation] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to make our documentation better 🙏 - - type: textarea - id: issue-description - validations: - required: true - attributes: - label: "💭 Description" - description: "A clear and concise description of what the issue is." - placeholder: "Documentation should not ..." - - type: checkboxes - id: no-duplicate-issues - attributes: - label: "👀 Have you spent some time to check if this issue has been raised before?" - description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" - options: - - label: "I checked and didn't find similar issue" - required: true - - type: checkboxes - id: read-code-of-conduct - attributes: - label: "🏢 Have you read the Code of Conduct?" - options: - - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" - required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml deleted file mode 100644 index 6181cda..0000000 --- a/.github/ISSUE_TEMPLATE/feature.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: 🚀 Feature -description: "Submit a proposal for a new feature" -title: "🚀 Feature: " -labels: [feature] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out our feature request form 🙏 - - type: textarea - id: feature-description - validations: - required: true - attributes: - label: "🔖 Feature description" - description: "A clear and concise description of what the feature is." - placeholder: "You should add ..." - - type: textarea - id: pitch - validations: - required: true - attributes: - label: "🎤 Pitch" - description: "Please explain why this feature should be implemented and how it would be used. Add examples, if applicable." - placeholder: "In my use-case, ..." - - type: checkboxes - id: no-duplicate-issues - attributes: - label: "👀 Have you spent some time to check if this issue has been raised before?" - description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" - options: - - label: "I checked and didn't find similar issue" - required: true - - type: checkboxes - id: read-code-of-conduct - attributes: - label: "🏢 Have you read the Code of Conduct?" - options: - - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" - required: true \ No newline at end of file diff --git a/.github/workflows/autoclose.yml b/.github/workflows/autoclose.yml deleted file mode 100644 index 3e2b3cb..0000000 --- a/.github/workflows/autoclose.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Auto-close External Pull Requests - -on: - pull_request_target: - types: [opened, reopened] - -jobs: - auto_close: - uses: appwrite/.github/.github/workflows/autoclose.yml@main - secrets: - GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }} diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php deleted file mode 100644 index a0d9a89..0000000 --- a/src/Appwrite/Services/TablesDb.php +++ /dev/null @@ -1,2605 +0,0 @@ -client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new Database. - * - * - * @param string $databaseId - * @param string $name - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function create(string $databaseId, string $name, ?bool $enabled = null): array - { - $apiPath = str_replace( - [], - [], - '/tablesdb' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['name'] = $name; - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * 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. - * - * @param string $databaseId - * @throws AppwriteException - * @return array - */ - public function get(string $databaseId): array - { - $apiPath = str_replace( - ['{databaseId}'], - [$databaseId], - '/tablesdb/{databaseId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a database by its unique ID. - * - * @param string $databaseId - * @param string $name - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function update(string $databaseId, string $name, ?bool $enabled = null): array - { - $apiPath = str_replace( - ['{databaseId}'], - [$databaseId], - '/tablesdb/{databaseId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['name'] = $name; - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete a database by its unique ID. Only API keys with with databases.write - * scope can delete a database. - * - * @param string $databaseId - * @throws AppwriteException - * @return string - */ - public function delete(string $databaseId): string - { - $apiPath = str_replace( - ['{databaseId}'], - [$databaseId], - '/tablesdb/{databaseId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a list of all tables that belong to the provided databaseId. You can - * use the search parameter to filter your results. - * - * @param string $databaseId - * @param ?array $queries - * @param ?string $search - * @param ?bool $total - * @throws AppwriteException - * @return array - */ - public function listTables(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): array - { - $apiPath = str_replace( - ['{databaseId}'], - [$databaseId], - '/tablesdb/{databaseId}/tables' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($search)) { - $apiParams['search'] = $search; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new Table. Before using this route, you should create a new - * database resource using either a [server - * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @param string $name - * @param ?array $permissions - * @param ?bool $rowSecurity - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array - { - $apiPath = str_replace( - ['{databaseId}'], - [$databaseId], - '/tablesdb/{databaseId}/tables' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['name'] = $name; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($rowSecurity)) { - $apiParams['rowSecurity'] = $rowSecurity; - } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a table by its unique ID. This endpoint response returns a JSON object - * with the table metadata. - * - * @param string $databaseId - * @param string $tableId - * @throws AppwriteException - * @return array - */ - public function getTable(string $databaseId, string $tableId): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a table by its unique ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $name - * @param ?array $permissions - * @param ?bool $rowSecurity - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function updateTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['name'] = $name; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($rowSecurity)) { - $apiParams['rowSecurity'] = $rowSecurity; - } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete a table by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param string $databaseId - * @param string $tableId - * @throws AppwriteException - * @return string - */ - public function deleteTable(string $databaseId, string $tableId): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * List columns in the table. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @param ?bool $total - * @throws AppwriteException - * @return array - */ - public function listColumns(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a boolean column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?bool $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a boolean column. Changing the `default` value will not update - * already existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?bool $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a date time column according to the ISO 8601 standard. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a date time column. Changing the `default` value will not update - * already existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create an email column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/email' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an email column. Changing the `default` value will not update - * already existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create an enumeration column. The `elements` param acts as a white-list of - * accepted values for this column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param array $elements - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['elements'] = $elements; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an enum column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param array $elements - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['elements'] = $elements; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a float column. Optionally, minimum and maximum values can be - * provided. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?float $min - * @param ?float $max - * @param ?float $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/float' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a float column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?float $xdefault - * @param ?float $min - * @param ?float $max - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create an integer column. Optionally, minimum and maximum values can be - * provided. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?int $min - * @param ?int $max - * @param ?int $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an integer column. Changing the `default` value will not update - * already existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?int $xdefault - * @param ?int $min - * @param ?int $max - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create IP address column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an ip column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a geometric line column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?array $xdefault - * @throws AppwriteException - * @return array - */ - public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/line' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a line column. Changing the `default` value will not update already - * existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?array $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a geometric point column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?array $xdefault - * @throws AppwriteException - * @return array - */ - public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/point' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a point column. Changing the `default` value will not update already - * existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?array $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a geometric polygon column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?array $xdefault - * @throws AppwriteException - * @return array - */ - public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a polygon column. Changing the `default` value will not update - * already existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?array $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param string $databaseId - * @param string $tableId - * @param string $relatedTableId - * @param RelationshipType $type - * @param ?bool $twoWay - * @param ?string $key - * @param ?string $twoWayKey - * @param ?RelationMutate $onDelete - * @throws AppwriteException - * @return array - */ - public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['relatedTableId'] = $relatedTableId; - $apiParams['type'] = $type; - - if (!is_null($twoWay)) { - $apiParams['twoWay'] = $twoWay; - } - - if (!is_null($key)) { - $apiParams['key'] = $key; - } - - if (!is_null($twoWayKey)) { - $apiParams['twoWayKey'] = $twoWayKey; - } - - if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a string column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param int $size - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @param ?bool $encrypt - * @throws AppwriteException - * @return array - */ - public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/string' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['size'] = $size; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - if (!is_null($encrypt)) { - $apiParams['encrypt'] = $encrypt; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a string column. Changing the `default` value will not update - * already existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?int $size - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($size)) { - $apiParams['size'] = $size; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a URL column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/columns/url' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an url column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get column by ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return array - */ - public function getColumn(string $databaseId, string $tableId, string $key): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Deletes a column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return string - */ - public function deleteColumn(string $databaseId, string $tableId, string $key): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param ?RelationMutate $onDelete - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * List indexes on the table. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @param ?bool $total - * @throws AppwriteException - * @return array - */ - public function listIndexes(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/indexes' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Creates an index on the columns listed. Your index should include all the - * columns you will query in a single request. - * Type can be `key`, `fulltext`, or `unique`. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param IndexType $type - * @param array $columns - * @param ?array $orders - * @param ?array $lengths - * @throws AppwriteException - * @return array - */ - public function createIndex(string $databaseId, string $tableId, string $key, IndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/indexes' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['type'] = $type; - $apiParams['columns'] = $columns; - - if (!is_null($orders)) { - $apiParams['orders'] = $orders; - } - - if (!is_null($lengths)) { - $apiParams['lengths'] = $lengths; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get index by ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return array - */ - public function getIndex(string $databaseId, string $tableId, string $key): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete an index. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return string - */ - public function deleteIndex(string $databaseId, string $tableId, string $key): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a list of all the user's rows in a given table. You can use the query - * params to filter your results. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @param ?string $transactionId - * @param ?bool $total - * @throws AppwriteException - * @return array - */ - public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new Row. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - $apiParams['data'] = $data; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create new Rows. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) - * API or directly from your database console. - * - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rows'] = $rows; - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create or update Rows. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) - * API or directly from your database console. - * - * - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rows'] = $rows; - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update all rows that match your queries, if no queries are submitted then - * all rows are updated. You can pass only specific fields to be updated. - * - * @param string $databaseId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($data)) { - $apiParams['data'] = $data; - } - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Bulk delete rows using queries, if no queries are passed then all rows are - * deleted. - * - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/tablesdb/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object - * with the row data. - * - * @param string $databaseId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create or update a Row. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - if (!is_null($data)) { - $apiParams['data'] = $data; - } - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a row by its unique ID. Using the patch method you can pass only - * specific fields that will get updated. - * - * @param string $databaseId - * @param string $tableId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - if (!is_null($data)) { - $apiParams['data'] = $data; - } - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete a row by its unique ID. - * - * @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 $transactionId = null): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Decrement a specific column of a row by a given value. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}', '{column}'], - [$databaseId, $tableId, $rowId, $column], - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - $apiParams['column'] = $column; - - if (!is_null($value)) { - $apiParams['value'] = $value; - } - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Increment a specific column of a row by a given value. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @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, ?string $transactionId = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}', '{column}'], - [$databaseId, $tableId, $rowId, $column], - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - $apiParams['column'] = $column; - - if (!is_null($value)) { - $apiParams['value'] = $value; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($transactionId)) { - $apiParams['transactionId'] = $transactionId; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } -} \ No newline at end of file diff --git a/tests/Appwrite/Services/TablesDbTest.php b/tests/Appwrite/Services/TablesDbTest.php deleted file mode 100644 index 5b5d008..0000000 --- a/tests/Appwrite/Services/TablesDbTest.php +++ /dev/null @@ -1,1487 +0,0 @@ -client = Mockery::mock(Client::class); - $this->tablesDB = new TablesDB($this->client); - } - - public function testMethodList(): void { - - $data = array( - "total" => 5, - "databases" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->list( - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreate(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "name" => "My Database", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "enabled" => true, - "type" => "legacy",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->create( - "", - "" - ); - - $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( - "\$id" => "5e5ea5c16897e", - "name" => "My Database", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "enabled" => true, - "type" => "legacy",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->get( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdate(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "name" => "My Database", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "enabled" => true, - "type" => "legacy",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->update( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDelete(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->delete( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListTables(): void { - - $data = array( - "total" => 5, - "tables" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->listTables( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateTable(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(), - "databaseId" => "5e5ea5c16897e", - "name" => "My Table", - "enabled" => true, - "rowSecurity" => true, - "columns" => array(), - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createTable( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetTable(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(), - "databaseId" => "5e5ea5c16897e", - "name" => "My Table", - "enabled" => true, - "rowSecurity" => true, - "columns" => array(), - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->getTable( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateTable(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(), - "databaseId" => "5e5ea5c16897e", - "name" => "My Table", - "enabled" => true, - "rowSecurity" => true, - "columns" => array(), - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateTable( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteTable(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->deleteTable( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListColumns(): void { - - $data = array( - "total" => 5, - "columns" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->listColumns( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateBooleanColumn(): void { - - $data = array( - "key" => "isEnabled", - "type" => "boolean", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->createBooleanColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateBooleanColumn(): void { - - $data = array( - "key" => "isEnabled", - "type" => "boolean", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->updateBooleanColumn( - "", - "", - "", - true, - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateDatetimeColumn(): void { - - $data = array( - "key" => "birthDay", - "type" => "datetime", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createDatetimeColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateDatetimeColumn(): void { - - $data = array( - "key" => "birthDay", - "type" => "datetime", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateDatetimeColumn( - "", - "", - "", - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateEmailColumn(): void { - - $data = array( - "key" => "userEmail", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createEmailColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateEmailColumn(): void { - - $data = array( - "key" => "userEmail", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateEmailColumn( - "", - "", - "", - true, - "email@example.com" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateEnumColumn(): void { - - $data = array( - "key" => "status", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "elements" => array(), - "format" => "enum",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createEnumColumn( - "", - "", - "", - array(), - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateEnumColumn(): void { - - $data = array( - "key" => "status", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "elements" => array(), - "format" => "enum",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateEnumColumn( - "", - "", - "", - array(), - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateFloatColumn(): void { - - $data = array( - "key" => "percentageCompleted", - "type" => "double", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->createFloatColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateFloatColumn(): void { - - $data = array( - "key" => "percentageCompleted", - "type" => "double", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->updateFloatColumn( - "", - "", - "", - true, - 1.0 - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateIntegerColumn(): void { - - $data = array( - "key" => "count", - "type" => "integer", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->createIntegerColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateIntegerColumn(): void { - - $data = array( - "key" => "count", - "type" => "integer", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->updateIntegerColumn( - "", - "", - "", - true, - 1 - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateIpColumn(): void { - - $data = array( - "key" => "ipAddress", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createIpColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateIpColumn(): void { - - $data = array( - "key" => "ipAddress", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateIpColumn( - "", - "", - "", - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateLineColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->createLineColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateLineColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->updateLineColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreatePointColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->createPointColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdatePointColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->updatePointColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreatePolygonColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->createPolygonColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdatePolygonColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "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->updatePolygonColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRelationshipColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createRelationshipColumn( - "", - "", - "", - "oneToOne" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateStringColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createStringColumn( - "", - "", - "", - 1, - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateStringColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateStringColumn( - "", - "", - "", - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateUrlColumn(): void { - - $data = array( - "key" => "githubUrl", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createUrlColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateUrlColumn(): void { - - $data = array( - "key" => "githubUrl", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateUrlColumn( - "", - "", - "", - true, - "https://example.com" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetColumn(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->getColumn( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteColumn(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->deleteColumn( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateRelationshipColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateRelationshipColumn( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListIndexes(): void { - - $data = array( - "total" => 5, - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->listIndexes( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateIndex(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "key" => "index1", - "type" => "primary", - "status" => "available", - "error" => "string", - "columns" => array(), - "lengths" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createIndex( - "", - "", - "", - "key", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetIndex(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "key" => "index1", - "type" => "primary", - "status" => "available", - "error" => "string", - "columns" => array(), - "lengths" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->getIndex( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteIndex(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->deleteIndex( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->listRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "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->tablesDB->createRow( - "", - "", - "", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->createRows( - "", - "", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpsertRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->upsertRows( - "", - "", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->updateRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->deleteRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "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->tablesDB->getRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpsertRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "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->tablesDB->upsertRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "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->tablesDB->updateRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteRow(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tablesDB->deleteRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDecrementRowColumn(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "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->tablesDB->decrementRowColumn( - "", - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodIncrementRowColumn(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "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->tablesDB->incrementRowColumn( - "", - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - -}