diff --git a/README.md b/README.md index cf9c47d..5815bf7 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ # 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-0.8.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-0.9.0-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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. - Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. - For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://appwrite.io/images/github.png) @@ -25,7 +24,7 @@ composer require appwrite/appwrite ## Getting Started ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section. ```php $client = new Client(); @@ -39,7 +38,7 @@ $client ``` ### Make Your First Request -Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. +Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section. ```php $users = new Users($client); @@ -80,7 +79,7 @@ try { ``` ### Learn more -You can use followng resources to learn more and get help +You can use following resources to learn more and get help - 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) - 📜 [Appwrite Docs](https://appwrite.io/docs) - 💬 [Discord Community](https://appwrite.io/discord) diff --git a/docs/account.md b/docs/account.md index 328032a..3f90008 100644 --- a/docs/account.md +++ b/docs/account.md @@ -141,6 +141,20 @@ DELETE https://appwrite.io/v1/account/sessions ** Delete all sessions from the user account and remove any sessions cookies from the end client. ** +## Get Session By ID + +```http request +GET https://appwrite.io/v1/account/sessions/{sessionId} +``` + +** Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| sessionId | string | **Required** Session unique ID. Use the string 'current' to get the current device session. | | + ## Delete Account Session ```http request diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md new file mode 100644 index 0000000..549f9be --- /dev/null +++ b/docs/examples/account/get-session.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token +; + +$account = new Account($client); + +$result = $account->getSession('[SESSION_ID]'); \ No newline at end of file diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 9d9d54a..6302707 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -13,4 +13,4 @@ $client $functions = new Functions($client); -$result = $functions->create('[NAME]', [], 'dotnet-3.1'); \ No newline at end of file +$result = $functions->create('[NAME]', [], 'java-11.0'); \ No newline at end of file diff --git a/docs/examples/users/update-verification.md b/docs/examples/users/update-verification.md new file mode 100644 index 0000000..5b1f086 --- /dev/null +++ b/docs/examples/users/update-verification.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->updateVerification('[USER_ID]', false); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index 2fe1534..ed718a7 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -31,7 +31,7 @@ POST https://appwrite.io/v1/functions | --- | --- | --- | --- | | name | string | Function name. Max length: 128 chars. | | | execute | array | An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| env | string | Execution enviornment. | | +| runtime | string | Execution runtime. | | | vars | object | Key-value JSON object. | {} | | events | array | Events list. | [] | | schedule | string | Schedule CRON syntax. | | diff --git a/docs/storage.md b/docs/storage.md index 00fd353..907d41a 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -106,11 +106,12 @@ GET https://appwrite.io/v1/storage/files/{fileId}/preview | fileId | string | **Required** File unique ID | | | width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | | height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | +| gravity | string | Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | | quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 | | borderWidth | integer | Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. | 0 | | borderColor | string | Preview image border color. Use a valid HEX color, no # is needed for prefix. | | | borderRadius | integer | Preview image border radius in pixels. Pass an integer between 0 to 4000. | 0 | -| opacity | integer | Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. | 1 | +| opacity | number | Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. | 1 | | rotation | integer | Preview image rotation in degrees. Pass an integer between 0 and 360. | 0 | | background | string | Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. | | | output | string | Output format type (jpeg, jpg, png, gif and webp). | | diff --git a/docs/users.md b/docs/users.md index 004f348..6e716f2 100644 --- a/docs/users.md +++ b/docs/users.md @@ -162,3 +162,18 @@ PATCH https://appwrite.io/v1/users/{userId}/status | userId | string | **Required** User unique ID. | | | status | integer | User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0 | | +## Update Email Verification + +```http request +PATCH https://appwrite.io/v1/users/{userId}/verification +``` + +** Update the user email verification status by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User unique ID. | | +| emailVerification | boolean | User Email Verification Status. | | + diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 832da6d..12b5389 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -35,7 +35,7 @@ class Client */ protected $headers = [ 'content-type' => '', - 'x-sdk-version' => 'appwrite:php:2.1.2', + 'x-sdk-version' => 'appwrite:php:2.2.0', ]; /** @@ -43,7 +43,7 @@ class Client */ public function __construct() { - $this->headers['X-Appwrite-Response-Format'] = '0.8.0'; + $this->headers['X-Appwrite-Response-Format'] = '0.9.0'; } diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 9317ed5..72f9c83 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -358,6 +358,30 @@ public function deleteSessions(): array ], $params); } + /** + * Get Session By ID + * + * Use this endpoint to get a logged in user's session using a Session ID. + * Inputting 'current' will return the current session being used. + * + * @param string $sessionId + * @throws AppwriteException + * @return array + */ + public function getSession(string $sessionId): array + { + if (empty($sessionId)) { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + + $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); + $params = []; + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + /** * Delete Account Session * diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index e9f5eba..937c115 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -56,7 +56,7 @@ public function list(string $search = null, int $limit = null, int $offset = nul * * @param string $name * @param array $execute - * @param string $env + * @param string $runtime * @param array $vars * @param array $events * @param string $schedule @@ -64,7 +64,7 @@ public function list(string $search = null, int $limit = null, int $offset = nul * @throws AppwriteException * @return array */ - public function create(string $name, array $execute, string $env, array $vars = null, array $events = null, string $schedule = null, int $timeout = null): array + public function create(string $name, array $execute, string $runtime, array $vars = null, array $events = null, string $schedule = null, int $timeout = null): array { if (empty($name)) { throw new AppwriteException('Missing required parameter: "name"'); @@ -74,8 +74,8 @@ public function create(string $name, array $execute, string $env, array $vars = throw new AppwriteException('Missing required parameter: "execute"'); } - if (empty($env)) { - throw new AppwriteException('Missing required parameter: "env"'); + if (empty($runtime)) { + throw new AppwriteException('Missing required parameter: "runtime"'); } $path = str_replace([], [], '/functions'); @@ -89,8 +89,8 @@ public function create(string $name, array $execute, string $env, array $vars = $params['execute'] = $execute; } - if (!is_null($env)) { - $params['env'] = $env; + if (!is_null($runtime)) { + $params['runtime'] = $runtime; } if (!is_null($vars)) { diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index b6ee267..543aaa1 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -213,6 +213,7 @@ public function getFileDownload(string $fileId): string * @param string $fileId * @param int $width * @param int $height + * @param string $gravity * @param int $quality * @param int $borderWidth * @param string $borderColor @@ -224,7 +225,7 @@ public function getFileDownload(string $fileId): string * @throws AppwriteException * @return string */ - public function getFilePreview(string $fileId, int $width = null, int $height = null, int $quality = null, int $borderWidth = null, string $borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string $background = null, string $output = null): string + public function getFilePreview(string $fileId, int $width = null, int $height = null, string $gravity = null, int $quality = null, int $borderWidth = null, string $borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string $background = null, string $output = null): string { if (empty($fileId)) { throw new AppwriteException('Missing required parameter: "fileId"'); @@ -241,6 +242,10 @@ public function getFilePreview(string $fileId, int $width = null, int $height = $params['height'] = $height; } + if (!is_null($gravity)) { + $params['gravity'] = $gravity; + } + if (!is_null($quality)) { $params['quality'] = $quality; } diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index c28bd8a..17259ab 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -318,4 +318,36 @@ public function updateStatus(string $userId, int $status): array 'content-type' => 'application/json', ], $params); } + + /** + * Update Email Verification + * + * Update the user email verification status by its unique ID. + * + * @param string $userId + * @param bool $emailVerification + * @throws AppwriteException + * @return array + */ + public function updateVerification(string $userId, bool $emailVerification): array + { + if (empty($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if (empty($emailVerification)) { + throw new AppwriteException('Missing required parameter: "emailVerification"'); + } + + $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification'); + $params = []; + + if (!is_null($emailVerification)) { + $params['emailVerification'] = $emailVerification; + } + + return $this->client->call(Client::METHOD_PATCH, $path, [ + 'content-type' => 'application/json', + ], $params); + } } \ No newline at end of file