From 09fd76b11918c2d0cce1e8ffe43ddabb65982730 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:28:48 +0100 Subject: [PATCH 1/5] fix: multipart testing --- docs/account.md | 20 +- docs/examples/functions/create-deployment.md | 4 +- docs/examples/functions/create-execution.md | 3 +- docs/examples/storage/create-file.md | 4 +- docs/functions.md | 2 +- docs/locale.md | 2 +- docs/storage.md | 2 +- docs/users.md | 20 +- src/Appwrite/Client.php | 86 +++- src/Appwrite/Enums/Runtime.php | 24 + src/Appwrite/InputFile.php | 51 --- src/Appwrite/Payload.php | 74 ++++ src/Appwrite/Services/Account.php | 87 +++- src/Appwrite/Services/Avatars.php | 47 +- src/Appwrite/Services/Databases.php | 164 ++++--- src/Appwrite/Services/Functions.php | 192 ++++---- src/Appwrite/Services/Graphql.php | 6 +- src/Appwrite/Services/Health.php | 57 ++- src/Appwrite/Services/Locale.php | 14 +- src/Appwrite/Services/Messaging.php | 434 ++++++++++--------- src/Appwrite/Services/Storage.php | 145 +++---- src/Appwrite/Services/Teams.php | 37 +- src/Appwrite/Services/Users.php | 120 +++-- tests/Appwrite/Services/AccountTest.php | 2 +- tests/Appwrite/Services/AvatarsTest.php | 2 +- tests/Appwrite/Services/DatabasesTest.php | 2 +- tests/Appwrite/Services/FunctionsTest.php | 8 +- tests/Appwrite/Services/GraphqlTest.php | 2 +- tests/Appwrite/Services/HealthTest.php | 2 +- tests/Appwrite/Services/LocaleTest.php | 2 +- tests/Appwrite/Services/MessagingTest.php | 2 +- tests/Appwrite/Services/StorageTest.php | 4 +- tests/Appwrite/Services/TeamsTest.php | 2 +- tests/Appwrite/Services/UsersTest.php | 2 +- 34 files changed, 974 insertions(+), 651 deletions(-) delete mode 100644 src/Appwrite/InputFile.php create mode 100644 src/Appwrite/Payload.php diff --git a/docs/account.md b/docs/account.md index d23e642..e942d48 100644 --- a/docs/account.md +++ b/docs/account.md @@ -42,7 +42,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, | email | string | User email. | | | password | string | User password. Must be at least 8 chars. | | -## List Identities +## List identities ```http request GET https://cloud.appwrite.io/v1/account/identities @@ -106,7 +106,7 @@ PATCH https://cloud.appwrite.io/v1/account/mfa | --- | --- | --- | --- | | mfa | boolean | Enable or disable MFA. | | -## Create Authenticator +## Create authenticator ```http request POST https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} @@ -120,7 +120,7 @@ POST https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} | --- | --- | --- | --- | | type | string | **Required** Type of authenticator. Must be `totp` | | -## Verify Authenticator +## Verify authenticator ```http request PUT https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} @@ -135,7 +135,7 @@ PUT https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} | type | string | **Required** Type of authenticator. | | | otp | string | Valid verification token. | | -## Delete Authenticator +## Delete authenticator ```http request DELETE https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} @@ -149,7 +149,7 @@ DELETE https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} | --- | --- | --- | --- | | type | string | **Required** Type of authenticator. | | -## Create MFA Challenge +## Create MFA challenge ```http request POST https://cloud.appwrite.io/v1/account/mfa/challenge @@ -163,7 +163,7 @@ POST https://cloud.appwrite.io/v1/account/mfa/challenge | --- | --- | --- | --- | | factor | string | Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. | | -## Create MFA Challenge (confirmation) +## Create MFA challenge (confirmation) ```http request PUT https://cloud.appwrite.io/v1/account/mfa/challenge @@ -178,7 +178,7 @@ PUT https://cloud.appwrite.io/v1/account/mfa/challenge | challengeId | string | ID of the challenge. | | | otp | string | Valid verification token. | | -## List Factors +## List factors ```http request GET https://cloud.appwrite.io/v1/account/mfa/factors @@ -186,7 +186,7 @@ GET https://cloud.appwrite.io/v1/account/mfa/factors ** List the factors available on the account to be used as a MFA challange. ** -## Get MFA Recovery Codes +## Get MFA recovery codes ```http request GET https://cloud.appwrite.io/v1/account/mfa/recovery-codes @@ -194,7 +194,7 @@ GET https://cloud.appwrite.io/v1/account/mfa/recovery-codes ** Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. ** -## Create MFA Recovery Codes +## Create MFA recovery codes ```http request POST https://cloud.appwrite.io/v1/account/mfa/recovery-codes @@ -202,7 +202,7 @@ POST https://cloud.appwrite.io/v1/account/mfa/recovery-codes ** Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. ** -## Regenerate MFA Recovery Codes +## Regenerate MFA recovery codes ```http request PATCH https://cloud.appwrite.io/v1/account/mfa/recovery-codes diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 90f4c7e..a844bbe 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,7 +1,7 @@ createDeployment( functionId: '', - code: InputFile::withPath('file.png'), + code: Payload::fromFile('file.png'), activate: false, entrypoint: '', // optional commands: '' // optional diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 4c62b9a..2e25414 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,6 +1,7 @@ createExecution( functionId: '', - body: '', // optional + body: Payload::fromJson([ 'x' => 'y' ]), // optional async: false, // optional path: '', // optional method: ExecutionMethod::GET(), // optional diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index a948546..727f3fb 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,7 +1,7 @@ createFile( bucketId: '', fileId: '', - file: InputFile::withPath('file.png'), + file: Payload::fromFile('file.png'), permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index 625d258..3e09fe4 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -280,7 +280,7 @@ POST https://cloud.appwrite.io/v1/functions/{functionId}/executions | Field Name | Type | Description | Default | | --- | --- | --- | --- | | functionId | string | **Required** Function ID. | | -| body | string | HTTP body of execution. Default value is empty string. | | +| body | payload | HTTP body of execution. Default value is empty string. | | | async | boolean | Execute code in the background. Default value is false. | | | path | string | HTTP path of execution. Path can include query params. Default value is / | / | | method | string | HTTP method of execution. Default value is GET. | POST | diff --git a/docs/locale.md b/docs/locale.md index 6678bf2..31b0be2 100644 --- a/docs/locale.md +++ b/docs/locale.md @@ -10,7 +10,7 @@ GET https://cloud.appwrite.io/v1/locale ([IP Geolocation by DB-IP](https://db-ip.com)) ** -## List Locale Codes +## List locale codes ```http request GET https://cloud.appwrite.io/v1/locale/codes diff --git a/docs/storage.md b/docs/storage.md index 2f07dbd..0acb0b1 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -161,7 +161,7 @@ PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId} | name | string | Name of the file | | | permissions | array | An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | -## Delete File +## Delete file ```http request DELETE https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId} diff --git a/docs/users.md b/docs/users.md index 4101f27..0e820fa 100644 --- a/docs/users.md +++ b/docs/users.md @@ -67,7 +67,7 @@ POST https://cloud.appwrite.io/v1/users/bcrypt | password | string | User password hashed using Bcrypt. | | | name | string | User name. Max length: 128 chars. | | -## List Identities +## List identities ```http request GET https://cloud.appwrite.io/v1/users/identities @@ -310,7 +310,7 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/mfa | userId | string | **Required** User ID. | | | mfa | boolean | Enable or disable MFA. | | -## Delete Authenticator +## Delete authenticator ```http request DELETE https://cloud.appwrite.io/v1/users/{userId}/mfa/authenticators/{type} @@ -325,7 +325,7 @@ DELETE https://cloud.appwrite.io/v1/users/{userId}/mfa/authenticators/{type} | userId | string | **Required** User ID. | | | type | string | **Required** Type of authenticator. | | -## List Factors +## List factors ```http request GET https://cloud.appwrite.io/v1/users/{userId}/mfa/factors @@ -339,7 +339,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/mfa/factors | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -## Get MFA Recovery Codes +## Get MFA recovery codes ```http request GET https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes @@ -353,7 +353,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -## Regenerate MFA Recovery Codes +## Regenerate MFA recovery codes ```http request PUT https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes @@ -367,7 +367,7 @@ PUT https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -## Create MFA Recovery Codes +## Create MFA recovery codes ```http request PATCH https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes @@ -529,7 +529,7 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/status | userId | string | **Required** User ID. | | | status | boolean | User Status. To activate the user pass `true` and to block the user pass `false`. | | -## List User Targets +## List user targets ```http request GET https://cloud.appwrite.io/v1/users/{userId}/targets @@ -544,7 +544,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/targets | userId | string | **Required** User ID. | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels | [] | -## Create User Target +## Create user target ```http request POST https://cloud.appwrite.io/v1/users/{userId}/targets @@ -563,7 +563,7 @@ POST https://cloud.appwrite.io/v1/users/{userId}/targets | providerId | string | Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. | | | name | string | Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. | | -## Get User Target +## Get user target ```http request GET https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId} @@ -578,7 +578,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId} | userId | string | **Required** User ID. | | | targetId | string | **Required** Target ID. | | -## Update User target +## Update user target ```http request PATCH https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId} diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index b102f8d..c22921f 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -50,7 +50,6 @@ class Client public function __construct() { $this->headers['X-Appwrite-Response-Format'] = '1.6.0'; - } /** @@ -177,7 +176,7 @@ public function setEndpoint(string $endpoint): Client public function addHeader(string $key, string $value): Client { $this->headers[strtolower($key)] = $value; - + return $this; } @@ -211,6 +210,7 @@ public function call( break; case 'multipart/form-data': + $headers['accept'] = 'multipart/form-data'; $query = $this->flatten($params); break; @@ -262,17 +262,23 @@ public function call( echo 'Warning: ' . $warning . PHP_EOL; } } - + switch(substr($contentType, 0, strpos($contentType, ';'))) { case 'application/json': $responseBody = json_decode($responseBody, true); break; } - + if (str_contains($contentType, 'multipart/form-data')) { + $matches = []; + preg_match('/(?[-]+[\w]+)--/m', $responseBody, $matches); + if (isset($matches['boundary'])) { + $responseBody = self::handleFormData($matches['boundary'], $responseBody); + } + } if (curl_errno($ch)) { throw new AppwriteException(curl_error($ch), $responseStatus, $responseBody['type'] ?? '', $responseBody); } - + curl_close($ch); if($responseStatus >= 400) { @@ -303,14 +309,76 @@ protected function flatten(array $data, string $prefix = ''): array { foreach($data as $key => $value) { $finalKey = $prefix ? "{$prefix}[{$key}]" : $key; - if (is_array($value)) { - $output += $this->flatten($value, $finalKey); // @todo: handle name collision here if needed - } - else { + if ($value instanceof Payload) { + if ($value->filename) { + if (class_exists('\CURLStringFile')) { + // Use CURLStringFile for in-memory data (PHP 8.1+) + $output[$finalKey] = new \CURLStringFile( + $value->toBinary(), + $value->filename, + $value->mimeType + ); + } else { + // For PHP versions < 8.1, write data to a temporary file + $tmpfname = tempnam(sys_get_temp_dir(), 'upload'); + file_put_contents($tmpfname, $value->toBinary()); + $output[$finalKey] = new \CURLFile( + $tmpfname, + $value->mimeType, + $value->filename + ); + } + } else { + $output[$finalKey] = $value->toBinary(); + } + } else if (is_array($value)) { + $output += $this->flatten($value, $finalKey); + } else { $output[$finalKey] = $value; } } return $output; } + + public static function handleFormData(string $boundary, mixed $responseBody) + { + $parts = explode($boundary, $responseBody); + $data = []; + foreach ($parts as $part) { + $lines = array_values(array_filter(explode("\r\n", $part))); + $matches = []; + $matched = preg_match('/name="?(?\w+)/s', $part, $matches); + if ($matched) { + array_shift($lines); + if(isset($lines[0]) && $lines[0] === 'Content-Type: application/json'){ + array_shift($lines); + $json = json_decode(implode($lines), true); + + if (count($json) > 0 && isset($json[0]['name']) && isset($json[0]['value'])) { + $json = array_combine( + array_map(fn($header) => $header['name'], $json), + array_map(fn($header) => $header['value'], $json) + ); + } + + $data[$matches['name']] = $json; + continue; + } + $data[$matches['name']] = implode("\r\n",$lines) ?? '';; + } + } + + if(isset($data['responseStatusCode'])) { + $data['responseStatusCode'] = (int) ($data['responseStatusCode'] ?? ''); + } + if(isset($data['duration'])) { + $data['duration'] = ((float) ($data['duration'] ?? '')); + } + if(isset($data['responseBody'])) { + $data['responseBody'] = Payload::fromBinary($data['responseBody'] ?? ''); + } + + return $data; + } } diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php index bb0fd1a..3eefca5 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -26,6 +26,9 @@ class Runtime implements JsonSerializable private static Runtime $PYTHON311; private static Runtime $PYTHON312; private static Runtime $PYTHONML311; + private static Runtime $DENO121; + private static Runtime $DENO124; + private static Runtime $DENO135; private static Runtime $DENO140; private static Runtime $DART215; private static Runtime $DART216; @@ -210,6 +213,27 @@ public static function PYTHONML311(): Runtime } return self::$PYTHONML311; } + public static function DENO121(): Runtime + { + if (!isset(self::$DENO121)) { + self::$DENO121 = new Runtime('deno-1.21'); + } + return self::$DENO121; + } + public static function DENO124(): Runtime + { + if (!isset(self::$DENO124)) { + self::$DENO124 = new Runtime('deno-1.24'); + } + return self::$DENO124; + } + public static function DENO135(): Runtime + { + if (!isset(self::$DENO135)) { + self::$DENO135 = new Runtime('deno-1.35'); + } + return self::$DENO135; + } public static function DENO140(): Runtime { if (!isset(self::$DENO140)) { diff --git a/src/Appwrite/InputFile.php b/src/Appwrite/InputFile.php deleted file mode 100644 index c8a0de7..0000000 --- a/src/Appwrite/InputFile.php +++ /dev/null @@ -1,51 +0,0 @@ -data; - } - - public function getPath(): ?string - { - return $this->path; - } - - public function getMimeType(): ?string - { - return $this->mimeType; - } - - public function getFilename(): ?string - { - return $this->filename; - } - - public static function withPath(string $path, ?string $mimeType = null, ?string $filename = null): InputFile - { - $instance = new InputFile(); - $instance->path = $path; - $instance->data = null; - $instance->mimeType = $mimeType; - $instance->filename = $filename; - return $instance; - } - - public static function withData(string $data, ?string $mimeType = null, ?string $filename = null): InputFile - { - $instance = new InputFile(); - $instance->path = null; - $instance->data = $data; - $instance->mimeType = $mimeType; - $instance->filename = $filename; - return $instance; - } -} \ No newline at end of file diff --git a/src/Appwrite/Payload.php b/src/Appwrite/Payload.php new file mode 100644 index 0000000..3b144a4 --- /dev/null +++ b/src/Appwrite/Payload.php @@ -0,0 +1,74 @@ +path = $path; + $instance->data = null; + return $instance; + } + + public static function fromBinary(string $data, ?string $filename = null, ?string $mimeType = null): self + { + $instance = new Payload(strlen($data), $filename, $mimeType); + $instance->path = null; + $instance->data = $data; + return $instance; + } + + public static function fromJson(array $data): self + { + $data = json_encode($data); + return self::fromString($data); + } + + public static function fromString(string $data): self + { + return self::fromBinary($data); + } + + public function toBinary(?int $offset = 0, ?int $length = null): string + { + $length = $length ?? ($this->size - $offset); + if ($this->data) { + return substr($this->data, $offset, $length); + } else { + return file_get_contents($this->path, false, null, $offset, $length); + } + } + + public function toJson(): mixed + { + return json_decode($this->data, true); + } + + public function toString(): string + { + return $this->data; + } + + public function toFile(string $path): void + { + file_put_contents($path, $this->data); + } +} diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index bbaec76..9c66ebe 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\AuthenticatorType; use Appwrite\Enums\AuthenticationFactor; use Appwrite\Enums\OAuthProvider; @@ -44,6 +44,7 @@ public function get(): array $apiHeaders, $apiParams ); + } /** @@ -78,7 +79,7 @@ public function create(string $userId, string $email, string $password, ?string $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -90,6 +91,7 @@ public function create(string $userId, string $email, string $password, ?string $apiHeaders, $apiParams ); + } /** @@ -130,10 +132,11 @@ public function updateEmail(string $email, string $password): array $apiHeaders, $apiParams ); + } /** - * List Identities + * List identities * * Get the list of identities for the currently logged in user. * @@ -152,7 +155,7 @@ public function listIdentities(?array $queries = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -164,6 +167,7 @@ public function listIdentities(?array $queries = null): array $apiHeaders, $apiParams ); + } /** @@ -195,6 +199,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders, $apiParams ); + } /** @@ -228,6 +233,7 @@ public function createJWT(): array $apiHeaders, $apiParams ); + } /** @@ -251,7 +257,7 @@ public function listLogs(?array $queries = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -263,6 +269,7 @@ public function listLogs(?array $queries = null): array $apiHeaders, $apiParams ); + } /** @@ -294,10 +301,11 @@ public function updateMFA(bool $mfa): array $apiHeaders, $apiParams ); + } /** - * Create Authenticator + * Create authenticator * * Add an authenticator app to be used as an MFA factor. Verify the * authenticator using the [verify @@ -328,10 +336,11 @@ public function createMfaAuthenticator(AuthenticatorType $type): array $apiHeaders, $apiParams ); + } /** - * Verify Authenticator + * Verify authenticator * * Verify an authenticator app after adding it using the [add * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -363,10 +372,11 @@ public function updateMfaAuthenticator(AuthenticatorType $type, string $otp): ar $apiHeaders, $apiParams ); + } /** - * Delete Authenticator + * Delete authenticator * * Delete an authenticator for a user by ID. * @@ -394,10 +404,11 @@ public function deleteMfaAuthenticator(AuthenticatorType $type): string $apiHeaders, $apiParams ); + } /** - * Create MFA Challenge + * Create MFA challenge * * Begin the process of MFA verification after sign-in. Finish the flow with * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -427,10 +438,11 @@ public function createMfaChallenge(AuthenticationFactor $factor): array $apiHeaders, $apiParams ); + } /** - * Create MFA Challenge (confirmation) + * Create MFA challenge (confirmation) * * Complete the MFA challenge by providing the one-time password. Finish the * process of MFA verification by providing the one-time password. To begin @@ -464,10 +476,11 @@ public function updateMfaChallenge(string $challengeId, string $otp): string $apiHeaders, $apiParams ); + } /** - * List Factors + * List factors * * List the factors available on the account to be used as a MFA challange. * @@ -493,10 +506,11 @@ public function listMfaFactors(): array $apiHeaders, $apiParams ); + } /** - * Get MFA Recovery Codes + * Get MFA recovery codes * * Get recovery codes that can be used as backup for MFA flow. Before getting * codes, they must be generated using @@ -525,10 +539,11 @@ public function getMfaRecoveryCodes(): array $apiHeaders, $apiParams ); + } /** - * Create MFA Recovery Codes + * Create MFA recovery codes * * Generate recovery codes as backup for MFA flow. It's recommended to * generate and show then immediately after user successfully adds their @@ -558,10 +573,11 @@ public function createMfaRecoveryCodes(): array $apiHeaders, $apiParams ); + } /** - * Regenerate MFA Recovery Codes + * Regenerate MFA recovery codes * * Regenerate recovery codes that can be used as backup for MFA flow. Before * regenerating codes, they must be first generated using @@ -590,6 +606,7 @@ public function updateMfaRecoveryCodes(): array $apiHeaders, $apiParams ); + } /** @@ -621,6 +638,7 @@ public function updateName(string $name): array $apiHeaders, $apiParams ); + } /** @@ -647,7 +665,7 @@ public function updatePassword(string $password, ?string $oldPassword = null): a $apiParams['password'] = $password; if (!is_null($oldPassword)) { - $apiParams['oldPassword'] = $oldPassword; + $apiParams['oldPassword'] = $oldPassword; } $apiHeaders = []; @@ -659,6 +677,7 @@ public function updatePassword(string $password, ?string $oldPassword = null): a $apiHeaders, $apiParams ); + } /** @@ -696,6 +715,7 @@ public function updatePhone(string $phone, string $password): array $apiHeaders, $apiParams ); + } /** @@ -725,6 +745,7 @@ public function getPrefs(): array $apiHeaders, $apiParams ); + } /** @@ -758,6 +779,7 @@ public function updatePrefs(array $prefs): array $apiHeaders, $apiParams ); + } /** @@ -798,6 +820,7 @@ public function createRecovery(string $email, string $url): array $apiHeaders, $apiParams ); + } /** @@ -842,6 +865,7 @@ public function updateRecovery(string $userId, string $secret, string $password) $apiHeaders, $apiParams ); + } /** @@ -872,6 +896,7 @@ public function listSessions(): array $apiHeaders, $apiParams ); + } /** @@ -902,6 +927,7 @@ public function deleteSessions(): string $apiHeaders, $apiParams ); + } /** @@ -937,6 +963,7 @@ public function createAnonymousSession(): array $apiHeaders, $apiParams ); + } /** @@ -975,6 +1002,7 @@ public function createEmailPasswordSession(string $email, string $password): arr $apiHeaders, $apiParams ); + } /** @@ -1010,6 +1038,7 @@ public function updateMagicURLSession(string $userId, string $secret): array $apiHeaders, $apiParams ); + } /** @@ -1045,6 +1074,7 @@ public function updatePhoneSession(string $userId, string $secret): array $apiHeaders, $apiParams ); + } /** @@ -1080,6 +1110,7 @@ public function createSession(string $userId, string $secret): array $apiHeaders, $apiParams ); + } /** @@ -1112,6 +1143,7 @@ public function getSession(string $sessionId): array $apiHeaders, $apiParams ); + } /** @@ -1145,6 +1177,7 @@ public function updateSession(string $sessionId): array $apiHeaders, $apiParams ); + } /** @@ -1180,6 +1213,7 @@ public function deleteSession(string $sessionId): string $apiHeaders, $apiParams ); + } /** @@ -1211,6 +1245,7 @@ public function updateStatus(): array $apiHeaders, $apiParams ); + } /** @@ -1246,7 +1281,7 @@ public function createEmailToken(string $userId, string $email, ?bool $phrase = $apiParams['email'] = $email; if (!is_null($phrase)) { - $apiParams['phrase'] = $phrase; + $apiParams['phrase'] = $phrase; } $apiHeaders = []; @@ -1258,6 +1293,7 @@ public function createEmailToken(string $userId, string $email, ?bool $phrase = $apiHeaders, $apiParams ); + } /** @@ -1300,11 +1336,11 @@ public function createMagicURLToken(string $userId, string $email, ?string $url $apiParams['email'] = $email; if (!is_null($url)) { - $apiParams['url'] = $url; + $apiParams['url'] = $url; } if (!is_null($phrase)) { - $apiParams['phrase'] = $phrase; + $apiParams['phrase'] = $phrase; } $apiHeaders = []; @@ -1316,6 +1352,7 @@ public function createMagicURLToken(string $userId, string $email, ?string $url $apiHeaders, $apiParams ); + } /** @@ -1355,15 +1392,15 @@ public function createOAuth2Token(OAuthProvider $provider, ?string $success = nu $apiParams['provider'] = $provider; if (!is_null($success)) { - $apiParams['success'] = $success; + $apiParams['success'] = $success; } if (!is_null($failure)) { - $apiParams['failure'] = $failure; + $apiParams['failure'] = $failure; } if (!is_null($scopes)) { - $apiParams['scopes'] = $scopes; + $apiParams['scopes'] = $scopes; } $apiHeaders = []; @@ -1375,6 +1412,7 @@ public function createOAuth2Token(OAuthProvider $provider, ?string $success = nu $apiHeaders, $apiParams, 'location' ); + } /** @@ -1417,6 +1455,7 @@ public function createPhoneToken(string $userId, string $phone): array $apiHeaders, $apiParams ); + } /** @@ -1462,6 +1501,7 @@ public function createVerification(string $url): array $apiHeaders, $apiParams ); + } /** @@ -1498,6 +1538,7 @@ public function updateVerification(string $userId, string $secret): array $apiHeaders, $apiParams ); + } /** @@ -1534,6 +1575,7 @@ public function createPhoneVerification(): array $apiHeaders, $apiParams ); + } /** @@ -1570,5 +1612,6 @@ public function updatePhoneVerification(string $userId, string $secret): array $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index 73052e5..09e72f6 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\Browser; use Appwrite\Enums\CreditCard; use Appwrite\Enums\Flag; @@ -50,15 +50,15 @@ public function getBrowser(Browser $code, ?int $width = null, ?int $height = nul $apiParams['code'] = $code; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } $apiHeaders = []; @@ -70,6 +70,7 @@ public function getBrowser(Browser $code, ?int $width = null, ?int $height = nul $apiHeaders, $apiParams ); + } /** @@ -104,15 +105,15 @@ public function getCreditCard(CreditCard $code, ?int $width = null, ?int $height $apiParams['code'] = $code; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } $apiHeaders = []; @@ -124,6 +125,7 @@ public function getCreditCard(CreditCard $code, ?int $width = null, ?int $height $apiHeaders, $apiParams ); + } /** @@ -158,6 +160,7 @@ public function getFavicon(string $url): string $apiHeaders, $apiParams ); + } /** @@ -193,15 +196,15 @@ public function getFlag(Flag $code, ?int $width = null, ?int $height = null, ?in $apiParams['code'] = $code; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } $apiHeaders = []; @@ -213,6 +216,7 @@ public function getFlag(Flag $code, ?int $width = null, ?int $height = null, ?in $apiHeaders, $apiParams ); + } /** @@ -248,11 +252,11 @@ public function getImage(string $url, ?int $width = null, ?int $height = null): $apiParams['url'] = $url; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } $apiHeaders = []; @@ -264,6 +268,7 @@ public function getImage(string $url, ?int $width = null, ?int $height = null): $apiHeaders, $apiParams ); + } /** @@ -304,19 +309,19 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig $apiParams = []; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($background)) { - $apiParams['background'] = $background; + $apiParams['background'] = $background; } $apiHeaders = []; @@ -328,6 +333,7 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig $apiHeaders, $apiParams ); + } /** @@ -356,15 +362,15 @@ public function getQR(string $text, ?int $size = null, ?int $margin = null, ?boo $apiParams['text'] = $text; if (!is_null($size)) { - $apiParams['size'] = $size; + $apiParams['size'] = $size; } if (!is_null($margin)) { - $apiParams['margin'] = $margin; + $apiParams['margin'] = $margin; } if (!is_null($download)) { - $apiParams['download'] = $download; + $apiParams['download'] = $download; } $apiHeaders = []; @@ -376,5 +382,6 @@ public function getQR(string $text, ?int $size = null, ?int $margin = null, ?boo $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 6eb85cf..a2d4402 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\RelationshipType; use Appwrite\Enums\RelationMutate; use Appwrite\Enums\IndexType; @@ -39,11 +39,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -55,6 +55,7 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); + } /** @@ -82,7 +83,7 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): $apiParams['name'] = $name; if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -94,6 +95,7 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): $apiHeaders, $apiParams ); + } /** @@ -126,6 +128,7 @@ public function get(string $databaseId): array $apiHeaders, $apiParams ); + } /** @@ -152,7 +155,7 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): $apiParams['name'] = $name; if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -164,6 +167,7 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): $apiHeaders, $apiParams ); + } /** @@ -196,6 +200,7 @@ public function delete(string $databaseId): string $apiHeaders, $apiParams ); + } /** @@ -222,11 +227,11 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str $apiParams['databaseId'] = $databaseId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -238,6 +243,7 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str $apiHeaders, $apiParams ); + } /** @@ -271,15 +277,15 @@ public function createCollection(string $databaseId, string $collectionId, strin $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($documentSecurity)) { - $apiParams['documentSecurity'] = $documentSecurity; + $apiParams['documentSecurity'] = $documentSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -291,6 +297,7 @@ public function createCollection(string $databaseId, string $collectionId, strin $apiHeaders, $apiParams ); + } /** @@ -325,6 +332,7 @@ public function getCollection(string $databaseId, string $collectionId): array $apiHeaders, $apiParams ); + } /** @@ -355,15 +363,15 @@ public function updateCollection(string $databaseId, string $collectionId, strin $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($documentSecurity)) { - $apiParams['documentSecurity'] = $documentSecurity; + $apiParams['documentSecurity'] = $documentSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -375,6 +383,7 @@ public function updateCollection(string $databaseId, string $collectionId, strin $apiHeaders, $apiParams ); + } /** @@ -409,6 +418,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders, $apiParams ); + } /** @@ -435,7 +445,7 @@ public function listAttributes(string $databaseId, string $collectionId, ?array $apiParams['collectionId'] = $collectionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -447,6 +457,7 @@ public function listAttributes(string $databaseId, string $collectionId, ?array $apiHeaders, $apiParams ); + } /** @@ -479,11 +490,11 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -495,6 +506,7 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); + } /** @@ -528,7 +540,7 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -540,6 +552,7 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); + } /** @@ -571,11 +584,11 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -587,6 +600,7 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId $apiHeaders, $apiParams ); + } /** @@ -620,7 +634,7 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -632,6 +646,7 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId $apiHeaders, $apiParams ); + } /** @@ -664,11 +679,11 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -680,6 +695,7 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); + } /** @@ -714,7 +730,7 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -726,6 +742,7 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); + } /** @@ -761,11 +778,11 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -777,6 +794,7 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st $apiHeaders, $apiParams ); + } /** @@ -813,7 +831,7 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -825,6 +843,7 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st $apiHeaders, $apiParams ); + } /** @@ -860,19 +879,19 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s $apiParams['required'] = $required; if (!is_null($min)) { - $apiParams['min'] = $min; + $apiParams['min'] = $min; } if (!is_null($max)) { - $apiParams['max'] = $max; + $apiParams['max'] = $max; } if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -884,6 +903,7 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); + } /** @@ -922,7 +942,7 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -934,6 +954,7 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); + } /** @@ -969,19 +990,19 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, $apiParams['required'] = $required; if (!is_null($min)) { - $apiParams['min'] = $min; + $apiParams['min'] = $min; } if (!is_null($max)) { - $apiParams['max'] = $max; + $apiParams['max'] = $max; } if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -993,6 +1014,7 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); + } /** @@ -1031,7 +1053,7 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1043,6 +1065,7 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); + } /** @@ -1075,11 +1098,11 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -1091,6 +1114,7 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri $apiHeaders, $apiParams ); + } /** @@ -1125,7 +1149,7 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1137,6 +1161,7 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri $apiHeaders, $apiParams ); + } /** @@ -1172,19 +1197,19 @@ public function createRelationshipAttribute(string $databaseId, string $collecti $apiParams['type'] = $type; if (!is_null($twoWay)) { - $apiParams['twoWay'] = $twoWay; + $apiParams['twoWay'] = $twoWay; } if (!is_null($key)) { - $apiParams['key'] = $key; + $apiParams['key'] = $key; } if (!is_null($twoWayKey)) { - $apiParams['twoWayKey'] = $twoWayKey; + $apiParams['twoWayKey'] = $twoWayKey; } if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; + $apiParams['onDelete'] = $onDelete; } $apiHeaders = []; @@ -1196,6 +1221,7 @@ public function createRelationshipAttribute(string $databaseId, string $collecti $apiHeaders, $apiParams ); + } /** @@ -1231,15 +1257,15 @@ public function createStringAttribute(string $databaseId, string $collectionId, $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } if (!is_null($encrypt)) { - $apiParams['encrypt'] = $encrypt; + $apiParams['encrypt'] = $encrypt; } $apiHeaders = []; @@ -1251,6 +1277,7 @@ public function createStringAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); + } /** @@ -1286,11 +1313,11 @@ public function updateStringAttribute(string $databaseId, string $collectionId, $apiParams['default'] = $xdefault; if (!is_null($size)) { - $apiParams['size'] = $size; + $apiParams['size'] = $size; } if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1302,6 +1329,7 @@ public function updateStringAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); + } /** @@ -1334,11 +1362,11 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -1350,6 +1378,7 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str $apiHeaders, $apiParams ); + } /** @@ -1384,7 +1413,7 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1396,6 +1425,7 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str $apiHeaders, $apiParams ); + } /** @@ -1431,6 +1461,7 @@ public function getAttribute(string $databaseId, string $collectionId, string $k $apiHeaders, $apiParams ); + } /** @@ -1466,6 +1497,7 @@ public function deleteAttribute(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); + } /** @@ -1497,11 +1529,11 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti $apiParams['key'] = $key; if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; + $apiParams['onDelete'] = $onDelete; } if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1513,6 +1545,7 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti $apiHeaders, $apiParams ); + } /** @@ -1540,7 +1573,7 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ $apiParams['collectionId'] = $collectionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1552,6 +1585,7 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ $apiHeaders, $apiParams ); + } /** @@ -1585,7 +1619,7 @@ public function createDocument(string $databaseId, string $collectionId, string $apiParams['data'] = $data; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; @@ -1597,6 +1631,7 @@ public function createDocument(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); + } /** @@ -1626,7 +1661,7 @@ public function getDocument(string $databaseId, string $collectionId, string $do $apiParams['documentId'] = $documentId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1638,6 +1673,7 @@ public function getDocument(string $databaseId, string $collectionId, string $do $apiHeaders, $apiParams ); + } /** @@ -1668,11 +1704,11 @@ public function updateDocument(string $databaseId, string $collectionId, string $apiParams['documentId'] = $documentId; if (!is_null($data)) { - $apiParams['data'] = $data; + $apiParams['data'] = $data; } if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; @@ -1684,6 +1720,7 @@ public function updateDocument(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); + } /** @@ -1719,6 +1756,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); + } /** @@ -1745,7 +1783,7 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu $apiParams['collectionId'] = $collectionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1757,6 +1795,7 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu $apiHeaders, $apiParams ); + } /** @@ -1791,7 +1830,7 @@ public function createIndex(string $databaseId, string $collectionId, string $ke $apiParams['attributes'] = $attributes; if (!is_null($orders)) { - $apiParams['orders'] = $orders; + $apiParams['orders'] = $orders; } $apiHeaders = []; @@ -1803,6 +1842,7 @@ public function createIndex(string $databaseId, string $collectionId, string $ke $apiHeaders, $apiParams ); + } /** @@ -1838,6 +1878,7 @@ public function getIndex(string $databaseId, string $collectionId, string $key): $apiHeaders, $apiParams ); + } /** @@ -1873,5 +1914,6 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 2e1d60f..ba87821 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\Runtime; use Appwrite\Enums\ExecutionMethod; @@ -38,11 +38,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -54,6 +54,7 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); + } /** @@ -103,79 +104,79 @@ public function create(string $functionId, string $name, Runtime $runtime, ?arra $apiParams['runtime'] = $runtime; if (!is_null($execute)) { - $apiParams['execute'] = $execute; + $apiParams['execute'] = $execute; } if (!is_null($events)) { - $apiParams['events'] = $events; + $apiParams['events'] = $events; } if (!is_null($schedule)) { - $apiParams['schedule'] = $schedule; + $apiParams['schedule'] = $schedule; } if (!is_null($timeout)) { - $apiParams['timeout'] = $timeout; + $apiParams['timeout'] = $timeout; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($logging)) { - $apiParams['logging'] = $logging; + $apiParams['logging'] = $logging; } if (!is_null($entrypoint)) { - $apiParams['entrypoint'] = $entrypoint; + $apiParams['entrypoint'] = $entrypoint; } if (!is_null($commands)) { - $apiParams['commands'] = $commands; + $apiParams['commands'] = $commands; } if (!is_null($scopes)) { - $apiParams['scopes'] = $scopes; + $apiParams['scopes'] = $scopes; } if (!is_null($installationId)) { - $apiParams['installationId'] = $installationId; + $apiParams['installationId'] = $installationId; } if (!is_null($providerRepositoryId)) { - $apiParams['providerRepositoryId'] = $providerRepositoryId; + $apiParams['providerRepositoryId'] = $providerRepositoryId; } if (!is_null($providerBranch)) { - $apiParams['providerBranch'] = $providerBranch; + $apiParams['providerBranch'] = $providerBranch; } if (!is_null($providerSilentMode)) { - $apiParams['providerSilentMode'] = $providerSilentMode; + $apiParams['providerSilentMode'] = $providerSilentMode; } if (!is_null($providerRootDirectory)) { - $apiParams['providerRootDirectory'] = $providerRootDirectory; + $apiParams['providerRootDirectory'] = $providerRootDirectory; } if (!is_null($templateRepository)) { - $apiParams['templateRepository'] = $templateRepository; + $apiParams['templateRepository'] = $templateRepository; } if (!is_null($templateOwner)) { - $apiParams['templateOwner'] = $templateOwner; + $apiParams['templateOwner'] = $templateOwner; } if (!is_null($templateRootDirectory)) { - $apiParams['templateRootDirectory'] = $templateRootDirectory; + $apiParams['templateRootDirectory'] = $templateRootDirectory; } if (!is_null($templateVersion)) { - $apiParams['templateVersion'] = $templateVersion; + $apiParams['templateVersion'] = $templateVersion; } if (!is_null($specification)) { - $apiParams['specification'] = $specification; + $apiParams['specification'] = $specification; } $apiHeaders = []; @@ -187,6 +188,7 @@ public function create(string $functionId, string $name, Runtime $runtime, ?arra $apiHeaders, $apiParams ); + } /** @@ -216,6 +218,7 @@ public function listRuntimes(): array $apiHeaders, $apiParams ); + } /** @@ -246,6 +249,7 @@ public function listSpecifications(): array $apiHeaders, $apiParams ); + } /** @@ -277,6 +281,7 @@ public function get(string $functionId): array $apiHeaders, $apiParams ); + } /** @@ -318,64 +323,64 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul $apiParams['name'] = $name; if (!is_null($runtime)) { - $apiParams['runtime'] = $runtime; + $apiParams['runtime'] = $runtime; } if (!is_null($execute)) { - $apiParams['execute'] = $execute; + $apiParams['execute'] = $execute; } if (!is_null($events)) { - $apiParams['events'] = $events; + $apiParams['events'] = $events; } if (!is_null($schedule)) { - $apiParams['schedule'] = $schedule; + $apiParams['schedule'] = $schedule; } if (!is_null($timeout)) { - $apiParams['timeout'] = $timeout; + $apiParams['timeout'] = $timeout; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($logging)) { - $apiParams['logging'] = $logging; + $apiParams['logging'] = $logging; } if (!is_null($entrypoint)) { - $apiParams['entrypoint'] = $entrypoint; + $apiParams['entrypoint'] = $entrypoint; } if (!is_null($commands)) { - $apiParams['commands'] = $commands; + $apiParams['commands'] = $commands; } if (!is_null($scopes)) { - $apiParams['scopes'] = $scopes; + $apiParams['scopes'] = $scopes; } if (!is_null($installationId)) { - $apiParams['installationId'] = $installationId; + $apiParams['installationId'] = $installationId; } $apiParams['providerRepositoryId'] = $providerRepositoryId; if (!is_null($providerBranch)) { - $apiParams['providerBranch'] = $providerBranch; + $apiParams['providerBranch'] = $providerBranch; } if (!is_null($providerSilentMode)) { - $apiParams['providerSilentMode'] = $providerSilentMode; + $apiParams['providerSilentMode'] = $providerSilentMode; } if (!is_null($providerRootDirectory)) { - $apiParams['providerRootDirectory'] = $providerRootDirectory; + $apiParams['providerRootDirectory'] = $providerRootDirectory; } if (!is_null($specification)) { - $apiParams['specification'] = $specification; + $apiParams['specification'] = $specification; } $apiHeaders = []; @@ -387,6 +392,7 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul $apiHeaders, $apiParams ); + } /** @@ -418,6 +424,7 @@ public function delete(string $functionId): string $apiHeaders, $apiParams ); + } /** @@ -444,11 +451,11 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str $apiParams['functionId'] = $functionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -460,6 +467,7 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str $apiHeaders, $apiParams ); + } /** @@ -477,14 +485,14 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str * Use the "command" param to set the entrypoint used to execute your code. * * @param string $functionId - * @param InputFile $code + * @param Payload $code * @param bool $activate * @param ?string $entrypoint * @param ?string $commands * @throws AppwriteException * @return array */ - public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, callable $onProgress = null): array + public function createDeployment(string $functionId, Payload $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, callable $onProgress = null): array { $apiPath = str_replace( ['{functionId}'], @@ -498,39 +506,21 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti $apiParams['activate'] = $activate; if (!is_null($entrypoint)) { - $apiParams['entrypoint'] = $entrypoint; + $apiParams['entrypoint'] = $entrypoint; } if (!is_null($commands)) { - $apiParams['commands'] = $commands; + $apiParams['commands'] = $commands; } $apiHeaders = []; $apiHeaders['content-type'] = 'multipart/form-data'; - $size = 0; - $mimeType = null; - $postedName = null; - if(empty($code->getPath() ?? null)) { - $size = strlen($code->getData()); - $mimeType = $code->getMimeType(); - $postedName = $code->getFilename(); - if ($size <= Client::CHUNK_SIZE) { - $apiParams['code'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($code->getData()), $mimeType, $postedName); - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'multipart/form-data', - ], $apiParams); - } - } else { - $size = filesize($code->getPath()); - $mimeType = $code->getMimeType() ?? mime_content_type($code->getPath()); - $postedName = $code->getFilename() ?? basename($code->getPath()); - //send single file if size is less than or equal to 5MB - if ($size <= Client::CHUNK_SIZE) { - $apiParams['code'] = new \CURLFile($code->getPath(), $mimeType, $postedName); - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'multipart/form-data', - ], $apiParams); - } + $size = $code->size; + + if ($size <= Client::CHUNK_SIZE) { + return $this->client->call(Client::METHOD_POST, $apiPath, [ + 'content-type' => 'multipart/form-data', + ], $apiParams); } $id = ''; @@ -538,22 +528,16 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti $apiHeaders = ['content-type' => 'multipart/form-data']; - $handle = null; - - if(!empty($code->getPath())) { - $handle = @fopen($code->getPath(), "rb"); - } $start = $counter * Client::CHUNK_SIZE; while ($start < $size) { - $chunk = ''; - if(!empty($handle)) { - fseek($handle, $start); - $chunk = @fread($handle, Client::CHUNK_SIZE); - } else { - $chunk = substr($file->getData(), $start, Client::CHUNK_SIZE); - } - $apiParams['code'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($chunk), $mimeType, $postedName); + + $apiParams['code'] = Payload::fromBinary( + $code->toBinary($start, Client::CHUNK_SIZE), + $code->filename, + $code->mimeType + ); + $apiHeaders['content-range'] = 'bytes ' . ($counter * Client::CHUNK_SIZE) . '-' . min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE) - 1), $size - 1) . '/' . $size; if(!empty($id)) { $apiHeaders['x-appwrite-id'] = $id; @@ -570,13 +554,10 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti 'progress' => min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE)), $size) / $size * 100, 'sizeUploaded' => min($counter * Client::CHUNK_SIZE), 'chunksTotal' => $response['chunksTotal'], - 'chunksUploaded' => $response['chunksUploaded'], + 'chunksUploaded' => $response['chunksUploaded'], ]); } } - if(!empty($handle)) { - @fclose($handle); - } return $response; } @@ -612,6 +593,7 @@ public function getDeployment(string $functionId, string $deploymentId): array $apiHeaders, $apiParams ); + } /** @@ -647,6 +629,7 @@ public function updateDeployment(string $functionId, string $deploymentId): arra $apiHeaders, $apiParams ); + } /** @@ -680,6 +663,7 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri $apiHeaders, $apiParams ); + } /** @@ -704,7 +688,7 @@ public function createBuild(string $functionId, string $deploymentId, ?string $b $apiParams['deploymentId'] = $deploymentId; if (!is_null($buildId)) { - $apiParams['buildId'] = $buildId; + $apiParams['buildId'] = $buildId; } $apiHeaders = []; @@ -716,6 +700,7 @@ public function createBuild(string $functionId, string $deploymentId, ?string $b $apiHeaders, $apiParams ); + } /** @@ -747,6 +732,7 @@ public function updateDeploymentBuild(string $functionId, string $deploymentId): $apiHeaders, $apiParams ); + } /** @@ -781,6 +767,7 @@ public function getDeploymentDownload(string $functionId, string $deploymentId): $apiHeaders, $apiParams ); + } /** @@ -807,11 +794,11 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri $apiParams['functionId'] = $functionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -823,6 +810,7 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri $apiHeaders, $apiParams ); + } /** @@ -834,7 +822,7 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri * function execution process will start asynchronously. * * @param string $functionId - * @param ?string $body + * @param ?Payload $body * @param ?bool $async * @param ?string $xpath * @param ?ExecutionMethod $method @@ -843,7 +831,7 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri * @throws AppwriteException * @return array */ - public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): array + public function createExecution(string $functionId, ?Payload $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null, callable $onProgress = null): array { $apiPath = str_replace( ['{functionId}'], @@ -855,31 +843,31 @@ public function createExecution(string $functionId, ?string $body = null, ?bool $apiParams['functionId'] = $functionId; if (!is_null($body)) { - $apiParams['body'] = $body; + $apiParams['body'] = $body; } if (!is_null($async)) { - $apiParams['async'] = $async; + $apiParams['async'] = $async; } if (!is_null($xpath)) { - $apiParams['path'] = $xpath; + $apiParams['path'] = $xpath; } if (!is_null($method)) { - $apiParams['method'] = $method; + $apiParams['method'] = $method; } if (!is_null($headers)) { - $apiParams['headers'] = $headers; + $apiParams['headers'] = $headers; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['content-type'] = 'multipart/form-data'; return $this->client->call( Client::METHOD_POST, @@ -887,6 +875,7 @@ public function createExecution(string $functionId, ?string $body = null, ?bool $apiHeaders, $apiParams ); + } /** @@ -920,6 +909,7 @@ public function getExecution(string $functionId, string $executionId): array $apiHeaders, $apiParams ); + } /** @@ -954,6 +944,7 @@ public function deleteExecution(string $functionId, string $executionId): string $apiHeaders, $apiParams ); + } /** @@ -985,6 +976,7 @@ public function listVariables(string $functionId): array $apiHeaders, $apiParams ); + } /** @@ -1021,6 +1013,7 @@ public function createVariable(string $functionId, string $key, string $value): $apiHeaders, $apiParams ); + } /** @@ -1054,6 +1047,7 @@ public function getVariable(string $functionId, string $variableId): array $apiHeaders, $apiParams ); + } /** @@ -1082,7 +1076,7 @@ public function updateVariable(string $functionId, string $variableId, string $k $apiParams['key'] = $key; if (!is_null($value)) { - $apiParams['value'] = $value; + $apiParams['value'] = $value; } $apiHeaders = []; @@ -1094,6 +1088,7 @@ public function updateVariable(string $functionId, string $variableId, string $k $apiHeaders, $apiParams ); + } /** @@ -1127,5 +1122,6 @@ public function deleteVariable(string $functionId, string $variableId): string $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Graphql.php b/src/Appwrite/Services/Graphql.php index fcb161c..f7bbf46 100644 --- a/src/Appwrite/Services/Graphql.php +++ b/src/Appwrite/Services/Graphql.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; class Graphql extends Service { @@ -44,6 +44,7 @@ public function query(array $query): array $apiHeaders, $apiParams ); + } /** @@ -76,5 +77,6 @@ public function mutation(array $query): array $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index 7ac5942..69221c9 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\Name; class Health extends Service @@ -42,6 +42,7 @@ public function get(): array $apiHeaders, $apiParams ); + } /** @@ -71,6 +72,7 @@ public function getAntivirus(): array $apiHeaders, $apiParams ); + } /** @@ -101,6 +103,7 @@ public function getCache(): array $apiHeaders, $apiParams ); + } /** @@ -123,7 +126,7 @@ public function getCertificate(?string $domain = null): array $apiParams = []; if (!is_null($domain)) { - $apiParams['domain'] = $domain; + $apiParams['domain'] = $domain; } $apiHeaders = []; @@ -135,6 +138,7 @@ public function getCertificate(?string $domain = null): array $apiHeaders, $apiParams ); + } /** @@ -164,6 +168,7 @@ public function getDB(): array $apiHeaders, $apiParams ); + } /** @@ -193,6 +198,7 @@ public function getPubSub(): array $apiHeaders, $apiParams ); + } /** @@ -223,6 +229,7 @@ public function getQueue(): array $apiHeaders, $apiParams ); + } /** @@ -246,7 +253,7 @@ public function getQueueBuilds(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -258,6 +265,7 @@ public function getQueueBuilds(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -282,7 +290,7 @@ public function getQueueCertificates(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -294,6 +302,7 @@ public function getQueueCertificates(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -318,11 +327,11 @@ public function getQueueDatabases(?string $name = null, ?int $threshold = null): $apiParams = []; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -334,6 +343,7 @@ public function getQueueDatabases(?string $name = null, ?int $threshold = null): $apiHeaders, $apiParams ); + } /** @@ -357,7 +367,7 @@ public function getQueueDeletes(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -369,6 +379,7 @@ public function getQueueDeletes(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -394,7 +405,7 @@ public function getFailedJobs(Name $name, ?int $threshold = null): array $apiParams['name'] = $name; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -406,6 +417,7 @@ public function getFailedJobs(Name $name, ?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -429,7 +441,7 @@ public function getQueueFunctions(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -441,6 +453,7 @@ public function getQueueFunctions(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -464,7 +477,7 @@ public function getQueueLogs(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -476,6 +489,7 @@ public function getQueueLogs(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -499,7 +513,7 @@ public function getQueueMails(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -511,6 +525,7 @@ public function getQueueMails(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -534,7 +549,7 @@ public function getQueueMessaging(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -546,6 +561,7 @@ public function getQueueMessaging(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -569,7 +585,7 @@ public function getQueueMigrations(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -581,6 +597,7 @@ public function getQueueMigrations(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -604,7 +621,7 @@ public function getQueueUsage(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -616,6 +633,7 @@ public function getQueueUsage(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -639,7 +657,7 @@ public function getQueueUsageDump(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -651,6 +669,7 @@ public function getQueueUsageDump(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -674,7 +693,7 @@ public function getQueueWebhooks(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -686,6 +705,7 @@ public function getQueueWebhooks(?int $threshold = null): array $apiHeaders, $apiParams ); + } /** @@ -715,6 +735,7 @@ public function getStorage(): array $apiHeaders, $apiParams ); + } /** @@ -744,6 +765,7 @@ public function getStorageLocal(): array $apiHeaders, $apiParams ); + } /** @@ -779,5 +801,6 @@ public function getTime(): array $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Locale.php b/src/Appwrite/Services/Locale.php index 6ea96d1..3249afa 100644 --- a/src/Appwrite/Services/Locale.php +++ b/src/Appwrite/Services/Locale.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; class Locale extends Service { @@ -46,10 +46,11 @@ public function get(): array $apiHeaders, $apiParams ); + } /** - * List Locale Codes + * List locale codes * * List of all locale codes in [ISO * 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). @@ -76,6 +77,7 @@ public function listCodes(): array $apiHeaders, $apiParams ); + } /** @@ -106,6 +108,7 @@ public function listContinents(): array $apiHeaders, $apiParams ); + } /** @@ -136,6 +139,7 @@ public function listCountries(): array $apiHeaders, $apiParams ); + } /** @@ -166,6 +170,7 @@ public function listCountriesEU(): array $apiHeaders, $apiParams ); + } /** @@ -196,6 +201,7 @@ public function listCountriesPhones(): array $apiHeaders, $apiParams ); + } /** @@ -227,6 +233,7 @@ public function listCurrencies(): array $apiHeaders, $apiParams ); + } /** @@ -257,5 +264,6 @@ public function listLanguages(): array $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index dc3b41b..824f339 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\SmtpEncryption; class Messaging extends Service @@ -36,11 +36,11 @@ public function listMessages(?array $queries = null, ?string $search = null): ar $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -52,6 +52,7 @@ public function listMessages(?array $queries = null, ?string $search = null): ar $apiHeaders, $apiParams ); + } /** @@ -88,39 +89,39 @@ public function createEmail(string $messageId, string $subject, string $content, $apiParams['content'] = $content; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($cc)) { - $apiParams['cc'] = $cc; + $apiParams['cc'] = $cc; } if (!is_null($bcc)) { - $apiParams['bcc'] = $bcc; + $apiParams['bcc'] = $bcc; } if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; + $apiParams['attachments'] = $attachments; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($html)) { - $apiParams['html'] = $html; + $apiParams['html'] = $html; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -132,6 +133,7 @@ public function createEmail(string $messageId, string $subject, string $content, $apiHeaders, $apiParams ); + } /** @@ -167,47 +169,47 @@ public function updateEmail(string $messageId, ?array $topics = null, ?array $us $apiParams['messageId'] = $messageId; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($subject)) { - $apiParams['subject'] = $subject; + $apiParams['subject'] = $subject; } if (!is_null($content)) { - $apiParams['content'] = $content; + $apiParams['content'] = $content; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($html)) { - $apiParams['html'] = $html; + $apiParams['html'] = $html; } if (!is_null($cc)) { - $apiParams['cc'] = $cc; + $apiParams['cc'] = $cc; } if (!is_null($bcc)) { - $apiParams['bcc'] = $bcc; + $apiParams['bcc'] = $bcc; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; + $apiParams['attachments'] = $attachments; } $apiHeaders = []; @@ -219,6 +221,7 @@ public function updateEmail(string $messageId, ?array $topics = null, ?array $us $apiHeaders, $apiParams ); + } /** @@ -259,55 +262,55 @@ public function createPush(string $messageId, string $title, string $body, ?arra $apiParams['body'] = $body; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($data)) { - $apiParams['data'] = $data; + $apiParams['data'] = $data; } if (!is_null($action)) { - $apiParams['action'] = $action; + $apiParams['action'] = $action; } if (!is_null($image)) { - $apiParams['image'] = $image; + $apiParams['image'] = $image; } if (!is_null($icon)) { - $apiParams['icon'] = $icon; + $apiParams['icon'] = $icon; } if (!is_null($sound)) { - $apiParams['sound'] = $sound; + $apiParams['sound'] = $sound; } if (!is_null($color)) { - $apiParams['color'] = $color; + $apiParams['color'] = $color; } if (!is_null($tag)) { - $apiParams['tag'] = $tag; + $apiParams['tag'] = $tag; } if (!is_null($badge)) { - $apiParams['badge'] = $badge; + $apiParams['badge'] = $badge; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -319,6 +322,7 @@ public function createPush(string $messageId, string $title, string $body, ?arra $apiHeaders, $apiParams ); + } /** @@ -358,63 +362,63 @@ public function updatePush(string $messageId, ?array $topics = null, ?array $use $apiParams['messageId'] = $messageId; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($title)) { - $apiParams['title'] = $title; + $apiParams['title'] = $title; } if (!is_null($body)) { - $apiParams['body'] = $body; + $apiParams['body'] = $body; } if (!is_null($data)) { - $apiParams['data'] = $data; + $apiParams['data'] = $data; } if (!is_null($action)) { - $apiParams['action'] = $action; + $apiParams['action'] = $action; } if (!is_null($image)) { - $apiParams['image'] = $image; + $apiParams['image'] = $image; } if (!is_null($icon)) { - $apiParams['icon'] = $icon; + $apiParams['icon'] = $icon; } if (!is_null($sound)) { - $apiParams['sound'] = $sound; + $apiParams['sound'] = $sound; } if (!is_null($color)) { - $apiParams['color'] = $color; + $apiParams['color'] = $color; } if (!is_null($tag)) { - $apiParams['tag'] = $tag; + $apiParams['tag'] = $tag; } if (!is_null($badge)) { - $apiParams['badge'] = $badge; + $apiParams['badge'] = $badge; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -426,6 +430,7 @@ public function updatePush(string $messageId, ?array $topics = null, ?array $use $apiHeaders, $apiParams ); + } /** @@ -456,23 +461,23 @@ public function createSms(string $messageId, string $content, ?array $topics = n $apiParams['content'] = $content; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -484,6 +489,7 @@ public function createSms(string $messageId, string $content, ?array $topics = n $apiHeaders, $apiParams ); + } /** @@ -514,27 +520,27 @@ public function updateSms(string $messageId, ?array $topics = null, ?array $user $apiParams['messageId'] = $messageId; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($content)) { - $apiParams['content'] = $content; + $apiParams['content'] = $content; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -546,6 +552,7 @@ public function updateSms(string $messageId, ?array $topics = null, ?array $user $apiHeaders, $apiParams ); + } /** @@ -578,6 +585,7 @@ public function getMessage(string $messageId): array $apiHeaders, $apiParams ); + } /** @@ -610,6 +618,7 @@ public function delete(string $messageId): string $apiHeaders, $apiParams ); + } /** @@ -634,7 +643,7 @@ public function listMessageLogs(string $messageId, ?array $queries = null): arra $apiParams['messageId'] = $messageId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -646,6 +655,7 @@ public function listMessageLogs(string $messageId, ?array $queries = null): arra $apiHeaders, $apiParams ); + } /** @@ -670,7 +680,7 @@ public function listTargets(string $messageId, ?array $queries = null): array $apiParams['messageId'] = $messageId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -682,6 +692,7 @@ public function listTargets(string $messageId, ?array $queries = null): array $apiHeaders, $apiParams ); + } /** @@ -705,11 +716,11 @@ public function listProviders(?array $queries = null, ?string $search = null): a $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -721,6 +732,7 @@ public function listProviders(?array $queries = null, ?string $search = null): a $apiHeaders, $apiParams ); + } /** @@ -752,27 +764,27 @@ public function createApnsProvider(string $providerId, string $name, ?string $au $apiParams['name'] = $name; if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } if (!is_null($authKeyId)) { - $apiParams['authKeyId'] = $authKeyId; + $apiParams['authKeyId'] = $authKeyId; } if (!is_null($teamId)) { - $apiParams['teamId'] = $teamId; + $apiParams['teamId'] = $teamId; } if (!is_null($bundleId)) { - $apiParams['bundleId'] = $bundleId; + $apiParams['bundleId'] = $bundleId; } if (!is_null($sandbox)) { - $apiParams['sandbox'] = $sandbox; + $apiParams['sandbox'] = $sandbox; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -784,6 +796,7 @@ public function createApnsProvider(string $providerId, string $name, ?string $au $apiHeaders, $apiParams ); + } /** @@ -814,31 +827,31 @@ public function updateApnsProvider(string $providerId, ?string $name = null, ?bo $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } if (!is_null($authKeyId)) { - $apiParams['authKeyId'] = $authKeyId; + $apiParams['authKeyId'] = $authKeyId; } if (!is_null($teamId)) { - $apiParams['teamId'] = $teamId; + $apiParams['teamId'] = $teamId; } if (!is_null($bundleId)) { - $apiParams['bundleId'] = $bundleId; + $apiParams['bundleId'] = $bundleId; } if (!is_null($sandbox)) { - $apiParams['sandbox'] = $sandbox; + $apiParams['sandbox'] = $sandbox; } $apiHeaders = []; @@ -850,6 +863,7 @@ public function updateApnsProvider(string $providerId, ?string $name = null, ?bo $apiHeaders, $apiParams ); + } /** @@ -877,11 +891,11 @@ public function createFcmProvider(string $providerId, string $name, ?array $serv $apiParams['name'] = $name; if (!is_null($serviceAccountJSON)) { - $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -893,6 +907,7 @@ public function createFcmProvider(string $providerId, string $name, ?array $serv $apiHeaders, $apiParams ); + } /** @@ -919,15 +934,15 @@ public function updateFcmProvider(string $providerId, ?string $name = null, ?boo $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($serviceAccountJSON)) { - $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; } $apiHeaders = []; @@ -939,6 +954,7 @@ public function updateFcmProvider(string $providerId, ?string $name = null, ?boo $apiHeaders, $apiParams ); + } /** @@ -972,35 +988,35 @@ public function createMailgunProvider(string $providerId, string $name, ?string $apiParams['name'] = $name; if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($domain)) { - $apiParams['domain'] = $domain; + $apiParams['domain'] = $domain; } if (!is_null($isEuRegion)) { - $apiParams['isEuRegion'] = $isEuRegion; + $apiParams['isEuRegion'] = $isEuRegion; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1012,6 +1028,7 @@ public function createMailgunProvider(string $providerId, string $name, ?string $apiHeaders, $apiParams ); + } /** @@ -1044,39 +1061,39 @@ public function updateMailgunProvider(string $providerId, ?string $name = null, $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($domain)) { - $apiParams['domain'] = $domain; + $apiParams['domain'] = $domain; } if (!is_null($isEuRegion)) { - $apiParams['isEuRegion'] = $isEuRegion; + $apiParams['isEuRegion'] = $isEuRegion; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } $apiHeaders = []; @@ -1088,6 +1105,7 @@ public function updateMailgunProvider(string $providerId, ?string $name = null, $apiHeaders, $apiParams ); + } /** @@ -1117,19 +1135,19 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t $apiParams['name'] = $name; if (!is_null($templateId)) { - $apiParams['templateId'] = $templateId; + $apiParams['templateId'] = $templateId; } if (!is_null($senderId)) { - $apiParams['senderId'] = $senderId; + $apiParams['senderId'] = $senderId; } if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1141,6 +1159,7 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t $apiHeaders, $apiParams ); + } /** @@ -1169,23 +1188,23 @@ public function updateMsg91Provider(string $providerId, ?string $name = null, ?b $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($templateId)) { - $apiParams['templateId'] = $templateId; + $apiParams['templateId'] = $templateId; } if (!is_null($senderId)) { - $apiParams['senderId'] = $senderId; + $apiParams['senderId'] = $senderId; } if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } $apiHeaders = []; @@ -1197,6 +1216,7 @@ public function updateMsg91Provider(string $providerId, ?string $name = null, ?b $apiHeaders, $apiParams ); + } /** @@ -1228,27 +1248,27 @@ public function createSendgridProvider(string $providerId, string $name, ?string $apiParams['name'] = $name; if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1260,6 +1280,7 @@ public function createSendgridProvider(string $providerId, string $name, ?string $apiHeaders, $apiParams ); + } /** @@ -1290,31 +1311,31 @@ public function updateSendgridProvider(string $providerId, ?string $name = null, $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } $apiHeaders = []; @@ -1326,6 +1347,7 @@ public function updateSendgridProvider(string $providerId, ?string $name = null, $apiHeaders, $apiParams ); + } /** @@ -1364,47 +1386,47 @@ public function createSmtpProvider(string $providerId, string $name, string $hos $apiParams['host'] = $host; if (!is_null($port)) { - $apiParams['port'] = $port; + $apiParams['port'] = $port; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($password)) { - $apiParams['password'] = $password; + $apiParams['password'] = $password; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($autoTLS)) { - $apiParams['autoTLS'] = $autoTLS; + $apiParams['autoTLS'] = $autoTLS; } if (!is_null($mailer)) { - $apiParams['mailer'] = $mailer; + $apiParams['mailer'] = $mailer; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1416,6 +1438,7 @@ public function createSmtpProvider(string $providerId, string $name, string $hos $apiHeaders, $apiParams ); + } /** @@ -1452,55 +1475,55 @@ public function updateSmtpProvider(string $providerId, ?string $name = null, ?st $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($host)) { - $apiParams['host'] = $host; + $apiParams['host'] = $host; } if (!is_null($port)) { - $apiParams['port'] = $port; + $apiParams['port'] = $port; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($password)) { - $apiParams['password'] = $password; + $apiParams['password'] = $password; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($autoTLS)) { - $apiParams['autoTLS'] = $autoTLS; + $apiParams['autoTLS'] = $autoTLS; } if (!is_null($mailer)) { - $apiParams['mailer'] = $mailer; + $apiParams['mailer'] = $mailer; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1512,6 +1535,7 @@ public function updateSmtpProvider(string $providerId, ?string $name = null, ?st $apiHeaders, $apiParams ); + } /** @@ -1541,19 +1565,19 @@ public function createTelesignProvider(string $providerId, string $name, ?string $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($customerId)) { - $apiParams['customerId'] = $customerId; + $apiParams['customerId'] = $customerId; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1565,6 +1589,7 @@ public function createTelesignProvider(string $providerId, string $name, ?string $apiHeaders, $apiParams ); + } /** @@ -1593,23 +1618,23 @@ public function updateTelesignProvider(string $providerId, ?string $name = null, $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($customerId)) { - $apiParams['customerId'] = $customerId; + $apiParams['customerId'] = $customerId; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1621,6 +1646,7 @@ public function updateTelesignProvider(string $providerId, ?string $name = null, $apiHeaders, $apiParams ); + } /** @@ -1650,19 +1676,19 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1674,6 +1700,7 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin $apiHeaders, $apiParams ); + } /** @@ -1702,23 +1729,23 @@ public function updateTextmagicProvider(string $providerId, ?string $name = null $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1730,6 +1757,7 @@ public function updateTextmagicProvider(string $providerId, ?string $name = null $apiHeaders, $apiParams ); + } /** @@ -1759,19 +1787,19 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($accountSid)) { - $apiParams['accountSid'] = $accountSid; + $apiParams['accountSid'] = $accountSid; } if (!is_null($authToken)) { - $apiParams['authToken'] = $authToken; + $apiParams['authToken'] = $authToken; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1783,6 +1811,7 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ $apiHeaders, $apiParams ); + } /** @@ -1811,23 +1840,23 @@ public function updateTwilioProvider(string $providerId, ?string $name = null, ? $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($accountSid)) { - $apiParams['accountSid'] = $accountSid; + $apiParams['accountSid'] = $accountSid; } if (!is_null($authToken)) { - $apiParams['authToken'] = $authToken; + $apiParams['authToken'] = $authToken; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1839,6 +1868,7 @@ public function updateTwilioProvider(string $providerId, ?string $name = null, ? $apiHeaders, $apiParams ); + } /** @@ -1868,19 +1898,19 @@ public function createVonageProvider(string $providerId, string $name, ?string $ $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($apiSecret)) { - $apiParams['apiSecret'] = $apiSecret; + $apiParams['apiSecret'] = $apiSecret; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1892,6 +1922,7 @@ public function createVonageProvider(string $providerId, string $name, ?string $ $apiHeaders, $apiParams ); + } /** @@ -1920,23 +1951,23 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($apiSecret)) { - $apiParams['apiSecret'] = $apiSecret; + $apiParams['apiSecret'] = $apiSecret; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1948,6 +1979,7 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? $apiHeaders, $apiParams ); + } /** @@ -1980,6 +2012,7 @@ public function getProvider(string $providerId): array $apiHeaders, $apiParams ); + } /** @@ -2011,6 +2044,7 @@ public function deleteProvider(string $providerId): string $apiHeaders, $apiParams ); + } /** @@ -2035,7 +2069,7 @@ public function listProviderLogs(string $providerId, ?array $queries = null): ar $apiParams['providerId'] = $providerId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -2047,6 +2081,7 @@ public function listProviderLogs(string $providerId, ?array $queries = null): ar $apiHeaders, $apiParams ); + } /** @@ -2071,7 +2106,7 @@ public function listSubscriberLogs(string $subscriberId, ?array $queries = null) $apiParams['subscriberId'] = $subscriberId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -2083,6 +2118,7 @@ public function listSubscriberLogs(string $subscriberId, ?array $queries = null) $apiHeaders, $apiParams ); + } /** @@ -2106,11 +2142,11 @@ public function listTopics(?array $queries = null, ?string $search = null): arra $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -2122,6 +2158,7 @@ public function listTopics(?array $queries = null, ?string $search = null): arra $apiHeaders, $apiParams ); + } /** @@ -2148,7 +2185,7 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n $apiParams['name'] = $name; if (!is_null($subscribe)) { - $apiParams['subscribe'] = $subscribe; + $apiParams['subscribe'] = $subscribe; } $apiHeaders = []; @@ -2160,6 +2197,7 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n $apiHeaders, $apiParams ); + } /** @@ -2192,6 +2230,7 @@ public function getTopic(string $topicId): array $apiHeaders, $apiParams ); + } /** @@ -2218,11 +2257,11 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc $apiParams['topicId'] = $topicId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($subscribe)) { - $apiParams['subscribe'] = $subscribe; + $apiParams['subscribe'] = $subscribe; } $apiHeaders = []; @@ -2234,6 +2273,7 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc $apiHeaders, $apiParams ); + } /** @@ -2265,6 +2305,7 @@ public function deleteTopic(string $topicId): string $apiHeaders, $apiParams ); + } /** @@ -2289,7 +2330,7 @@ public function listTopicLogs(string $topicId, ?array $queries = null): array $apiParams['topicId'] = $topicId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -2301,6 +2342,7 @@ public function listTopicLogs(string $topicId, ?array $queries = null): array $apiHeaders, $apiParams ); + } /** @@ -2326,11 +2368,11 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string $apiParams['topicId'] = $topicId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -2342,6 +2384,7 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string $apiHeaders, $apiParams ); + } /** @@ -2377,6 +2420,7 @@ public function createSubscriber(string $topicId, string $subscriberId, string $ $apiHeaders, $apiParams ); + } /** @@ -2411,6 +2455,7 @@ public function getSubscriber(string $topicId, string $subscriberId): array $apiHeaders, $apiParams ); + } /** @@ -2444,5 +2489,6 @@ public function deleteSubscriber(string $topicId, string $subscriberId): string $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index fd2ebf9..47c9cc1 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\Compression; use Appwrite\Enums\ImageGravity; use Appwrite\Enums\ImageFormat; @@ -39,11 +39,11 @@ public function listBuckets(?array $queries = null, ?string $search = null): arr $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -55,6 +55,7 @@ public function listBuckets(?array $queries = null, ?string $search = null): arr $apiHeaders, $apiParams ); + } /** @@ -88,35 +89,35 @@ public function createBucket(string $bucketId, string $name, ?array $permissions $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($fileSecurity)) { - $apiParams['fileSecurity'] = $fileSecurity; + $apiParams['fileSecurity'] = $fileSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; + $apiParams['maximumFileSize'] = $maximumFileSize; } if (!is_null($allowedFileExtensions)) { - $apiParams['allowedFileExtensions'] = $allowedFileExtensions; + $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } if (!is_null($compression)) { - $apiParams['compression'] = $compression; + $apiParams['compression'] = $compression; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($antivirus)) { - $apiParams['antivirus'] = $antivirus; + $apiParams['antivirus'] = $antivirus; } $apiHeaders = []; @@ -128,6 +129,7 @@ public function createBucket(string $bucketId, string $name, ?array $permissions $apiHeaders, $apiParams ); + } /** @@ -160,6 +162,7 @@ public function getBucket(string $bucketId): array $apiHeaders, $apiParams ); + } /** @@ -193,35 +196,35 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($fileSecurity)) { - $apiParams['fileSecurity'] = $fileSecurity; + $apiParams['fileSecurity'] = $fileSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; + $apiParams['maximumFileSize'] = $maximumFileSize; } if (!is_null($allowedFileExtensions)) { - $apiParams['allowedFileExtensions'] = $allowedFileExtensions; + $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } if (!is_null($compression)) { - $apiParams['compression'] = $compression; + $apiParams['compression'] = $compression; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($antivirus)) { - $apiParams['antivirus'] = $antivirus; + $apiParams['antivirus'] = $antivirus; } $apiHeaders = []; @@ -233,6 +236,7 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions $apiHeaders, $apiParams ); + } /** @@ -264,6 +268,7 @@ public function deleteBucket(string $bucketId): string $apiHeaders, $apiParams ); + } /** @@ -290,11 +295,11 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea $apiParams['bucketId'] = $bucketId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -306,6 +311,7 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea $apiHeaders, $apiParams ); + } /** @@ -332,12 +338,12 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea * * @param string $bucketId * @param string $fileId - * @param InputFile $file + * @param Payload $file * @param ?array $permissions * @throws AppwriteException * @return array */ - public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, callable $onProgress = null): array + public function createFile(string $bucketId, string $fileId, Payload $file, ?array $permissions = null, callable $onProgress = null): array { $apiPath = str_replace( ['{bucketId}'], @@ -351,35 +357,17 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a $apiParams['file'] = $file; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; $apiHeaders['content-type'] = 'multipart/form-data'; - $size = 0; - $mimeType = null; - $postedName = null; - if(empty($file->getPath() ?? null)) { - $size = strlen($file->getData()); - $mimeType = $file->getMimeType(); - $postedName = $file->getFilename(); - if ($size <= Client::CHUNK_SIZE) { - $apiParams['file'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($file->getData()), $mimeType, $postedName); - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'multipart/form-data', - ], $apiParams); - } - } else { - $size = filesize($file->getPath()); - $mimeType = $file->getMimeType() ?? mime_content_type($file->getPath()); - $postedName = $file->getFilename() ?? basename($file->getPath()); - //send single file if size is less than or equal to 5MB - if ($size <= Client::CHUNK_SIZE) { - $apiParams['file'] = new \CURLFile($file->getPath(), $mimeType, $postedName); - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'multipart/form-data', - ], $apiParams); - } + $size = $file->size; + + if ($size <= Client::CHUNK_SIZE) { + return $this->client->call(Client::METHOD_POST, $apiPath, [ + 'content-type' => 'multipart/form-data', + ], $apiParams); } $id = ''; @@ -394,22 +382,16 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a } $apiHeaders = ['content-type' => 'multipart/form-data']; - $handle = null; - - if(!empty($file->getPath())) { - $handle = @fopen($file->getPath(), "rb"); - } $start = $counter * Client::CHUNK_SIZE; while ($start < $size) { - $chunk = ''; - if(!empty($handle)) { - fseek($handle, $start); - $chunk = @fread($handle, Client::CHUNK_SIZE); - } else { - $chunk = substr($file->getData(), $start, Client::CHUNK_SIZE); - } - $apiParams['file'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($chunk), $mimeType, $postedName); + + $apiParams['file'] = Payload::fromBinary( + $file->toBinary($start, Client::CHUNK_SIZE), + $file->filename, + $file->mimeType + ); + $apiHeaders['content-range'] = 'bytes ' . ($counter * Client::CHUNK_SIZE) . '-' . min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE) - 1), $size - 1) . '/' . $size; if(!empty($id)) { $apiHeaders['x-appwrite-id'] = $id; @@ -426,13 +408,10 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a 'progress' => min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE)), $size) / $size * 100, 'sizeUploaded' => min($counter * Client::CHUNK_SIZE), 'chunksTotal' => $response['chunksTotal'], - 'chunksUploaded' => $response['chunksUploaded'], + 'chunksUploaded' => $response['chunksUploaded'], ]); } } - if(!empty($handle)) { - @fclose($handle); - } return $response; } @@ -469,6 +448,7 @@ public function getFile(string $bucketId, string $fileId): array $apiHeaders, $apiParams ); + } /** @@ -497,11 +477,11 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul $apiParams['fileId'] = $fileId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; @@ -513,10 +493,11 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul $apiHeaders, $apiParams ); + } /** - * Delete File + * Delete file * * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. @@ -547,6 +528,7 @@ public function deleteFile(string $bucketId, string $fileId): string $apiHeaders, $apiParams ); + } /** @@ -582,6 +564,7 @@ public function getFileDownload(string $bucketId, string $fileId): string $apiHeaders, $apiParams ); + } /** @@ -622,47 +605,47 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n $apiParams['fileId'] = $fileId; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($gravity)) { - $apiParams['gravity'] = $gravity; + $apiParams['gravity'] = $gravity; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } if (!is_null($borderWidth)) { - $apiParams['borderWidth'] = $borderWidth; + $apiParams['borderWidth'] = $borderWidth; } if (!is_null($borderColor)) { - $apiParams['borderColor'] = $borderColor; + $apiParams['borderColor'] = $borderColor; } if (!is_null($borderRadius)) { - $apiParams['borderRadius'] = $borderRadius; + $apiParams['borderRadius'] = $borderRadius; } if (!is_null($opacity)) { - $apiParams['opacity'] = $opacity; + $apiParams['opacity'] = $opacity; } if (!is_null($rotation)) { - $apiParams['rotation'] = $rotation; + $apiParams['rotation'] = $rotation; } if (!is_null($background)) { - $apiParams['background'] = $background; + $apiParams['background'] = $background; } if (!is_null($output)) { - $apiParams['output'] = $output; + $apiParams['output'] = $output; } $apiHeaders = []; @@ -674,6 +657,7 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n $apiHeaders, $apiParams ); + } /** @@ -709,5 +693,6 @@ public function getFileView(string $bucketId, string $fileId): string $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 53c35b1..bd0ae46 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; class Teams extends Service { @@ -36,11 +36,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -52,6 +52,7 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); + } /** @@ -80,7 +81,7 @@ public function create(string $teamId, string $name, ?array $roles = null): arra $apiParams['name'] = $name; if (!is_null($roles)) { - $apiParams['roles'] = $roles; + $apiParams['roles'] = $roles; } $apiHeaders = []; @@ -92,6 +93,7 @@ public function create(string $teamId, string $name, ?array $roles = null): arra $apiHeaders, $apiParams ); + } /** @@ -123,6 +125,7 @@ public function get(string $teamId): array $apiHeaders, $apiParams ); + } /** @@ -156,6 +159,7 @@ public function updateName(string $teamId, string $name): array $apiHeaders, $apiParams ); + } /** @@ -188,6 +192,7 @@ public function delete(string $teamId): string $apiHeaders, $apiParams ); + } /** @@ -214,11 +219,11 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string $apiParams['teamId'] = $teamId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -230,6 +235,7 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string $apiHeaders, $apiParams ); + } /** @@ -280,23 +286,23 @@ public function createMembership(string $teamId, array $roles, ?string $email = $apiParams['roles'] = $roles; if (!is_null($email)) { - $apiParams['email'] = $email; + $apiParams['email'] = $email; } if (!is_null($userId)) { - $apiParams['userId'] = $userId; + $apiParams['userId'] = $userId; } if (!is_null($phone)) { - $apiParams['phone'] = $phone; + $apiParams['phone'] = $phone; } if (!is_null($url)) { - $apiParams['url'] = $url; + $apiParams['url'] = $url; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -308,6 +314,7 @@ public function createMembership(string $teamId, array $roles, ?string $email = $apiHeaders, $apiParams ); + } /** @@ -342,6 +349,7 @@ public function getMembership(string $teamId, string $membershipId): array $apiHeaders, $apiParams ); + } /** @@ -380,6 +388,7 @@ public function updateMembership(string $teamId, string $membershipId, array $ro $apiHeaders, $apiParams ); + } /** @@ -415,6 +424,7 @@ public function deleteMembership(string $teamId, string $membershipId): string $apiHeaders, $apiParams ); + } /** @@ -458,6 +468,7 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str $apiHeaders, $apiParams ); + } /** @@ -491,6 +502,7 @@ public function getPrefs(string $teamId): array $apiHeaders, $apiParams ); + } /** @@ -526,5 +538,6 @@ public function updatePrefs(string $teamId, array $prefs): array $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index 3da6d52..afc1aba 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\InputFile; +use Appwrite\Payload; use Appwrite\Enums\PasswordHash; use Appwrite\Enums\AuthenticatorType; use Appwrite\Enums\MessagingProviderType; @@ -39,11 +39,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -55,6 +55,7 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); + } /** @@ -82,19 +83,19 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiParams['userId'] = $userId; if (!is_null($email)) { - $apiParams['email'] = $email; + $apiParams['email'] = $email; } if (!is_null($phone)) { - $apiParams['phone'] = $phone; + $apiParams['phone'] = $phone; } if (!is_null($password)) { - $apiParams['password'] = $password; + $apiParams['password'] = $password; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -106,6 +107,7 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiHeaders, $apiParams ); + } /** @@ -137,7 +139,7 @@ public function createArgon2User(string $userId, string $email, string $password $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -149,6 +151,7 @@ public function createArgon2User(string $userId, string $email, string $password $apiHeaders, $apiParams ); + } /** @@ -180,7 +183,7 @@ public function createBcryptUser(string $userId, string $email, string $password $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -192,10 +195,11 @@ public function createBcryptUser(string $userId, string $email, string $password $apiHeaders, $apiParams ); + } /** - * List Identities + * List identities * * Get identities for all users. * @@ -215,11 +219,11 @@ public function listIdentities(?array $queries = null, ?string $search = null): $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -231,6 +235,7 @@ public function listIdentities(?array $queries = null, ?string $search = null): $apiHeaders, $apiParams ); + } /** @@ -262,6 +267,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders, $apiParams ); + } /** @@ -293,7 +299,7 @@ public function createMD5User(string $userId, string $email, string $password, ? $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -305,6 +311,7 @@ public function createMD5User(string $userId, string $email, string $password, ? $apiHeaders, $apiParams ); + } /** @@ -336,7 +343,7 @@ public function createPHPassUser(string $userId, string $email, string $password $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -348,6 +355,7 @@ public function createPHPassUser(string $userId, string $email, string $password $apiHeaders, $apiParams ); + } /** @@ -389,7 +397,7 @@ public function createScryptUser(string $userId, string $email, string $password $apiParams['passwordLength'] = $passwordLength; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -401,6 +409,7 @@ public function createScryptUser(string $userId, string $email, string $password $apiHeaders, $apiParams ); + } /** @@ -439,7 +448,7 @@ public function createScryptModifiedUser(string $userId, string $email, string $ $apiParams['passwordSignerKey'] = $passwordSignerKey; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -451,6 +460,7 @@ public function createScryptModifiedUser(string $userId, string $email, string $ $apiHeaders, $apiParams ); + } /** @@ -483,11 +493,11 @@ public function createSHAUser(string $userId, string $email, string $password, ? $apiParams['password'] = $password; if (!is_null($passwordVersion)) { - $apiParams['passwordVersion'] = $passwordVersion; + $apiParams['passwordVersion'] = $passwordVersion; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -499,6 +509,7 @@ public function createSHAUser(string $userId, string $email, string $password, ? $apiHeaders, $apiParams ); + } /** @@ -530,6 +541,7 @@ public function get(string $userId): array $apiHeaders, $apiParams ); + } /** @@ -566,6 +578,7 @@ public function delete(string $userId): string $apiHeaders, $apiParams ); + } /** @@ -599,6 +612,7 @@ public function updateEmail(string $userId, string $email): array $apiHeaders, $apiParams ); + } /** @@ -626,11 +640,11 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat $apiParams['userId'] = $userId; if (!is_null($sessionId)) { - $apiParams['sessionId'] = $sessionId; + $apiParams['sessionId'] = $sessionId; } if (!is_null($duration)) { - $apiParams['duration'] = $duration; + $apiParams['duration'] = $duration; } $apiHeaders = []; @@ -642,6 +656,7 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat $apiHeaders, $apiParams ); + } /** @@ -680,6 +695,7 @@ public function updateLabels(string $userId, array $labels): array $apiHeaders, $apiParams ); + } /** @@ -704,7 +720,7 @@ public function listLogs(string $userId, ?array $queries = null): array $apiParams['userId'] = $userId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -716,6 +732,7 @@ public function listLogs(string $userId, ?array $queries = null): array $apiHeaders, $apiParams ); + } /** @@ -747,6 +764,7 @@ public function listMemberships(string $userId): array $apiHeaders, $apiParams ); + } /** @@ -780,10 +798,11 @@ public function updateMfa(string $userId, bool $mfa): array $apiHeaders, $apiParams ); + } /** - * Delete Authenticator + * Delete authenticator * * Delete an authenticator app. * @@ -813,10 +832,11 @@ public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): $apiHeaders, $apiParams ); + } /** - * List Factors + * List factors * * List the factors available on the account to be used as a MFA challange. * @@ -844,10 +864,11 @@ public function listMfaFactors(string $userId): array $apiHeaders, $apiParams ); + } /** - * Get MFA Recovery Codes + * Get MFA recovery codes * * Get recovery codes that can be used as backup for MFA flow by User ID. * Before getting codes, they must be generated using @@ -878,10 +899,11 @@ public function getMfaRecoveryCodes(string $userId): array $apiHeaders, $apiParams ); + } /** - * Regenerate MFA Recovery Codes + * Regenerate MFA recovery codes * * Regenerate recovery codes that can be used as backup for MFA flow by User * ID. Before regenerating codes, they must be first generated using @@ -912,10 +934,11 @@ public function updateMfaRecoveryCodes(string $userId): array $apiHeaders, $apiParams ); + } /** - * Create MFA Recovery Codes + * Create MFA recovery codes * * Generate recovery codes used as backup for MFA flow for User ID. Recovery * codes can be used as a MFA verification type in @@ -946,6 +969,7 @@ public function createMfaRecoveryCodes(string $userId): array $apiHeaders, $apiParams ); + } /** @@ -979,6 +1003,7 @@ public function updateName(string $userId, string $name): array $apiHeaders, $apiParams ); + } /** @@ -1012,6 +1037,7 @@ public function updatePassword(string $userId, string $password): array $apiHeaders, $apiParams ); + } /** @@ -1045,6 +1071,7 @@ public function updatePhone(string $userId, string $number): array $apiHeaders, $apiParams ); + } /** @@ -1076,6 +1103,7 @@ public function getPrefs(string $userId): array $apiHeaders, $apiParams ); + } /** @@ -1111,6 +1139,7 @@ public function updatePrefs(string $userId, array $prefs): array $apiHeaders, $apiParams ); + } /** @@ -1142,6 +1171,7 @@ public function listSessions(string $userId): array $apiHeaders, $apiParams ); + } /** @@ -1178,6 +1208,7 @@ public function createSession(string $userId): array $apiHeaders, $apiParams ); + } /** @@ -1209,6 +1240,7 @@ public function deleteSessions(string $userId): string $apiHeaders, $apiParams ); + } /** @@ -1242,6 +1274,7 @@ public function deleteSession(string $userId, string $sessionId): string $apiHeaders, $apiParams ); + } /** @@ -1276,10 +1309,11 @@ public function updateStatus(string $userId, bool $status): array $apiHeaders, $apiParams ); + } /** - * List User Targets + * List user targets * * List the messaging targets that are associated with a user. * @@ -1300,7 +1334,7 @@ public function listTargets(string $userId, ?array $queries = null): array $apiParams['userId'] = $userId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1312,10 +1346,11 @@ public function listTargets(string $userId, ?array $queries = null): array $apiHeaders, $apiParams ); + } /** - * Create User Target + * Create user target * * Create a messaging target. * @@ -1343,11 +1378,11 @@ public function createTarget(string $userId, string $targetId, MessagingProvider $apiParams['identifier'] = $identifier; if (!is_null($providerId)) { - $apiParams['providerId'] = $providerId; + $apiParams['providerId'] = $providerId; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -1359,10 +1394,11 @@ public function createTarget(string $userId, string $targetId, MessagingProvider $apiHeaders, $apiParams ); + } /** - * Get User Target + * Get user target * * Get a user's push notification target by ID. * @@ -1392,10 +1428,11 @@ public function getTarget(string $userId, string $targetId): array $apiHeaders, $apiParams ); + } /** - * Update User target + * Update user target * * Update a messaging target. * @@ -1420,15 +1457,15 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi $apiParams['targetId'] = $targetId; if (!is_null($identifier)) { - $apiParams['identifier'] = $identifier; + $apiParams['identifier'] = $identifier; } if (!is_null($providerId)) { - $apiParams['providerId'] = $providerId; + $apiParams['providerId'] = $providerId; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -1440,6 +1477,7 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi $apiHeaders, $apiParams ); + } /** @@ -1473,6 +1511,7 @@ public function deleteTarget(string $userId, string $targetId): string $apiHeaders, $apiParams ); + } /** @@ -1502,11 +1541,11 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = $apiParams['userId'] = $userId; if (!is_null($length)) { - $apiParams['length'] = $length; + $apiParams['length'] = $length; } if (!is_null($expire)) { - $apiParams['expire'] = $expire; + $apiParams['expire'] = $expire; } $apiHeaders = []; @@ -1518,6 +1557,7 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = $apiHeaders, $apiParams ); + } /** @@ -1551,6 +1591,7 @@ public function updateEmailVerification(string $userId, bool $emailVerification) $apiHeaders, $apiParams ); + } /** @@ -1584,5 +1625,6 @@ public function updatePhoneVerification(string $userId, bool $phoneVerification) $apiHeaders, $apiParams ); + } -} \ No newline at end of file +} diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index 9c518a5..a5f54da 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/AvatarsTest.php b/tests/Appwrite/Services/AvatarsTest.php index cb2790e..1161626 100644 --- a/tests/Appwrite/Services/AvatarsTest.php +++ b/tests/Appwrite/Services/AvatarsTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index cf4f452..5659fca 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 854f83b..57a7ce4 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; @@ -259,7 +259,7 @@ public function testMethodCreateDeployment(): void { $response = $this->functions->createDeployment( "", - InputFile::withData('', "image/png"), + Payload::fromBinary('', "image/png"), true ); @@ -457,7 +457,7 @@ public function testMethodCreateExecution(): void { "requestPath" => "/articles?id=5", "requestHeaders" => array(), "responseStatusCode" => 200, - "responseBody" => "Developers are awesome.", + "responseBody" => , "responseHeaders" => array(), "logs" => "", "errors" => "", @@ -489,7 +489,7 @@ public function testMethodGetExecution(): void { "requestPath" => "/articles?id=5", "requestHeaders" => array(), "responseStatusCode" => 200, - "responseBody" => "Developers are awesome.", + "responseBody" => , "responseHeaders" => array(), "logs" => "", "errors" => "", diff --git a/tests/Appwrite/Services/GraphqlTest.php b/tests/Appwrite/Services/GraphqlTest.php index 6c587b8..7ef6824 100644 --- a/tests/Appwrite/Services/GraphqlTest.php +++ b/tests/Appwrite/Services/GraphqlTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php index bed4e21..e2c2083 100644 --- a/tests/Appwrite/Services/HealthTest.php +++ b/tests/Appwrite/Services/HealthTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/LocaleTest.php b/tests/Appwrite/Services/LocaleTest.php index 6e8f9db..3dc58a1 100644 --- a/tests/Appwrite/Services/LocaleTest.php +++ b/tests/Appwrite/Services/LocaleTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/MessagingTest.php b/tests/Appwrite/Services/MessagingTest.php index 49cdac9..ca5ce08 100644 --- a/tests/Appwrite/Services/MessagingTest.php +++ b/tests/Appwrite/Services/MessagingTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/StorageTest.php b/tests/Appwrite/Services/StorageTest.php index e6b1923..ae820c4 100644 --- a/tests/Appwrite/Services/StorageTest.php +++ b/tests/Appwrite/Services/StorageTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; @@ -176,7 +176,7 @@ public function testMethodCreateFile(): void { $response = $this->storage->createFile( "", "", - InputFile::withData('', "image/png") + Payload::fromBinary('', "image/png") ); $this->assertSame($data, $response); diff --git a/tests/Appwrite/Services/TeamsTest.php b/tests/Appwrite/Services/TeamsTest.php index d77d0de..cde62f0 100644 --- a/tests/Appwrite/Services/TeamsTest.php +++ b/tests/Appwrite/Services/TeamsTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index 4cb0911..b9408b1 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\InputFile; +use Appwrite\Payload; use Mockery; use PHPUnit\Framework\TestCase; From 57d4161ec59f44851355e5d2df45ccf82346a75a Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:22:04 +0100 Subject: [PATCH 2/5] feat: multipart --- src/Appwrite/Enums/ImageFormat.php | 8 +++ tests/Appwrite/Services/DatabasesTest.php | 60 ++++++++++++++++++++--- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/Enums/ImageFormat.php b/src/Appwrite/Enums/ImageFormat.php index 9ec15d2..092d94d 100644 --- a/src/Appwrite/Enums/ImageFormat.php +++ b/src/Appwrite/Enums/ImageFormat.php @@ -11,6 +11,7 @@ class ImageFormat implements JsonSerializable private static ImageFormat $GIF; private static ImageFormat $PNG; private static ImageFormat $WEBP; + private static ImageFormat $AVIF; private string $value; @@ -64,4 +65,11 @@ public static function WEBP(): ImageFormat } return self::$WEBP; } + public static function AVIF(): ImageFormat + { + if (!isset(self::$AVIF)) { + self::$AVIF = new ImageFormat('avif'); + } + return self::$AVIF; + } } \ No newline at end of file diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 5659fca..9589c7b 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -258,7 +258,9 @@ public function testMethodCreateBooleanAttribute(): void { "type" => "boolean", "status" => "available", "error" => "string", - "required" => true,); + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -282,7 +284,9 @@ public function testMethodUpdateBooleanAttribute(): void { "type" => "boolean", "status" => "available", "error" => "string", - "required" => true,); + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -308,6 +312,8 @@ public function testMethodCreateDatetimeAttribute(): void { "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",); @@ -333,6 +339,8 @@ public function testMethodUpdateDatetimeAttribute(): void { "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",); @@ -359,6 +367,8 @@ public function testMethodCreateEmailAttribute(): void { "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",); @@ -384,6 +394,8 @@ public function testMethodUpdateEmailAttribute(): void { "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",); @@ -410,6 +422,8 @@ public function testMethodCreateEnumAttribute(): void { "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",); @@ -437,6 +451,8 @@ public function testMethodUpdateEnumAttribute(): void { "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",); @@ -464,7 +480,9 @@ public function testMethodCreateFloatAttribute(): void { "type" => "double", "status" => "available", "error" => "string", - "required" => true,); + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -488,7 +506,9 @@ public function testMethodUpdateFloatAttribute(): void { "type" => "double", "status" => "available", "error" => "string", - "required" => true,); + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -515,7 +535,9 @@ public function testMethodCreateIntegerAttribute(): void { "type" => "integer", "status" => "available", "error" => "string", - "required" => true,); + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -539,7 +561,9 @@ public function testMethodUpdateIntegerAttribute(): void { "type" => "integer", "status" => "available", "error" => "string", - "required" => true,); + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -567,6 +591,8 @@ public function testMethodCreateIpAttribute(): void { "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",); @@ -592,6 +618,8 @@ public function testMethodUpdateIpAttribute(): void { "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",); @@ -618,6 +646,8 @@ public function testMethodCreateRelationshipAttribute(): void { "status" => "available", "error" => "string", "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "relatedCollection" => "collection", "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", "twoWay" => true, @@ -648,6 +678,8 @@ public function testMethodCreateStringAttribute(): void { "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,); @@ -674,6 +706,8 @@ public function testMethodUpdateStringAttribute(): void { "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,); @@ -700,6 +734,8 @@ public function testMethodCreateUrlAttribute(): void { "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",); @@ -725,6 +761,8 @@ public function testMethodUpdateUrlAttribute(): void { "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",); @@ -787,6 +825,8 @@ public function testMethodUpdateRelationshipAttribute(): void { "status" => "available", "error" => "string", "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "relatedCollection" => "collection", "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", "twoWay" => true, @@ -944,7 +984,9 @@ public function testMethodCreateIndex(): void { "type" => "primary", "status" => "available", "error" => "string", - "attributes" => array(),); + "attributes" => array(), + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client @@ -969,7 +1011,9 @@ public function testMethodGetIndex(): void { "type" => "primary", "status" => "available", "error" => "string", - "attributes" => array(),); + "attributes" => array(), + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client From 34dd90539897308eb03db8930c69dceecc74e338 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Dec 2024 00:35:29 +1300 Subject: [PATCH 3/5] Add new push message parameters --- README.md | 2 +- docs/account.md | 2 +- .../databases/update-string-attribute.md | 2 +- docs/examples/functions/create-deployment.md | 4 +- docs/examples/functions/create-execution.md | 3 +- docs/examples/messaging/create-push.md | 11 +- docs/examples/messaging/update-push.md | 5 +- docs/examples/storage/create-file.md | 4 +- docs/functions.md | 6 +- docs/messaging.md | 12 +- docs/teams.md | 4 +- src/Appwrite/Client.php | 90 +--- src/Appwrite/Enums/MessagePriority.php | 43 ++ src/Appwrite/Enums/Runtime.php | 90 +++- src/Appwrite/InputFile.php | 51 ++ src/Appwrite/Payload.php | 74 --- src/Appwrite/Services/Account.php | 71 +-- src/Appwrite/Services/Avatars.php | 47 +- src/Appwrite/Services/Databases.php | 164 +++--- src/Appwrite/Services/Functions.php | 192 +++---- src/Appwrite/Services/Graphql.php | 6 +- src/Appwrite/Services/Health.php | 57 +- src/Appwrite/Services/Locale.php | 12 +- src/Appwrite/Services/Messaging.php | 485 +++++++++--------- src/Appwrite/Services/Storage.php | 143 +++--- src/Appwrite/Services/Teams.php | 43 +- src/Appwrite/Services/Users.php | 100 ++-- tests/Appwrite/Services/AccountTest.php | 2 +- tests/Appwrite/Services/AvatarsTest.php | 2 +- tests/Appwrite/Services/DatabasesTest.php | 2 +- tests/Appwrite/Services/FunctionsTest.php | 16 +- tests/Appwrite/Services/GraphqlTest.php | 2 +- tests/Appwrite/Services/HealthTest.php | 2 +- tests/Appwrite/Services/LocaleTest.php | 2 +- tests/Appwrite/Services/MessagingTest.php | 6 +- tests/Appwrite/Services/StorageTest.php | 4 +- tests/Appwrite/Services/TeamsTest.php | 2 +- tests/Appwrite/Services/UsersTest.php | 17 +- 38 files changed, 827 insertions(+), 953 deletions(-) create mode 100644 src/Appwrite/Enums/MessagePriority.php create mode 100644 src/Appwrite/InputFile.php delete mode 100644 src/Appwrite/Payload.php diff --git a/README.md b/README.md index 57ef550..52309eb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/docs/account.md b/docs/account.md index e942d48..94cc0ec 100644 --- a/docs/account.md +++ b/docs/account.md @@ -469,7 +469,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about POST https://cloud.appwrite.io/v1/account/tokens/magic-url ``` -** Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. +** Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 9e821e4..721ba32 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -16,6 +16,6 @@ $result = $databases->updateStringAttribute( key: '', required: false, default: '', - size: null, // optional + size: 1, // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index a844bbe..90f4c7e 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,7 +1,7 @@ createDeployment( functionId: '', - code: Payload::fromFile('file.png'), + code: InputFile::withPath('file.png'), activate: false, entrypoint: '', // optional commands: '' // optional diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 2e25414..4c62b9a 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,7 +1,6 @@ createExecution( functionId: '', - body: Payload::fromJson([ 'x' => 'y' ]), // optional + body: '', // optional async: false, // optional path: '', // optional method: ExecutionMethod::GET(), // optional diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 7838576..9aaf6ad 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -12,8 +12,8 @@ $messaging = new Messaging($client); $result = $messaging->createPush( messageId: '', - title: '', - body: '<BODY>', + title: '<TITLE>', // optional + body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional @@ -24,7 +24,10 @@ $result = $messaging->createPush( sound: '<SOUND>', // optional color: '<COLOR>', // optional tag: '<TAG>', // optional - badge: '<BADGE>', // optional + badge: null, // optional draft: false, // optional - scheduledAt: '' // optional + scheduledAt: '', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority::NORMAL() // optional ); \ No newline at end of file diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 09a4d96..7546fc8 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -26,5 +26,8 @@ $result = $messaging->updatePush( tag: '<TAG>', // optional badge: null, // optional draft: false, // optional - scheduledAt: '' // optional + scheduledAt: '', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority::NORMAL() // optional ); \ No newline at end of file diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 727f3fb..a948546 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,7 +1,7 @@ <?php use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Services\Storage; $client = (new Client()) @@ -14,6 +14,6 @@ $storage = new Storage($client); $result = $storage->createFile( bucketId: '<BUCKET_ID>', fileId: '<FILE_ID>', - file: Payload::fromFile('file.png'), + file: InputFile::withPath('file.png'), permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index 3e09fe4..00b15ea 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -48,7 +48,7 @@ POST https://cloud.appwrite.io/v1/functions | templateOwner | string | The name of the owner of the template. | | | templateRootDirectory | string | Path to function code in the template repo. | | | templateVersion | string | Version (tag) for the repo linked to the function template. | | -| specification | string | Runtime specification for the function and builds. | s-0.5vcpu-512mb | +| specification | string | Runtime specification for the function and builds. | s-1vcpu-512mb | ## List runtimes @@ -110,7 +110,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | providerBranch | string | Production branch for the repo linked to the function | | | providerSilentMode | boolean | Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. | | | providerRootDirectory | string | Path to function code in the linked repo. | | -| specification | string | Runtime specification for the function and builds. | s-0.5vcpu-512mb | +| specification | string | Runtime specification for the function and builds. | s-1vcpu-512mb | ## Delete function @@ -280,7 +280,7 @@ POST https://cloud.appwrite.io/v1/functions/{functionId}/executions | Field Name | Type | Description | Default | | --- | --- | --- | --- | | functionId | string | **Required** Function ID. | | -| body | payload | HTTP body of execution. Default value is empty string. | | +| body | string | HTTP body of execution. Default value is empty string. | | | async | boolean | Execute code in the background. Default value is false. | | | path | string | HTTP path of execution. Path can include query params. Default value is / | / | | method | string | HTTP method of execution. Default value is GET. | POST | diff --git a/docs/messaging.md b/docs/messaging.md index f4fc48f..984c26b 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -84,16 +84,19 @@ POST https://cloud.appwrite.io/v1/messaging/messages/push | topics | array | List of Topic IDs. | [] | | users | array | List of User IDs. | [] | | targets | array | List of Targets IDs. | [] | -| data | object | Additional Data for push notification. | {} | +| data | object | Additional key-value pair data for push notification. | {} | | action | string | Action for push notification. | | | image | string | Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. | | | icon | string | Icon for push notification. Available only for Android and Web Platform. | | -| sound | string | Sound for push notification. Available only for Android and IOS Platform. | | +| sound | string | Sound for push notification. Available only for Android and iOS Platform. | | | color | string | Color for push notification. Available only for Android Platform. | | | tag | string | Tag for push notification. Available only for Android Platform. | | -| badge | string | Badge for push notification. Available only for IOS Platform. | | +| badge | integer | Badge for push notification. Available only for iOS Platform. | -1 | | draft | boolean | Is message a draft | | | scheduledAt | string | Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. | | +| contentAvailable | boolean | If set to true, the notification will be delivered in the background. Available only for iOS Platform. | | +| critical | boolean | If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. | | +| priority | string | Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. | high | ## Update push notification @@ -124,6 +127,9 @@ PATCH https://cloud.appwrite.io/v1/messaging/messages/push/{messageId} | badge | integer | Badge for push notification. Available only for iOS platforms. | | | draft | boolean | Is message a draft | | | scheduledAt | string | Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. | | +| contentAvailable | boolean | If set to true, the notification will be delivered in the background. Available only for iOS Platform. | | +| critical | boolean | If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. | | +| priority | string | Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. | | ## Create SMS diff --git a/docs/teams.md b/docs/teams.md index 0804aee..74301f1 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -80,7 +80,7 @@ DELETE https://cloud.appwrite.io/v1/teams/{teamId} GET https://cloud.appwrite.io/v1/teams/{teamId}/memberships ``` -** Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. ** +** Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. ** ### Parameters @@ -123,7 +123,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee GET https://cloud.appwrite.io/v1/teams/{teamId}/memberships/{membershipId} ``` -** Get a team member by the membership unique id. All team members have read access for this resource. ** +** Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. ** ### Parameters diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index c22921f..02421c7 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/12.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/12.2.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '12.0.0', + 'x-sdk-version'=> '12.2.0', ]; /** @@ -50,6 +50,7 @@ class Client public function __construct() { $this->headers['X-Appwrite-Response-Format'] = '1.6.0'; + } /** @@ -176,7 +177,7 @@ public function setEndpoint(string $endpoint): Client public function addHeader(string $key, string $value): Client { $this->headers[strtolower($key)] = $value; - + return $this; } @@ -210,7 +211,6 @@ public function call( break; case 'multipart/form-data': - $headers['accept'] = 'multipart/form-data'; $query = $this->flatten($params); break; @@ -262,23 +262,17 @@ public function call( echo 'Warning: ' . $warning . PHP_EOL; } } - + switch(substr($contentType, 0, strpos($contentType, ';'))) { case 'application/json': $responseBody = json_decode($responseBody, true); break; } - if (str_contains($contentType, 'multipart/form-data')) { - $matches = []; - preg_match('/(?<boundary>[-]+[\w]+)--/m', $responseBody, $matches); - if (isset($matches['boundary'])) { - $responseBody = self::handleFormData($matches['boundary'], $responseBody); - } - } + if (curl_errno($ch)) { throw new AppwriteException(curl_error($ch), $responseStatus, $responseBody['type'] ?? '', $responseBody); } - + curl_close($ch); if($responseStatus >= 400) { @@ -309,76 +303,14 @@ protected function flatten(array $data, string $prefix = ''): array { foreach($data as $key => $value) { $finalKey = $prefix ? "{$prefix}[{$key}]" : $key; - if ($value instanceof Payload) { - if ($value->filename) { - if (class_exists('\CURLStringFile')) { - // Use CURLStringFile for in-memory data (PHP 8.1+) - $output[$finalKey] = new \CURLStringFile( - $value->toBinary(), - $value->filename, - $value->mimeType - ); - } else { - // For PHP versions < 8.1, write data to a temporary file - $tmpfname = tempnam(sys_get_temp_dir(), 'upload'); - file_put_contents($tmpfname, $value->toBinary()); - $output[$finalKey] = new \CURLFile( - $tmpfname, - $value->mimeType, - $value->filename - ); - } - } else { - $output[$finalKey] = $value->toBinary(); - } - } else if (is_array($value)) { - $output += $this->flatten($value, $finalKey); - } else { + if (is_array($value)) { + $output += $this->flatten($value, $finalKey); // @todo: handle name collision here if needed + } + else { $output[$finalKey] = $value; } } return $output; } - - public static function handleFormData(string $boundary, mixed $responseBody) - { - $parts = explode($boundary, $responseBody); - $data = []; - foreach ($parts as $part) { - $lines = array_values(array_filter(explode("\r\n", $part))); - $matches = []; - $matched = preg_match('/name="?(?<name>\w+)/s', $part, $matches); - if ($matched) { - array_shift($lines); - if(isset($lines[0]) && $lines[0] === 'Content-Type: application/json'){ - array_shift($lines); - $json = json_decode(implode($lines), true); - - if (count($json) > 0 && isset($json[0]['name']) && isset($json[0]['value'])) { - $json = array_combine( - array_map(fn($header) => $header['name'], $json), - array_map(fn($header) => $header['value'], $json) - ); - } - - $data[$matches['name']] = $json; - continue; - } - $data[$matches['name']] = implode("\r\n",$lines) ?? '';; - } - } - - if(isset($data['responseStatusCode'])) { - $data['responseStatusCode'] = (int) ($data['responseStatusCode'] ?? ''); - } - if(isset($data['duration'])) { - $data['duration'] = ((float) ($data['duration'] ?? '')); - } - if(isset($data['responseBody'])) { - $data['responseBody'] = Payload::fromBinary($data['responseBody'] ?? ''); - } - - return $data; - } } diff --git a/src/Appwrite/Enums/MessagePriority.php b/src/Appwrite/Enums/MessagePriority.php new file mode 100644 index 0000000..e23d253 --- /dev/null +++ b/src/Appwrite/Enums/MessagePriority.php @@ -0,0 +1,43 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class MessagePriority implements JsonSerializable +{ + private static MessagePriority $NORMAL; + private static MessagePriority $HIGH; + + private string $value; + + private function __construct(string $value) + { + $this->value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function NORMAL(): MessagePriority + { + if (!isset(self::$NORMAL)) { + self::$NORMAL = new MessagePriority('normal'); + } + return self::$NORMAL; + } + public static function HIGH(): MessagePriority + { + if (!isset(self::$HIGH)) { + self::$HIGH = new MessagePriority('high'); + } + return self::$HIGH; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php index 3eefca5..d5da338 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -12,6 +12,7 @@ class Runtime implements JsonSerializable private static Runtime $NODE190; private static Runtime $NODE200; private static Runtime $NODE210; + private static Runtime $NODE22; private static Runtime $PHP80; private static Runtime $PHP81; private static Runtime $PHP82; @@ -30,6 +31,8 @@ class Runtime implements JsonSerializable private static Runtime $DENO124; private static Runtime $DENO135; private static Runtime $DENO140; + private static Runtime $DENO146; + private static Runtime $DENO20; private static Runtime $DART215; private static Runtime $DART216; private static Runtime $DART217; @@ -37,24 +40,31 @@ class Runtime implements JsonSerializable private static Runtime $DART30; private static Runtime $DART31; private static Runtime $DART33; - private static Runtime $DOTNET31; + private static Runtime $DART35; private static Runtime $DOTNET60; private static Runtime $DOTNET70; + private static Runtime $DOTNET80; private static Runtime $JAVA80; private static Runtime $JAVA110; private static Runtime $JAVA170; private static Runtime $JAVA180; private static Runtime $JAVA210; + private static Runtime $JAVA22; private static Runtime $SWIFT55; private static Runtime $SWIFT58; private static Runtime $SWIFT59; + private static Runtime $SWIFT510; private static Runtime $KOTLIN16; private static Runtime $KOTLIN18; private static Runtime $KOTLIN19; + private static Runtime $KOTLIN20; private static Runtime $CPP17; private static Runtime $CPP20; private static Runtime $BUN10; + private static Runtime $BUN11; private static Runtime $GO123; + private static Runtime $STATIC1; + private static Runtime $FLUTTER324; private string $value; @@ -115,6 +125,13 @@ public static function NODE210(): Runtime } return self::$NODE210; } + public static function NODE22(): Runtime + { + if (!isset(self::$NODE22)) { + self::$NODE22 = new Runtime('node-22'); + } + return self::$NODE22; + } public static function PHP80(): Runtime { if (!isset(self::$PHP80)) { @@ -241,6 +258,20 @@ public static function DENO140(): Runtime } return self::$DENO140; } + public static function DENO146(): Runtime + { + if (!isset(self::$DENO146)) { + self::$DENO146 = new Runtime('deno-1.46'); + } + return self::$DENO146; + } + public static function DENO20(): Runtime + { + if (!isset(self::$DENO20)) { + self::$DENO20 = new Runtime('deno-2.0'); + } + return self::$DENO20; + } public static function DART215(): Runtime { if (!isset(self::$DART215)) { @@ -290,12 +321,12 @@ public static function DART33(): Runtime } return self::$DART33; } - public static function DOTNET31(): Runtime + public static function DART35(): Runtime { - if (!isset(self::$DOTNET31)) { - self::$DOTNET31 = new Runtime('dotnet-3.1'); + if (!isset(self::$DART35)) { + self::$DART35 = new Runtime('dart-3.5'); } - return self::$DOTNET31; + return self::$DART35; } public static function DOTNET60(): Runtime { @@ -311,6 +342,13 @@ public static function DOTNET70(): Runtime } return self::$DOTNET70; } + public static function DOTNET80(): Runtime + { + if (!isset(self::$DOTNET80)) { + self::$DOTNET80 = new Runtime('dotnet-8.0'); + } + return self::$DOTNET80; + } public static function JAVA80(): Runtime { if (!isset(self::$JAVA80)) { @@ -346,6 +384,13 @@ public static function JAVA210(): Runtime } return self::$JAVA210; } + public static function JAVA22(): Runtime + { + if (!isset(self::$JAVA22)) { + self::$JAVA22 = new Runtime('java-22'); + } + return self::$JAVA22; + } public static function SWIFT55(): Runtime { if (!isset(self::$SWIFT55)) { @@ -367,6 +412,13 @@ public static function SWIFT59(): Runtime } return self::$SWIFT59; } + public static function SWIFT510(): Runtime + { + if (!isset(self::$SWIFT510)) { + self::$SWIFT510 = new Runtime('swift-5.10'); + } + return self::$SWIFT510; + } public static function KOTLIN16(): Runtime { if (!isset(self::$KOTLIN16)) { @@ -388,6 +440,13 @@ public static function KOTLIN19(): Runtime } return self::$KOTLIN19; } + public static function KOTLIN20(): Runtime + { + if (!isset(self::$KOTLIN20)) { + self::$KOTLIN20 = new Runtime('kotlin-2.0'); + } + return self::$KOTLIN20; + } public static function CPP17(): Runtime { if (!isset(self::$CPP17)) { @@ -409,6 +468,13 @@ public static function BUN10(): Runtime } return self::$BUN10; } + public static function BUN11(): Runtime + { + if (!isset(self::$BUN11)) { + self::$BUN11 = new Runtime('bun-1.1'); + } + return self::$BUN11; + } public static function GO123(): Runtime { if (!isset(self::$GO123)) { @@ -416,4 +482,18 @@ public static function GO123(): Runtime } return self::$GO123; } + public static function STATIC1(): Runtime + { + if (!isset(self::$STATIC1)) { + self::$STATIC1 = new Runtime('static-1'); + } + return self::$STATIC1; + } + public static function FLUTTER324(): Runtime + { + if (!isset(self::$FLUTTER324)) { + self::$FLUTTER324 = new Runtime('flutter-3.24'); + } + return self::$FLUTTER324; + } } \ No newline at end of file diff --git a/src/Appwrite/InputFile.php b/src/Appwrite/InputFile.php new file mode 100644 index 0000000..c8a0de7 --- /dev/null +++ b/src/Appwrite/InputFile.php @@ -0,0 +1,51 @@ +<?php +namespace Appwrite; + +class InputFile { + private ?string $data; + private ?string $mimeType; + private ?string $filename; + private ?string $path; + + public function __construct(){} + + public function getData(): ?string + { + return $this->data; + } + + public function getPath(): ?string + { + return $this->path; + } + + public function getMimeType(): ?string + { + return $this->mimeType; + } + + public function getFilename(): ?string + { + return $this->filename; + } + + public static function withPath(string $path, ?string $mimeType = null, ?string $filename = null): InputFile + { + $instance = new InputFile(); + $instance->path = $path; + $instance->data = null; + $instance->mimeType = $mimeType; + $instance->filename = $filename; + return $instance; + } + + public static function withData(string $data, ?string $mimeType = null, ?string $filename = null): InputFile + { + $instance = new InputFile(); + $instance->path = null; + $instance->data = $data; + $instance->mimeType = $mimeType; + $instance->filename = $filename; + return $instance; + } +} \ No newline at end of file diff --git a/src/Appwrite/Payload.php b/src/Appwrite/Payload.php deleted file mode 100644 index 3b144a4..0000000 --- a/src/Appwrite/Payload.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -namespace Appwrite; - -class Payload { - private ?string $data; - private ?string $path; - - public function __construct( - public int $size = 0, - public ?string $filename = null, - public ?string $mimeType = null - ) - { - } - - public static function fromFile(string $path, ?string $filename = null): self - { - if (!file_exists($path)) { - throw new \Exception('File not found at path: ' . $path); - } - if ($filename === null) { - $filename = basename($path); - } - $mimeType = mime_content_type($path); - $instance = new Payload(filesize($path), $filename, $mimeType); - $instance->path = $path; - $instance->data = null; - return $instance; - } - - public static function fromBinary(string $data, ?string $filename = null, ?string $mimeType = null): self - { - $instance = new Payload(strlen($data), $filename, $mimeType); - $instance->path = null; - $instance->data = $data; - return $instance; - } - - public static function fromJson(array $data): self - { - $data = json_encode($data); - return self::fromString($data); - } - - public static function fromString(string $data): self - { - return self::fromBinary($data); - } - - public function toBinary(?int $offset = 0, ?int $length = null): string - { - $length = $length ?? ($this->size - $offset); - if ($this->data) { - return substr($this->data, $offset, $length); - } else { - return file_get_contents($this->path, false, null, $offset, $length); - } - } - - public function toJson(): mixed - { - return json_decode($this->data, true); - } - - public function toString(): string - { - return $this->data; - } - - public function toFile(string $path): void - { - file_put_contents($path, $this->data); - } -} diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 9c66ebe..5b350da 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\AuthenticatorType; use Appwrite\Enums\AuthenticationFactor; use Appwrite\Enums\OAuthProvider; @@ -44,7 +44,6 @@ public function get(): array $apiHeaders, $apiParams ); - } /** @@ -79,7 +78,7 @@ public function create(string $userId, string $email, string $password, ?string $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -91,7 +90,6 @@ public function create(string $userId, string $email, string $password, ?string $apiHeaders, $apiParams ); - } /** @@ -132,7 +130,6 @@ public function updateEmail(string $email, string $password): array $apiHeaders, $apiParams ); - } /** @@ -155,7 +152,7 @@ public function listIdentities(?array $queries = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -167,7 +164,6 @@ public function listIdentities(?array $queries = null): array $apiHeaders, $apiParams ); - } /** @@ -199,7 +195,6 @@ public function deleteIdentity(string $identityId): string $apiHeaders, $apiParams ); - } /** @@ -233,7 +228,6 @@ public function createJWT(): array $apiHeaders, $apiParams ); - } /** @@ -257,7 +251,7 @@ public function listLogs(?array $queries = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -269,7 +263,6 @@ public function listLogs(?array $queries = null): array $apiHeaders, $apiParams ); - } /** @@ -301,7 +294,6 @@ public function updateMFA(bool $mfa): array $apiHeaders, $apiParams ); - } /** @@ -336,7 +328,6 @@ public function createMfaAuthenticator(AuthenticatorType $type): array $apiHeaders, $apiParams ); - } /** @@ -372,7 +363,6 @@ public function updateMfaAuthenticator(AuthenticatorType $type, string $otp): ar $apiHeaders, $apiParams ); - } /** @@ -404,7 +394,6 @@ public function deleteMfaAuthenticator(AuthenticatorType $type): string $apiHeaders, $apiParams ); - } /** @@ -438,7 +427,6 @@ public function createMfaChallenge(AuthenticationFactor $factor): array $apiHeaders, $apiParams ); - } /** @@ -476,7 +464,6 @@ public function updateMfaChallenge(string $challengeId, string $otp): string $apiHeaders, $apiParams ); - } /** @@ -506,7 +493,6 @@ public function listMfaFactors(): array $apiHeaders, $apiParams ); - } /** @@ -539,7 +525,6 @@ public function getMfaRecoveryCodes(): array $apiHeaders, $apiParams ); - } /** @@ -573,7 +558,6 @@ public function createMfaRecoveryCodes(): array $apiHeaders, $apiParams ); - } /** @@ -606,7 +590,6 @@ public function updateMfaRecoveryCodes(): array $apiHeaders, $apiParams ); - } /** @@ -638,7 +621,6 @@ public function updateName(string $name): array $apiHeaders, $apiParams ); - } /** @@ -665,7 +647,7 @@ public function updatePassword(string $password, ?string $oldPassword = null): a $apiParams['password'] = $password; if (!is_null($oldPassword)) { - $apiParams['oldPassword'] = $oldPassword; + $apiParams['oldPassword'] = $oldPassword; } $apiHeaders = []; @@ -677,7 +659,6 @@ public function updatePassword(string $password, ?string $oldPassword = null): a $apiHeaders, $apiParams ); - } /** @@ -715,7 +696,6 @@ public function updatePhone(string $phone, string $password): array $apiHeaders, $apiParams ); - } /** @@ -745,7 +725,6 @@ public function getPrefs(): array $apiHeaders, $apiParams ); - } /** @@ -779,7 +758,6 @@ public function updatePrefs(array $prefs): array $apiHeaders, $apiParams ); - } /** @@ -820,7 +798,6 @@ public function createRecovery(string $email, string $url): array $apiHeaders, $apiParams ); - } /** @@ -865,7 +842,6 @@ public function updateRecovery(string $userId, string $secret, string $password) $apiHeaders, $apiParams ); - } /** @@ -896,7 +872,6 @@ public function listSessions(): array $apiHeaders, $apiParams ); - } /** @@ -927,7 +902,6 @@ public function deleteSessions(): string $apiHeaders, $apiParams ); - } /** @@ -963,7 +937,6 @@ public function createAnonymousSession(): array $apiHeaders, $apiParams ); - } /** @@ -1002,7 +975,6 @@ public function createEmailPasswordSession(string $email, string $password): arr $apiHeaders, $apiParams ); - } /** @@ -1038,7 +1010,6 @@ public function updateMagicURLSession(string $userId, string $secret): array $apiHeaders, $apiParams ); - } /** @@ -1074,7 +1045,6 @@ public function updatePhoneSession(string $userId, string $secret): array $apiHeaders, $apiParams ); - } /** @@ -1110,7 +1080,6 @@ public function createSession(string $userId, string $secret): array $apiHeaders, $apiParams ); - } /** @@ -1143,7 +1112,6 @@ public function getSession(string $sessionId): array $apiHeaders, $apiParams ); - } /** @@ -1177,7 +1145,6 @@ public function updateSession(string $sessionId): array $apiHeaders, $apiParams ); - } /** @@ -1213,7 +1180,6 @@ public function deleteSession(string $sessionId): string $apiHeaders, $apiParams ); - } /** @@ -1245,7 +1211,6 @@ public function updateStatus(): array $apiHeaders, $apiParams ); - } /** @@ -1281,7 +1246,7 @@ public function createEmailToken(string $userId, string $email, ?bool $phrase = $apiParams['email'] = $email; if (!is_null($phrase)) { - $apiParams['phrase'] = $phrase; + $apiParams['phrase'] = $phrase; } $apiHeaders = []; @@ -1293,7 +1258,6 @@ public function createEmailToken(string $userId, string $email, ?bool $phrase = $apiHeaders, $apiParams ); - } /** @@ -1307,9 +1271,7 @@ public function createEmailToken(string $userId, string $email, ?bool $phrase = * [POST * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) * endpoint to complete the login process. The link sent to the user's email - * address is valid for 1 hour. If you are on a mobile device you can leave - * the URL parameter empty, so that the login completion will be handled by - * your Appwrite instance by default. + * address is valid for 1 hour. * * A user is limited to 10 active sessions at a time by default. [Learn more * about session @@ -1336,11 +1298,11 @@ public function createMagicURLToken(string $userId, string $email, ?string $url $apiParams['email'] = $email; if (!is_null($url)) { - $apiParams['url'] = $url; + $apiParams['url'] = $url; } if (!is_null($phrase)) { - $apiParams['phrase'] = $phrase; + $apiParams['phrase'] = $phrase; } $apiHeaders = []; @@ -1352,7 +1314,6 @@ public function createMagicURLToken(string $userId, string $email, ?string $url $apiHeaders, $apiParams ); - } /** @@ -1392,15 +1353,15 @@ public function createOAuth2Token(OAuthProvider $provider, ?string $success = nu $apiParams['provider'] = $provider; if (!is_null($success)) { - $apiParams['success'] = $success; + $apiParams['success'] = $success; } if (!is_null($failure)) { - $apiParams['failure'] = $failure; + $apiParams['failure'] = $failure; } if (!is_null($scopes)) { - $apiParams['scopes'] = $scopes; + $apiParams['scopes'] = $scopes; } $apiHeaders = []; @@ -1412,7 +1373,6 @@ public function createOAuth2Token(OAuthProvider $provider, ?string $success = nu $apiHeaders, $apiParams, 'location' ); - } /** @@ -1455,7 +1415,6 @@ public function createPhoneToken(string $userId, string $phone): array $apiHeaders, $apiParams ); - } /** @@ -1501,7 +1460,6 @@ public function createVerification(string $url): array $apiHeaders, $apiParams ); - } /** @@ -1538,7 +1496,6 @@ public function updateVerification(string $userId, string $secret): array $apiHeaders, $apiParams ); - } /** @@ -1575,7 +1532,6 @@ public function createPhoneVerification(): array $apiHeaders, $apiParams ); - } /** @@ -1612,6 +1568,5 @@ public function updatePhoneVerification(string $userId, string $secret): array $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index 09e72f6..73052e5 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\Browser; use Appwrite\Enums\CreditCard; use Appwrite\Enums\Flag; @@ -50,15 +50,15 @@ public function getBrowser(Browser $code, ?int $width = null, ?int $height = nul $apiParams['code'] = $code; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } $apiHeaders = []; @@ -70,7 +70,6 @@ public function getBrowser(Browser $code, ?int $width = null, ?int $height = nul $apiHeaders, $apiParams ); - } /** @@ -105,15 +104,15 @@ public function getCreditCard(CreditCard $code, ?int $width = null, ?int $height $apiParams['code'] = $code; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } $apiHeaders = []; @@ -125,7 +124,6 @@ public function getCreditCard(CreditCard $code, ?int $width = null, ?int $height $apiHeaders, $apiParams ); - } /** @@ -160,7 +158,6 @@ public function getFavicon(string $url): string $apiHeaders, $apiParams ); - } /** @@ -196,15 +193,15 @@ public function getFlag(Flag $code, ?int $width = null, ?int $height = null, ?in $apiParams['code'] = $code; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } $apiHeaders = []; @@ -216,7 +213,6 @@ public function getFlag(Flag $code, ?int $width = null, ?int $height = null, ?in $apiHeaders, $apiParams ); - } /** @@ -252,11 +248,11 @@ public function getImage(string $url, ?int $width = null, ?int $height = null): $apiParams['url'] = $url; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } $apiHeaders = []; @@ -268,7 +264,6 @@ public function getImage(string $url, ?int $width = null, ?int $height = null): $apiHeaders, $apiParams ); - } /** @@ -309,19 +304,19 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig $apiParams = []; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($background)) { - $apiParams['background'] = $background; + $apiParams['background'] = $background; } $apiHeaders = []; @@ -333,7 +328,6 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig $apiHeaders, $apiParams ); - } /** @@ -362,15 +356,15 @@ public function getQR(string $text, ?int $size = null, ?int $margin = null, ?boo $apiParams['text'] = $text; if (!is_null($size)) { - $apiParams['size'] = $size; + $apiParams['size'] = $size; } if (!is_null($margin)) { - $apiParams['margin'] = $margin; + $apiParams['margin'] = $margin; } if (!is_null($download)) { - $apiParams['download'] = $download; + $apiParams['download'] = $download; } $apiHeaders = []; @@ -382,6 +376,5 @@ public function getQR(string $text, ?int $size = null, ?int $margin = null, ?boo $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index a2d4402..6eb85cf 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\RelationshipType; use Appwrite\Enums\RelationMutate; use Appwrite\Enums\IndexType; @@ -39,11 +39,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -55,7 +55,6 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); - } /** @@ -83,7 +82,7 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): $apiParams['name'] = $name; if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -95,7 +94,6 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): $apiHeaders, $apiParams ); - } /** @@ -128,7 +126,6 @@ public function get(string $databaseId): array $apiHeaders, $apiParams ); - } /** @@ -155,7 +152,7 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): $apiParams['name'] = $name; if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -167,7 +164,6 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): $apiHeaders, $apiParams ); - } /** @@ -200,7 +196,6 @@ public function delete(string $databaseId): string $apiHeaders, $apiParams ); - } /** @@ -227,11 +222,11 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str $apiParams['databaseId'] = $databaseId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -243,7 +238,6 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str $apiHeaders, $apiParams ); - } /** @@ -277,15 +271,15 @@ public function createCollection(string $databaseId, string $collectionId, strin $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($documentSecurity)) { - $apiParams['documentSecurity'] = $documentSecurity; + $apiParams['documentSecurity'] = $documentSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -297,7 +291,6 @@ public function createCollection(string $databaseId, string $collectionId, strin $apiHeaders, $apiParams ); - } /** @@ -332,7 +325,6 @@ public function getCollection(string $databaseId, string $collectionId): array $apiHeaders, $apiParams ); - } /** @@ -363,15 +355,15 @@ public function updateCollection(string $databaseId, string $collectionId, strin $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($documentSecurity)) { - $apiParams['documentSecurity'] = $documentSecurity; + $apiParams['documentSecurity'] = $documentSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -383,7 +375,6 @@ public function updateCollection(string $databaseId, string $collectionId, strin $apiHeaders, $apiParams ); - } /** @@ -418,7 +409,6 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders, $apiParams ); - } /** @@ -445,7 +435,7 @@ public function listAttributes(string $databaseId, string $collectionId, ?array $apiParams['collectionId'] = $collectionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -457,7 +447,6 @@ public function listAttributes(string $databaseId, string $collectionId, ?array $apiHeaders, $apiParams ); - } /** @@ -490,11 +479,11 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -506,7 +495,6 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); - } /** @@ -540,7 +528,7 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -552,7 +540,6 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); - } /** @@ -584,11 +571,11 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -600,7 +587,6 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId $apiHeaders, $apiParams ); - } /** @@ -634,7 +620,7 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -646,7 +632,6 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId $apiHeaders, $apiParams ); - } /** @@ -679,11 +664,11 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -695,7 +680,6 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); - } /** @@ -730,7 +714,7 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -742,7 +726,6 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); - } /** @@ -778,11 +761,11 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -794,7 +777,6 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st $apiHeaders, $apiParams ); - } /** @@ -831,7 +813,7 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -843,7 +825,6 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st $apiHeaders, $apiParams ); - } /** @@ -879,19 +860,19 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s $apiParams['required'] = $required; if (!is_null($min)) { - $apiParams['min'] = $min; + $apiParams['min'] = $min; } if (!is_null($max)) { - $apiParams['max'] = $max; + $apiParams['max'] = $max; } if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -903,7 +884,6 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); - } /** @@ -942,7 +922,7 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -954,7 +934,6 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s $apiHeaders, $apiParams ); - } /** @@ -990,19 +969,19 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, $apiParams['required'] = $required; if (!is_null($min)) { - $apiParams['min'] = $min; + $apiParams['min'] = $min; } if (!is_null($max)) { - $apiParams['max'] = $max; + $apiParams['max'] = $max; } if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -1014,7 +993,6 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); - } /** @@ -1053,7 +1031,7 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1065,7 +1043,6 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); - } /** @@ -1098,11 +1075,11 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -1114,7 +1091,6 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri $apiHeaders, $apiParams ); - } /** @@ -1149,7 +1125,7 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1161,7 +1137,6 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri $apiHeaders, $apiParams ); - } /** @@ -1197,19 +1172,19 @@ public function createRelationshipAttribute(string $databaseId, string $collecti $apiParams['type'] = $type; if (!is_null($twoWay)) { - $apiParams['twoWay'] = $twoWay; + $apiParams['twoWay'] = $twoWay; } if (!is_null($key)) { - $apiParams['key'] = $key; + $apiParams['key'] = $key; } if (!is_null($twoWayKey)) { - $apiParams['twoWayKey'] = $twoWayKey; + $apiParams['twoWayKey'] = $twoWayKey; } if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; + $apiParams['onDelete'] = $onDelete; } $apiHeaders = []; @@ -1221,7 +1196,6 @@ public function createRelationshipAttribute(string $databaseId, string $collecti $apiHeaders, $apiParams ); - } /** @@ -1257,15 +1231,15 @@ public function createStringAttribute(string $databaseId, string $collectionId, $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } if (!is_null($encrypt)) { - $apiParams['encrypt'] = $encrypt; + $apiParams['encrypt'] = $encrypt; } $apiHeaders = []; @@ -1277,7 +1251,6 @@ public function createStringAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); - } /** @@ -1313,11 +1286,11 @@ public function updateStringAttribute(string $databaseId, string $collectionId, $apiParams['default'] = $xdefault; if (!is_null($size)) { - $apiParams['size'] = $size; + $apiParams['size'] = $size; } if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1329,7 +1302,6 @@ public function updateStringAttribute(string $databaseId, string $collectionId, $apiHeaders, $apiParams ); - } /** @@ -1362,11 +1334,11 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str $apiParams['required'] = $required; if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; + $apiParams['default'] = $xdefault; } if (!is_null($xarray)) { - $apiParams['array'] = $xarray; + $apiParams['array'] = $xarray; } $apiHeaders = []; @@ -1378,7 +1350,6 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str $apiHeaders, $apiParams ); - } /** @@ -1413,7 +1384,7 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str $apiParams['default'] = $xdefault; if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1425,7 +1396,6 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str $apiHeaders, $apiParams ); - } /** @@ -1461,7 +1431,6 @@ public function getAttribute(string $databaseId, string $collectionId, string $k $apiHeaders, $apiParams ); - } /** @@ -1497,7 +1466,6 @@ public function deleteAttribute(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); - } /** @@ -1529,11 +1497,11 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti $apiParams['key'] = $key; if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; + $apiParams['onDelete'] = $onDelete; } if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; + $apiParams['newKey'] = $newKey; } $apiHeaders = []; @@ -1545,7 +1513,6 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti $apiHeaders, $apiParams ); - } /** @@ -1573,7 +1540,7 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ $apiParams['collectionId'] = $collectionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1585,7 +1552,6 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ $apiHeaders, $apiParams ); - } /** @@ -1619,7 +1585,7 @@ public function createDocument(string $databaseId, string $collectionId, string $apiParams['data'] = $data; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; @@ -1631,7 +1597,6 @@ public function createDocument(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); - } /** @@ -1661,7 +1626,7 @@ public function getDocument(string $databaseId, string $collectionId, string $do $apiParams['documentId'] = $documentId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1673,7 +1638,6 @@ public function getDocument(string $databaseId, string $collectionId, string $do $apiHeaders, $apiParams ); - } /** @@ -1704,11 +1668,11 @@ public function updateDocument(string $databaseId, string $collectionId, string $apiParams['documentId'] = $documentId; if (!is_null($data)) { - $apiParams['data'] = $data; + $apiParams['data'] = $data; } if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; @@ -1720,7 +1684,6 @@ public function updateDocument(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); - } /** @@ -1756,7 +1719,6 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders, $apiParams ); - } /** @@ -1783,7 +1745,7 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu $apiParams['collectionId'] = $collectionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1795,7 +1757,6 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu $apiHeaders, $apiParams ); - } /** @@ -1830,7 +1791,7 @@ public function createIndex(string $databaseId, string $collectionId, string $ke $apiParams['attributes'] = $attributes; if (!is_null($orders)) { - $apiParams['orders'] = $orders; + $apiParams['orders'] = $orders; } $apiHeaders = []; @@ -1842,7 +1803,6 @@ public function createIndex(string $databaseId, string $collectionId, string $ke $apiHeaders, $apiParams ); - } /** @@ -1878,7 +1838,6 @@ public function getIndex(string $databaseId, string $collectionId, string $key): $apiHeaders, $apiParams ); - } /** @@ -1914,6 +1873,5 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index ba87821..2e1d60f 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\Runtime; use Appwrite\Enums\ExecutionMethod; @@ -38,11 +38,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -54,7 +54,6 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); - } /** @@ -104,79 +103,79 @@ public function create(string $functionId, string $name, Runtime $runtime, ?arra $apiParams['runtime'] = $runtime; if (!is_null($execute)) { - $apiParams['execute'] = $execute; + $apiParams['execute'] = $execute; } if (!is_null($events)) { - $apiParams['events'] = $events; + $apiParams['events'] = $events; } if (!is_null($schedule)) { - $apiParams['schedule'] = $schedule; + $apiParams['schedule'] = $schedule; } if (!is_null($timeout)) { - $apiParams['timeout'] = $timeout; + $apiParams['timeout'] = $timeout; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($logging)) { - $apiParams['logging'] = $logging; + $apiParams['logging'] = $logging; } if (!is_null($entrypoint)) { - $apiParams['entrypoint'] = $entrypoint; + $apiParams['entrypoint'] = $entrypoint; } if (!is_null($commands)) { - $apiParams['commands'] = $commands; + $apiParams['commands'] = $commands; } if (!is_null($scopes)) { - $apiParams['scopes'] = $scopes; + $apiParams['scopes'] = $scopes; } if (!is_null($installationId)) { - $apiParams['installationId'] = $installationId; + $apiParams['installationId'] = $installationId; } if (!is_null($providerRepositoryId)) { - $apiParams['providerRepositoryId'] = $providerRepositoryId; + $apiParams['providerRepositoryId'] = $providerRepositoryId; } if (!is_null($providerBranch)) { - $apiParams['providerBranch'] = $providerBranch; + $apiParams['providerBranch'] = $providerBranch; } if (!is_null($providerSilentMode)) { - $apiParams['providerSilentMode'] = $providerSilentMode; + $apiParams['providerSilentMode'] = $providerSilentMode; } if (!is_null($providerRootDirectory)) { - $apiParams['providerRootDirectory'] = $providerRootDirectory; + $apiParams['providerRootDirectory'] = $providerRootDirectory; } if (!is_null($templateRepository)) { - $apiParams['templateRepository'] = $templateRepository; + $apiParams['templateRepository'] = $templateRepository; } if (!is_null($templateOwner)) { - $apiParams['templateOwner'] = $templateOwner; + $apiParams['templateOwner'] = $templateOwner; } if (!is_null($templateRootDirectory)) { - $apiParams['templateRootDirectory'] = $templateRootDirectory; + $apiParams['templateRootDirectory'] = $templateRootDirectory; } if (!is_null($templateVersion)) { - $apiParams['templateVersion'] = $templateVersion; + $apiParams['templateVersion'] = $templateVersion; } if (!is_null($specification)) { - $apiParams['specification'] = $specification; + $apiParams['specification'] = $specification; } $apiHeaders = []; @@ -188,7 +187,6 @@ public function create(string $functionId, string $name, Runtime $runtime, ?arra $apiHeaders, $apiParams ); - } /** @@ -218,7 +216,6 @@ public function listRuntimes(): array $apiHeaders, $apiParams ); - } /** @@ -249,7 +246,6 @@ public function listSpecifications(): array $apiHeaders, $apiParams ); - } /** @@ -281,7 +277,6 @@ public function get(string $functionId): array $apiHeaders, $apiParams ); - } /** @@ -323,64 +318,64 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul $apiParams['name'] = $name; if (!is_null($runtime)) { - $apiParams['runtime'] = $runtime; + $apiParams['runtime'] = $runtime; } if (!is_null($execute)) { - $apiParams['execute'] = $execute; + $apiParams['execute'] = $execute; } if (!is_null($events)) { - $apiParams['events'] = $events; + $apiParams['events'] = $events; } if (!is_null($schedule)) { - $apiParams['schedule'] = $schedule; + $apiParams['schedule'] = $schedule; } if (!is_null($timeout)) { - $apiParams['timeout'] = $timeout; + $apiParams['timeout'] = $timeout; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($logging)) { - $apiParams['logging'] = $logging; + $apiParams['logging'] = $logging; } if (!is_null($entrypoint)) { - $apiParams['entrypoint'] = $entrypoint; + $apiParams['entrypoint'] = $entrypoint; } if (!is_null($commands)) { - $apiParams['commands'] = $commands; + $apiParams['commands'] = $commands; } if (!is_null($scopes)) { - $apiParams['scopes'] = $scopes; + $apiParams['scopes'] = $scopes; } if (!is_null($installationId)) { - $apiParams['installationId'] = $installationId; + $apiParams['installationId'] = $installationId; } $apiParams['providerRepositoryId'] = $providerRepositoryId; if (!is_null($providerBranch)) { - $apiParams['providerBranch'] = $providerBranch; + $apiParams['providerBranch'] = $providerBranch; } if (!is_null($providerSilentMode)) { - $apiParams['providerSilentMode'] = $providerSilentMode; + $apiParams['providerSilentMode'] = $providerSilentMode; } if (!is_null($providerRootDirectory)) { - $apiParams['providerRootDirectory'] = $providerRootDirectory; + $apiParams['providerRootDirectory'] = $providerRootDirectory; } if (!is_null($specification)) { - $apiParams['specification'] = $specification; + $apiParams['specification'] = $specification; } $apiHeaders = []; @@ -392,7 +387,6 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul $apiHeaders, $apiParams ); - } /** @@ -424,7 +418,6 @@ public function delete(string $functionId): string $apiHeaders, $apiParams ); - } /** @@ -451,11 +444,11 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str $apiParams['functionId'] = $functionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -467,7 +460,6 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str $apiHeaders, $apiParams ); - } /** @@ -485,14 +477,14 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str * Use the "command" param to set the entrypoint used to execute your code. * * @param string $functionId - * @param Payload $code + * @param InputFile $code * @param bool $activate * @param ?string $entrypoint * @param ?string $commands * @throws AppwriteException * @return array */ - public function createDeployment(string $functionId, Payload $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, callable $onProgress = null): array + public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, callable $onProgress = null): array { $apiPath = str_replace( ['{functionId}'], @@ -506,21 +498,39 @@ public function createDeployment(string $functionId, Payload $code, bool $activa $apiParams['activate'] = $activate; if (!is_null($entrypoint)) { - $apiParams['entrypoint'] = $entrypoint; + $apiParams['entrypoint'] = $entrypoint; } if (!is_null($commands)) { - $apiParams['commands'] = $commands; + $apiParams['commands'] = $commands; } $apiHeaders = []; $apiHeaders['content-type'] = 'multipart/form-data'; - $size = $code->size; - - if ($size <= Client::CHUNK_SIZE) { - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'multipart/form-data', - ], $apiParams); + $size = 0; + $mimeType = null; + $postedName = null; + if(empty($code->getPath() ?? null)) { + $size = strlen($code->getData()); + $mimeType = $code->getMimeType(); + $postedName = $code->getFilename(); + if ($size <= Client::CHUNK_SIZE) { + $apiParams['code'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($code->getData()), $mimeType, $postedName); + return $this->client->call(Client::METHOD_POST, $apiPath, [ + 'content-type' => 'multipart/form-data', + ], $apiParams); + } + } else { + $size = filesize($code->getPath()); + $mimeType = $code->getMimeType() ?? mime_content_type($code->getPath()); + $postedName = $code->getFilename() ?? basename($code->getPath()); + //send single file if size is less than or equal to 5MB + if ($size <= Client::CHUNK_SIZE) { + $apiParams['code'] = new \CURLFile($code->getPath(), $mimeType, $postedName); + return $this->client->call(Client::METHOD_POST, $apiPath, [ + 'content-type' => 'multipart/form-data', + ], $apiParams); + } } $id = ''; @@ -528,16 +538,22 @@ public function createDeployment(string $functionId, Payload $code, bool $activa $apiHeaders = ['content-type' => 'multipart/form-data']; + $handle = null; + + if(!empty($code->getPath())) { + $handle = @fopen($code->getPath(), "rb"); + } $start = $counter * Client::CHUNK_SIZE; while ($start < $size) { - - $apiParams['code'] = Payload::fromBinary( - $code->toBinary($start, Client::CHUNK_SIZE), - $code->filename, - $code->mimeType - ); - + $chunk = ''; + if(!empty($handle)) { + fseek($handle, $start); + $chunk = @fread($handle, Client::CHUNK_SIZE); + } else { + $chunk = substr($file->getData(), $start, Client::CHUNK_SIZE); + } + $apiParams['code'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($chunk), $mimeType, $postedName); $apiHeaders['content-range'] = 'bytes ' . ($counter * Client::CHUNK_SIZE) . '-' . min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE) - 1), $size - 1) . '/' . $size; if(!empty($id)) { $apiHeaders['x-appwrite-id'] = $id; @@ -554,10 +570,13 @@ public function createDeployment(string $functionId, Payload $code, bool $activa 'progress' => min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE)), $size) / $size * 100, 'sizeUploaded' => min($counter * Client::CHUNK_SIZE), 'chunksTotal' => $response['chunksTotal'], - 'chunksUploaded' => $response['chunksUploaded'], + 'chunksUploaded' => $response['chunksUploaded'], ]); } } + if(!empty($handle)) { + @fclose($handle); + } return $response; } @@ -593,7 +612,6 @@ public function getDeployment(string $functionId, string $deploymentId): array $apiHeaders, $apiParams ); - } /** @@ -629,7 +647,6 @@ public function updateDeployment(string $functionId, string $deploymentId): arra $apiHeaders, $apiParams ); - } /** @@ -663,7 +680,6 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri $apiHeaders, $apiParams ); - } /** @@ -688,7 +704,7 @@ public function createBuild(string $functionId, string $deploymentId, ?string $b $apiParams['deploymentId'] = $deploymentId; if (!is_null($buildId)) { - $apiParams['buildId'] = $buildId; + $apiParams['buildId'] = $buildId; } $apiHeaders = []; @@ -700,7 +716,6 @@ public function createBuild(string $functionId, string $deploymentId, ?string $b $apiHeaders, $apiParams ); - } /** @@ -732,7 +747,6 @@ public function updateDeploymentBuild(string $functionId, string $deploymentId): $apiHeaders, $apiParams ); - } /** @@ -767,7 +781,6 @@ public function getDeploymentDownload(string $functionId, string $deploymentId): $apiHeaders, $apiParams ); - } /** @@ -794,11 +807,11 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri $apiParams['functionId'] = $functionId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -810,7 +823,6 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri $apiHeaders, $apiParams ); - } /** @@ -822,7 +834,7 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri * function execution process will start asynchronously. * * @param string $functionId - * @param ?Payload $body + * @param ?string $body * @param ?bool $async * @param ?string $xpath * @param ?ExecutionMethod $method @@ -831,7 +843,7 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri * @throws AppwriteException * @return array */ - public function createExecution(string $functionId, ?Payload $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null, callable $onProgress = null): array + public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): array { $apiPath = str_replace( ['{functionId}'], @@ -843,31 +855,31 @@ public function createExecution(string $functionId, ?Payload $body = null, ?bool $apiParams['functionId'] = $functionId; if (!is_null($body)) { - $apiParams['body'] = $body; + $apiParams['body'] = $body; } if (!is_null($async)) { - $apiParams['async'] = $async; + $apiParams['async'] = $async; } if (!is_null($xpath)) { - $apiParams['path'] = $xpath; + $apiParams['path'] = $xpath; } if (!is_null($method)) { - $apiParams['method'] = $method; + $apiParams['method'] = $method; } if (!is_null($headers)) { - $apiParams['headers'] = $headers; + $apiParams['headers'] = $headers; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; - $apiHeaders['content-type'] = 'multipart/form-data'; + $apiHeaders['content-type'] = 'application/json'; return $this->client->call( Client::METHOD_POST, @@ -875,7 +887,6 @@ public function createExecution(string $functionId, ?Payload $body = null, ?bool $apiHeaders, $apiParams ); - } /** @@ -909,7 +920,6 @@ public function getExecution(string $functionId, string $executionId): array $apiHeaders, $apiParams ); - } /** @@ -944,7 +954,6 @@ public function deleteExecution(string $functionId, string $executionId): string $apiHeaders, $apiParams ); - } /** @@ -976,7 +985,6 @@ public function listVariables(string $functionId): array $apiHeaders, $apiParams ); - } /** @@ -1013,7 +1021,6 @@ public function createVariable(string $functionId, string $key, string $value): $apiHeaders, $apiParams ); - } /** @@ -1047,7 +1054,6 @@ public function getVariable(string $functionId, string $variableId): array $apiHeaders, $apiParams ); - } /** @@ -1076,7 +1082,7 @@ public function updateVariable(string $functionId, string $variableId, string $k $apiParams['key'] = $key; if (!is_null($value)) { - $apiParams['value'] = $value; + $apiParams['value'] = $value; } $apiHeaders = []; @@ -1088,7 +1094,6 @@ public function updateVariable(string $functionId, string $variableId, string $k $apiHeaders, $apiParams ); - } /** @@ -1122,6 +1127,5 @@ public function deleteVariable(string $functionId, string $variableId): string $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Graphql.php b/src/Appwrite/Services/Graphql.php index f7bbf46..fcb161c 100644 --- a/src/Appwrite/Services/Graphql.php +++ b/src/Appwrite/Services/Graphql.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; class Graphql extends Service { @@ -44,7 +44,6 @@ public function query(array $query): array $apiHeaders, $apiParams ); - } /** @@ -77,6 +76,5 @@ public function mutation(array $query): array $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index 69221c9..7ac5942 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\Name; class Health extends Service @@ -42,7 +42,6 @@ public function get(): array $apiHeaders, $apiParams ); - } /** @@ -72,7 +71,6 @@ public function getAntivirus(): array $apiHeaders, $apiParams ); - } /** @@ -103,7 +101,6 @@ public function getCache(): array $apiHeaders, $apiParams ); - } /** @@ -126,7 +123,7 @@ public function getCertificate(?string $domain = null): array $apiParams = []; if (!is_null($domain)) { - $apiParams['domain'] = $domain; + $apiParams['domain'] = $domain; } $apiHeaders = []; @@ -138,7 +135,6 @@ public function getCertificate(?string $domain = null): array $apiHeaders, $apiParams ); - } /** @@ -168,7 +164,6 @@ public function getDB(): array $apiHeaders, $apiParams ); - } /** @@ -198,7 +193,6 @@ public function getPubSub(): array $apiHeaders, $apiParams ); - } /** @@ -229,7 +223,6 @@ public function getQueue(): array $apiHeaders, $apiParams ); - } /** @@ -253,7 +246,7 @@ public function getQueueBuilds(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -265,7 +258,6 @@ public function getQueueBuilds(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -290,7 +282,7 @@ public function getQueueCertificates(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -302,7 +294,6 @@ public function getQueueCertificates(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -327,11 +318,11 @@ public function getQueueDatabases(?string $name = null, ?int $threshold = null): $apiParams = []; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -343,7 +334,6 @@ public function getQueueDatabases(?string $name = null, ?int $threshold = null): $apiHeaders, $apiParams ); - } /** @@ -367,7 +357,7 @@ public function getQueueDeletes(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -379,7 +369,6 @@ public function getQueueDeletes(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -405,7 +394,7 @@ public function getFailedJobs(Name $name, ?int $threshold = null): array $apiParams['name'] = $name; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -417,7 +406,6 @@ public function getFailedJobs(Name $name, ?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -441,7 +429,7 @@ public function getQueueFunctions(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -453,7 +441,6 @@ public function getQueueFunctions(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -477,7 +464,7 @@ public function getQueueLogs(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -489,7 +476,6 @@ public function getQueueLogs(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -513,7 +499,7 @@ public function getQueueMails(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -525,7 +511,6 @@ public function getQueueMails(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -549,7 +534,7 @@ public function getQueueMessaging(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -561,7 +546,6 @@ public function getQueueMessaging(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -585,7 +569,7 @@ public function getQueueMigrations(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -597,7 +581,6 @@ public function getQueueMigrations(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -621,7 +604,7 @@ public function getQueueUsage(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -633,7 +616,6 @@ public function getQueueUsage(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -657,7 +639,7 @@ public function getQueueUsageDump(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -669,7 +651,6 @@ public function getQueueUsageDump(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -693,7 +674,7 @@ public function getQueueWebhooks(?int $threshold = null): array $apiParams = []; if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; + $apiParams['threshold'] = $threshold; } $apiHeaders = []; @@ -705,7 +686,6 @@ public function getQueueWebhooks(?int $threshold = null): array $apiHeaders, $apiParams ); - } /** @@ -735,7 +715,6 @@ public function getStorage(): array $apiHeaders, $apiParams ); - } /** @@ -765,7 +744,6 @@ public function getStorageLocal(): array $apiHeaders, $apiParams ); - } /** @@ -801,6 +779,5 @@ public function getTime(): array $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Locale.php b/src/Appwrite/Services/Locale.php index 3249afa..8f20ebc 100644 --- a/src/Appwrite/Services/Locale.php +++ b/src/Appwrite/Services/Locale.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; class Locale extends Service { @@ -46,7 +46,6 @@ public function get(): array $apiHeaders, $apiParams ); - } /** @@ -77,7 +76,6 @@ public function listCodes(): array $apiHeaders, $apiParams ); - } /** @@ -108,7 +106,6 @@ public function listContinents(): array $apiHeaders, $apiParams ); - } /** @@ -139,7 +136,6 @@ public function listCountries(): array $apiHeaders, $apiParams ); - } /** @@ -170,7 +166,6 @@ public function listCountriesEU(): array $apiHeaders, $apiParams ); - } /** @@ -201,7 +196,6 @@ public function listCountriesPhones(): array $apiHeaders, $apiParams ); - } /** @@ -233,7 +227,6 @@ public function listCurrencies(): array $apiHeaders, $apiParams ); - } /** @@ -264,6 +257,5 @@ public function listLanguages(): array $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 824f339..cf90e70 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -5,7 +5,8 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; +use Appwrite\Enums\MessagePriority; use Appwrite\Enums\SmtpEncryption; class Messaging extends Service @@ -36,11 +37,11 @@ public function listMessages(?array $queries = null, ?string $search = null): ar $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -52,7 +53,6 @@ public function listMessages(?array $queries = null, ?string $search = null): ar $apiHeaders, $apiParams ); - } /** @@ -89,39 +89,39 @@ public function createEmail(string $messageId, string $subject, string $content, $apiParams['content'] = $content; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($cc)) { - $apiParams['cc'] = $cc; + $apiParams['cc'] = $cc; } if (!is_null($bcc)) { - $apiParams['bcc'] = $bcc; + $apiParams['bcc'] = $bcc; } if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; + $apiParams['attachments'] = $attachments; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($html)) { - $apiParams['html'] = $html; + $apiParams['html'] = $html; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -133,7 +133,6 @@ public function createEmail(string $messageId, string $subject, string $content, $apiHeaders, $apiParams ); - } /** @@ -169,47 +168,47 @@ public function updateEmail(string $messageId, ?array $topics = null, ?array $us $apiParams['messageId'] = $messageId; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($subject)) { - $apiParams['subject'] = $subject; + $apiParams['subject'] = $subject; } if (!is_null($content)) { - $apiParams['content'] = $content; + $apiParams['content'] = $content; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($html)) { - $apiParams['html'] = $html; + $apiParams['html'] = $html; } if (!is_null($cc)) { - $apiParams['cc'] = $cc; + $apiParams['cc'] = $cc; } if (!is_null($bcc)) { - $apiParams['bcc'] = $bcc; + $apiParams['bcc'] = $bcc; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; + $apiParams['attachments'] = $attachments; } $apiHeaders = []; @@ -221,7 +220,6 @@ public function updateEmail(string $messageId, ?array $topics = null, ?array $us $apiHeaders, $apiParams ); - } /** @@ -230,8 +228,8 @@ public function updateEmail(string $messageId, ?array $topics = null, ?array $us * Create a new push notification. * * @param string $messageId - * @param string $title - * @param string $body + * @param ?string $title + * @param ?string $body * @param ?array $topics * @param ?array $users * @param ?array $targets @@ -242,13 +240,16 @@ public function updateEmail(string $messageId, ?array $topics = null, ?array $us * @param ?string $sound * @param ?string $color * @param ?string $tag - * @param ?string $badge + * @param ?int $badge * @param ?bool $draft * @param ?string $scheduledAt + * @param ?bool $contentAvailable + * @param ?bool $critical + * @param ?MessagePriority $priority * @throws AppwriteException * @return array */ - public function createPush(string $messageId, string $title, string $body, ?array $topics = null, ?array $users = null, ?array $targets = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?string $badge = null, ?bool $draft = null, ?string $scheduledAt = null): array + public function createPush(string $messageId, ?string $title = null, ?string $body = null, ?array $topics = null, ?array $users = null, ?array $targets = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null, ?bool $contentAvailable = null, ?bool $critical = null, ?MessagePriority $priority = null): array { $apiPath = str_replace( [], @@ -258,59 +259,77 @@ public function createPush(string $messageId, string $title, string $body, ?arra $apiParams = []; $apiParams['messageId'] = $messageId; - $apiParams['title'] = $title; - $apiParams['body'] = $body; + + if (!is_null($title)) { + $apiParams['title'] = $title; + } + + if (!is_null($body)) { + $apiParams['body'] = $body; + } if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($data)) { - $apiParams['data'] = $data; + $apiParams['data'] = $data; } if (!is_null($action)) { - $apiParams['action'] = $action; + $apiParams['action'] = $action; } if (!is_null($image)) { - $apiParams['image'] = $image; + $apiParams['image'] = $image; } if (!is_null($icon)) { - $apiParams['icon'] = $icon; + $apiParams['icon'] = $icon; } if (!is_null($sound)) { - $apiParams['sound'] = $sound; + $apiParams['sound'] = $sound; } if (!is_null($color)) { - $apiParams['color'] = $color; + $apiParams['color'] = $color; } if (!is_null($tag)) { - $apiParams['tag'] = $tag; + $apiParams['tag'] = $tag; } if (!is_null($badge)) { - $apiParams['badge'] = $badge; + $apiParams['badge'] = $badge; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; + } + + if (!is_null($contentAvailable)) { + $apiParams['contentAvailable'] = $contentAvailable; + } + + if (!is_null($critical)) { + $apiParams['critical'] = $critical; + } + + if (!is_null($priority)) { + $apiParams['priority'] = $priority; } $apiHeaders = []; @@ -322,7 +341,6 @@ public function createPush(string $messageId, string $title, string $body, ?arra $apiHeaders, $apiParams ); - } /** @@ -347,10 +365,13 @@ public function createPush(string $messageId, string $title, string $body, ?arra * @param ?int $badge * @param ?bool $draft * @param ?string $scheduledAt + * @param ?bool $contentAvailable + * @param ?bool $critical + * @param ?MessagePriority $priority * @throws AppwriteException * @return array */ - public function updatePush(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $title = null, ?string $body = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null): array + public function updatePush(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $title = null, ?string $body = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null, ?bool $contentAvailable = null, ?bool $critical = null, ?MessagePriority $priority = null): array { $apiPath = str_replace( ['{messageId}'], @@ -362,63 +383,75 @@ public function updatePush(string $messageId, ?array $topics = null, ?array $use $apiParams['messageId'] = $messageId; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($title)) { - $apiParams['title'] = $title; + $apiParams['title'] = $title; } if (!is_null($body)) { - $apiParams['body'] = $body; + $apiParams['body'] = $body; } if (!is_null($data)) { - $apiParams['data'] = $data; + $apiParams['data'] = $data; } if (!is_null($action)) { - $apiParams['action'] = $action; + $apiParams['action'] = $action; } if (!is_null($image)) { - $apiParams['image'] = $image; + $apiParams['image'] = $image; } if (!is_null($icon)) { - $apiParams['icon'] = $icon; + $apiParams['icon'] = $icon; } if (!is_null($sound)) { - $apiParams['sound'] = $sound; + $apiParams['sound'] = $sound; } if (!is_null($color)) { - $apiParams['color'] = $color; + $apiParams['color'] = $color; } if (!is_null($tag)) { - $apiParams['tag'] = $tag; + $apiParams['tag'] = $tag; } if (!is_null($badge)) { - $apiParams['badge'] = $badge; + $apiParams['badge'] = $badge; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; + } + + if (!is_null($contentAvailable)) { + $apiParams['contentAvailable'] = $contentAvailable; + } + + if (!is_null($critical)) { + $apiParams['critical'] = $critical; + } + + if (!is_null($priority)) { + $apiParams['priority'] = $priority; } $apiHeaders = []; @@ -430,7 +463,6 @@ public function updatePush(string $messageId, ?array $topics = null, ?array $use $apiHeaders, $apiParams ); - } /** @@ -461,23 +493,23 @@ public function createSms(string $messageId, string $content, ?array $topics = n $apiParams['content'] = $content; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -489,7 +521,6 @@ public function createSms(string $messageId, string $content, ?array $topics = n $apiHeaders, $apiParams ); - } /** @@ -520,27 +551,27 @@ public function updateSms(string $messageId, ?array $topics = null, ?array $user $apiParams['messageId'] = $messageId; if (!is_null($topics)) { - $apiParams['topics'] = $topics; + $apiParams['topics'] = $topics; } if (!is_null($users)) { - $apiParams['users'] = $users; + $apiParams['users'] = $users; } if (!is_null($targets)) { - $apiParams['targets'] = $targets; + $apiParams['targets'] = $targets; } if (!is_null($content)) { - $apiParams['content'] = $content; + $apiParams['content'] = $content; } if (!is_null($draft)) { - $apiParams['draft'] = $draft; + $apiParams['draft'] = $draft; } if (!is_null($scheduledAt)) { - $apiParams['scheduledAt'] = $scheduledAt; + $apiParams['scheduledAt'] = $scheduledAt; } $apiHeaders = []; @@ -552,7 +583,6 @@ public function updateSms(string $messageId, ?array $topics = null, ?array $user $apiHeaders, $apiParams ); - } /** @@ -585,7 +615,6 @@ public function getMessage(string $messageId): array $apiHeaders, $apiParams ); - } /** @@ -618,7 +647,6 @@ public function delete(string $messageId): string $apiHeaders, $apiParams ); - } /** @@ -643,7 +671,7 @@ public function listMessageLogs(string $messageId, ?array $queries = null): arra $apiParams['messageId'] = $messageId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -655,7 +683,6 @@ public function listMessageLogs(string $messageId, ?array $queries = null): arra $apiHeaders, $apiParams ); - } /** @@ -680,7 +707,7 @@ public function listTargets(string $messageId, ?array $queries = null): array $apiParams['messageId'] = $messageId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -692,7 +719,6 @@ public function listTargets(string $messageId, ?array $queries = null): array $apiHeaders, $apiParams ); - } /** @@ -716,11 +742,11 @@ public function listProviders(?array $queries = null, ?string $search = null): a $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -732,7 +758,6 @@ public function listProviders(?array $queries = null, ?string $search = null): a $apiHeaders, $apiParams ); - } /** @@ -764,27 +789,27 @@ public function createApnsProvider(string $providerId, string $name, ?string $au $apiParams['name'] = $name; if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } if (!is_null($authKeyId)) { - $apiParams['authKeyId'] = $authKeyId; + $apiParams['authKeyId'] = $authKeyId; } if (!is_null($teamId)) { - $apiParams['teamId'] = $teamId; + $apiParams['teamId'] = $teamId; } if (!is_null($bundleId)) { - $apiParams['bundleId'] = $bundleId; + $apiParams['bundleId'] = $bundleId; } if (!is_null($sandbox)) { - $apiParams['sandbox'] = $sandbox; + $apiParams['sandbox'] = $sandbox; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -796,7 +821,6 @@ public function createApnsProvider(string $providerId, string $name, ?string $au $apiHeaders, $apiParams ); - } /** @@ -827,31 +851,31 @@ public function updateApnsProvider(string $providerId, ?string $name = null, ?bo $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } if (!is_null($authKeyId)) { - $apiParams['authKeyId'] = $authKeyId; + $apiParams['authKeyId'] = $authKeyId; } if (!is_null($teamId)) { - $apiParams['teamId'] = $teamId; + $apiParams['teamId'] = $teamId; } if (!is_null($bundleId)) { - $apiParams['bundleId'] = $bundleId; + $apiParams['bundleId'] = $bundleId; } if (!is_null($sandbox)) { - $apiParams['sandbox'] = $sandbox; + $apiParams['sandbox'] = $sandbox; } $apiHeaders = []; @@ -863,7 +887,6 @@ public function updateApnsProvider(string $providerId, ?string $name = null, ?bo $apiHeaders, $apiParams ); - } /** @@ -891,11 +914,11 @@ public function createFcmProvider(string $providerId, string $name, ?array $serv $apiParams['name'] = $name; if (!is_null($serviceAccountJSON)) { - $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -907,7 +930,6 @@ public function createFcmProvider(string $providerId, string $name, ?array $serv $apiHeaders, $apiParams ); - } /** @@ -934,15 +956,15 @@ public function updateFcmProvider(string $providerId, ?string $name = null, ?boo $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($serviceAccountJSON)) { - $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; } $apiHeaders = []; @@ -954,7 +976,6 @@ public function updateFcmProvider(string $providerId, ?string $name = null, ?boo $apiHeaders, $apiParams ); - } /** @@ -988,35 +1009,35 @@ public function createMailgunProvider(string $providerId, string $name, ?string $apiParams['name'] = $name; if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($domain)) { - $apiParams['domain'] = $domain; + $apiParams['domain'] = $domain; } if (!is_null($isEuRegion)) { - $apiParams['isEuRegion'] = $isEuRegion; + $apiParams['isEuRegion'] = $isEuRegion; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1028,7 +1049,6 @@ public function createMailgunProvider(string $providerId, string $name, ?string $apiHeaders, $apiParams ); - } /** @@ -1061,39 +1081,39 @@ public function updateMailgunProvider(string $providerId, ?string $name = null, $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($domain)) { - $apiParams['domain'] = $domain; + $apiParams['domain'] = $domain; } if (!is_null($isEuRegion)) { - $apiParams['isEuRegion'] = $isEuRegion; + $apiParams['isEuRegion'] = $isEuRegion; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } $apiHeaders = []; @@ -1105,7 +1125,6 @@ public function updateMailgunProvider(string $providerId, ?string $name = null, $apiHeaders, $apiParams ); - } /** @@ -1135,19 +1154,19 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t $apiParams['name'] = $name; if (!is_null($templateId)) { - $apiParams['templateId'] = $templateId; + $apiParams['templateId'] = $templateId; } if (!is_null($senderId)) { - $apiParams['senderId'] = $senderId; + $apiParams['senderId'] = $senderId; } if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1159,7 +1178,6 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t $apiHeaders, $apiParams ); - } /** @@ -1188,23 +1206,23 @@ public function updateMsg91Provider(string $providerId, ?string $name = null, ?b $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($templateId)) { - $apiParams['templateId'] = $templateId; + $apiParams['templateId'] = $templateId; } if (!is_null($senderId)) { - $apiParams['senderId'] = $senderId; + $apiParams['senderId'] = $senderId; } if (!is_null($authKey)) { - $apiParams['authKey'] = $authKey; + $apiParams['authKey'] = $authKey; } $apiHeaders = []; @@ -1216,7 +1234,6 @@ public function updateMsg91Provider(string $providerId, ?string $name = null, ?b $apiHeaders, $apiParams ); - } /** @@ -1248,27 +1265,27 @@ public function createSendgridProvider(string $providerId, string $name, ?string $apiParams['name'] = $name; if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1280,7 +1297,6 @@ public function createSendgridProvider(string $providerId, string $name, ?string $apiHeaders, $apiParams ); - } /** @@ -1311,31 +1327,31 @@ public function updateSendgridProvider(string $providerId, ?string $name = null, $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } $apiHeaders = []; @@ -1347,7 +1363,6 @@ public function updateSendgridProvider(string $providerId, ?string $name = null, $apiHeaders, $apiParams ); - } /** @@ -1386,47 +1401,47 @@ public function createSmtpProvider(string $providerId, string $name, string $hos $apiParams['host'] = $host; if (!is_null($port)) { - $apiParams['port'] = $port; + $apiParams['port'] = $port; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($password)) { - $apiParams['password'] = $password; + $apiParams['password'] = $password; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($autoTLS)) { - $apiParams['autoTLS'] = $autoTLS; + $apiParams['autoTLS'] = $autoTLS; } if (!is_null($mailer)) { - $apiParams['mailer'] = $mailer; + $apiParams['mailer'] = $mailer; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1438,7 +1453,6 @@ public function createSmtpProvider(string $providerId, string $name, string $hos $apiHeaders, $apiParams ); - } /** @@ -1475,55 +1489,55 @@ public function updateSmtpProvider(string $providerId, ?string $name = null, ?st $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($host)) { - $apiParams['host'] = $host; + $apiParams['host'] = $host; } if (!is_null($port)) { - $apiParams['port'] = $port; + $apiParams['port'] = $port; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($password)) { - $apiParams['password'] = $password; + $apiParams['password'] = $password; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($autoTLS)) { - $apiParams['autoTLS'] = $autoTLS; + $apiParams['autoTLS'] = $autoTLS; } if (!is_null($mailer)) { - $apiParams['mailer'] = $mailer; + $apiParams['mailer'] = $mailer; } if (!is_null($fromName)) { - $apiParams['fromName'] = $fromName; + $apiParams['fromName'] = $fromName; } if (!is_null($fromEmail)) { - $apiParams['fromEmail'] = $fromEmail; + $apiParams['fromEmail'] = $fromEmail; } if (!is_null($replyToName)) { - $apiParams['replyToName'] = $replyToName; + $apiParams['replyToName'] = $replyToName; } if (!is_null($replyToEmail)) { - $apiParams['replyToEmail'] = $replyToEmail; + $apiParams['replyToEmail'] = $replyToEmail; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1535,7 +1549,6 @@ public function updateSmtpProvider(string $providerId, ?string $name = null, ?st $apiHeaders, $apiParams ); - } /** @@ -1565,19 +1578,19 @@ public function createTelesignProvider(string $providerId, string $name, ?string $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($customerId)) { - $apiParams['customerId'] = $customerId; + $apiParams['customerId'] = $customerId; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1589,7 +1602,6 @@ public function createTelesignProvider(string $providerId, string $name, ?string $apiHeaders, $apiParams ); - } /** @@ -1618,23 +1630,23 @@ public function updateTelesignProvider(string $providerId, ?string $name = null, $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($customerId)) { - $apiParams['customerId'] = $customerId; + $apiParams['customerId'] = $customerId; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1646,7 +1658,6 @@ public function updateTelesignProvider(string $providerId, ?string $name = null, $apiHeaders, $apiParams ); - } /** @@ -1676,19 +1687,19 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1700,7 +1711,6 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin $apiHeaders, $apiParams ); - } /** @@ -1729,23 +1739,23 @@ public function updateTextmagicProvider(string $providerId, ?string $name = null $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($username)) { - $apiParams['username'] = $username; + $apiParams['username'] = $username; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1757,7 +1767,6 @@ public function updateTextmagicProvider(string $providerId, ?string $name = null $apiHeaders, $apiParams ); - } /** @@ -1787,19 +1796,19 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($accountSid)) { - $apiParams['accountSid'] = $accountSid; + $apiParams['accountSid'] = $accountSid; } if (!is_null($authToken)) { - $apiParams['authToken'] = $authToken; + $apiParams['authToken'] = $authToken; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1811,7 +1820,6 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ $apiHeaders, $apiParams ); - } /** @@ -1840,23 +1848,23 @@ public function updateTwilioProvider(string $providerId, ?string $name = null, ? $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($accountSid)) { - $apiParams['accountSid'] = $accountSid; + $apiParams['accountSid'] = $accountSid; } if (!is_null($authToken)) { - $apiParams['authToken'] = $authToken; + $apiParams['authToken'] = $authToken; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1868,7 +1876,6 @@ public function updateTwilioProvider(string $providerId, ?string $name = null, ? $apiHeaders, $apiParams ); - } /** @@ -1898,19 +1905,19 @@ public function createVonageProvider(string $providerId, string $name, ?string $ $apiParams['name'] = $name; if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($apiSecret)) { - $apiParams['apiSecret'] = $apiSecret; + $apiParams['apiSecret'] = $apiSecret; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } $apiHeaders = []; @@ -1922,7 +1929,6 @@ public function createVonageProvider(string $providerId, string $name, ?string $ $apiHeaders, $apiParams ); - } /** @@ -1951,23 +1957,23 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? $apiParams['providerId'] = $providerId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($apiKey)) { - $apiParams['apiKey'] = $apiKey; + $apiParams['apiKey'] = $apiKey; } if (!is_null($apiSecret)) { - $apiParams['apiSecret'] = $apiSecret; + $apiParams['apiSecret'] = $apiSecret; } if (!is_null($from)) { - $apiParams['from'] = $from; + $apiParams['from'] = $from; } $apiHeaders = []; @@ -1979,7 +1985,6 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? $apiHeaders, $apiParams ); - } /** @@ -2012,7 +2017,6 @@ public function getProvider(string $providerId): array $apiHeaders, $apiParams ); - } /** @@ -2044,7 +2048,6 @@ public function deleteProvider(string $providerId): string $apiHeaders, $apiParams ); - } /** @@ -2069,7 +2072,7 @@ public function listProviderLogs(string $providerId, ?array $queries = null): ar $apiParams['providerId'] = $providerId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -2081,7 +2084,6 @@ public function listProviderLogs(string $providerId, ?array $queries = null): ar $apiHeaders, $apiParams ); - } /** @@ -2106,7 +2108,7 @@ public function listSubscriberLogs(string $subscriberId, ?array $queries = null) $apiParams['subscriberId'] = $subscriberId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -2118,7 +2120,6 @@ public function listSubscriberLogs(string $subscriberId, ?array $queries = null) $apiHeaders, $apiParams ); - } /** @@ -2142,11 +2143,11 @@ public function listTopics(?array $queries = null, ?string $search = null): arra $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -2158,7 +2159,6 @@ public function listTopics(?array $queries = null, ?string $search = null): arra $apiHeaders, $apiParams ); - } /** @@ -2185,7 +2185,7 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n $apiParams['name'] = $name; if (!is_null($subscribe)) { - $apiParams['subscribe'] = $subscribe; + $apiParams['subscribe'] = $subscribe; } $apiHeaders = []; @@ -2197,7 +2197,6 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n $apiHeaders, $apiParams ); - } /** @@ -2230,7 +2229,6 @@ public function getTopic(string $topicId): array $apiHeaders, $apiParams ); - } /** @@ -2257,11 +2255,11 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc $apiParams['topicId'] = $topicId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($subscribe)) { - $apiParams['subscribe'] = $subscribe; + $apiParams['subscribe'] = $subscribe; } $apiHeaders = []; @@ -2273,7 +2271,6 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc $apiHeaders, $apiParams ); - } /** @@ -2305,7 +2302,6 @@ public function deleteTopic(string $topicId): string $apiHeaders, $apiParams ); - } /** @@ -2330,7 +2326,7 @@ public function listTopicLogs(string $topicId, ?array $queries = null): array $apiParams['topicId'] = $topicId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -2342,7 +2338,6 @@ public function listTopicLogs(string $topicId, ?array $queries = null): array $apiHeaders, $apiParams ); - } /** @@ -2368,11 +2363,11 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string $apiParams['topicId'] = $topicId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -2384,7 +2379,6 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string $apiHeaders, $apiParams ); - } /** @@ -2420,7 +2414,6 @@ public function createSubscriber(string $topicId, string $subscriberId, string $ $apiHeaders, $apiParams ); - } /** @@ -2455,7 +2448,6 @@ public function getSubscriber(string $topicId, string $subscriberId): array $apiHeaders, $apiParams ); - } /** @@ -2489,6 +2481,5 @@ public function deleteSubscriber(string $topicId, string $subscriberId): string $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index 47c9cc1..27d5a64 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\Compression; use Appwrite\Enums\ImageGravity; use Appwrite\Enums\ImageFormat; @@ -39,11 +39,11 @@ public function listBuckets(?array $queries = null, ?string $search = null): arr $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -55,7 +55,6 @@ public function listBuckets(?array $queries = null, ?string $search = null): arr $apiHeaders, $apiParams ); - } /** @@ -89,35 +88,35 @@ public function createBucket(string $bucketId, string $name, ?array $permissions $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($fileSecurity)) { - $apiParams['fileSecurity'] = $fileSecurity; + $apiParams['fileSecurity'] = $fileSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; + $apiParams['maximumFileSize'] = $maximumFileSize; } if (!is_null($allowedFileExtensions)) { - $apiParams['allowedFileExtensions'] = $allowedFileExtensions; + $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } if (!is_null($compression)) { - $apiParams['compression'] = $compression; + $apiParams['compression'] = $compression; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($antivirus)) { - $apiParams['antivirus'] = $antivirus; + $apiParams['antivirus'] = $antivirus; } $apiHeaders = []; @@ -129,7 +128,6 @@ public function createBucket(string $bucketId, string $name, ?array $permissions $apiHeaders, $apiParams ); - } /** @@ -162,7 +160,6 @@ public function getBucket(string $bucketId): array $apiHeaders, $apiParams ); - } /** @@ -196,35 +193,35 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions $apiParams['name'] = $name; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } if (!is_null($fileSecurity)) { - $apiParams['fileSecurity'] = $fileSecurity; + $apiParams['fileSecurity'] = $fileSecurity; } if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; + $apiParams['enabled'] = $enabled; } if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; + $apiParams['maximumFileSize'] = $maximumFileSize; } if (!is_null($allowedFileExtensions)) { - $apiParams['allowedFileExtensions'] = $allowedFileExtensions; + $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } if (!is_null($compression)) { - $apiParams['compression'] = $compression; + $apiParams['compression'] = $compression; } if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; + $apiParams['encryption'] = $encryption; } if (!is_null($antivirus)) { - $apiParams['antivirus'] = $antivirus; + $apiParams['antivirus'] = $antivirus; } $apiHeaders = []; @@ -236,7 +233,6 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions $apiHeaders, $apiParams ); - } /** @@ -268,7 +264,6 @@ public function deleteBucket(string $bucketId): string $apiHeaders, $apiParams ); - } /** @@ -295,11 +290,11 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea $apiParams['bucketId'] = $bucketId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -311,7 +306,6 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea $apiHeaders, $apiParams ); - } /** @@ -338,12 +332,12 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea * * @param string $bucketId * @param string $fileId - * @param Payload $file + * @param InputFile $file * @param ?array $permissions * @throws AppwriteException * @return array */ - public function createFile(string $bucketId, string $fileId, Payload $file, ?array $permissions = null, callable $onProgress = null): array + public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, callable $onProgress = null): array { $apiPath = str_replace( ['{bucketId}'], @@ -357,17 +351,35 @@ public function createFile(string $bucketId, string $fileId, Payload $file, ?arr $apiParams['file'] = $file; if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; $apiHeaders['content-type'] = 'multipart/form-data'; - $size = $file->size; - - if ($size <= Client::CHUNK_SIZE) { - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'multipart/form-data', - ], $apiParams); + $size = 0; + $mimeType = null; + $postedName = null; + if(empty($file->getPath() ?? null)) { + $size = strlen($file->getData()); + $mimeType = $file->getMimeType(); + $postedName = $file->getFilename(); + if ($size <= Client::CHUNK_SIZE) { + $apiParams['file'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($file->getData()), $mimeType, $postedName); + return $this->client->call(Client::METHOD_POST, $apiPath, [ + 'content-type' => 'multipart/form-data', + ], $apiParams); + } + } else { + $size = filesize($file->getPath()); + $mimeType = $file->getMimeType() ?? mime_content_type($file->getPath()); + $postedName = $file->getFilename() ?? basename($file->getPath()); + //send single file if size is less than or equal to 5MB + if ($size <= Client::CHUNK_SIZE) { + $apiParams['file'] = new \CURLFile($file->getPath(), $mimeType, $postedName); + return $this->client->call(Client::METHOD_POST, $apiPath, [ + 'content-type' => 'multipart/form-data', + ], $apiParams); + } } $id = ''; @@ -382,16 +394,22 @@ public function createFile(string $bucketId, string $fileId, Payload $file, ?arr } $apiHeaders = ['content-type' => 'multipart/form-data']; + $handle = null; + + if(!empty($file->getPath())) { + $handle = @fopen($file->getPath(), "rb"); + } $start = $counter * Client::CHUNK_SIZE; while ($start < $size) { - - $apiParams['file'] = Payload::fromBinary( - $file->toBinary($start, Client::CHUNK_SIZE), - $file->filename, - $file->mimeType - ); - + $chunk = ''; + if(!empty($handle)) { + fseek($handle, $start); + $chunk = @fread($handle, Client::CHUNK_SIZE); + } else { + $chunk = substr($file->getData(), $start, Client::CHUNK_SIZE); + } + $apiParams['file'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($chunk), $mimeType, $postedName); $apiHeaders['content-range'] = 'bytes ' . ($counter * Client::CHUNK_SIZE) . '-' . min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE) - 1), $size - 1) . '/' . $size; if(!empty($id)) { $apiHeaders['x-appwrite-id'] = $id; @@ -408,10 +426,13 @@ public function createFile(string $bucketId, string $fileId, Payload $file, ?arr 'progress' => min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE)), $size) / $size * 100, 'sizeUploaded' => min($counter * Client::CHUNK_SIZE), 'chunksTotal' => $response['chunksTotal'], - 'chunksUploaded' => $response['chunksUploaded'], + 'chunksUploaded' => $response['chunksUploaded'], ]); } } + if(!empty($handle)) { + @fclose($handle); + } return $response; } @@ -448,7 +469,6 @@ public function getFile(string $bucketId, string $fileId): array $apiHeaders, $apiParams ); - } /** @@ -477,11 +497,11 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul $apiParams['fileId'] = $fileId; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; + $apiParams['permissions'] = $permissions; } $apiHeaders = []; @@ -493,7 +513,6 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul $apiHeaders, $apiParams ); - } /** @@ -528,7 +547,6 @@ public function deleteFile(string $bucketId, string $fileId): string $apiHeaders, $apiParams ); - } /** @@ -564,7 +582,6 @@ public function getFileDownload(string $bucketId, string $fileId): string $apiHeaders, $apiParams ); - } /** @@ -605,47 +622,47 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n $apiParams['fileId'] = $fileId; if (!is_null($width)) { - $apiParams['width'] = $width; + $apiParams['width'] = $width; } if (!is_null($height)) { - $apiParams['height'] = $height; + $apiParams['height'] = $height; } if (!is_null($gravity)) { - $apiParams['gravity'] = $gravity; + $apiParams['gravity'] = $gravity; } if (!is_null($quality)) { - $apiParams['quality'] = $quality; + $apiParams['quality'] = $quality; } if (!is_null($borderWidth)) { - $apiParams['borderWidth'] = $borderWidth; + $apiParams['borderWidth'] = $borderWidth; } if (!is_null($borderColor)) { - $apiParams['borderColor'] = $borderColor; + $apiParams['borderColor'] = $borderColor; } if (!is_null($borderRadius)) { - $apiParams['borderRadius'] = $borderRadius; + $apiParams['borderRadius'] = $borderRadius; } if (!is_null($opacity)) { - $apiParams['opacity'] = $opacity; + $apiParams['opacity'] = $opacity; } if (!is_null($rotation)) { - $apiParams['rotation'] = $rotation; + $apiParams['rotation'] = $rotation; } if (!is_null($background)) { - $apiParams['background'] = $background; + $apiParams['background'] = $background; } if (!is_null($output)) { - $apiParams['output'] = $output; + $apiParams['output'] = $output; } $apiHeaders = []; @@ -657,7 +674,6 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n $apiHeaders, $apiParams ); - } /** @@ -693,6 +709,5 @@ public function getFileView(string $bucketId, string $fileId): string $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index bd0ae46..d4712bc 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; class Teams extends Service { @@ -36,11 +36,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -52,7 +52,6 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); - } /** @@ -81,7 +80,7 @@ public function create(string $teamId, string $name, ?array $roles = null): arra $apiParams['name'] = $name; if (!is_null($roles)) { - $apiParams['roles'] = $roles; + $apiParams['roles'] = $roles; } $apiHeaders = []; @@ -93,7 +92,6 @@ public function create(string $teamId, string $name, ?array $roles = null): arra $apiHeaders, $apiParams ); - } /** @@ -125,7 +123,6 @@ public function get(string $teamId): array $apiHeaders, $apiParams ); - } /** @@ -159,7 +156,6 @@ public function updateName(string $teamId, string $name): array $apiHeaders, $apiParams ); - } /** @@ -192,14 +188,14 @@ public function delete(string $teamId): string $apiHeaders, $apiParams ); - } /** * List team memberships * * Use this endpoint to list a team's members using the team's ID. All team - * members have read access to this endpoint. + * members have read access to this endpoint. Hide sensitive attributes from + * the response by toggling membership privacy in the Console. * * @param string $teamId * @param ?array $queries @@ -219,11 +215,11 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string $apiParams['teamId'] = $teamId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -235,7 +231,6 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string $apiHeaders, $apiParams ); - } /** @@ -286,23 +281,23 @@ public function createMembership(string $teamId, array $roles, ?string $email = $apiParams['roles'] = $roles; if (!is_null($email)) { - $apiParams['email'] = $email; + $apiParams['email'] = $email; } if (!is_null($userId)) { - $apiParams['userId'] = $userId; + $apiParams['userId'] = $userId; } if (!is_null($phone)) { - $apiParams['phone'] = $phone; + $apiParams['phone'] = $phone; } if (!is_null($url)) { - $apiParams['url'] = $url; + $apiParams['url'] = $url; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -314,14 +309,14 @@ public function createMembership(string $teamId, array $roles, ?string $email = $apiHeaders, $apiParams ); - } /** * Get team membership * * Get a team member by the membership unique id. All team members have read - * access for this resource. + * access for this resource. Hide sensitive attributes from the response by + * toggling membership privacy in the Console. * * @param string $teamId * @param string $membershipId @@ -349,7 +344,6 @@ public function getMembership(string $teamId, string $membershipId): array $apiHeaders, $apiParams ); - } /** @@ -388,7 +382,6 @@ public function updateMembership(string $teamId, string $membershipId, array $ro $apiHeaders, $apiParams ); - } /** @@ -424,7 +417,6 @@ public function deleteMembership(string $teamId, string $membershipId): string $apiHeaders, $apiParams ); - } /** @@ -468,7 +460,6 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str $apiHeaders, $apiParams ); - } /** @@ -502,7 +493,6 @@ public function getPrefs(string $teamId): array $apiHeaders, $apiParams ); - } /** @@ -538,6 +528,5 @@ public function updatePrefs(string $teamId, array $prefs): array $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index afc1aba..d25e5c9 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -5,7 +5,7 @@ use Appwrite\AppwriteException; use Appwrite\Client; use Appwrite\Service; -use Appwrite\Payload; +use Appwrite\InputFile; use Appwrite\Enums\PasswordHash; use Appwrite\Enums\AuthenticatorType; use Appwrite\Enums\MessagingProviderType; @@ -39,11 +39,11 @@ public function list(?array $queries = null, ?string $search = null): array $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -55,7 +55,6 @@ public function list(?array $queries = null, ?string $search = null): array $apiHeaders, $apiParams ); - } /** @@ -83,19 +82,19 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiParams['userId'] = $userId; if (!is_null($email)) { - $apiParams['email'] = $email; + $apiParams['email'] = $email; } if (!is_null($phone)) { - $apiParams['phone'] = $phone; + $apiParams['phone'] = $phone; } if (!is_null($password)) { - $apiParams['password'] = $password; + $apiParams['password'] = $password; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -107,7 +106,6 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiHeaders, $apiParams ); - } /** @@ -139,7 +137,7 @@ public function createArgon2User(string $userId, string $email, string $password $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -151,7 +149,6 @@ public function createArgon2User(string $userId, string $email, string $password $apiHeaders, $apiParams ); - } /** @@ -183,7 +180,7 @@ public function createBcryptUser(string $userId, string $email, string $password $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -195,7 +192,6 @@ public function createBcryptUser(string $userId, string $email, string $password $apiHeaders, $apiParams ); - } /** @@ -219,11 +215,11 @@ public function listIdentities(?array $queries = null, ?string $search = null): $apiParams = []; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } if (!is_null($search)) { - $apiParams['search'] = $search; + $apiParams['search'] = $search; } $apiHeaders = []; @@ -235,7 +231,6 @@ public function listIdentities(?array $queries = null, ?string $search = null): $apiHeaders, $apiParams ); - } /** @@ -267,7 +262,6 @@ public function deleteIdentity(string $identityId): string $apiHeaders, $apiParams ); - } /** @@ -299,7 +293,7 @@ public function createMD5User(string $userId, string $email, string $password, ? $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -311,7 +305,6 @@ public function createMD5User(string $userId, string $email, string $password, ? $apiHeaders, $apiParams ); - } /** @@ -343,7 +336,7 @@ public function createPHPassUser(string $userId, string $email, string $password $apiParams['password'] = $password; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -355,7 +348,6 @@ public function createPHPassUser(string $userId, string $email, string $password $apiHeaders, $apiParams ); - } /** @@ -397,7 +389,7 @@ public function createScryptUser(string $userId, string $email, string $password $apiParams['passwordLength'] = $passwordLength; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -409,7 +401,6 @@ public function createScryptUser(string $userId, string $email, string $password $apiHeaders, $apiParams ); - } /** @@ -448,7 +439,7 @@ public function createScryptModifiedUser(string $userId, string $email, string $ $apiParams['passwordSignerKey'] = $passwordSignerKey; if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -460,7 +451,6 @@ public function createScryptModifiedUser(string $userId, string $email, string $ $apiHeaders, $apiParams ); - } /** @@ -493,11 +483,11 @@ public function createSHAUser(string $userId, string $email, string $password, ? $apiParams['password'] = $password; if (!is_null($passwordVersion)) { - $apiParams['passwordVersion'] = $passwordVersion; + $apiParams['passwordVersion'] = $passwordVersion; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -509,7 +499,6 @@ public function createSHAUser(string $userId, string $email, string $password, ? $apiHeaders, $apiParams ); - } /** @@ -541,7 +530,6 @@ public function get(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -578,7 +566,6 @@ public function delete(string $userId): string $apiHeaders, $apiParams ); - } /** @@ -612,7 +599,6 @@ public function updateEmail(string $userId, string $email): array $apiHeaders, $apiParams ); - } /** @@ -640,11 +626,11 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat $apiParams['userId'] = $userId; if (!is_null($sessionId)) { - $apiParams['sessionId'] = $sessionId; + $apiParams['sessionId'] = $sessionId; } if (!is_null($duration)) { - $apiParams['duration'] = $duration; + $apiParams['duration'] = $duration; } $apiHeaders = []; @@ -656,7 +642,6 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat $apiHeaders, $apiParams ); - } /** @@ -695,7 +680,6 @@ public function updateLabels(string $userId, array $labels): array $apiHeaders, $apiParams ); - } /** @@ -720,7 +704,7 @@ public function listLogs(string $userId, ?array $queries = null): array $apiParams['userId'] = $userId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -732,7 +716,6 @@ public function listLogs(string $userId, ?array $queries = null): array $apiHeaders, $apiParams ); - } /** @@ -764,7 +747,6 @@ public function listMemberships(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -798,7 +780,6 @@ public function updateMfa(string $userId, bool $mfa): array $apiHeaders, $apiParams ); - } /** @@ -832,7 +813,6 @@ public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): $apiHeaders, $apiParams ); - } /** @@ -864,7 +844,6 @@ public function listMfaFactors(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -899,7 +878,6 @@ public function getMfaRecoveryCodes(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -934,7 +912,6 @@ public function updateMfaRecoveryCodes(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -969,7 +946,6 @@ public function createMfaRecoveryCodes(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -1003,7 +979,6 @@ public function updateName(string $userId, string $name): array $apiHeaders, $apiParams ); - } /** @@ -1037,7 +1012,6 @@ public function updatePassword(string $userId, string $password): array $apiHeaders, $apiParams ); - } /** @@ -1071,7 +1045,6 @@ public function updatePhone(string $userId, string $number): array $apiHeaders, $apiParams ); - } /** @@ -1103,7 +1076,6 @@ public function getPrefs(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -1139,7 +1111,6 @@ public function updatePrefs(string $userId, array $prefs): array $apiHeaders, $apiParams ); - } /** @@ -1171,7 +1142,6 @@ public function listSessions(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -1208,7 +1178,6 @@ public function createSession(string $userId): array $apiHeaders, $apiParams ); - } /** @@ -1240,7 +1209,6 @@ public function deleteSessions(string $userId): string $apiHeaders, $apiParams ); - } /** @@ -1274,7 +1242,6 @@ public function deleteSession(string $userId, string $sessionId): string $apiHeaders, $apiParams ); - } /** @@ -1309,7 +1276,6 @@ public function updateStatus(string $userId, bool $status): array $apiHeaders, $apiParams ); - } /** @@ -1334,7 +1300,7 @@ public function listTargets(string $userId, ?array $queries = null): array $apiParams['userId'] = $userId; if (!is_null($queries)) { - $apiParams['queries'] = $queries; + $apiParams['queries'] = $queries; } $apiHeaders = []; @@ -1346,7 +1312,6 @@ public function listTargets(string $userId, ?array $queries = null): array $apiHeaders, $apiParams ); - } /** @@ -1378,11 +1343,11 @@ public function createTarget(string $userId, string $targetId, MessagingProvider $apiParams['identifier'] = $identifier; if (!is_null($providerId)) { - $apiParams['providerId'] = $providerId; + $apiParams['providerId'] = $providerId; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -1394,7 +1359,6 @@ public function createTarget(string $userId, string $targetId, MessagingProvider $apiHeaders, $apiParams ); - } /** @@ -1428,7 +1392,6 @@ public function getTarget(string $userId, string $targetId): array $apiHeaders, $apiParams ); - } /** @@ -1457,15 +1420,15 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi $apiParams['targetId'] = $targetId; if (!is_null($identifier)) { - $apiParams['identifier'] = $identifier; + $apiParams['identifier'] = $identifier; } if (!is_null($providerId)) { - $apiParams['providerId'] = $providerId; + $apiParams['providerId'] = $providerId; } if (!is_null($name)) { - $apiParams['name'] = $name; + $apiParams['name'] = $name; } $apiHeaders = []; @@ -1477,7 +1440,6 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi $apiHeaders, $apiParams ); - } /** @@ -1511,7 +1473,6 @@ public function deleteTarget(string $userId, string $targetId): string $apiHeaders, $apiParams ); - } /** @@ -1541,11 +1502,11 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = $apiParams['userId'] = $userId; if (!is_null($length)) { - $apiParams['length'] = $length; + $apiParams['length'] = $length; } if (!is_null($expire)) { - $apiParams['expire'] = $expire; + $apiParams['expire'] = $expire; } $apiHeaders = []; @@ -1557,7 +1518,6 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = $apiHeaders, $apiParams ); - } /** @@ -1591,7 +1551,6 @@ public function updateEmailVerification(string $userId, bool $emailVerification) $apiHeaders, $apiParams ); - } /** @@ -1625,6 +1584,5 @@ public function updatePhoneVerification(string $userId, bool $phoneVerification) $apiHeaders, $apiParams ); - } -} +} \ No newline at end of file diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index a5f54da..9c518a5 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/AvatarsTest.php b/tests/Appwrite/Services/AvatarsTest.php index 1161626..cb2790e 100644 --- a/tests/Appwrite/Services/AvatarsTest.php +++ b/tests/Appwrite/Services/AvatarsTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 9589c7b..a1bf00e 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 57a7ce4..66266dd 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; @@ -59,7 +59,7 @@ public function testMethodCreate(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-0.5vcpu-512mb",); + "specification" => "s-1vcpu-512mb",); $this->client @@ -135,7 +135,7 @@ public function testMethodGet(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-0.5vcpu-512mb",); + "specification" => "s-1vcpu-512mb",); $this->client @@ -175,7 +175,7 @@ public function testMethodUpdate(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-0.5vcpu-512mb",); + "specification" => "s-1vcpu-512mb",); $this->client @@ -259,7 +259,7 @@ public function testMethodCreateDeployment(): void { $response = $this->functions->createDeployment( "<FUNCTION_ID>", - Payload::fromBinary('', "image/png"), + InputFile::withData('', "image/png"), true ); @@ -333,7 +333,7 @@ public function testMethodUpdateDeployment(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-0.5vcpu-512mb",); + "specification" => "s-1vcpu-512mb",); $this->client @@ -457,7 +457,7 @@ public function testMethodCreateExecution(): void { "requestPath" => "/articles?id=5", "requestHeaders" => array(), "responseStatusCode" => 200, - "responseBody" => , + "responseBody" => "", "responseHeaders" => array(), "logs" => "", "errors" => "", @@ -489,7 +489,7 @@ public function testMethodGetExecution(): void { "requestPath" => "/articles?id=5", "requestHeaders" => array(), "responseStatusCode" => 200, - "responseBody" => , + "responseBody" => "", "responseHeaders" => array(), "logs" => "", "errors" => "", diff --git a/tests/Appwrite/Services/GraphqlTest.php b/tests/Appwrite/Services/GraphqlTest.php index 7ef6824..6c587b8 100644 --- a/tests/Appwrite/Services/GraphqlTest.php +++ b/tests/Appwrite/Services/GraphqlTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php index e2c2083..bed4e21 100644 --- a/tests/Appwrite/Services/HealthTest.php +++ b/tests/Appwrite/Services/HealthTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/LocaleTest.php b/tests/Appwrite/Services/LocaleTest.php index 3dc58a1..6e8f9db 100644 --- a/tests/Appwrite/Services/LocaleTest.php +++ b/tests/Appwrite/Services/LocaleTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/MessagingTest.php b/tests/Appwrite/Services/MessagingTest.php index ca5ce08..f447883 100644 --- a/tests/Appwrite/Services/MessagingTest.php +++ b/tests/Appwrite/Services/MessagingTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; @@ -107,9 +107,7 @@ public function testMethodCreatePush(): void { ->andReturn($data); $response = $this->messaging->createPush( - "<MESSAGE_ID>", - "<TITLE>", - "<BODY>" + "<MESSAGE_ID>" ); $this->assertSame($data, $response); diff --git a/tests/Appwrite/Services/StorageTest.php b/tests/Appwrite/Services/StorageTest.php index ae820c4..e6b1923 100644 --- a/tests/Appwrite/Services/StorageTest.php +++ b/tests/Appwrite/Services/StorageTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; @@ -176,7 +176,7 @@ public function testMethodCreateFile(): void { $response = $this->storage->createFile( "<BUCKET_ID>", "<FILE_ID>", - Payload::fromBinary('', "image/png") + InputFile::withData('', "image/png") ); $this->assertSame($data, $response); diff --git a/tests/Appwrite/Services/TeamsTest.php b/tests/Appwrite/Services/TeamsTest.php index cde62f0..d77d0de 100644 --- a/tests/Appwrite/Services/TeamsTest.php +++ b/tests/Appwrite/Services/TeamsTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index b9408b1..e686783 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -3,7 +3,7 @@ namespace Appwrite\Services; use Appwrite\Client; -use Appwrite\Payload; +use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; @@ -933,10 +933,11 @@ public function testMethodCreateTarget(): void { "\$id" => "259125845563242502", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Aegon apple token", + "name" => "Apple iPhone 12", "userId" => "259125845563242502", "providerType" => "email", - "identifier" => "token",); + "identifier" => "token", + "expired" => true,); $this->client @@ -959,10 +960,11 @@ public function testMethodGetTarget(): void { "\$id" => "259125845563242502", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Aegon apple token", + "name" => "Apple iPhone 12", "userId" => "259125845563242502", "providerType" => "email", - "identifier" => "token",); + "identifier" => "token", + "expired" => true,); $this->client @@ -983,10 +985,11 @@ public function testMethodUpdateTarget(): void { "\$id" => "259125845563242502", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Aegon apple token", + "name" => "Apple iPhone 12", "userId" => "259125845563242502", "providerType" => "email", - "identifier" => "token",); + "identifier" => "token", + "expired" => true,); $this->client From fbffbc8ff1ee5aad786b57c2ac99633a8e865887 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 28 Jan 2025 18:29:49 +0000 Subject: [PATCH 4/5] fix: pong response & chunked upload --- LICENSE | 2 +- docs/functions.md | 4 ++++ docs/messaging.md | 2 +- src/Appwrite/Client.php | 4 ++-- src/Appwrite/Enums/ImageFormat.php | 8 +++++++ src/Appwrite/Services/Account.php | 4 ++-- src/Appwrite/Services/Functions.php | 14 ++++++++++- src/Appwrite/Services/Messaging.php | 2 +- src/Appwrite/Services/Storage.php | 12 ++++------ src/Appwrite/Services/Users.php | 4 ++-- tests/Appwrite/Services/AccountTest.php | 31 ++++++++++++++++++++++++- tests/Appwrite/Services/UsersTest.php | 18 +------------- 12 files changed, 70 insertions(+), 35 deletions(-) diff --git a/LICENSE b/LICENSE index 5479bb8..c1602fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/docs/functions.md b/docs/functions.md index 00b15ea..5317962 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -215,6 +215,8 @@ DELETE https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deployme POST https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId}/build ``` +** Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. ** + ### Parameters | Field Name | Type | Description | Default | @@ -229,6 +231,8 @@ POST https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deployment PATCH https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId}/build ``` +** Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. ** + ### Parameters | Field Name | Type | Description | Default | diff --git a/docs/messaging.md b/docs/messaging.md index 984c26b..556ee39 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -157,7 +157,7 @@ POST https://cloud.appwrite.io/v1/messaging/messages/sms PATCH https://cloud.appwrite.io/v1/messaging/messages/sms/{messageId} ``` -** Update an email message by its unique ID. +** Update an SMS message by its unique ID. ** ### Parameters diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 02421c7..290264c 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/12.2.0 ()', + 'user-agent' => 'AppwritePHPSDK/12.2.1 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '12.2.0', + 'x-sdk-version'=> '12.2.1', ]; /** diff --git a/src/Appwrite/Enums/ImageFormat.php b/src/Appwrite/Enums/ImageFormat.php index 092d94d..9495e34 100644 --- a/src/Appwrite/Enums/ImageFormat.php +++ b/src/Appwrite/Enums/ImageFormat.php @@ -11,6 +11,7 @@ class ImageFormat implements JsonSerializable private static ImageFormat $GIF; private static ImageFormat $PNG; private static ImageFormat $WEBP; + private static ImageFormat $HEIC; private static ImageFormat $AVIF; private string $value; @@ -65,6 +66,13 @@ public static function WEBP(): ImageFormat } return self::$WEBP; } + public static function HEIC(): ImageFormat + { + if (!isset(self::$HEIC)) { + self::$HEIC = new ImageFormat('heic'); + } + return self::$HEIC; + } public static function AVIF(): ImageFormat { if (!isset(self::$AVIF)) { diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 5b350da..2ea52db 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -441,9 +441,9 @@ public function createMfaChallenge(AuthenticationFactor $factor): array * @param string $challengeId * @param string $otp * @throws AppwriteException - * @return string + * @return array */ - public function updateMfaChallenge(string $challengeId, string $otp): string + public function updateMfaChallenge(string $challengeId, string $otp): array { $apiPath = str_replace( [], diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 2e1d60f..94c107b 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -570,7 +570,7 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti 'progress' => min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE)), $size) / $size * 100, 'sizeUploaded' => min($counter * Client::CHUNK_SIZE), 'chunksTotal' => $response['chunksTotal'], - 'chunksUploaded' => $response['chunksUploaded'], + 'chunksUploaded' => $response['chunksUploaded'], ]); } } @@ -685,6 +685,12 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri /** * Rebuild deployment * + * Create a new build for an existing function deployment. This endpoint + * allows you to rebuild a deployment with the updated function configuration, + * including its entrypoint and build commands if they have been modified The + * build process will be queued and executed asynchronously. The original + * deployment's code will be preserved and used for the new build. + * * @param string $functionId * @param string $deploymentId * @param ?string $buildId @@ -721,6 +727,12 @@ public function createBuild(string $functionId, string $deploymentId, ?string $b /** * Cancel deployment * + * Cancel an ongoing function deployment build. If the build is already in + * progress, it will be stopped and marked as canceled. If the build hasn't + * started yet, it will be marked as canceled without executing. You cannot + * cancel builds that have already completed (status 'ready') or failed. The + * response includes the final build status and details. + * * @param string $functionId * @param string $deploymentId * @throws AppwriteException diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index cf90e70..b23647d 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -526,7 +526,7 @@ public function createSms(string $messageId, string $content, ?array $topics = n /** * Update SMS * - * Update an email message by its unique ID. + * Update an SMS message by its unique ID. * * * @param string $messageId diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index 27d5a64..9035248 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -385,12 +385,10 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a $id = ''; $counter = 0; - if($fileId != 'unique()') { - try { - $response = $this->client->call(Client::METHOD_GET, $apiPath . '/' . $fileId); - $counter = $response['chunksUploaded'] ?? 0; - } catch(\Exception $e) { - } + try { + $response = $this->client->call(Client::METHOD_GET, $apiPath . '/' . $fileId); + $counter = $response['chunksUploaded'] ?? 0; + } catch(\Exception $e) { } $apiHeaders = ['content-type' => 'multipart/form-data']; @@ -426,7 +424,7 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a 'progress' => min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE)), $size) / $size * 100, 'sizeUploaded' => min($counter * Client::CHUNK_SIZE), 'chunksTotal' => $response['chunksTotal'], - 'chunksUploaded' => $response['chunksUploaded'], + 'chunksUploaded' => $response['chunksUploaded'], ]); } } diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index d25e5c9..32df3d8 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -790,9 +790,9 @@ public function updateMfa(string $userId, bool $mfa): array * @param string $userId * @param AuthenticatorType $type * @throws AppwriteException - * @return array + * @return string */ - public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): array + public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): string { $apiPath = str_replace( ['{userId}', '{type}'], diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index 9c518a5..8419699 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -301,7 +301,36 @@ public function testMethodCreateMfaChallenge(): void { public function testMethodUpdateMfaChallenge(): void { - $data = ''; + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5bb8c16897e", + "expire" => "2020-10-15T06:38:00.000+00:00", + "provider" => "email", + "providerUid" => "user@example.com", + "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip" => "127.0.0.1", + "osCode" => "Mac", + "osName" => "Mac", + "osVersion" => "Mac", + "clientType" => "browser", + "clientCode" => "CM", + "clientName" => "Chrome Mobile iOS", + "clientVersion" => "84.0", + "clientEngine" => "WebKit", + "clientEngineVersion" => "605.1.15", + "deviceName" => "smartphone", + "deviceBrand" => "Google", + "deviceModel" => "Nexus 5", + "countryCode" => "US", + "countryName" => "United States", + "current" => true, + "factors" => array(), + "secret" => "5e5bb8c16897e", + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); $this->client diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index e686783..abbe31e 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -546,23 +546,7 @@ public function testMethodUpdateMfa(): void { public function testMethodDeleteMfaAuthenticator(): void { - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "John Doe", - "registration" => "2020-10-15T06:38:00.000+00:00", - "status" => true, - "labels" => array(), - "passwordUpdate" => "2020-10-15T06:38:00.000+00:00", - "email" => "john@appwrite.io", - "phone" => "+4930901820", - "emailVerification" => true, - "phoneVerification" => true, - "mfa" => true, - "prefs" => array(), - "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); + $data = ''; $this->client From a9842c9246538e7808a9259975bb8c849cfc4ab4 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:04:02 +0000 Subject: [PATCH 5/5] chore: bump versions --- src/Appwrite/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 290264c..68eefe7 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/12.2.1 ()', + 'user-agent' => 'AppwritePHPSDK/13.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '12.2.1', + 'x-sdk-version'=> '13.0.0', ]; /**