diff --git a/LICENSE b/LICENSE index 47cfdfb..5479bb8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2024 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/README.md b/README.md index 94aee42..7125d34 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # 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.4.12-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.5.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?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) -**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version 1.5.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](https://appwrite.io/images/github.png) +![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) ## Installation @@ -43,7 +43,7 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```php $users = new Users($client); -$user = $users->create(ID::unique(), 'email@example.com', 'password'); +$user = $users->create(ID::unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); ``` ### Full Example @@ -63,7 +63,7 @@ $client $users = new Users($client); -$user = $users->create(ID::unique(), 'email@example.com', 'password'); +$user = $users->create(ID::unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); ``` ### Error Handling @@ -72,7 +72,7 @@ The Appwrite PHP SDK raises `AppwriteException` object with `message`, `code` an ```php $users = new Users($client); try { - $user = $users->create(ID::unique(), 'email@example.com', 'password'); + $user = $users->create(ID::unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); } catch(AppwriteException $error) { echo $error->message; } diff --git a/composer.json b/composer.json index ddf75fb..6dea965 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "3.7.35" + "phpunit/phpunit": "^10", + "mockery/mockery": "^1.6.6" }, "minimum-stability": "dev" } \ No newline at end of file diff --git a/docs/account.md b/docs/account.md index 6fa02d8..b310dbd 100644 --- a/docs/account.md +++ b/docs/account.md @@ -3,15 +3,32 @@ ## Get account ```http request -GET https://HOSTNAME/v1/account +GET https://cloud.appwrite.io/v1/account ``` ** Get the currently logged in user. ** +## Create account + +```http request +POST https://cloud.appwrite.io/v1/account +``` + +** Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| email | string | User email. | | +| password | string | New user password. Must be between 8 and 256 chars. | | +| name | string | User name. Max length: 128 chars. | | + ## Update email ```http request -PATCH https://HOSTNAME/v1/account/email +PATCH https://cloud.appwrite.io/v1/account/email ``` ** Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. @@ -28,7 +45,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, ## List Identities ```http request -GET https://HOSTNAME/v1/account/identities +GET https://cloud.appwrite.io/v1/account/identities ``` ** Get the list of identities for the currently logged in user. ** @@ -37,12 +54,12 @@ GET https://HOSTNAME/v1/account/identities | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| queries | string | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry | [] | -## Delete Identity +## Delete identity ```http request -DELETE https://HOSTNAME/v1/account/identities/{identityId} +DELETE https://cloud.appwrite.io/v1/account/identities/{identityId} ``` ** Delete an identity by its unique ID. ** @@ -53,10 +70,18 @@ DELETE https://HOSTNAME/v1/account/identities/{identityId} | --- | --- | --- | --- | | identityId | string | **Required** Identity ID. | | +## Create JWT + +```http request +POST https://cloud.appwrite.io/v1/account/jwt +``` + +** Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. ** + ## List logs ```http request -GET https://HOSTNAME/v1/account/logs +GET https://cloud.appwrite.io/v1/account/logs ``` ** Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. ** @@ -67,10 +92,129 @@ GET https://HOSTNAME/v1/account/logs | --- | --- | --- | --- | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset | [] | +## Update MFA + +```http request +PATCH https://cloud.appwrite.io/v1/account/mfa +``` + +** Enable or disable MFA on an account. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| mfa | boolean | Enable or disable MFA. | | + +## Add Authenticator + +```http request +POST https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} +``` + +** Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | **Required** Type of authenticator. Must be `totp` | | + +## Verify Authenticator + +```http request +PUT https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} +``` + +** Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | **Required** Type of authenticator. | | +| otp | string | Valid verification token. | | + +## Delete Authenticator + +```http request +DELETE https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} +``` + +** Delete an authenticator for a user by ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | **Required** Type of authenticator. | | +| otp | string | Valid verification token. | | + +## Create 2FA Challenge + +```http request +POST https://cloud.appwrite.io/v1/account/mfa/challenge +``` + +** Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| factor | string | Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. | | + +## Create MFA Challenge (confirmation) + +```http request +PUT https://cloud.appwrite.io/v1/account/mfa/challenge +``` + +** Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| challengeId | string | ID of the challenge. | | +| otp | string | Valid verification token. | | + +## List Factors + +```http request +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 + +```http request +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 + +```http request +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 + +```http request +PATCH https://cloud.appwrite.io/v1/account/mfa/recovery-codes +``` + +** Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. ** + ## Update name ```http request -PATCH https://HOSTNAME/v1/account/name +PATCH https://cloud.appwrite.io/v1/account/name ``` ** Update currently logged in user account name. ** @@ -84,7 +228,7 @@ PATCH https://HOSTNAME/v1/account/name ## Update password ```http request -PATCH https://HOSTNAME/v1/account/password +PATCH https://cloud.appwrite.io/v1/account/password ``` ** Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. ** @@ -99,7 +243,7 @@ PATCH https://HOSTNAME/v1/account/password ## Update phone ```http request -PATCH https://HOSTNAME/v1/account/phone +PATCH https://cloud.appwrite.io/v1/account/phone ``` ** Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. ** @@ -114,7 +258,7 @@ PATCH https://HOSTNAME/v1/account/phone ## Get account preferences ```http request -GET https://HOSTNAME/v1/account/prefs +GET https://cloud.appwrite.io/v1/account/prefs ``` ** Get the preferences as a key-value object for the currently logged in user. ** @@ -122,7 +266,7 @@ GET https://HOSTNAME/v1/account/prefs ## Update preferences ```http request -PATCH https://HOSTNAME/v1/account/prefs +PATCH https://cloud.appwrite.io/v1/account/prefs ``` ** Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. ** @@ -136,7 +280,7 @@ PATCH https://HOSTNAME/v1/account/prefs ## Create password recovery ```http request -POST https://HOSTNAME/v1/account/recovery +POST https://cloud.appwrite.io/v1/account/recovery ``` ** Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. ** @@ -151,7 +295,7 @@ POST https://HOSTNAME/v1/account/recovery ## Create password recovery (confirmation) ```http request -PUT https://HOSTNAME/v1/account/recovery +PUT https://cloud.appwrite.io/v1/account/recovery ``` ** Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. @@ -164,13 +308,12 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ | --- | --- | --- | --- | | userId | string | User ID. | | | secret | string | Valid reset token. | | -| password | string | New user password. Must be at least 8 chars. | | -| passwordAgain | string | Repeat new user password. Must be at least 8 chars. | | +| password | string | New user password. Must be between 8 and 256 chars. | | ## List sessions ```http request -GET https://HOSTNAME/v1/account/sessions +GET https://cloud.appwrite.io/v1/account/sessions ``` ** Get the list of active sessions across different devices for the currently logged in user. ** @@ -178,15 +321,85 @@ GET https://HOSTNAME/v1/account/sessions ## Delete sessions ```http request -DELETE https://HOSTNAME/v1/account/sessions +DELETE https://cloud.appwrite.io/v1/account/sessions ``` ** Delete all sessions from the user account and remove any sessions cookies from the end client. ** +## Create anonymous session + +```http request +POST https://cloud.appwrite.io/v1/account/sessions/anonymous +``` + +** Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). ** + +## Create email password session + +```http request +POST https://cloud.appwrite.io/v1/account/sessions/email +``` + +** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. + +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). ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| email | string | User email. | | +| password | string | User password. Must be at least 8 chars. | | + +## Update magic URL session + +```http request +PUT https://cloud.appwrite.io/v1/account/sessions/magic-url +``` + +** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| secret | string | Valid verification token. | | + +## Update phone session + +```http request +PUT https://cloud.appwrite.io/v1/account/sessions/phone +``` + +** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| secret | string | Valid verification token. | | + +## Create session + +```http request +POST https://cloud.appwrite.io/v1/account/sessions/token +``` + +** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| secret | string | Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. | | + ## Get session ```http request -GET https://HOSTNAME/v1/account/sessions/{sessionId} +GET https://cloud.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. ** @@ -197,13 +410,13 @@ GET https://HOSTNAME/v1/account/sessions/{sessionId} | --- | --- | --- | --- | | sessionId | string | **Required** Session ID. Use the string 'current' to get the current device session. | | -## Update OAuth session (refresh tokens) +## Update session ```http request -PATCH https://HOSTNAME/v1/account/sessions/{sessionId} +PATCH https://cloud.appwrite.io/v1/account/sessions/{sessionId} ``` -** Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token. ** +** Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. ** ### Parameters @@ -214,7 +427,7 @@ PATCH https://HOSTNAME/v1/account/sessions/{sessionId} ## Delete session ```http request -DELETE https://HOSTNAME/v1/account/sessions/{sessionId} +DELETE https://cloud.appwrite.io/v1/account/sessions/{sessionId} ``` ** Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. ** @@ -228,15 +441,91 @@ DELETE https://HOSTNAME/v1/account/sessions/{sessionId} ## Update status ```http request -PATCH https://HOSTNAME/v1/account/status +PATCH https://cloud.appwrite.io/v1/account/status ``` ** Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. ** +## Create email token (OTP) + +```http request +POST https://cloud.appwrite.io/v1/account/tokens/email +``` + +** Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and 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 secret sent to the user's email is valid for 15 minutes. + +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). ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| email | string | User email. | | +| phrase | boolean | Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. | | + +## Create magic URL token + +```http request +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. + +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). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| email | string | User email. | | +| url | string | URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | +| phrase | boolean | Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. | | + +## Create OAuth2 token + +```http request +GET https://cloud.appwrite.io/v1/account/tokens/oauth2/{provider} +``` + +** Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + +If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. + +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). ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. | | +| success | string | URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | +| failure | string | URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | +| scopes | array | A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. | [] | + +## Create phone token + +```http request +POST https://cloud.appwrite.io/v1/account/tokens/phone +``` + +** Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and 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 secret sent to the user's phone is valid for 15 minutes. + +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). ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | + ## Create email verification ```http request -POST https://HOSTNAME/v1/account/verification +POST https://cloud.appwrite.io/v1/account/verification ``` ** Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -253,7 +542,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ ## Create email verification (confirmation) ```http request -PUT https://HOSTNAME/v1/account/verification +PUT https://cloud.appwrite.io/v1/account/verification ``` ** Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. ** @@ -268,7 +557,7 @@ PUT https://HOSTNAME/v1/account/verification ## Create phone verification ```http request -POST https://HOSTNAME/v1/account/verification/phone +POST https://cloud.appwrite.io/v1/account/verification/phone ``` ** Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. ** @@ -276,7 +565,7 @@ POST https://HOSTNAME/v1/account/verification/phone ## Create phone verification (confirmation) ```http request -PUT https://HOSTNAME/v1/account/verification/phone +PUT https://cloud.appwrite.io/v1/account/verification/phone ``` ** Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. ** diff --git a/docs/avatars.md b/docs/avatars.md index 761ed50..1e17e44 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -3,7 +3,7 @@ ## Get browser icon ```http request -GET https://HOSTNAME/v1/avatars/browsers/{code} +GET https://cloud.appwrite.io/v1/avatars/browsers/{code} ``` ** You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. @@ -22,7 +22,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre ## Get credit card icon ```http request -GET https://HOSTNAME/v1/avatars/credit-cards/{code} +GET https://cloud.appwrite.io/v1/avatars/credit-cards/{code} ``` ** The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. @@ -42,7 +42,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre ## Get favicon ```http request -GET https://HOSTNAME/v1/avatars/favicon +GET https://cloud.appwrite.io/v1/avatars/favicon ``` ** Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. @@ -57,7 +57,7 @@ GET https://HOSTNAME/v1/avatars/favicon ## Get country flag ```http request -GET https://HOSTNAME/v1/avatars/flags/{code} +GET https://cloud.appwrite.io/v1/avatars/flags/{code} ``` ** You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. @@ -77,7 +77,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre ## Get image from URL ```http request -GET https://HOSTNAME/v1/avatars/image +GET https://cloud.appwrite.io/v1/avatars/image ``` ** Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. @@ -96,7 +96,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre ## Get user initials ```http request -GET https://HOSTNAME/v1/avatars/initials +GET https://cloud.appwrite.io/v1/avatars/initials ``` ** Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. @@ -118,7 +118,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre ## Get QR code ```http request -GET https://HOSTNAME/v1/avatars/qr +GET https://cloud.appwrite.io/v1/avatars/qr ``` ** Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. diff --git a/docs/databases.md b/docs/databases.md index 146742b..9267e14 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -3,7 +3,7 @@ ## List databases ```http request -GET https://HOSTNAME/v1/databases +GET https://cloud.appwrite.io/v1/databases ``` ** Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. ** @@ -18,7 +18,7 @@ GET https://HOSTNAME/v1/databases ## Create database ```http request -POST https://HOSTNAME/v1/databases +POST https://cloud.appwrite.io/v1/databases ``` ** Create a new Database. @@ -35,7 +35,7 @@ POST https://HOSTNAME/v1/databases ## Get database ```http request -GET https://HOSTNAME/v1/databases/{databaseId} +GET https://cloud.appwrite.io/v1/databases/{databaseId} ``` ** Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. ** @@ -49,7 +49,7 @@ GET https://HOSTNAME/v1/databases/{databaseId} ## Update database ```http request -PUT https://HOSTNAME/v1/databases/{databaseId} +PUT https://cloud.appwrite.io/v1/databases/{databaseId} ``` ** Update a database by its unique ID. ** @@ -65,7 +65,7 @@ PUT https://HOSTNAME/v1/databases/{databaseId} ## Delete database ```http request -DELETE https://HOSTNAME/v1/databases/{databaseId} +DELETE https://cloud.appwrite.io/v1/databases/{databaseId} ``` ** Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. ** @@ -79,7 +79,7 @@ DELETE https://HOSTNAME/v1/databases/{databaseId} ## List collections ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections ``` ** Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. ** @@ -95,7 +95,7 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections ## Create collection ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections ``` ** Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** @@ -114,7 +114,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections ## Get collection ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId} ``` ** Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. ** @@ -129,7 +129,7 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} ## Update collection ```http request -PUT https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} +PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId} ``` ** Update a collection by its unique ID. ** @@ -148,7 +148,7 @@ PUT https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} ## Delete collection ```http request -DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId} ``` ** Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. ** @@ -163,9 +163,11 @@ DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} ## List attributes ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes ``` +** List attributes in the collection. ** + ### Parameters | Field Name | Type | Description | Default | @@ -177,7 +179,7 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attrib ## Create boolean attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/boolean +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/boolean ``` ** Create a boolean attribute. @@ -197,9 +199,11 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update boolean attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key} ``` +** Update a boolean attribute. Changing the `default` value will not update already existing documents. ** + ### Parameters | Field Name | Type | Description | Default | @@ -213,9 +217,11 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create datetime attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/datetime +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/datetime ``` +** Create a date time attribute according to the ISO 8601 standard. ** + ### Parameters | Field Name | Type | Description | Default | @@ -224,15 +230,17 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for the attribute in ISO 8601 format. Cannot be set when attribute is required. | | +| default | string | Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | ## Update dateTime attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key} ``` +** Update a date time attribute. Changing the `default` value will not update already existing documents. ** + ### Parameters | Field Name | Type | Description | Default | @@ -246,7 +254,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create email attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/email +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/email ``` ** Create an email attribute. @@ -266,7 +274,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update email attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/email/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/email/{key} ``` ** Update an email attribute. Changing the `default` value will not update already existing documents. @@ -285,9 +293,12 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create enum attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/enum +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/enum ``` +** Create an enumeration attribute. The `elements` param acts as a white-list of accepted values for this attribute. + ** + ### Parameters | Field Name | Type | Description | Default | @@ -295,7 +306,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | -| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long. | | +| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -303,7 +314,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update enum attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key} ``` ** Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -316,14 +327,14 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | -| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long. | | +| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | ## Create float attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/float +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/float ``` ** Create a float attribute. Optionally, minimum and maximum values can be provided. @@ -345,7 +356,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update float attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/float/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/float/{key} ``` ** Update a float attribute. Changing the `default` value will not update already existing documents. @@ -366,7 +377,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create integer attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/integer +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/integer ``` ** Create an integer attribute. Optionally, minimum and maximum values can be provided. @@ -388,7 +399,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update integer attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key} ``` ** Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -409,7 +420,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create IP address attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/ip +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/ip ``` ** Create IP address attribute. @@ -429,7 +440,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update IP address attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key} ``` ** Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -448,7 +459,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create relationship attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/relationship +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/relationship ``` ** Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -470,7 +481,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Create string attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/string +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/string ``` ** Create a string attribute. @@ -492,7 +503,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update string attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/string/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/string/{key} ``` ** Update a string attribute. Changing the `default` value will not update already existing documents. @@ -511,7 +522,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Create URL attribute ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/url +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/url ``` ** Create a URL attribute. @@ -531,7 +542,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri ## Update URL attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/url/{key} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/url/{key} ``` ** Update an url attribute. Changing the `default` value will not update already existing documents. @@ -550,9 +561,11 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## Get attribute ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key} +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key} ``` +** Get attribute by ID. ** + ### Parameters | Field Name | Type | Description | Default | @@ -564,9 +577,11 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attrib ## Delete attribute ```http request -DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key} +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key} ``` +** Deletes an attribute. ** + ### Parameters | Field Name | Type | Description | Default | @@ -578,7 +593,7 @@ DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/att ## Update relationship attribute ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship ``` ** Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -596,7 +611,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attr ## List documents ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` ** Get a list of all the user's documents in a given collection. You can use the query params to filter your results. ** @@ -612,7 +627,7 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docume ## Create document ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` ** Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** @@ -630,7 +645,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docum ## Get document ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` ** Get a document by its unique ID. This endpoint response returns a JSON object with the document data. ** @@ -642,12 +657,12 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docume | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | documentId | string | **Required** Document ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only method allowed is select. | [] | +| 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. | [] | ## Update document ```http request -PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` ** Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. ** @@ -665,7 +680,7 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docu ## Delete document ```http request -DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` ** Delete a document by its unique ID. ** @@ -681,9 +696,11 @@ DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/doc ## List indexes ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexes +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes ``` +** List indexes in the collection. ** + ### Parameters | Field Name | Type | Description | Default | @@ -695,9 +712,12 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexe ## Create index ```http request -POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexes +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes ``` +** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. +Attributes can be `key`, `fulltext`, and `unique`. ** + ### Parameters | Field Name | Type | Description | Default | @@ -712,9 +732,11 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/index ## Get index ```http request -GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexes/{key} +GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes/{key} ``` +** Get index by ID. ** + ### Parameters | Field Name | Type | Description | Default | @@ -726,9 +748,11 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexe ## Delete index ```http request -DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexes/{key} +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes/{key} ``` +** Delete an index. ** + ### Parameters | Field Name | Type | Description | Default | diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md new file mode 100644 index 0000000..950bb4a --- /dev/null +++ b/docs/examples/account/create-anonymous-session.md @@ -0,0 +1,12 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createAnonymousSession(); diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md new file mode 100644 index 0000000..3fd96f3 --- /dev/null +++ b/docs/examples/account/create-email-password-session.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createEmailPasswordSession( + email: 'email@example.com', + password: 'password' +); \ No newline at end of file diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md new file mode 100644 index 0000000..1477366 --- /dev/null +++ b/docs/examples/account/create-email-token.md @@ -0,0 +1,16 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createEmailToken( + userId: '', + email: 'email@example.com', + phrase: false // optional +); \ No newline at end of file diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md new file mode 100644 index 0000000..d59316f --- /dev/null +++ b/docs/examples/account/create-j-w-t.md @@ -0,0 +1,12 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createJWT(); diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md new file mode 100644 index 0000000..e744157 --- /dev/null +++ b/docs/examples/account/create-magic-u-r-l-token.md @@ -0,0 +1,17 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createMagicURLToken( + userId: '', + email: 'email@example.com', + url: 'https://example.com', // optional + phrase: false // optional +); \ No newline at end of file diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md new file mode 100644 index 0000000..1b3d176 --- /dev/null +++ b/docs/examples/account/create-mfa-authenticator.md @@ -0,0 +1,16 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->createMfaAuthenticator( + type: AuthenticatorType::TOTP() +); \ No newline at end of file diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md new file mode 100644 index 0000000..5cef510 --- /dev/null +++ b/docs/examples/account/create-mfa-challenge.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createMfaChallenge( + factor: AuthenticationFactor::EMAIL() +); \ No newline at end of file diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md new file mode 100644 index 0000000..8adf247 --- /dev/null +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -0,0 +1,13 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->createMfaRecoveryCodes(); diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md new file mode 100644 index 0000000..dc97ef6 --- /dev/null +++ b/docs/examples/account/create-o-auth2token.md @@ -0,0 +1,18 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createOAuth2Token( + provider: OAuthProvider::AMAZON(), + success: 'https://example.com', // optional + failure: 'https://example.com', // optional + scopes: [] // optional +); \ No newline at end of file diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md new file mode 100644 index 0000000..43ff008 --- /dev/null +++ b/docs/examples/account/create-phone-token.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createPhoneToken( + userId: '', + phone: '+12065550100' +); \ No newline at end of file diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index 1c41a30..c4b52f3 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->createPhoneVerification(); \ No newline at end of file +$result = $account->createPhoneVerification(); diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 8ca78fc..b35c58f 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->createRecovery('email@example.com', 'https://example.com'); \ No newline at end of file +$result = $account->createRecovery( + email: 'email@example.com', + url: 'https://example.com' +); \ No newline at end of file diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md new file mode 100644 index 0000000..71fa75c --- /dev/null +++ b/docs/examples/account/create-session.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->createSession( + userId: '', + secret: '' +); \ No newline at end of file diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 92fb381..b1ca321 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->createVerification('https://example.com'); \ No newline at end of file +$result = $account->createVerification( + url: 'https://example.com' +); \ No newline at end of file diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md new file mode 100644 index 0000000..c07c2d7 --- /dev/null +++ b/docs/examples/account/create.md @@ -0,0 +1,17 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->create( + userId: '', + email: 'email@example.com', + password: '', + name: '' // optional +); \ No newline at end of file diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 0b509af..06a6a38 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->deleteIdentity('[IDENTITY_ID]'); \ No newline at end of file +$result = $account->deleteIdentity( + identityId: '' +); \ No newline at end of file diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md new file mode 100644 index 0000000..78a304f --- /dev/null +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -0,0 +1,17 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->deleteMfaAuthenticator( + type: AuthenticatorType::TOTP(), + otp: '' +); \ No newline at end of file diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 51bf3e2..9b06705 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->deleteSession('[SESSION_ID]'); \ No newline at end of file +$result = $account->deleteSession( + sessionId: '' +); \ No newline at end of file diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index bf3bc2a..7f927fa 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->deleteSessions(); \ No newline at end of file +$result = $account->deleteSessions(); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md new file mode 100644 index 0000000..795559b --- /dev/null +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -0,0 +1,13 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->getMfaRecoveryCodes(); diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index a91b888..57990c1 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->getPrefs(); \ No newline at end of file +$result = $account->getPrefs(); diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index 9e2341c..5236002 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->getSession('[SESSION_ID]'); \ No newline at end of file +$result = $account->getSession( + sessionId: '' +); \ No newline at end of file diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index 4333bf2..4b6d8e2 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->get(); \ No newline at end of file +$result = $account->get(); diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index c522a15..da36bbd 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->listIdentities(); \ No newline at end of file +$result = $account->listIdentities( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 62bc86d..a83c39a 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->listLogs(); \ No newline at end of file +$result = $account->listLogs( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md new file mode 100644 index 0000000..448f18d --- /dev/null +++ b/docs/examples/account/list-mfa-factors.md @@ -0,0 +1,13 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->listMfaFactors(); diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 7942a3d..bae339f 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->listSessions(); \ No newline at end of file +$result = $account->listSessions(); diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index a7ac5ed..efe3d99 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updateEmail('email@example.com', 'password'); \ No newline at end of file +$result = $account->updateEmail( + email: 'email@example.com', + password: 'password' +); \ No newline at end of file diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md new file mode 100644 index 0000000..5247ec4 --- /dev/null +++ b/docs/examples/account/update-m-f-a.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->updateMFA( + mfa: false +); \ No newline at end of file diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md new file mode 100644 index 0000000..1fa3422 --- /dev/null +++ b/docs/examples/account/update-magic-u-r-l-session.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->updateMagicURLSession( + userId: '', + secret: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md new file mode 100644 index 0000000..e97fff5 --- /dev/null +++ b/docs/examples/account/update-mfa-authenticator.md @@ -0,0 +1,17 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->updateMfaAuthenticator( + type: AuthenticatorType::TOTP(), + otp: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md new file mode 100644 index 0000000..d0f278c --- /dev/null +++ b/docs/examples/account/update-mfa-challenge.md @@ -0,0 +1,16 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->updateMfaChallenge( + challengeId: '', + otp: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md new file mode 100644 index 0000000..7b6809f --- /dev/null +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -0,0 +1,13 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->updateMfaRecoveryCodes(); diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 21bac94..ea6353f 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updateName('[NAME]'); \ No newline at end of file +$result = $account->updateName( + name: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 47e4c96..dc873db 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updatePassword(''); \ No newline at end of file +$result = $account->updatePassword( + password: '', + oldPassword: 'password' // optional +); \ No newline at end of file diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md new file mode 100644 index 0000000..9681b35 --- /dev/null +++ b/docs/examples/account/update-phone-session.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2'); // Your project ID + +$account = new Account($client); + +$result = $account->updatePhoneSession( + userId: '', + secret: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 0245872..9c3d3b7 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updatePhoneVerification('[USER_ID]', '[SECRET]'); \ No newline at end of file +$result = $account->updatePhoneVerification( + userId: '', + secret: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index eaa1898..cbaf93a 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updatePhone('+12065550100', 'password'); \ No newline at end of file +$result = $account->updatePhone( + phone: '+12065550100', + password: 'password' +); \ No newline at end of file diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 96d0be5..f057471 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updatePrefs([]); \ No newline at end of file +$result = $account->updatePrefs( + prefs: [] +); \ No newline at end of file diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 379b219..5b7f88b 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updateRecovery('[USER_ID]', '[SECRET]', 'password', 'password'); \ No newline at end of file +$result = $account->updateRecovery( + userId: '', + secret: '', + password: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 462be6b..d0220da 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updateSession('[SESSION_ID]'); \ No newline at end of file +$result = $account->updateSession( + sessionId: '' +); \ No newline at end of file diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index b1a1f2c..e5d51ec 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updateStatus(); \ No newline at end of file +$result = $account->updateStatus(); diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index ad583a4..b7cd6f9 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Account; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $account = new Account($client); -$result = $account->updateVerification('[USER_ID]', '[SECRET]'); \ No newline at end of file +$result = $account->updateVerification( + userId: '', + secret: '' +); \ No newline at end of file diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 362106f..02bc411 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -2,15 +2,18 @@ use Appwrite\Client; use Appwrite\Services\Avatars; +use Appwrite\Enums\Browser; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getBrowser('aa'); \ No newline at end of file +$result = $avatars->getBrowser( + code: Browser::AVANTBROWSER(), + width: 0, // optional + height: 0, // optional + quality: 0 // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index c85ebea..be93427 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -2,15 +2,18 @@ use Appwrite\Client; use Appwrite\Services\Avatars; +use Appwrite\Enums\CreditCard; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getCreditCard('amex'); \ No newline at end of file +$result = $avatars->getCreditCard( + code: CreditCard::AMERICANEXPRESS(), + width: 0, // optional + height: 0, // optional + quality: 0 // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 088524e..ff48929 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Avatars; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getFavicon('https://example.com'); \ No newline at end of file +$result = $avatars->getFavicon( + url: 'https://example.com' +); \ No newline at end of file diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 2f2705b..b2cd79a 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -2,15 +2,18 @@ use Appwrite\Client; use Appwrite\Services\Avatars; +use Appwrite\Enums\Flag; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getFlag('af'); \ No newline at end of file +$result = $avatars->getFlag( + code: Flag::AFGHANISTAN(), + width: 0, // optional + height: 0, // optional + quality: 0 // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index d576232..f069e7f 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Avatars; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getImage('https://example.com'); \ No newline at end of file +$result = $avatars->getImage( + url: 'https://example.com', + width: 0, // optional + height: 0 // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 4e924c7..448e1a6 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Avatars; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getInitials(); \ No newline at end of file +$result = $avatars->getInitials( + name: '', // optional + width: 0, // optional + height: 0, // optional + background: '' // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index fde6e35..8d19ddd 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Avatars; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $avatars = new Avatars($client); -$result = $avatars->getQR('[TEXT]'); \ No newline at end of file +$result = $avatars->getQR( + text: '', + size: 1, // optional + margin: 0, // optional + download: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 17c9224..9344cff 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createBooleanAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createBooleanAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: false, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 2fd5fb6..f5c5cb3 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); \ No newline at end of file +$result = $databases->createCollection( + databaseId: '', + collectionId: '', + name: '', + permissions: ["read("any")"], // optional + documentSecurity: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index 284163c..3169914 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createDatetimeAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createDatetimeAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 509160b..83ffc07 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); -$result = $databases->createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', []); \ No newline at end of file +$result = $databases->createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: [], + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index df68be7..c88a039 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createEmailAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createEmailAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'email@example.com', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index c469679..e12bb36 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -3,14 +3,19 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createEnumAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], false); \ No newline at end of file +$result = $databases->createEnumAttribute( + databaseId: '', + collectionId: '', + key: '', + elements: [], + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index c182d0a..c685c6a 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -3,14 +3,20 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createFloatAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 6ecd4cc..b658234 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -2,15 +2,20 @@ use Appwrite\Client; use Appwrite\Services\Databases; +use Appwrite\Enums\IndexType; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createIndex('[DATABASE_ID]', '[COLLECTION_ID]', '', 'key', []); \ No newline at end of file +$result = $databases->createIndex( + databaseId: '', + collectionId: '', + key: '', + type: IndexType::KEY(), + attributes: [], + orders: [] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index d86ca70..ef63e05 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -3,14 +3,20 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createIntegerAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createIntegerAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 823fa99..a3d9de9 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createIpAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 4840a66..1d262cf 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -2,15 +2,22 @@ use Appwrite\Client; use Appwrite\Services\Databases; +use Appwrite\Enums\RelationshipType; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createRelationshipAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '[RELATED_COLLECTION_ID]', 'oneToOne'); \ No newline at end of file +$result = $databases->createRelationshipAttribute( + databaseId: '', + collectionId: '', + relatedCollectionId: '', + type: RelationshipType::ONETOONE(), + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate::CASCADE() // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 50abd0a..2a88397 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -3,14 +3,20 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', 1, false); \ No newline at end of file +$result = $databases->createStringAttribute( + databaseId: '', + collectionId: '', + key: '', + size: 1, + required: false, + default: '', // optional + array: false, // optional + encrypt: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 5520cb1..299ff70 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->createUrlAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createUrlAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'https://example.com', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 16176b9..10f46ff 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->create('[DATABASE_ID]', '[NAME]'); \ No newline at end of file +$result = $databases->create( + databaseId: '', + name: '', + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index d89c7de..097e7f0 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->deleteAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->deleteAttribute( + databaseId: '', + collectionId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 29c627b..5c3606b 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->deleteCollection('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->deleteCollection( + databaseId: '', + collectionId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 9d5f1f0..892dc03 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); -$result = $databases->deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file +$result = $databases->deleteDocument( + databaseId: '', + collectionId: '', + documentId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 073aa3a..f0ba6e7 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->deleteIndex('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->deleteIndex( + databaseId: '', + collectionId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 3dab79b..999fe3a 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->delete('[DATABASE_ID]'); \ No newline at end of file +$result = $databases->delete( + databaseId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index c286a76..87f684e 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->getAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->getAttribute( + databaseId: '', + collectionId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 7cc578d..cf9fa77 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->getCollection('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->getCollection( + databaseId: '', + collectionId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 7637e03..25bc79a 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); -$result = $databases->getDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file +$result = $databases->getDocument( + databaseId: '', + collectionId: '', + documentId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index a674a59..be8fab3 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->getIndex('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->getIndex( + databaseId: '', + collectionId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index adc415f..d30acdc 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->get('[DATABASE_ID]'); \ No newline at end of file +$result = $databases->get( + databaseId: '' +); \ No newline at end of file diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 424c4b2..2e087d0 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->listAttributes('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->listAttributes( + databaseId: '', + collectionId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 3f311f3..0f43e4d 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->listCollections('[DATABASE_ID]'); \ No newline at end of file +$result = $databases->listCollections( + databaseId: '', + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index c9a6bbe..bead79b 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); -$result = $databases->listDocuments('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->listDocuments( + databaseId: '', + collectionId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 733d20b..2ba17a4 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->listIndexes('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->listIndexes( + databaseId: '', + collectionId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 4596371..d2bfe71 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->list(); \ No newline at end of file +$result = $databases->list( + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index 9e8b869..a070a83 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateBooleanAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, false); \ No newline at end of file +$result = $databases->updateBooleanAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: false +); \ No newline at end of file diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 878bf20..c923217 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); \ No newline at end of file +$result = $databases->updateCollection( + databaseId: '', + collectionId: '', + name: '', + permissions: ["read("any")"], // optional + documentSecurity: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index 26214fb..e4e89ad 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateDatetimeAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, ''); \ No newline at end of file +$result = $databases->updateDatetimeAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '' +); \ No newline at end of file diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 796e460..837653f 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); -$result = $databases->updateDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file +$result = $databases->updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: [], // optional + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index 7278881..518a255 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateEmailAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, 'email@example.com'); \ No newline at end of file +$result = $databases->updateEmailAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'email@example.com' +); \ No newline at end of file diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index a77211b..55368c6 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateEnumAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], false, '[DEFAULT]'); \ No newline at end of file +$result = $databases->updateEnumAttribute( + databaseId: '', + collectionId: '', + key: '', + elements: [], + required: false, + default: '' +); \ No newline at end of file diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index e73793e..a7ec238 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -3,14 +3,19 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, null, null, null); \ No newline at end of file +$result = $databases->updateFloatAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, + max: null, + default: null +); \ No newline at end of file diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 1cff205..4567a3c 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -3,14 +3,19 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateIntegerAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, null, null, null); \ No newline at end of file +$result = $databases->updateIntegerAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, + max: null, + default: null +); \ No newline at end of file diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index bb49d89..8e7c87b 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, ''); \ No newline at end of file +$result = $databases->updateIpAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '' +); \ No newline at end of file diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index b68025b..756de78 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateRelationshipAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->updateRelationshipAttribute( + databaseId: '', + collectionId: '', + key: '', + onDelete: RelationMutate::CASCADE() // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 775d0fa..819aee4 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, '[DEFAULT]'); \ No newline at end of file +$result = $databases->updateStringAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '' +); \ No newline at end of file diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 6d4845e..d7f9c89 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->updateUrlAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false, 'https://example.com'); \ No newline at end of file +$result = $databases->updateUrlAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'https://example.com' +); \ No newline at end of file diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index db1ae76..484875a 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Databases; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $databases = new Databases($client); -$result = $databases->update('[DATABASE_ID]', '[NAME]'); \ No newline at end of file +$result = $databases->update( + databaseId: '', + name: '', + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/functions/create-build.md b/docs/examples/functions/create-build.md index ac66cc2..6d60cb8 100644 --- a/docs/examples/functions/create-build.md +++ b/docs/examples/functions/create-build.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->createBuild('[FUNCTION_ID]', '[DEPLOYMENT_ID]', '[BUILD_ID]'); \ No newline at end of file +$result = $functions->createBuild( + functionId: '', + deploymentId: '', + buildId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index b219b50..370ca1d 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -4,14 +4,17 @@ use Appwrite\Client; use Appwrite\InputFile; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->createDeployment('[FUNCTION_ID]', InputFile::withPath('file.png'), false); \ No newline at end of file +$result = $functions->createDeployment( + functionId: '', + code: InputFile::withPath('file.png'), + activate: false, + entrypoint: '', // optional + commands: '' // optional +); \ No newline at end of file diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 038126a..59493d4 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -3,14 +3,18 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $functions = new Functions($client); -$result = $functions->createExecution('[FUNCTION_ID]'); \ No newline at end of file +$result = $functions->createExecution( + functionId: '', + body: '', // optional + async: false, // optional + path: '', // optional + method: ExecutionMethod::GET(), // optional + headers: [] // optional +); \ No newline at end of file diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index f09e618..f1d35c3 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->createVariable('[FUNCTION_ID]', '[KEY]', '[VALUE]'); \ No newline at end of file +$result = $functions->createVariable( + functionId: '', + key: '', + value: '' +); \ No newline at end of file diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index cd4b02b..0c282ba 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -2,15 +2,34 @@ use Appwrite\Client; use Appwrite\Services\Functions; +use Appwrite\Enums\; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->create('[FUNCTION_ID]', '[NAME]', 'node-18.0'); \ No newline at end of file +$result = $functions->create( + functionId: '', + name: '', + runtime: ::NODE145(), + execute: ["any"], // optional + events: [], // optional + schedule: '', // optional + timeout: 1, // optional + enabled: false, // optional + logging: false, // optional + entrypoint: '', // optional + commands: '', // optional + installationId: '', // optional + providerRepositoryId: '', // optional + providerBranch: '', // optional + providerSilentMode: false, // optional + providerRootDirectory: '', // optional + templateRepository: '', // optional + templateOwner: '', // optional + templateRootDirectory: '', // optional + templateBranch: '' // optional +); \ No newline at end of file diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index 7227cd9..6a609cd 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->deleteDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]'); \ No newline at end of file +$result = $functions->deleteDeployment( + functionId: '', + deploymentId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index a457846..d25df57 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->deleteVariable('[FUNCTION_ID]', '[VARIABLE_ID]'); \ No newline at end of file +$result = $functions->deleteVariable( + functionId: '', + variableId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index d06c732..08b5cc4 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->delete('[FUNCTION_ID]'); \ No newline at end of file +$result = $functions->delete( + functionId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/download-deployment.md b/docs/examples/functions/download-deployment.md index d7a6d55..9f3b3da 100644 --- a/docs/examples/functions/download-deployment.md +++ b/docs/examples/functions/download-deployment.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->downloadDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]'); \ No newline at end of file +$result = $functions->downloadDeployment( + functionId: '', + deploymentId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 4c4fe49..12e37f3 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->getDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]'); \ No newline at end of file +$result = $functions->getDeployment( + functionId: '', + deploymentId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index ff59dc1..47270d6 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $functions = new Functions($client); -$result = $functions->getExecution('[FUNCTION_ID]', '[EXECUTION_ID]'); \ No newline at end of file +$result = $functions->getExecution( + functionId: '', + executionId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index e80b8f9..3635372 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->getVariable('[FUNCTION_ID]', '[VARIABLE_ID]'); \ No newline at end of file +$result = $functions->getVariable( + functionId: '', + variableId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index aef5806..00993f7 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->get('[FUNCTION_ID]'); \ No newline at end of file +$result = $functions->get( + functionId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 366e5fd..7f64808 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->listDeployments('[FUNCTION_ID]'); \ No newline at end of file +$result = $functions->listDeployments( + functionId: '', + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 34a80ad..b446868 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $functions = new Functions($client); -$result = $functions->listExecutions('[FUNCTION_ID]'); \ No newline at end of file +$result = $functions->listExecutions( + functionId: '', + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index b35dadf..75be157 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->listRuntimes(); \ No newline at end of file +$result = $functions->listRuntimes(); diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index cf74289..681102b 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->listVariables('[FUNCTION_ID]'); \ No newline at end of file +$result = $functions->listVariables( + functionId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index f578755..b59494b 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->list(); \ No newline at end of file +$result = $functions->list( + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/functions/update-deployment.md b/docs/examples/functions/update-deployment.md index b5f09cd..4405767 100644 --- a/docs/examples/functions/update-deployment.md +++ b/docs/examples/functions/update-deployment.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->updateDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]'); \ No newline at end of file +$result = $functions->updateDeployment( + functionId: '', + deploymentId: '' +); \ No newline at end of file diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 4eb52d9..cdce618 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->updateVariable('[FUNCTION_ID]', '[VARIABLE_ID]', '[KEY]'); \ No newline at end of file +$result = $functions->updateVariable( + functionId: '', + variableId: '', + key: '', + value: '' // optional +); \ No newline at end of file diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 072ff5c..e55108f 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -3,14 +3,28 @@ use Appwrite\Client; use Appwrite\Services\Functions; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $functions = new Functions($client); -$result = $functions->update('[FUNCTION_ID]', '[NAME]'); \ No newline at end of file +$result = $functions->update( + functionId: '', + name: '', + runtime: ::NODE145(), // optional + execute: ["any"], // optional + events: [], // optional + schedule: '', // optional + timeout: 1, // optional + enabled: false, // optional + logging: false, // optional + entrypoint: '', // optional + commands: '', // optional + installationId: '', // optional + providerRepositoryId: '', // optional + providerBranch: '', // optional + providerSilentMode: false, // optional + providerRootDirectory: '' // optional +); \ No newline at end of file diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 5622f7f..1be4802 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Graphql; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $graphql = new Graphql($client); -$result = $graphql->mutation([]); \ No newline at end of file +$result = $graphql->mutation( + query: [] +); \ No newline at end of file diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 3ca1d94..5467fe1 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Graphql; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $graphql = new Graphql($client); -$result = $graphql->query([]); \ No newline at end of file +$result = $graphql->query( + query: [] +); \ No newline at end of file diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index 4f14835..7f4fcb8 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/health/get-antivirus.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getAntivirus(); \ No newline at end of file +$result = $health->getAntivirus(); diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 3d1b19b..4fe6e69 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getCache(); \ No newline at end of file +$result = $health->getCache(); diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md new file mode 100644 index 0000000..1f4d55e --- /dev/null +++ b/docs/examples/health/get-certificate.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$health = new Health($client); + +$result = $health->getCertificate( + domain: '' // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md index c03ba23..ca1349b 100644 --- a/docs/examples/health/get-d-b.md +++ b/docs/examples/health/get-d-b.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getDB(); \ No newline at end of file +$result = $health->getDB(); diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md new file mode 100644 index 0000000..94a8d74 --- /dev/null +++ b/docs/examples/health/get-failed-jobs.md @@ -0,0 +1,17 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$health = new Health($client); + +$result = $health->getFailedJobs( + name: ::V1DATABASE(), + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md index 721b5c2..63cd764 100644 --- a/docs/examples/health/get-pub-sub.md +++ b/docs/examples/health/get-pub-sub.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getPubSub(); \ No newline at end of file +$result = $health->getPubSub(); diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md index 71d6ea8..56d342b 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/health/get-queue-builds.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueBuilds(); \ No newline at end of file +$result = $health->getQueueBuilds( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 76236de..10c1308 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueCertificates(); \ No newline at end of file +$result = $health->getQueueCertificates( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md index 154625a..c51e123 100644 --- a/docs/examples/health/get-queue-databases.md +++ b/docs/examples/health/get-queue-databases.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueDatabases(); \ No newline at end of file +$result = $health->getQueueDatabases( + name: '', // optional + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md index 84107ad..70dcaca 100644 --- a/docs/examples/health/get-queue-deletes.md +++ b/docs/examples/health/get-queue-deletes.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueDeletes(); \ No newline at end of file +$result = $health->getQueueDeletes( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index 31f65de..46cde88 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueFunctions(); \ No newline at end of file +$result = $health->getQueueFunctions( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index ff1adb2..c982068 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueLogs(); \ No newline at end of file +$result = $health->getQueueLogs( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md index ec7459a..ad415fc 100644 --- a/docs/examples/health/get-queue-mails.md +++ b/docs/examples/health/get-queue-mails.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueMails(); \ No newline at end of file +$result = $health->getQueueMails( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md index 4b47d2f..a722d2f 100644 --- a/docs/examples/health/get-queue-messaging.md +++ b/docs/examples/health/get-queue-messaging.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueMessaging(); \ No newline at end of file +$result = $health->getQueueMessaging( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md index 3b7a001..2e2826d 100644 --- a/docs/examples/health/get-queue-migrations.md +++ b/docs/examples/health/get-queue-migrations.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueMigrations(); \ No newline at end of file +$result = $health->getQueueMigrations( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-usage-dump.md b/docs/examples/health/get-queue-usage-dump.md new file mode 100644 index 0000000..050cbeb --- /dev/null +++ b/docs/examples/health/get-queue-usage-dump.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$health = new Health($client); + +$result = $health->getQueueUsageDump( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000..d9a3fb9 --- /dev/null +++ b/docs/examples/health/get-queue-usage.md @@ -0,0 +1,15 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$health = new Health($client); + +$result = $health->getQueueUsage( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index 99592bc..e1d6e6f 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueueWebhooks(); \ No newline at end of file +$result = $health->getQueueWebhooks( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/health/get-queue.md b/docs/examples/health/get-queue.md index 9feb1ad..a8b1393 100644 --- a/docs/examples/health/get-queue.md +++ b/docs/examples/health/get-queue.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getQueue(); \ No newline at end of file +$result = $health->getQueue(); diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index 55212c3..43bef96 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getStorageLocal(); \ No newline at end of file +$result = $health->getStorageLocal(); diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md new file mode 100644 index 0000000..d5d817a --- /dev/null +++ b/docs/examples/health/get-storage.md @@ -0,0 +1,13 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$health = new Health($client); + +$result = $health->getStorage(); diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index 5410124..d31e757 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->getTime(); \ No newline at end of file +$result = $health->getTime(); diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index 62cab8a..6e8216c 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Health; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $health = new Health($client); -$result = $health->get(); \ No newline at end of file +$result = $health->get(); diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index c491046..beecee9 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->get(); \ No newline at end of file +$result = $locale->get(); diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index 55207ce..699326f 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listCodes(); \ No newline at end of file +$result = $locale->listCodes(); diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 9cd8fb1..038f099 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listContinents(); \ No newline at end of file +$result = $locale->listContinents(); diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md index 1f2ef98..1b895e5 100644 --- a/docs/examples/locale/list-countries-e-u.md +++ b/docs/examples/locale/list-countries-e-u.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listCountriesEU(); \ No newline at end of file +$result = $locale->listCountriesEU(); diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 6f8acb7..503ff39 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listCountriesPhones(); \ No newline at end of file +$result = $locale->listCountriesPhones(); diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 28c518e..3e092d7 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listCountries(); \ No newline at end of file +$result = $locale->listCountries(); diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index 37784f3..81157c9 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listCurrencies(); \ No newline at end of file +$result = $locale->listCurrencies(); diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index 8b4f082..31de740 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -3,14 +3,11 @@ use Appwrite\Client; use Appwrite\Services\Locale; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $locale = new Locale($client); -$result = $locale->listLanguages(); \ No newline at end of file +$result = $locale->listLanguages(); diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md new file mode 100644 index 0000000..4814078 --- /dev/null +++ b/docs/examples/messaging/create-apns-provider.md @@ -0,0 +1,22 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createApnsProvider( + providerId: '', + name: '', + authKey: '', // optional + authKeyId: '', // optional + teamId: '', // optional + bundleId: '', // optional + sandbox: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md new file mode 100644 index 0000000..8327f74 --- /dev/null +++ b/docs/examples/messaging/create-email.md @@ -0,0 +1,26 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createEmail( + messageId: '', + subject: '', + content: '', + topics: [], // optional + users: [], // optional + targets: [], // optional + cc: [], // optional + bcc: [], // optional + attachments: [], // optional + draft: false, // optional + html: false, // optional + scheduledAt: '' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md new file mode 100644 index 0000000..4bb7123 --- /dev/null +++ b/docs/examples/messaging/create-fcm-provider.md @@ -0,0 +1,18 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createFcmProvider( + providerId: '', + name: '', + serviceAccountJSON: [], // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md new file mode 100644 index 0000000..8ffa70c --- /dev/null +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -0,0 +1,24 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createMailgunProvider( + providerId: '', + name: '', + apiKey: '', // optional + domain: '', // optional + isEuRegion: false, // optional + fromName: '', // optional + fromEmail: 'email@example.com', // optional + replyToName: '', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg91provider.md new file mode 100644 index 0000000..7325093 --- /dev/null +++ b/docs/examples/messaging/create-msg91provider.md @@ -0,0 +1,20 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createMsg91Provider( + providerId: '', + name: '', + from: '+12065550100', // optional + senderId: '', // optional + authKey: '', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md new file mode 100644 index 0000000..7b7eb8e --- /dev/null +++ b/docs/examples/messaging/create-push.md @@ -0,0 +1,30 @@ +setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createPush( + messageId: '', + title: '', + body: '<BODY>', + topics: [], // optional + users: [], // optional + targets: [], // optional + data: [], // optional + action: '<ACTION>', // optional + image: '[ID1:ID2]', // optional + icon: '<ICON>', // optional + sound: '<SOUND>', // optional + color: '<COLOR>', // optional + tag: '<TAG>', // optional + badge: '<BADGE>', // optional + draft: false, // optional + scheduledAt: '' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md new file mode 100644 index 0000000..fbaa819 --- /dev/null +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -0,0 +1,22 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createSendgridProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md new file mode 100644 index 0000000..ae28808 --- /dev/null +++ b/docs/examples/messaging/create-sms.md @@ -0,0 +1,21 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createSms( + messageId: '<MESSAGE_ID>', + content: '<CONTENT>', + topics: [], // optional + users: [], // optional + targets: [], // optional + draft: false, // optional + scheduledAt: '' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md new file mode 100644 index 0000000..4c6d384 --- /dev/null +++ b/docs/examples/messaging/create-smtp-provider.md @@ -0,0 +1,28 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createSmtpProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + host: '<HOST>', + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: SmtpEncryption::NONE(), // optional + autoTLS: false, // optional + mailer: '<MAILER>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md new file mode 100644 index 0000000..36a2a76 --- /dev/null +++ b/docs/examples/messaging/create-subscriber.md @@ -0,0 +1,17 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...'); // Your secret JSON Web Token + +$messaging = new Messaging($client); + +$result = $messaging->createSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', + targetId: '<TARGET_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md new file mode 100644 index 0000000..d84c93f --- /dev/null +++ b/docs/examples/messaging/create-telesign-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createTelesignProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + customerId: '<CUSTOMER_ID>', // optional + apiKey: '<API_KEY>', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md new file mode 100644 index 0000000..c1d0337 --- /dev/null +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createTextmagicProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + username: '<USERNAME>', // optional + apiKey: '<API_KEY>', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md new file mode 100644 index 0000000..bf21494 --- /dev/null +++ b/docs/examples/messaging/create-topic.md @@ -0,0 +1,17 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createTopic( + topicId: '<TOPIC_ID>', + name: '<NAME>', + subscribe: ["any"] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md new file mode 100644 index 0000000..915cc94 --- /dev/null +++ b/docs/examples/messaging/create-twilio-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createTwilioProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + accountSid: '<ACCOUNT_SID>', // optional + authToken: '<AUTH_TOKEN>', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md new file mode 100644 index 0000000..bd1e665 --- /dev/null +++ b/docs/examples/messaging/create-vonage-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->createVonageProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md new file mode 100644 index 0000000..b52e5f0 --- /dev/null +++ b/docs/examples/messaging/delete-provider.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->deleteProvider( + providerId: '<PROVIDER_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md new file mode 100644 index 0000000..1736d00 --- /dev/null +++ b/docs/examples/messaging/delete-subscriber.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...'); // Your secret JSON Web Token + +$messaging = new Messaging($client); + +$result = $messaging->deleteSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md new file mode 100644 index 0000000..25ed35e --- /dev/null +++ b/docs/examples/messaging/delete-topic.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->deleteTopic( + topicId: '<TOPIC_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md new file mode 100644 index 0000000..5c05eed --- /dev/null +++ b/docs/examples/messaging/delete.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->delete( + messageId: '<MESSAGE_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md new file mode 100644 index 0000000..47b6afd --- /dev/null +++ b/docs/examples/messaging/get-message.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->getMessage( + messageId: '<MESSAGE_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md new file mode 100644 index 0000000..1576107 --- /dev/null +++ b/docs/examples/messaging/get-provider.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->getProvider( + providerId: '<PROVIDER_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md new file mode 100644 index 0000000..3fa4c0a --- /dev/null +++ b/docs/examples/messaging/get-subscriber.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->getSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md new file mode 100644 index 0000000..f732fcb --- /dev/null +++ b/docs/examples/messaging/get-topic.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->getTopic( + topicId: '<TOPIC_ID>' +); \ No newline at end of file diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md new file mode 100644 index 0000000..58c026e --- /dev/null +++ b/docs/examples/messaging/list-message-logs.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listMessageLogs( + messageId: '<MESSAGE_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md new file mode 100644 index 0000000..681863b --- /dev/null +++ b/docs/examples/messaging/list-messages.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listMessages( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md new file mode 100644 index 0000000..3809e67 --- /dev/null +++ b/docs/examples/messaging/list-provider-logs.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listProviderLogs( + providerId: '<PROVIDER_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md new file mode 100644 index 0000000..99c8cc1 --- /dev/null +++ b/docs/examples/messaging/list-providers.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listProviders( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md new file mode 100644 index 0000000..4583790 --- /dev/null +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listSubscriberLogs( + subscriberId: '<SUBSCRIBER_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md new file mode 100644 index 0000000..36054d2 --- /dev/null +++ b/docs/examples/messaging/list-subscribers.md @@ -0,0 +1,17 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listSubscribers( + topicId: '<TOPIC_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md new file mode 100644 index 0000000..b12aa44 --- /dev/null +++ b/docs/examples/messaging/list-targets.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listTargets( + messageId: '<MESSAGE_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md new file mode 100644 index 0000000..49bcc04 --- /dev/null +++ b/docs/examples/messaging/list-topic-logs.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listTopicLogs( + topicId: '<TOPIC_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md new file mode 100644 index 0000000..565504a --- /dev/null +++ b/docs/examples/messaging/list-topics.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->listTopics( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md new file mode 100644 index 0000000..5de36f2 --- /dev/null +++ b/docs/examples/messaging/update-apns-provider.md @@ -0,0 +1,22 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateApnsProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + authKey: '<AUTH_KEY>', // optional + authKeyId: '<AUTH_KEY_ID>', // optional + teamId: '<TEAM_ID>', // optional + bundleId: '<BUNDLE_ID>', // optional + sandbox: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md new file mode 100644 index 0000000..ee95fa0 --- /dev/null +++ b/docs/examples/messaging/update-email.md @@ -0,0 +1,25 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateEmail( + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional + cc: [], // optional + bcc: [], // optional + scheduledAt: '' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md new file mode 100644 index 0000000..2cadd87 --- /dev/null +++ b/docs/examples/messaging/update-fcm-provider.md @@ -0,0 +1,18 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateFcmProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + serviceAccountJSON: [] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md new file mode 100644 index 0000000..7f36655 --- /dev/null +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -0,0 +1,24 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateMailgunProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + apiKey: '<API_KEY>', // optional + domain: '<DOMAIN>', // optional + isEuRegion: false, // optional + enabled: false, // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg91provider.md new file mode 100644 index 0000000..8ec9bf5 --- /dev/null +++ b/docs/examples/messaging/update-msg91provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateMsg91Provider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + senderId: '<SENDER_ID>', // optional + authKey: '<AUTH_KEY>', // optional + from: '<FROM>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md new file mode 100644 index 0000000..204c63d --- /dev/null +++ b/docs/examples/messaging/update-push.md @@ -0,0 +1,30 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updatePush( + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional + data: [], // optional + action: '<ACTION>', // optional + image: '[ID1:ID2]', // optional + icon: '<ICON>', // optional + sound: '<SOUND>', // optional + color: '<COLOR>', // optional + tag: '<TAG>', // optional + badge: null, // optional + draft: false, // optional + scheduledAt: '' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md new file mode 100644 index 0000000..61253a4 --- /dev/null +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -0,0 +1,22 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateSendgridProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md new file mode 100644 index 0000000..9f4b241 --- /dev/null +++ b/docs/examples/messaging/update-sms.md @@ -0,0 +1,21 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateSms( + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + content: '<CONTENT>', // optional + draft: false, // optional + scheduledAt: '' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md new file mode 100644 index 0000000..e4b0ad8 --- /dev/null +++ b/docs/examples/messaging/update-smtp-provider.md @@ -0,0 +1,28 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateSmtpProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + host: '<HOST>', // optional + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: SmtpEncryption::NONE(), // optional + autoTLS: false, // optional + mailer: '<MAILER>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md new file mode 100644 index 0000000..b77a45c --- /dev/null +++ b/docs/examples/messaging/update-telesign-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateTelesignProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + customerId: '<CUSTOMER_ID>', // optional + apiKey: '<API_KEY>', // optional + from: '<FROM>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md new file mode 100644 index 0000000..e3e3f2b --- /dev/null +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateTextmagicProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + username: '<USERNAME>', // optional + apiKey: '<API_KEY>', // optional + from: '<FROM>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md new file mode 100644 index 0000000..50671b1 --- /dev/null +++ b/docs/examples/messaging/update-topic.md @@ -0,0 +1,17 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateTopic( + topicId: '<TOPIC_ID>', + name: '<NAME>', // optional + subscribe: ["any"] // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md new file mode 100644 index 0000000..60eef45 --- /dev/null +++ b/docs/examples/messaging/update-twilio-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateTwilioProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + accountSid: '<ACCOUNT_SID>', // optional + authToken: '<AUTH_TOKEN>', // optional + from: '<FROM>' // optional +); \ No newline at end of file diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md new file mode 100644 index 0000000..4a3ee5a --- /dev/null +++ b/docs/examples/messaging/update-vonage-provider.md @@ -0,0 +1,20 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Messaging; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$messaging = new Messaging($client); + +$result = $messaging->updateVonageProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + from: '<FROM>' // optional +); \ No newline at end of file diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index bf54c22..0582e18 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -3,14 +3,22 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $storage = new Storage($client); -$result = $storage->createBucket('[BUCKET_ID]', '[NAME]'); \ No newline at end of file +$result = $storage->createBucket( + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: ::NONE(), // optional + encryption: false, // optional + antivirus: false // optional +); \ No newline at end of file diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index e2cfce7..e73af54 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -4,14 +4,16 @@ use Appwrite\Client; use Appwrite\InputFile; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->createFile('[BUCKET_ID]', '[FILE_ID]', InputFile::withPath('file.png')); \ No newline at end of file +$result = $storage->createFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + file: InputFile::withPath('file.png'), + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index b3659b6..6d5278d 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $storage = new Storage($client); -$result = $storage->deleteBucket('[BUCKET_ID]'); \ No newline at end of file +$result = $storage->deleteBucket( + bucketId: '<BUCKET_ID>' +); \ No newline at end of file diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 00db855..eff096d 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->deleteFile('[BUCKET_ID]', '[FILE_ID]'); \ No newline at end of file +$result = $storage->deleteFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>' +); \ No newline at end of file diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index d4d152a..a7a8c1d 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $storage = new Storage($client); -$result = $storage->getBucket('[BUCKET_ID]'); \ No newline at end of file +$result = $storage->getBucket( + bucketId: '<BUCKET_ID>' +); \ No newline at end of file diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 0c7fefd..1d49695 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->getFileDownload('[BUCKET_ID]', '[FILE_ID]'); \ No newline at end of file +$result = $storage->getFileDownload( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>' +); \ No newline at end of file diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index c1b91e5..519ee53 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -3,14 +3,25 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->getFilePreview('[BUCKET_ID]', '[FILE_ID]'); \ No newline at end of file +$result = $storage->getFilePreview( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + width: 0, // optional + height: 0, // optional + gravity: ImageGravity::CENTER(), // optional + quality: 0, // optional + borderWidth: 0, // optional + borderColor: '', // optional + borderRadius: 0, // optional + opacity: 0, // optional + rotation: -360, // optional + background: '', // optional + output: ImageFormat::JPG() // optional +); \ No newline at end of file diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index f527c1b..9e37230 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->getFileView('[BUCKET_ID]', '[FILE_ID]'); \ No newline at end of file +$result = $storage->getFileView( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>' +); \ No newline at end of file diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index cb56c96..894c8bb 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->getFile('[BUCKET_ID]', '[FILE_ID]'); \ No newline at end of file +$result = $storage->getFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>' +); \ No newline at end of file diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index b92dc82..06f4e2a 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $storage = new Storage($client); -$result = $storage->listBuckets(); \ No newline at end of file +$result = $storage->listBuckets( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index e0b7918..824ae30 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->listFiles('[BUCKET_ID]'); \ No newline at end of file +$result = $storage->listFiles( + bucketId: '<BUCKET_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 5e46dfc..451ff80 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -3,14 +3,22 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $storage = new Storage($client); -$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]'); \ No newline at end of file +$result = $storage->updateBucket( + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: ::NONE(), // optional + encryption: false, // optional + antivirus: false // optional +); \ No newline at end of file diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 1d3e01e..531a843 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Storage; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $storage = new Storage($client); -$result = $storage->updateFile('[BUCKET_ID]', '[FILE_ID]'); \ No newline at end of file +$result = $storage->updateFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + name: '<NAME>', // optional + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index b20e15f..ef9bf44 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -3,14 +3,19 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->createMembership('[TEAM_ID]', []); \ No newline at end of file +$result = $teams->createMembership( + teamId: '<TEAM_ID>', + roles: [], + email: 'email@example.com', // optional + userId: '<USER_ID>', // optional + phone: '+12065550100', // optional + url: 'https://example.com', // optional + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index e5efe49..de01cbc 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->create('[TEAM_ID]', '[NAME]'); \ No newline at end of file +$result = $teams->create( + teamId: '<TEAM_ID>', + name: '<NAME>', + roles: [] // optional +); \ No newline at end of file diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 2b40c17..b68b692 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->deleteMembership('[TEAM_ID]', '[MEMBERSHIP_ID]'); \ No newline at end of file +$result = $teams->deleteMembership( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>' +); \ No newline at end of file diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 5ec2ed9..45f2100 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->delete('[TEAM_ID]'); \ No newline at end of file +$result = $teams->delete( + teamId: '<TEAM_ID>' +); \ No newline at end of file diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index fdd3024..f075372 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->getMembership('[TEAM_ID]', '[MEMBERSHIP_ID]'); \ No newline at end of file +$result = $teams->getMembership( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>' +); \ No newline at end of file diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 0436f96..738a6c7 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->getPrefs('[TEAM_ID]'); \ No newline at end of file +$result = $teams->getPrefs( + teamId: '<TEAM_ID>' +); \ No newline at end of file diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 94b8a26..f68c415 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->get('[TEAM_ID]'); \ No newline at end of file +$result = $teams->get( + teamId: '<TEAM_ID>' +); \ No newline at end of file diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index f23b78e..27d5d00 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->listMemberships('[TEAM_ID]'); \ No newline at end of file +$result = $teams->listMemberships( + teamId: '<TEAM_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 66f54b6..90cdcfd 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->list(); \ No newline at end of file +$result = $teams->list( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 15504ad..4a802a5 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->updateMembershipStatus('[TEAM_ID]', '[MEMBERSHIP_ID]', '[USER_ID]', '[SECRET]'); \ No newline at end of file +$result = $teams->updateMembershipStatus( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + userId: '<USER_ID>', + secret: '<SECRET>' +); \ No newline at end of file diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 37b8fa7..308f7f1 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -3,14 +3,15 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->updateMembership('[TEAM_ID]', '[MEMBERSHIP_ID]', []); \ No newline at end of file +$result = $teams->updateMembership( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + roles: [] +); \ No newline at end of file diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index e88a318..088d32e 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->updateName('[TEAM_ID]', '[NAME]'); \ No newline at end of file +$result = $teams->updateName( + teamId: '<TEAM_ID>', + name: '<NAME>' +); \ No newline at end of file diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index 4d044cc..c2a9aad 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Teams; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token -; + ->setSession(''); // The user session to authenticate with $teams = new Teams($client); -$result = $teams->updatePrefs('[TEAM_ID]', []); \ No newline at end of file +$result = $teams->updatePrefs( + teamId: '<TEAM_ID>', + prefs: [] +); \ No newline at end of file diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md index 1036ca1..db01dda 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-argon2user.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createArgon2User('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file +$result = $users->createArgon2User( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index de15110..0a061f9 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createBcryptUser('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file +$result = $users->createBcryptUser( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md index 15f4ebe..400b6bd 100644 --- a/docs/examples/users/create-m-d5user.md +++ b/docs/examples/users/create-m-d5user.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createMD5User('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file +$result = $users->createMD5User( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md new file mode 100644 index 0000000..e8b3b60 --- /dev/null +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->createMfaRecoveryCodes( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md index 2eb682f..e0d7342 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-p-h-pass-user.md @@ -3,14 +3,16 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createPHPassUser('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file +$result = $users->createPHPassUser( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md index 3e63bd9..9cb35ee 100644 --- a/docs/examples/users/create-s-h-a-user.md +++ b/docs/examples/users/create-s-h-a-user.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createSHAUser('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file +$result = $users->createSHAUser( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordVersion: PasswordHash::SHA1(), // optional + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index bcf7c52..325745d 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -3,14 +3,19 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createScryptModifiedUser('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', '[PASSWORD_SALT_SEPARATOR]', '[PASSWORD_SIGNER_KEY]'); \ No newline at end of file +$result = $users->createScryptModifiedUser( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordSalt: '<PASSWORD_SALT>', + passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>', + passwordSignerKey: '<PASSWORD_SIGNER_KEY>', + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index 43a4bcc..0828acc 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -3,14 +3,21 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->createScryptUser('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', null, null, null, null); \ No newline at end of file +$result = $users->createScryptUser( + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordSalt: '<PASSWORD_SALT>', + passwordCpu: null, + passwordMemory: null, + passwordParallel: null, + passwordLength: null, + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md new file mode 100644 index 0000000..c4f9052 --- /dev/null +++ b/docs/examples/users/create-session.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->createSession( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md new file mode 100644 index 0000000..2820472 --- /dev/null +++ b/docs/examples/users/create-target.md @@ -0,0 +1,21 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; +use Appwrite\Enums\MessagingProviderType; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->createTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + providerType: MessagingProviderType::EMAIL(), + identifier: '<IDENTIFIER>', + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md new file mode 100644 index 0000000..83f05e1 --- /dev/null +++ b/docs/examples/users/create-token.md @@ -0,0 +1,17 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->createToken( + userId: '<USER_ID>', + length: 4, // optional + expire: 60 // optional +); \ No newline at end of file diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index dab8a5e..7cf4b6f 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -3,14 +3,17 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->create('[USER_ID]'); \ No newline at end of file +$result = $users->create( + userId: '<USER_ID>', + email: 'email@example.com', // optional + phone: '+12065550100', // optional + password: '', // optional + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index a252227..81751a1 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->deleteIdentity('[IDENTITY_ID]'); \ No newline at end of file +$result = $users->deleteIdentity( + identityId: '<IDENTITY_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md new file mode 100644 index 0000000..aa7405e --- /dev/null +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -0,0 +1,17 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; +use Appwrite\Enums\AuthenticatorType; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->deleteMfaAuthenticator( + userId: '<USER_ID>', + type: AuthenticatorType::TOTP() +); \ No newline at end of file diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index c6a507c..3ef58aa 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->deleteSession('[USER_ID]', '[SESSION_ID]'); \ No newline at end of file +$result = $users->deleteSession( + userId: '<USER_ID>', + sessionId: '<SESSION_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 570d258..e89b65f 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->deleteSessions('[USER_ID]'); \ No newline at end of file +$result = $users->deleteSessions( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md new file mode 100644 index 0000000..444c496 --- /dev/null +++ b/docs/examples/users/delete-target.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->deleteTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 1d5a822..b715e84 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->delete('[USER_ID]'); \ No newline at end of file +$result = $users->delete( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md new file mode 100644 index 0000000..a852fa5 --- /dev/null +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->getMfaRecoveryCodes( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index e9c8c58..79f778a 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->getPrefs('[USER_ID]'); \ No newline at end of file +$result = $users->getPrefs( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md new file mode 100644 index 0000000..489e1e2 --- /dev/null +++ b/docs/examples/users/get-target.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->getTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 51482d3..5428d73 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->get('[USER_ID]'); \ No newline at end of file +$result = $users->get( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 2d229e4..0fde8a3 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->listIdentities(); \ No newline at end of file +$result = $users->listIdentities( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index e628756..863bab5 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->listLogs('[USER_ID]'); \ No newline at end of file +$result = $users->listLogs( + userId: '<USER_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 039216b..616f014 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->listMemberships('[USER_ID]'); \ No newline at end of file +$result = $users->listMemberships( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md new file mode 100644 index 0000000..3058966 --- /dev/null +++ b/docs/examples/users/list-mfa-factors.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->listMfaFactors( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index e09b65d..3b0c490 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -3,14 +3,13 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->listSessions('[USER_ID]'); \ No newline at end of file +$result = $users->listSessions( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md new file mode 100644 index 0000000..c441a1c --- /dev/null +++ b/docs/examples/users/list-targets.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->listTargets( + userId: '<USER_ID>', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 8d86e86..63616e5 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->list(); \ No newline at end of file +$result = $users->list( + queries: [], // optional + search: '<SEARCH>' // optional +); \ No newline at end of file diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 67c3e12..74ef340 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updateEmailVerification('[USER_ID]', false); \ No newline at end of file +$result = $users->updateEmailVerification( + userId: '<USER_ID>', + emailVerification: false +); \ No newline at end of file diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index c6a7412..fb8e231 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updateEmail('[USER_ID]', 'email@example.com'); \ No newline at end of file +$result = $users->updateEmail( + userId: '<USER_ID>', + email: 'email@example.com' +); \ No newline at end of file diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index b9f4dc3..87e1b66 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updateLabels('[USER_ID]', []); \ No newline at end of file +$result = $users->updateLabels( + userId: '<USER_ID>', + labels: [] +); \ No newline at end of file diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md new file mode 100644 index 0000000..aec96fa --- /dev/null +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -0,0 +1,15 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->updateMfaRecoveryCodes( + userId: '<USER_ID>' +); \ No newline at end of file diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md new file mode 100644 index 0000000..83a3e37 --- /dev/null +++ b/docs/examples/users/update-mfa.md @@ -0,0 +1,16 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->updateMfa( + userId: '<USER_ID>', + mfa: false +); \ No newline at end of file diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 598ef2a..33ca175 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updateName('[USER_ID]', '[NAME]'); \ No newline at end of file +$result = $users->updateName( + userId: '<USER_ID>', + name: '<NAME>' +); \ No newline at end of file diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index de5ec7d..a6226eb 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updatePassword('[USER_ID]', ''); \ No newline at end of file +$result = $users->updatePassword( + userId: '<USER_ID>', + password: '' +); \ No newline at end of file diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index e9929a5..8d26d64 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updatePhoneVerification('[USER_ID]', false); \ No newline at end of file +$result = $users->updatePhoneVerification( + userId: '<USER_ID>', + phoneVerification: false +); \ No newline at end of file diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 0df380a..eb5f55e 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updatePhone('[USER_ID]', '+12065550100'); \ No newline at end of file +$result = $users->updatePhone( + userId: '<USER_ID>', + number: '+12065550100' +); \ No newline at end of file diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index 9c4ebaa..b96ff17 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updatePrefs('[USER_ID]', []); \ No newline at end of file +$result = $users->updatePrefs( + userId: '<USER_ID>', + prefs: [] +); \ No newline at end of file diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index ad3f6bd..ef74801 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -3,14 +3,14 @@ use Appwrite\Client; use Appwrite\Services\Users; -$client = new Client(); - -$client +$client = (new Client()) ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID - ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key $users = new Users($client); -$result = $users->updateStatus('[USER_ID]', false); \ No newline at end of file +$result = $users->updateStatus( + userId: '<USER_ID>', + status: false +); \ No newline at end of file diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md new file mode 100644 index 0000000..4d40c83 --- /dev/null +++ b/docs/examples/users/update-target.md @@ -0,0 +1,19 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = (new Client()) + ->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +$users = new Users($client); + +$result = $users->updateTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + identifier: '<IDENTIFIER>', // optional + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index 7394641..f742744 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -3,7 +3,7 @@ ## List functions ```http request -GET https://HOSTNAME/v1/functions +GET https://cloud.appwrite.io/v1/functions ``` ** Get a list of all the project's functions. You can use the query params to filter your results. ** @@ -18,7 +18,7 @@ GET https://HOSTNAME/v1/functions ## Create function ```http request -POST https://HOSTNAME/v1/functions +POST https://cloud.appwrite.io/v1/functions ``` ** Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. ** @@ -51,7 +51,7 @@ POST https://HOSTNAME/v1/functions ## List runtimes ```http request -GET https://HOSTNAME/v1/functions/runtimes +GET https://cloud.appwrite.io/v1/functions/runtimes ``` ** Get a list of all runtimes that are currently active on your instance. ** @@ -59,7 +59,7 @@ GET https://HOSTNAME/v1/functions/runtimes ## Get function ```http request -GET https://HOSTNAME/v1/functions/{functionId} +GET https://cloud.appwrite.io/v1/functions/{functionId} ``` ** Get a function by its unique ID. ** @@ -73,7 +73,7 @@ GET https://HOSTNAME/v1/functions/{functionId} ## Update function ```http request -PUT https://HOSTNAME/v1/functions/{functionId} +PUT https://cloud.appwrite.io/v1/functions/{functionId} ``` ** Update function by its unique ID. ** @@ -102,7 +102,7 @@ PUT https://HOSTNAME/v1/functions/{functionId} ## Delete function ```http request -DELETE https://HOSTNAME/v1/functions/{functionId} +DELETE https://cloud.appwrite.io/v1/functions/{functionId} ``` ** Delete a function by its unique ID. ** @@ -116,7 +116,7 @@ DELETE https://HOSTNAME/v1/functions/{functionId} ## List deployments ```http request -GET https://HOSTNAME/v1/functions/{functionId}/deployments +GET https://cloud.appwrite.io/v1/functions/{functionId}/deployments ``` ** Get a list of all the project's code deployments. You can use the query params to filter your results. ** @@ -132,7 +132,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/deployments ## Create deployment ```http request -POST https://HOSTNAME/v1/functions/{functionId}/deployments +POST https://cloud.appwrite.io/v1/functions/{functionId}/deployments ``` ** Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. @@ -154,7 +154,7 @@ Use the "command" param to set the entrypoint used to execute your cod ## Get deployment ```http request -GET https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId} +GET https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId} ``` ** Get a code deployment by its unique ID. ** @@ -169,7 +169,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId} ## Update function deployment ```http request -PATCH https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId} +PATCH https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId} ``` ** Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint. ** @@ -184,7 +184,7 @@ PATCH https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId} ## Delete deployment ```http request -DELETE https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId} +DELETE https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId} ``` ** Delete a code deployment by its unique ID. ** @@ -199,7 +199,7 @@ DELETE https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId} ## Create build ```http request -POST https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId}/builds/{buildId} +POST https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId}/builds/{buildId} ``` ** Create a new build for an Appwrite Function deployment. This endpoint can be used to retry a failed build. ** @@ -215,7 +215,7 @@ POST https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId}/build ## Download Deployment ```http request -GET https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId}/download +GET https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentId}/download ``` ** Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download. ** @@ -230,7 +230,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/deployments/{deploymentId}/downlo ## List executions ```http request -GET https://HOSTNAME/v1/functions/{functionId}/executions +GET https://cloud.appwrite.io/v1/functions/{functionId}/executions ``` ** Get a list of all the current user function execution logs. You can use the query params to filter your results. ** @@ -246,7 +246,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/executions ## Create execution ```http request -POST https://HOSTNAME/v1/functions/{functionId}/executions +POST https://cloud.appwrite.io/v1/functions/{functionId}/executions ``` ** Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. ** @@ -265,7 +265,7 @@ POST https://HOSTNAME/v1/functions/{functionId}/executions ## Get execution ```http request -GET https://HOSTNAME/v1/functions/{functionId}/executions/{executionId} +GET https://cloud.appwrite.io/v1/functions/{functionId}/executions/{executionId} ``` ** Get a function execution log by its unique ID. ** @@ -280,7 +280,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/executions/{executionId} ## List variables ```http request -GET https://HOSTNAME/v1/functions/{functionId}/variables +GET https://cloud.appwrite.io/v1/functions/{functionId}/variables ``` ** Get a list of all variables of a specific function. ** @@ -294,7 +294,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/variables ## Create variable ```http request -POST https://HOSTNAME/v1/functions/{functionId}/variables +POST https://cloud.appwrite.io/v1/functions/{functionId}/variables ``` ** Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. ** @@ -310,7 +310,7 @@ POST https://HOSTNAME/v1/functions/{functionId}/variables ## Get variable ```http request -GET https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} +GET https://cloud.appwrite.io/v1/functions/{functionId}/variables/{variableId} ``` ** Get a variable by its unique ID. ** @@ -325,7 +325,7 @@ GET https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} ## Update variable ```http request -PUT https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} +PUT https://cloud.appwrite.io/v1/functions/{functionId}/variables/{variableId} ``` ** Update variable by its unique ID. ** @@ -342,7 +342,7 @@ PUT https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} ## Delete variable ```http request -DELETE https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} +DELETE https://cloud.appwrite.io/v1/functions/{functionId}/variables/{variableId} ``` ** Delete a variable by its unique ID. ** diff --git a/docs/graphql.md b/docs/graphql.md index 9de0180..e012b47 100644 --- a/docs/graphql.md +++ b/docs/graphql.md @@ -3,7 +3,7 @@ ## GraphQL endpoint ```http request -POST https://HOSTNAME/v1/graphql +POST https://cloud.appwrite.io/v1/graphql ``` ** Execute a GraphQL mutation. ** @@ -17,7 +17,7 @@ POST https://HOSTNAME/v1/graphql ## GraphQL endpoint ```http request -POST https://HOSTNAME/v1/graphql/mutation +POST https://cloud.appwrite.io/v1/graphql/mutation ``` ** Execute a GraphQL mutation. ** diff --git a/docs/health.md b/docs/health.md index 4d87ce8..083119e 100644 --- a/docs/health.md +++ b/docs/health.md @@ -3,7 +3,7 @@ ## Get HTTP ```http request -GET https://HOSTNAME/v1/health +GET https://cloud.appwrite.io/v1/health ``` ** Check the Appwrite HTTP server is up and responsive. ** @@ -11,7 +11,7 @@ GET https://HOSTNAME/v1/health ## Get antivirus ```http request -GET https://HOSTNAME/v1/health/anti-virus +GET https://cloud.appwrite.io/v1/health/anti-virus ``` ** Check the Appwrite Antivirus server is up and connection is successful. ** @@ -19,15 +19,29 @@ GET https://HOSTNAME/v1/health/anti-virus ## Get cache ```http request -GET https://HOSTNAME/v1/health/cache +GET https://cloud.appwrite.io/v1/health/cache ``` ** Check the Appwrite in-memory cache servers are up and connection is successful. ** +## Get the SSL certificate for a domain + +```http request +GET https://cloud.appwrite.io/v1/health/certificate +``` + +** Get the SSL certificate for a domain ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| domain | string | string | | + ## Get DB ```http request -GET https://HOSTNAME/v1/health/db +GET https://cloud.appwrite.io/v1/health/db ``` ** Check the Appwrite database servers are up and connection is successful. ** @@ -35,7 +49,7 @@ GET https://HOSTNAME/v1/health/db ## Get pubsub ```http request -GET https://HOSTNAME/v1/health/pubsub +GET https://cloud.appwrite.io/v1/health/pubsub ``` ** Check the Appwrite pub-sub servers are up and connection is successful. ** @@ -43,7 +57,7 @@ GET https://HOSTNAME/v1/health/pubsub ## Get queue ```http request -GET https://HOSTNAME/v1/health/queue +GET https://cloud.appwrite.io/v1/health/queue ``` ** Check the Appwrite queue messaging servers are up and connection is successful. ** @@ -51,7 +65,7 @@ GET https://HOSTNAME/v1/health/queue ## Get builds queue ```http request -GET https://HOSTNAME/v1/health/queue/builds +GET https://cloud.appwrite.io/v1/health/queue/builds ``` ** Get the number of builds that are waiting to be processed in the Appwrite internal queue server. ** @@ -65,7 +79,7 @@ GET https://HOSTNAME/v1/health/queue/builds ## Get certificates queue ```http request -GET https://HOSTNAME/v1/health/queue/certificates +GET https://cloud.appwrite.io/v1/health/queue/certificates ``` ** Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. ** @@ -79,7 +93,7 @@ GET https://HOSTNAME/v1/health/queue/certificates ## Get databases queue ```http request -GET https://HOSTNAME/v1/health/queue/databases +GET https://cloud.appwrite.io/v1/health/queue/databases ``` ** Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. ** @@ -94,7 +108,7 @@ GET https://HOSTNAME/v1/health/queue/databases ## Get deletes queue ```http request -GET https://HOSTNAME/v1/health/queue/deletes +GET https://cloud.appwrite.io/v1/health/queue/deletes ``` ** Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. ** @@ -105,12 +119,30 @@ GET https://HOSTNAME/v1/health/queue/deletes | --- | --- | --- | --- | | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +## Get number of failed queue jobs + +```http request +GET https://cloud.appwrite.io/v1/health/queue/failed/{name} +``` + +** Returns the amount of failed jobs in a given queue. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| name | string | **Required** The name of the queue | | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | + ## Get functions queue ```http request -GET https://HOSTNAME/v1/health/queue/functions +GET https://cloud.appwrite.io/v1/health/queue/functions ``` +** Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. ** + ### Parameters | Field Name | Type | Description | Default | @@ -120,7 +152,7 @@ GET https://HOSTNAME/v1/health/queue/functions ## Get logs queue ```http request -GET https://HOSTNAME/v1/health/queue/logs +GET https://cloud.appwrite.io/v1/health/queue/logs ``` ** Get the number of logs that are waiting to be processed in the Appwrite internal queue server. ** @@ -134,7 +166,7 @@ GET https://HOSTNAME/v1/health/queue/logs ## Get mails queue ```http request -GET https://HOSTNAME/v1/health/queue/mails +GET https://cloud.appwrite.io/v1/health/queue/mails ``` ** Get the number of mails that are waiting to be processed in the Appwrite internal queue server. ** @@ -148,7 +180,7 @@ GET https://HOSTNAME/v1/health/queue/mails ## Get messaging queue ```http request -GET https://HOSTNAME/v1/health/queue/messaging +GET https://cloud.appwrite.io/v1/health/queue/messaging ``` ** Get the number of messages that are waiting to be processed in the Appwrite internal queue server. ** @@ -162,7 +194,7 @@ GET https://HOSTNAME/v1/health/queue/messaging ## Get migrations queue ```http request -GET https://HOSTNAME/v1/health/queue/migrations +GET https://cloud.appwrite.io/v1/health/queue/migrations ``` ** Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. ** @@ -173,10 +205,38 @@ GET https://HOSTNAME/v1/health/queue/migrations | --- | --- | --- | --- | | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +## Get usage queue + +```http request +GET https://cloud.appwrite.io/v1/health/queue/usage +``` + +** Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | + +## Get usage dump queue + +```http request +GET https://cloud.appwrite.io/v1/health/queue/usage-dump +``` + +** Get the number of projects containing metrics that are waiting to be processed in the Appwrite internal queue server. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | + ## Get webhooks queue ```http request -GET https://HOSTNAME/v1/health/queue/webhooks +GET https://cloud.appwrite.io/v1/health/queue/webhooks ``` ** Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. ** @@ -187,10 +247,18 @@ GET https://HOSTNAME/v1/health/queue/webhooks | --- | --- | --- | --- | | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +## Get storage + +```http request +GET https://cloud.appwrite.io/v1/health/storage +``` + +** Check the Appwrite storage device is up and connection is successful. ** + ## Get local storage ```http request -GET https://HOSTNAME/v1/health/storage/local +GET https://cloud.appwrite.io/v1/health/storage/local ``` ** Check the Appwrite local storage device is up and connection is successful. ** @@ -198,7 +266,7 @@ GET https://HOSTNAME/v1/health/storage/local ## Get time ```http request -GET https://HOSTNAME/v1/health/time +GET https://cloud.appwrite.io/v1/health/time ``` ** Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. ** diff --git a/docs/locale.md b/docs/locale.md index 2dd12d7..6678bf2 100644 --- a/docs/locale.md +++ b/docs/locale.md @@ -3,7 +3,7 @@ ## Get user locale ```http request -GET https://HOSTNAME/v1/locale +GET https://cloud.appwrite.io/v1/locale ``` ** Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. @@ -13,7 +13,7 @@ GET https://HOSTNAME/v1/locale ## List Locale Codes ```http request -GET https://HOSTNAME/v1/locale/codes +GET https://cloud.appwrite.io/v1/locale/codes ``` ** List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). ** @@ -21,7 +21,7 @@ GET https://HOSTNAME/v1/locale/codes ## List continents ```http request -GET https://HOSTNAME/v1/locale/continents +GET https://cloud.appwrite.io/v1/locale/continents ``` ** List of all continents. You can use the locale header to get the data in a supported language. ** @@ -29,7 +29,7 @@ GET https://HOSTNAME/v1/locale/continents ## List countries ```http request -GET https://HOSTNAME/v1/locale/countries +GET https://cloud.appwrite.io/v1/locale/countries ``` ** List of all countries. You can use the locale header to get the data in a supported language. ** @@ -37,7 +37,7 @@ GET https://HOSTNAME/v1/locale/countries ## List EU countries ```http request -GET https://HOSTNAME/v1/locale/countries/eu +GET https://cloud.appwrite.io/v1/locale/countries/eu ``` ** List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. ** @@ -45,7 +45,7 @@ GET https://HOSTNAME/v1/locale/countries/eu ## List countries phone codes ```http request -GET https://HOSTNAME/v1/locale/countries/phones +GET https://cloud.appwrite.io/v1/locale/countries/phones ``` ** List of all countries phone codes. You can use the locale header to get the data in a supported language. ** @@ -53,7 +53,7 @@ GET https://HOSTNAME/v1/locale/countries/phones ## List currencies ```http request -GET https://HOSTNAME/v1/locale/currencies +GET https://cloud.appwrite.io/v1/locale/currencies ``` ** List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. ** @@ -61,7 +61,7 @@ GET https://HOSTNAME/v1/locale/currencies ## List languages ```http request -GET https://HOSTNAME/v1/locale/languages +GET https://cloud.appwrite.io/v1/locale/languages ``` ** List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. ** diff --git a/docs/messaging.md b/docs/messaging.md new file mode 100644 index 0000000..d0b95e8 --- /dev/null +++ b/docs/messaging.md @@ -0,0 +1,863 @@ +# Messaging Service + +## List messages + +```http request +GET https://cloud.appwrite.io/v1/messaging/messages +``` + +** Get a list of all messages from the current Appwrite project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + +## Create email + +```http request +POST https://cloud.appwrite.io/v1/messaging/messages/email +``` + +** Create a new email message. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| subject | string | Email Subject. | | +| content | string | Email Content. | | +| topics | array | List of Topic IDs. | [] | +| users | array | List of User IDs. | [] | +| targets | array | List of Targets IDs. | [] | +| cc | array | Array of target IDs to be added as CC. | [] | +| bcc | array | Array of target IDs to be added as BCC. | [] | +| attachments | array | Array of compound bucket IDs to file IDs to be attached to the email. | [] | +| draft | boolean | Is message a draft | | +| html | boolean | Is content of type HTML | | +| 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. | | + +## Update email + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/messages/email/{messageId} +``` + +** Update an email message by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message ID. | | +| topics | array | List of Topic IDs. | | +| users | array | List of User IDs. | | +| targets | array | List of Targets IDs. | | +| subject | string | Email Subject. | | +| content | string | Email Content. | | +| draft | boolean | Is message a draft | | +| html | boolean | Is content of type HTML | | +| cc | array | Array of target IDs to be added as CC. | | +| bcc | array | Array of target IDs to be added as BCC. | | +| 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. | | + +## Create push notification + +```http request +POST https://cloud.appwrite.io/v1/messaging/messages/push +``` + +** Create a new push notification. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| title | string | Title for push notification. | | +| body | string | Body for push notification. | | +| 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. | {} | +| 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. | | +| 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. | | +| 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. | | +| 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. | | + +## Update push notification + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/messages/push/{messageId} +``` + +** Update a push notification by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message ID. | | +| topics | array | List of Topic IDs. | | +| users | array | List of User IDs. | | +| targets | array | List of Targets IDs. | | +| title | string | Title for push notification. | | +| body | string | Body for push notification. | | +| data | object | Additional 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. | | +| icon | string | Icon for push notification. Available only for Android and Web platforms. | | +| sound | string | Sound for push notification. Available only for Android and iOS platforms. | | +| color | string | Color for push notification. Available only for Android platforms. | | +| tag | string | Tag for push notification. Available only for Android platforms. | | +| 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. | | + +## Create SMS + +```http request +POST https://cloud.appwrite.io/v1/messaging/messages/sms +``` + +** Create a new SMS message. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| content | string | SMS Content. | | +| topics | array | List of Topic IDs. | [] | +| users | array | List of User IDs. | [] | +| targets | array | List of Targets IDs. | [] | +| 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. | | + +## Update SMS + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/messages/sms/{messageId} +``` + +** Update an email message by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message ID. | | +| topics | array | List of Topic IDs. | | +| users | array | List of User IDs. | | +| targets | array | List of Targets IDs. | | +| content | string | Email Content. | | +| 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. | | + +## Get message + +```http request +GET https://cloud.appwrite.io/v1/messaging/messages/{messageId} +``` + +** Get a message by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message ID. | | + +## Delete message + +```http request +DELETE https://cloud.appwrite.io/v1/messaging/messages/{messageId} +``` + +** Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message ID. | | + +## List message logs + +```http request +GET https://cloud.appwrite.io/v1/messaging/messages/{messageId}/logs +``` + +** Get the message activity logs listed by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message 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). Only supported methods are limit and offset | [] | + +## List message targets + +```http request +GET https://cloud.appwrite.io/v1/messaging/messages/{messageId}/targets +``` + +** Get a list of the targets associated with a message. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| messageId | string | **Required** Message 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: userId, providerId, identifier, providerType | [] | + +## List providers + +```http request +GET https://cloud.appwrite.io/v1/messaging/providers +``` + +** Get a list of all providers from the current Appwrite project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + +## Create APNS provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/apns +``` + +** Create a new Apple Push Notification service provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| authKey | string | APNS authentication key. | | +| authKeyId | string | APNS authentication key ID. | | +| teamId | string | APNS team ID. | | +| bundleId | string | APNS bundle ID. | | +| sandbox | boolean | Use APNS sandbox environment. | | +| enabled | boolean | Set as enabled. | | + +## Update APNS provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/apns/{providerId} +``` + +** Update a Apple Push Notification service provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| authKey | string | APNS authentication key. | | +| authKeyId | string | APNS authentication key ID. | | +| teamId | string | APNS team ID. | | +| bundleId | string | APNS bundle ID. | | +| sandbox | boolean | Use APNS sandbox environment. | | + +## Create FCM provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/fcm +``` + +** Create a new Firebase Cloud Messaging provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| serviceAccountJSON | object | FCM service account JSON. | {} | +| enabled | boolean | Set as enabled. | | + +## Update FCM provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/fcm/{providerId} +``` + +** Update a Firebase Cloud Messaging provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| serviceAccountJSON | object | FCM service account JSON. | {} | + +## Create Mailgun provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/mailgun +``` + +** Create a new Mailgun provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| apiKey | string | Mailgun API Key. | | +| domain | string | Mailgun Domain. | | +| isEuRegion | boolean | Set as EU region. | | +| fromName | string | Sender Name. | | +| fromEmail | string | Sender email address. | | +| replyToName | string | Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. | | +| replyToEmail | string | Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. | | +| enabled | boolean | Set as enabled. | | + +## Update Mailgun provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/mailgun/{providerId} +``` + +** Update a Mailgun provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| apiKey | string | Mailgun API Key. | | +| domain | string | Mailgun Domain. | | +| isEuRegion | boolean | Set as EU region. | | +| enabled | boolean | Set as enabled. | | +| fromName | string | Sender Name. | | +| fromEmail | string | Sender email address. | | +| replyToName | string | Name set in the reply to field for the mail. Default value is sender name. | | +| replyToEmail | string | Email set in the reply to field for the mail. Default value is sender email. | | + +## Create Msg91 provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/msg91 +``` + +** Create a new MSG91 provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| senderId | string | Msg91 Sender ID. | | +| authKey | string | Msg91 Auth Key. | | +| enabled | boolean | Set as enabled. | | + +## Update Msg91 provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/msg91/{providerId} +``` + +** Update a MSG91 provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| senderId | string | Msg91 Sender ID. | | +| authKey | string | Msg91 Auth Key. | | +| from | string | Sender number. | | + +## Create Sendgrid provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/sendgrid +``` + +** Create a new Sendgrid provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| apiKey | string | Sendgrid API key. | | +| fromName | string | Sender Name. | | +| fromEmail | string | Sender email address. | | +| replyToName | string | Name set in the reply to field for the mail. Default value is sender name. | | +| replyToEmail | string | Email set in the reply to field for the mail. Default value is sender email. | | +| enabled | boolean | Set as enabled. | | + +## Update Sendgrid provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/sendgrid/{providerId} +``` + +** Update a Sendgrid provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| apiKey | string | Sendgrid API key. | | +| fromName | string | Sender Name. | | +| fromEmail | string | Sender email address. | | +| replyToName | string | Name set in the Reply To field for the mail. Default value is Sender Name. | | +| replyToEmail | string | Email set in the Reply To field for the mail. Default value is Sender Email. | | + +## Create SMTP provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/smtp +``` + +** Create a new SMTP provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| host | string | SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. | | +| port | integer | The default SMTP server port. | 587 | +| username | string | Authentication username. | | +| password | string | Authentication password. | | +| encryption | string | Encryption type. Can be omitted, 'ssl', or 'tls' | | +| autoTLS | boolean | Enable SMTP AutoTLS feature. | 1 | +| mailer | string | The value to use for the X-Mailer header. | | +| fromName | string | Sender Name. | | +| fromEmail | string | Sender email address. | | +| replyToName | string | Name set in the reply to field for the mail. Default value is sender name. | | +| replyToEmail | string | Email set in the reply to field for the mail. Default value is sender email. | | +| enabled | boolean | Set as enabled. | | + +## Update SMTP provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/smtp/{providerId} +``` + +** Update a SMTP provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| host | string | SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. | | +| port | integer | SMTP port. | | +| username | string | Authentication username. | | +| password | string | Authentication password. | | +| encryption | string | Encryption type. Can be 'ssl' or 'tls' | | +| autoTLS | boolean | Enable SMTP AutoTLS feature. | | +| mailer | string | The value to use for the X-Mailer header. | | +| fromName | string | Sender Name. | | +| fromEmail | string | Sender email address. | | +| replyToName | string | Name set in the Reply To field for the mail. Default value is Sender Name. | | +| replyToEmail | string | Email set in the Reply To field for the mail. Default value is Sender Email. | | +| enabled | boolean | Set as enabled. | | + +## Create Telesign provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/telesign +``` + +** Create a new Telesign provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| customerId | string | Telesign customer ID. | | +| apiKey | string | Telesign API key. | | +| enabled | boolean | Set as enabled. | | + +## Update Telesign provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/telesign/{providerId} +``` + +** Update a Telesign provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| customerId | string | Telesign customer ID. | | +| apiKey | string | Telesign API key. | | +| from | string | Sender number. | | + +## Create Textmagic provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/textmagic +``` + +** Create a new Textmagic provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| username | string | Textmagic username. | | +| apiKey | string | Textmagic apiKey. | | +| enabled | boolean | Set as enabled. | | + +## Update Textmagic provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/textmagic/{providerId} +``` + +** Update a Textmagic provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| username | string | Textmagic username. | | +| apiKey | string | Textmagic apiKey. | | +| from | string | Sender number. | | + +## Create Twilio provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/twilio +``` + +** Create a new Twilio provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| accountSid | string | Twilio account secret ID. | | +| authToken | string | Twilio authentication token. | | +| enabled | boolean | Set as enabled. | | + +## Update Twilio provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/twilio/{providerId} +``` + +** Update a Twilio provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| accountSid | string | Twilio account secret ID. | | +| authToken | string | Twilio authentication token. | | +| from | string | Sender number. | | + +## Create Vonage provider + +```http request +POST https://cloud.appwrite.io/v1/messaging/providers/vonage +``` + +** Create a new Vonage provider. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Provider name. | | +| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| apiKey | string | Vonage API key. | | +| apiSecret | string | Vonage API secret. | | +| enabled | boolean | Set as enabled. | | + +## Update Vonage provider + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/providers/vonage/{providerId} +``` + +** Update a Vonage provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | +| name | string | Provider name. | | +| enabled | boolean | Set as enabled. | | +| apiKey | string | Vonage API key. | | +| apiSecret | string | Vonage API secret. | | +| from | string | Sender number. | | + +## Get provider + +```http request +GET https://cloud.appwrite.io/v1/messaging/providers/{providerId} +``` + +** Get a provider by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | + +## Delete provider + +```http request +DELETE https://cloud.appwrite.io/v1/messaging/providers/{providerId} +``` + +** Delete a provider by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider ID. | | + +## List provider logs + +```http request +GET https://cloud.appwrite.io/v1/messaging/providers/{providerId}/logs +``` + +** Get the provider activity logs listed by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| providerId | string | **Required** Provider 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). Only supported methods are limit and offset | [] | + +## List subscriber logs + +```http request +GET https://cloud.appwrite.io/v1/messaging/subscribers/{subscriberId}/logs +``` + +** Get the subscriber activity logs listed by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| subscriberId | string | **Required** Subscriber 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). Only supported methods are limit and offset | [] | + +## List topics + +```http request +GET https://cloud.appwrite.io/v1/messaging/topics +``` + +** Get a list of all topics from the current Appwrite project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, description, emailTotal, smsTotal, pushTotal | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + +## Create topic + +```http request +POST https://cloud.appwrite.io/v1/messaging/topics +``` + +** Create a new topic. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | Topic ID. Choose a custom Topic ID or a new Topic ID. | | +| name | string | Topic Name. | | +| subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | ["users"] | + +## Get topic + +```http request +GET https://cloud.appwrite.io/v1/messaging/topics/{topicId} +``` + +** Get a topic by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. | | + +## Update topic + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/topics/{topicId} +``` + +** Update a topic by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. | | +| name | string | Topic Name. | | +| subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | | + +## Delete topic + +```http request +DELETE https://cloud.appwrite.io/v1/messaging/topics/{topicId} +``` + +** Delete a topic by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. | | + +## List topic logs + +```http request +GET https://cloud.appwrite.io/v1/messaging/topics/{topicId}/logs +``` + +** Get the topic activity logs listed by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic 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). Only supported methods are limit and offset | [] | + +## List subscribers + +```http request +GET https://cloud.appwrite.io/v1/messaging/topics/{topicId}/subscribers +``` + +** Get a list of all subscribers from the current Appwrite project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. The topic ID subscribed to. | | +| 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, provider, type, enabled | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + +## Create subscriber + +```http request +POST https://cloud.appwrite.io/v1/messaging/topics/{topicId}/subscribers +``` + +** Create a new subscriber. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. The topic ID to subscribe to. | | +| subscriberId | string | Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. | | +| targetId | string | Target ID. The target ID to link to the specified Topic ID. | | + +## Get subscriber + +```http request +GET https://cloud.appwrite.io/v1/messaging/topics/{topicId}/subscribers/{subscriberId} +``` + +** Get a subscriber by its unique ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. The topic ID subscribed to. | | +| subscriberId | string | **Required** Subscriber ID. | | + +## Delete subscriber + +```http request +DELETE https://cloud.appwrite.io/v1/messaging/topics/{topicId}/subscribers/{subscriberId} +``` + +** Delete a subscriber by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| topicId | string | **Required** Topic ID. The topic ID subscribed to. | | +| subscriberId | string | **Required** Subscriber ID. | | + diff --git a/docs/storage.md b/docs/storage.md index 66204e2..5e8d7c9 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -3,7 +3,7 @@ ## List buckets ```http request -GET https://HOSTNAME/v1/storage/buckets +GET https://cloud.appwrite.io/v1/storage/buckets ``` ** Get a list of all the storage buckets. You can use the query params to filter your results. ** @@ -18,7 +18,7 @@ GET https://HOSTNAME/v1/storage/buckets ## Create bucket ```http request -POST https://HOSTNAME/v1/storage/buckets +POST https://cloud.appwrite.io/v1/storage/buckets ``` ** Create a new storage bucket. ** @@ -41,7 +41,7 @@ POST https://HOSTNAME/v1/storage/buckets ## Get bucket ```http request -GET https://HOSTNAME/v1/storage/buckets/{bucketId} +GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId} ``` ** Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. ** @@ -55,7 +55,7 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId} ## Update bucket ```http request -PUT https://HOSTNAME/v1/storage/buckets/{bucketId} +PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId} ``` ** Update a storage bucket by its unique ID. ** @@ -78,7 +78,7 @@ PUT https://HOSTNAME/v1/storage/buckets/{bucketId} ## Delete bucket ```http request -DELETE https://HOSTNAME/v1/storage/buckets/{bucketId} +DELETE https://cloud.appwrite.io/v1/storage/buckets/{bucketId} ``` ** Delete a storage bucket by its unique ID. ** @@ -92,7 +92,7 @@ DELETE https://HOSTNAME/v1/storage/buckets/{bucketId} ## List files ```http request -GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files +GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files ``` ** Get a list of all the user files. You can use the query params to filter your results. ** @@ -108,7 +108,7 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files ## Create file ```http request -POST https://HOSTNAME/v1/storage/buckets/{bucketId}/files +POST https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files ``` ** Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. @@ -132,7 +132,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk ## Get file ```http request -GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} +GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId} ``` ** Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. ** @@ -147,7 +147,7 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} ## Update file ```http request -PUT https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} +PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId} ``` ** Update a file by its unique ID. Only users with write permissions have access to update this resource. ** @@ -164,7 +164,7 @@ PUT https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} ## Delete File ```http request -DELETE https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} +DELETE https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId} ``` ** Delete a file by its unique ID. Only users with write permissions have access to delete this resource. ** @@ -179,7 +179,7 @@ DELETE https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} ## Get file for download ```http request -GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId}/download +GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/download ``` ** Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. ** @@ -194,7 +194,7 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId}/download ## Get file preview ```http request -GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId}/preview +GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/preview ``` ** Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. ** @@ -220,7 +220,7 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId}/preview ## Get file for view ```http request -GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId}/view +GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/view ``` ** Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. ** diff --git a/docs/teams.md b/docs/teams.md index 34854af..1a7dfec 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -3,7 +3,7 @@ ## List teams ```http request -GET https://HOSTNAME/v1/teams +GET https://cloud.appwrite.io/v1/teams ``` ** Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. ** @@ -12,13 +12,13 @@ GET https://HOSTNAME/v1/teams | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total | [] | +| 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, total, billingPlan | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | ## Create team ```http request -POST https://HOSTNAME/v1/teams +POST https://cloud.appwrite.io/v1/teams ``` ** Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. ** @@ -34,7 +34,7 @@ POST https://HOSTNAME/v1/teams ## Get team ```http request -GET https://HOSTNAME/v1/teams/{teamId} +GET https://cloud.appwrite.io/v1/teams/{teamId} ``` ** Get a team by its ID. All team members have read access for this resource. ** @@ -48,7 +48,7 @@ GET https://HOSTNAME/v1/teams/{teamId} ## Update name ```http request -PUT https://HOSTNAME/v1/teams/{teamId} +PUT https://cloud.appwrite.io/v1/teams/{teamId} ``` ** Update the team's name by its unique ID. ** @@ -63,7 +63,7 @@ PUT https://HOSTNAME/v1/teams/{teamId} ## Delete team ```http request -DELETE https://HOSTNAME/v1/teams/{teamId} +DELETE https://cloud.appwrite.io/v1/teams/{teamId} ``` ** Delete a team using its ID. Only team members with the owner role can delete the team. ** @@ -77,7 +77,7 @@ DELETE https://HOSTNAME/v1/teams/{teamId} ## List team memberships ```http request -GET https://HOSTNAME/v1/teams/{teamId}/memberships +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. ** @@ -93,7 +93,7 @@ GET https://HOSTNAME/v1/teams/{teamId}/memberships ## Create team membership ```http request -POST https://HOSTNAME/v1/teams/{teamId}/memberships +POST https://cloud.appwrite.io/v1/teams/{teamId}/memberships ``` ** Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. @@ -120,7 +120,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee ## Get team membership ```http request -GET https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId} +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. ** @@ -135,7 +135,7 @@ GET https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId} ## Update membership ```http request -PATCH https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId} +PATCH https://cloud.appwrite.io/v1/teams/{teamId}/memberships/{membershipId} ``` ** Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). @@ -152,7 +152,7 @@ PATCH https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId} ## Delete team membership ```http request -DELETE https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId} +DELETE https://cloud.appwrite.io/v1/teams/{teamId}/memberships/{membershipId} ``` ** This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. ** @@ -167,7 +167,7 @@ DELETE https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId} ## Update team membership status ```http request -PATCH https://HOSTNAME/v1/teams/{teamId}/memberships/{membershipId}/status +PATCH https://cloud.appwrite.io/v1/teams/{teamId}/memberships/{membershipId}/status ``` ** Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. @@ -187,7 +187,7 @@ If the request is successful, a session for the user is automatically created. ## Get team preferences ```http request -GET https://HOSTNAME/v1/teams/{teamId}/prefs +GET https://cloud.appwrite.io/v1/teams/{teamId}/prefs ``` ** Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). ** @@ -201,7 +201,7 @@ GET https://HOSTNAME/v1/teams/{teamId}/prefs ## Update preferences ```http request -PUT https://HOSTNAME/v1/teams/{teamId}/prefs +PUT https://cloud.appwrite.io/v1/teams/{teamId}/prefs ``` ** Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. ** diff --git a/docs/users.md b/docs/users.md index 527f6ce..44139dc 100644 --- a/docs/users.md +++ b/docs/users.md @@ -3,7 +3,7 @@ ## List users ```http request -GET https://HOSTNAME/v1/users +GET https://cloud.appwrite.io/v1/users ``` ** Get a list of all the project's users. You can use the query params to filter your results. ** @@ -12,13 +12,13 @@ GET https://HOSTNAME/v1/users | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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 | [] | +| 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 | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | ## Create user ```http request -POST https://HOSTNAME/v1/users +POST https://cloud.appwrite.io/v1/users ``` ** Create a new user. ** @@ -36,7 +36,7 @@ POST https://HOSTNAME/v1/users ## Create user with Argon2 password ```http request -POST https://HOSTNAME/v1/users/argon2 +POST https://cloud.appwrite.io/v1/users/argon2 ``` ** Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -53,7 +53,7 @@ POST https://HOSTNAME/v1/users/argon2 ## Create user with bcrypt password ```http request -POST https://HOSTNAME/v1/users/bcrypt +POST https://cloud.appwrite.io/v1/users/bcrypt ``` ** Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -70,7 +70,7 @@ POST https://HOSTNAME/v1/users/bcrypt ## List Identities ```http request -GET https://HOSTNAME/v1/users/identities +GET https://cloud.appwrite.io/v1/users/identities ``` ** Get identities for all users. ** @@ -79,13 +79,13 @@ GET https://HOSTNAME/v1/users/identities | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| queries | string | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -## Delete Identity +## Delete identity ```http request -DELETE https://HOSTNAME/v1/users/identities/{identityId} +DELETE https://cloud.appwrite.io/v1/users/identities/{identityId} ``` ** Delete an identity by its unique ID. ** @@ -99,7 +99,7 @@ DELETE https://HOSTNAME/v1/users/identities/{identityId} ## Create user with MD5 password ```http request -POST https://HOSTNAME/v1/users/md5 +POST https://cloud.appwrite.io/v1/users/md5 ``` ** Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -116,7 +116,7 @@ POST https://HOSTNAME/v1/users/md5 ## Create user with PHPass password ```http request -POST https://HOSTNAME/v1/users/phpass +POST https://cloud.appwrite.io/v1/users/phpass ``` ** Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -133,7 +133,7 @@ POST https://HOSTNAME/v1/users/phpass ## Create user with Scrypt password ```http request -POST https://HOSTNAME/v1/users/scrypt +POST https://cloud.appwrite.io/v1/users/scrypt ``` ** Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -155,7 +155,7 @@ POST https://HOSTNAME/v1/users/scrypt ## Create user with Scrypt modified password ```http request -POST https://HOSTNAME/v1/users/scrypt-modified +POST https://cloud.appwrite.io/v1/users/scrypt-modified ``` ** Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -175,7 +175,7 @@ POST https://HOSTNAME/v1/users/scrypt-modified ## Create user with SHA password ```http request -POST https://HOSTNAME/v1/users/sha +POST https://cloud.appwrite.io/v1/users/sha ``` ** Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** @@ -193,7 +193,7 @@ POST https://HOSTNAME/v1/users/sha ## Get user ```http request -GET https://HOSTNAME/v1/users/{userId} +GET https://cloud.appwrite.io/v1/users/{userId} ``` ** Get a user by its unique ID. ** @@ -207,7 +207,7 @@ GET https://HOSTNAME/v1/users/{userId} ## Delete user ```http request -DELETE https://HOSTNAME/v1/users/{userId} +DELETE https://cloud.appwrite.io/v1/users/{userId} ``` ** Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. ** @@ -221,7 +221,7 @@ DELETE https://HOSTNAME/v1/users/{userId} ## Update email ```http request -PATCH https://HOSTNAME/v1/users/{userId}/email +PATCH https://cloud.appwrite.io/v1/users/{userId}/email ``` ** Update the user email by its unique ID. ** @@ -236,7 +236,7 @@ PATCH https://HOSTNAME/v1/users/{userId}/email ## Update user labels ```http request -PUT https://HOSTNAME/v1/users/{userId}/labels +PUT https://cloud.appwrite.io/v1/users/{userId}/labels ``` ** Update the user labels by its unique ID. @@ -248,12 +248,12 @@ Labels can be used to grant access to resources. While teams are a way for user& | Field Name | Type | Description | Default | | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -| labels | array | Array of user labels. Replaces the previous labels. Maximum of 100 labels are allowed, each up to 36 alphanumeric characters long. | | +| labels | array | Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | ## List user logs ```http request -GET https://HOSTNAME/v1/users/{userId}/logs +GET https://cloud.appwrite.io/v1/users/{userId}/logs ``` ** Get the user activity logs list by its unique ID. ** @@ -268,7 +268,7 @@ GET https://HOSTNAME/v1/users/{userId}/logs ## List user memberships ```http request -GET https://HOSTNAME/v1/users/{userId}/memberships +GET https://cloud.appwrite.io/v1/users/{userId}/memberships ``` ** Get the user membership list by its unique ID. ** @@ -279,10 +279,96 @@ GET https://HOSTNAME/v1/users/{userId}/memberships | --- | --- | --- | --- | | userId | string | **Required** User ID. | | +## Update MFA + +```http request +PATCH https://cloud.appwrite.io/v1/users/{userId}/mfa +``` + +** Enable or disable MFA on a user account. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| mfa | boolean | Enable or disable MFA. | | + +## Delete Authenticator + +```http request +DELETE https://cloud.appwrite.io/v1/users/{userId}/mfa/authenticators/{type} +``` + +** Delete an authenticator app. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| type | string | **Required** Type of authenticator. | | + +## List Factors + +```http request +GET https://cloud.appwrite.io/v1/users/{userId}/mfa/factors +``` + +** List the factors available on the account to be used as a MFA challange. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | + +## Get MFA Recovery Codes + +```http request +GET https://cloud.appwrite.io/v1/users/{userId}/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 [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | + +## Regenerate MFA Recovery Codes + +```http request +PUT https://cloud.appwrite.io/v1/users/{userId}/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 [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | + +## Create MFA Recovery Codes + +```http request +PATCH https://cloud.appwrite.io/v1/users/{userId}/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 [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | + ## Update name ```http request -PATCH https://HOSTNAME/v1/users/{userId}/name +PATCH https://cloud.appwrite.io/v1/users/{userId}/name ``` ** Update the user name by its unique ID. ** @@ -297,7 +383,7 @@ PATCH https://HOSTNAME/v1/users/{userId}/name ## Update password ```http request -PATCH https://HOSTNAME/v1/users/{userId}/password +PATCH https://cloud.appwrite.io/v1/users/{userId}/password ``` ** Update the user password by its unique ID. ** @@ -312,7 +398,7 @@ PATCH https://HOSTNAME/v1/users/{userId}/password ## Update phone ```http request -PATCH https://HOSTNAME/v1/users/{userId}/phone +PATCH https://cloud.appwrite.io/v1/users/{userId}/phone ``` ** Update the user phone by its unique ID. ** @@ -327,7 +413,7 @@ PATCH https://HOSTNAME/v1/users/{userId}/phone ## Get user preferences ```http request -GET https://HOSTNAME/v1/users/{userId}/prefs +GET https://cloud.appwrite.io/v1/users/{userId}/prefs ``` ** Get the user preferences by its unique ID. ** @@ -341,7 +427,7 @@ GET https://HOSTNAME/v1/users/{userId}/prefs ## Update user preferences ```http request -PATCH https://HOSTNAME/v1/users/{userId}/prefs +PATCH https://cloud.appwrite.io/v1/users/{userId}/prefs ``` ** Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. ** @@ -356,7 +442,7 @@ PATCH https://HOSTNAME/v1/users/{userId}/prefs ## List user sessions ```http request -GET https://HOSTNAME/v1/users/{userId}/sessions +GET https://cloud.appwrite.io/v1/users/{userId}/sessions ``` ** Get the user sessions list by its unique ID. ** @@ -367,10 +453,26 @@ GET https://HOSTNAME/v1/users/{userId}/sessions | --- | --- | --- | --- | | userId | string | **Required** User ID. | | +## Create session + +```http request +POST https://cloud.appwrite.io/v1/users/{userId}/sessions +``` + +** Creates a session for a user. Returns an immediately usable session object. + +If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + ## Delete user sessions ```http request -DELETE https://HOSTNAME/v1/users/{userId}/sessions +DELETE https://cloud.appwrite.io/v1/users/{userId}/sessions ``` ** Delete all user's sessions by using the user's unique ID. ** @@ -384,7 +486,7 @@ DELETE https://HOSTNAME/v1/users/{userId}/sessions ## Delete user session ```http request -DELETE https://HOSTNAME/v1/users/{userId}/sessions/{sessionId} +DELETE https://cloud.appwrite.io/v1/users/{userId}/sessions/{sessionId} ``` ** Delete a user sessions by its unique ID. ** @@ -399,7 +501,7 @@ DELETE https://HOSTNAME/v1/users/{userId}/sessions/{sessionId} ## Update user status ```http request -PATCH https://HOSTNAME/v1/users/{userId}/status +PATCH https://cloud.appwrite.io/v1/users/{userId}/status ``` ** Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. ** @@ -411,10 +513,108 @@ PATCH https://HOSTNAME/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 + +```http request +GET https://cloud.appwrite.io/v1/users/{userId}/targets +``` + +** List the messaging targets that are associated with a user. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels | [] | + +## Create User Target + +```http request +POST https://cloud.appwrite.io/v1/users/{userId}/targets +``` + +** Create a messaging target. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| targetId | string | Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| providerType | string | The target provider type. Can be one of the following: `email`, `sms` or `push`. | | +| identifier | string | The target identifier (token, email, phone etc.) | | +| 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 + +```http request +GET https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId} +``` + +** Get a user's push notification target by ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| targetId | string | **Required** Target ID. | | + +## Update User target + +```http request +PATCH https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId} +``` + +** Update a messaging target. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| targetId | string | **Required** Target ID. | | +| identifier | string | The target identifier (token, email, phone etc.) | | +| 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. | | + +## Delete user target + +```http request +DELETE https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId} +``` + +** Delete a messaging target. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| targetId | string | **Required** Target ID. | | + +## Create token + +```http request +POST https://cloud.appwrite.io/v1/users/{userId}/tokens +``` + +** Returns a token with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) endpoint to complete the login process. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | **Required** User ID. | | +| length | integer | Token length in characters. The default length is 6 characters | 6 | +| expire | integer | Token expiration period in seconds. The default expiration is 15 minutes. | 900 | + ## Update email verification ```http request -PATCH https://HOSTNAME/v1/users/{userId}/verification +PATCH https://cloud.appwrite.io/v1/users/{userId}/verification ``` ** Update the user email verification status by its unique ID. ** @@ -429,7 +629,7 @@ PATCH https://HOSTNAME/v1/users/{userId}/verification ## Update phone verification ```http request -PATCH https://HOSTNAME/v1/users/{userId}/verification/phone +PATCH https://cloud.appwrite.io/v1/users/{userId}/verification/phone ``` ** Update the user phone verification status by its unique ID. ** diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 5b37539..926c9fe 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -28,7 +28,7 @@ class Client * * @var string */ - protected $endpoint = 'https://HOSTNAME/v1'; + protected $endpoint = 'https://cloud.appwrite.io/v1'; /** * Global Headers @@ -37,11 +37,11 @@ class Client */ protected $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/10.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/11.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '10.1.0', + 'x-sdk-version'=> '11.0.0', ]; /** @@ -49,7 +49,7 @@ class Client */ public function __construct() { - $this->headers['X-Appwrite-Response-Format'] = '1.4.0'; + $this->headers['X-Appwrite-Response-Format'] = '1.5.0'; } @@ -115,6 +115,38 @@ public function setLocale($value) return $this; } + /** + * Set Session + * + * The user session to authenticate with + * + * @param string $value + * + * @return Client + */ + public function setSession($value) + { + $this->addHeader('X-Appwrite-Session', $value); + + return $this; + } + + /** + * Set ForwardedUserAgent + * + * The user agent string of the client that made the request + * + * @param string $value + * + * @return Client + */ + public function setForwardedUserAgent($value) + { + $this->addHeader('X-Forwarded-User-Agent', $value); + + return $this; + } + /*** * @param bool $status @@ -161,14 +193,11 @@ public function addHeader($key, $value) * @return array|string * @throws AppwriteException */ - public function call($method, $path = '', $headers = array(), array $params = array()) + public function call($method, $path = '', $headers = array(), array $params = array(), ?string $responseType = null) { - $headers = array_merge($this->headers, $headers); - $ch = curl_init($this->endpoint . $path . (($method == self::METHOD_GET && !empty($params)) ? '?' . http_build_query($params) : '')); - $responseHeaders = []; - $responseStatus = -1; - $responseType = ''; - $responseBody = ''; + $headers = array_merge($this->headers, $headers); + $ch = curl_init($this->endpoint . $path . (($method == self::METHOD_GET && !empty($params)) ? '?' . http_build_query($params) : '')); + $responseHeaders = []; switch ($headers['content-type']) { case 'application/json': @@ -193,7 +222,7 @@ public function call($method, $path = '', $headers = array(), array $params = ar curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, php_uname('s') . '-' . php_uname('r') . ':php-' . phpversion()); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $responseType !== 'location'); curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$responseHeaders) { $len = strlen($header); $header = explode(':', strtolower($header), 2); @@ -218,10 +247,10 @@ public function call($method, $path = '', $headers = array(), array $params = ar } $responseBody = curl_exec($ch); - $responseType = $responseHeaders['content-type'] ?? ''; + $contentType = $responseHeaders['content-type'] ?? ''; $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); - switch(substr($responseType, 0, strpos($responseType, ';'))) { + switch(substr($contentType, 0, strpos($contentType, ';'))) { case 'application/json': $responseBody = json_decode($responseBody, true); break; @@ -241,6 +270,9 @@ public function call($method, $path = '', $headers = array(), array $params = ar } } + if ($responseType === 'location') { + return $responseHeaders['location']; + } return $responseBody; } diff --git a/src/Appwrite/Enums/AuthenticationFactor.php b/src/Appwrite/Enums/AuthenticationFactor.php new file mode 100644 index 0000000..5258c8c --- /dev/null +++ b/src/Appwrite/Enums/AuthenticationFactor.php @@ -0,0 +1,59 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class AuthenticationFactor implements JsonSerializable +{ + private static AuthenticationFactor $EMAIL; + private static AuthenticationFactor $PHONE; + private static AuthenticationFactor $TOTP; + private static AuthenticationFactor $RECOVERYCODE; + + 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 EMAIL(): AuthenticationFactor + { + if (!isset(self::$EMAIL)) { + self::$EMAIL = new AuthenticationFactor('email'); + } + return self::$EMAIL; + } + public static function PHONE(): AuthenticationFactor + { + if (!isset(self::$PHONE)) { + self::$PHONE = new AuthenticationFactor('phone'); + } + return self::$PHONE; + } + public static function TOTP(): AuthenticationFactor + { + if (!isset(self::$TOTP)) { + self::$TOTP = new AuthenticationFactor('totp'); + } + return self::$TOTP; + } + public static function RECOVERYCODE(): AuthenticationFactor + { + if (!isset(self::$RECOVERYCODE)) { + self::$RECOVERYCODE = new AuthenticationFactor('recoverycode'); + } + return self::$RECOVERYCODE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/AuthenticatorType.php b/src/Appwrite/Enums/AuthenticatorType.php new file mode 100644 index 0000000..9e8634a --- /dev/null +++ b/src/Appwrite/Enums/AuthenticatorType.php @@ -0,0 +1,35 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class AuthenticatorType implements JsonSerializable +{ + private static AuthenticatorType $TOTP; + + 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 TOTP(): AuthenticatorType + { + if (!isset(self::$TOTP)) { + self::$TOTP = new AuthenticatorType('totp'); + } + return self::$TOTP; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Browser.php b/src/Appwrite/Enums/Browser.php new file mode 100644 index 0000000..fc560f2 --- /dev/null +++ b/src/Appwrite/Enums/Browser.php @@ -0,0 +1,139 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class Browser implements JsonSerializable +{ + private static Browser $AVANTBROWSER; + private static Browser $ANDROIDWEBVIEWBETA; + private static Browser $GOOGLECHROME; + private static Browser $GOOGLECHROMEIOS; + private static Browser $GOOGLECHROMEMOBILE; + private static Browser $CHROMIUM; + private static Browser $MOZILLAFIREFOX; + private static Browser $SAFARI; + private static Browser $MOBILESAFARI; + private static Browser $MICROSOFTEDGE; + private static Browser $MICROSOFTEDGEIOS; + private static Browser $OPERAMINI; + private static Browser $OPERA; + private static Browser $OPERANEXT; + + 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 AVANTBROWSER(): Browser + { + if (!isset(self::$AVANTBROWSER)) { + self::$AVANTBROWSER = new Browser('aa'); + } + return self::$AVANTBROWSER; + } + public static function ANDROIDWEBVIEWBETA(): Browser + { + if (!isset(self::$ANDROIDWEBVIEWBETA)) { + self::$ANDROIDWEBVIEWBETA = new Browser('an'); + } + return self::$ANDROIDWEBVIEWBETA; + } + public static function GOOGLECHROME(): Browser + { + if (!isset(self::$GOOGLECHROME)) { + self::$GOOGLECHROME = new Browser('ch'); + } + return self::$GOOGLECHROME; + } + public static function GOOGLECHROMEIOS(): Browser + { + if (!isset(self::$GOOGLECHROMEIOS)) { + self::$GOOGLECHROMEIOS = new Browser('ci'); + } + return self::$GOOGLECHROMEIOS; + } + public static function GOOGLECHROMEMOBILE(): Browser + { + if (!isset(self::$GOOGLECHROMEMOBILE)) { + self::$GOOGLECHROMEMOBILE = new Browser('cm'); + } + return self::$GOOGLECHROMEMOBILE; + } + public static function CHROMIUM(): Browser + { + if (!isset(self::$CHROMIUM)) { + self::$CHROMIUM = new Browser('cr'); + } + return self::$CHROMIUM; + } + public static function MOZILLAFIREFOX(): Browser + { + if (!isset(self::$MOZILLAFIREFOX)) { + self::$MOZILLAFIREFOX = new Browser('ff'); + } + return self::$MOZILLAFIREFOX; + } + public static function SAFARI(): Browser + { + if (!isset(self::$SAFARI)) { + self::$SAFARI = new Browser('sf'); + } + return self::$SAFARI; + } + public static function MOBILESAFARI(): Browser + { + if (!isset(self::$MOBILESAFARI)) { + self::$MOBILESAFARI = new Browser('mf'); + } + return self::$MOBILESAFARI; + } + public static function MICROSOFTEDGE(): Browser + { + if (!isset(self::$MICROSOFTEDGE)) { + self::$MICROSOFTEDGE = new Browser('ps'); + } + return self::$MICROSOFTEDGE; + } + public static function MICROSOFTEDGEIOS(): Browser + { + if (!isset(self::$MICROSOFTEDGEIOS)) { + self::$MICROSOFTEDGEIOS = new Browser('oi'); + } + return self::$MICROSOFTEDGEIOS; + } + public static function OPERAMINI(): Browser + { + if (!isset(self::$OPERAMINI)) { + self::$OPERAMINI = new Browser('om'); + } + return self::$OPERAMINI; + } + public static function OPERA(): Browser + { + if (!isset(self::$OPERA)) { + self::$OPERA = new Browser('op'); + } + return self::$OPERA; + } + public static function OPERANEXT(): Browser + { + if (!isset(self::$OPERANEXT)) { + self::$OPERANEXT = new Browser('on'); + } + return self::$OPERANEXT; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Compression.php b/src/Appwrite/Enums/Compression.php new file mode 100644 index 0000000..1e73987 --- /dev/null +++ b/src/Appwrite/Enums/Compression.php @@ -0,0 +1,51 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class Compression implements JsonSerializable +{ + private static Compression $NONE; + private static Compression $GZIP; + private static Compression $ZSTD; + + 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 NONE(): Compression + { + if (!isset(self::$NONE)) { + self::$NONE = new Compression('none'); + } + return self::$NONE; + } + public static function GZIP(): Compression + { + if (!isset(self::$GZIP)) { + self::$GZIP = new Compression('gzip'); + } + return self::$GZIP; + } + public static function ZSTD(): Compression + { + if (!isset(self::$ZSTD)) { + self::$ZSTD = new Compression('zstd'); + } + return self::$ZSTD; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/CreditCard.php b/src/Appwrite/Enums/CreditCard.php new file mode 100644 index 0000000..f634026 --- /dev/null +++ b/src/Appwrite/Enums/CreditCard.php @@ -0,0 +1,155 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class CreditCard implements JsonSerializable +{ + private static CreditCard $AMERICANEXPRESS; + private static CreditCard $ARGENCARD; + private static CreditCard $CABAL; + private static CreditCard $CONSOSUD; + private static CreditCard $DINERSCLUB; + private static CreditCard $DISCOVER; + private static CreditCard $ELO; + private static CreditCard $HIPERCARD; + private static CreditCard $JCB; + private static CreditCard $MASTERCARD; + private static CreditCard $NARANJA; + private static CreditCard $TARJETASHOPPING; + private static CreditCard $UNIONCHINAPAY; + private static CreditCard $VISA; + private static CreditCard $MIR; + private static CreditCard $MAESTRO; + + 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 AMERICANEXPRESS(): CreditCard + { + if (!isset(self::$AMERICANEXPRESS)) { + self::$AMERICANEXPRESS = new CreditCard('amex'); + } + return self::$AMERICANEXPRESS; + } + public static function ARGENCARD(): CreditCard + { + if (!isset(self::$ARGENCARD)) { + self::$ARGENCARD = new CreditCard('argencard'); + } + return self::$ARGENCARD; + } + public static function CABAL(): CreditCard + { + if (!isset(self::$CABAL)) { + self::$CABAL = new CreditCard('cabal'); + } + return self::$CABAL; + } + public static function CONSOSUD(): CreditCard + { + if (!isset(self::$CONSOSUD)) { + self::$CONSOSUD = new CreditCard('censosud'); + } + return self::$CONSOSUD; + } + public static function DINERSCLUB(): CreditCard + { + if (!isset(self::$DINERSCLUB)) { + self::$DINERSCLUB = new CreditCard('diners'); + } + return self::$DINERSCLUB; + } + public static function DISCOVER(): CreditCard + { + if (!isset(self::$DISCOVER)) { + self::$DISCOVER = new CreditCard('discover'); + } + return self::$DISCOVER; + } + public static function ELO(): CreditCard + { + if (!isset(self::$ELO)) { + self::$ELO = new CreditCard('elo'); + } + return self::$ELO; + } + public static function HIPERCARD(): CreditCard + { + if (!isset(self::$HIPERCARD)) { + self::$HIPERCARD = new CreditCard('hipercard'); + } + return self::$HIPERCARD; + } + public static function JCB(): CreditCard + { + if (!isset(self::$JCB)) { + self::$JCB = new CreditCard('jcb'); + } + return self::$JCB; + } + public static function MASTERCARD(): CreditCard + { + if (!isset(self::$MASTERCARD)) { + self::$MASTERCARD = new CreditCard('mastercard'); + } + return self::$MASTERCARD; + } + public static function NARANJA(): CreditCard + { + if (!isset(self::$NARANJA)) { + self::$NARANJA = new CreditCard('naranja'); + } + return self::$NARANJA; + } + public static function TARJETASHOPPING(): CreditCard + { + if (!isset(self::$TARJETASHOPPING)) { + self::$TARJETASHOPPING = new CreditCard('targeta-shopping'); + } + return self::$TARJETASHOPPING; + } + public static function UNIONCHINAPAY(): CreditCard + { + if (!isset(self::$UNIONCHINAPAY)) { + self::$UNIONCHINAPAY = new CreditCard('union-china-pay'); + } + return self::$UNIONCHINAPAY; + } + public static function VISA(): CreditCard + { + if (!isset(self::$VISA)) { + self::$VISA = new CreditCard('visa'); + } + return self::$VISA; + } + public static function MIR(): CreditCard + { + if (!isset(self::$MIR)) { + self::$MIR = new CreditCard('mir'); + } + return self::$MIR; + } + public static function MAESTRO(): CreditCard + { + if (!isset(self::$MAESTRO)) { + self::$MAESTRO = new CreditCard('maestro'); + } + return self::$MAESTRO; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/ExecutionMethod.php b/src/Appwrite/Enums/ExecutionMethod.php new file mode 100644 index 0000000..9ffea9c --- /dev/null +++ b/src/Appwrite/Enums/ExecutionMethod.php @@ -0,0 +1,75 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class ExecutionMethod implements JsonSerializable +{ + private static ExecutionMethod $GET; + private static ExecutionMethod $POST; + private static ExecutionMethod $PUT; + private static ExecutionMethod $PATCH; + private static ExecutionMethod $DELETE; + private static ExecutionMethod $OPTIONS; + + 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 GET(): ExecutionMethod + { + if (!isset(self::$GET)) { + self::$GET = new ExecutionMethod('GET'); + } + return self::$GET; + } + public static function POST(): ExecutionMethod + { + if (!isset(self::$POST)) { + self::$POST = new ExecutionMethod('POST'); + } + return self::$POST; + } + public static function PUT(): ExecutionMethod + { + if (!isset(self::$PUT)) { + self::$PUT = new ExecutionMethod('PUT'); + } + return self::$PUT; + } + public static function PATCH(): ExecutionMethod + { + if (!isset(self::$PATCH)) { + self::$PATCH = new ExecutionMethod('PATCH'); + } + return self::$PATCH; + } + public static function DELETE(): ExecutionMethod + { + if (!isset(self::$DELETE)) { + self::$DELETE = new ExecutionMethod('DELETE'); + } + return self::$DELETE; + } + public static function OPTIONS(): ExecutionMethod + { + if (!isset(self::$OPTIONS)) { + self::$OPTIONS = new ExecutionMethod('OPTIONS'); + } + return self::$OPTIONS; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Flag.php b/src/Appwrite/Enums/Flag.php new file mode 100644 index 0000000..5702423 --- /dev/null +++ b/src/Appwrite/Enums/Flag.php @@ -0,0 +1,1579 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class Flag implements JsonSerializable +{ + private static Flag $AFGHANISTAN; + private static Flag $ANGOLA; + private static Flag $ALBANIA; + private static Flag $ANDORRA; + private static Flag $UNITEDARABEMIRATES; + private static Flag $ARGENTINA; + private static Flag $ARMENIA; + private static Flag $ANTIGUAANDBARBUDA; + private static Flag $AUSTRALIA; + private static Flag $AUSTRIA; + private static Flag $AZERBAIJAN; + private static Flag $BURUNDI; + private static Flag $BELGIUM; + private static Flag $BENIN; + private static Flag $BURKINAFASO; + private static Flag $BANGLADESH; + private static Flag $BULGARIA; + private static Flag $BAHRAIN; + private static Flag $BAHAMAS; + private static Flag $BOSNIAANDHERZEGOVINA; + private static Flag $BELARUS; + private static Flag $BELIZE; + private static Flag $BOLIVIA; + private static Flag $BRAZIL; + private static Flag $BARBADOS; + private static Flag $BRUNEIDARUSSALAM; + private static Flag $BHUTAN; + private static Flag $BOTSWANA; + private static Flag $CENTRALAFRICANREPUBLIC; + private static Flag $CANADA; + private static Flag $SWITZERLAND; + private static Flag $CHILE; + private static Flag $CHINA; + private static Flag $CTEDIVOIRE; + private static Flag $CAMEROON; + private static Flag $DEMOCRATICREPUBLICOFTHECONGO; + private static Flag $REPUBLICOFTHECONGO; + private static Flag $COLOMBIA; + private static Flag $COMOROS; + private static Flag $CAPEVERDE; + private static Flag $COSTARICA; + private static Flag $CUBA; + private static Flag $CYPRUS; + private static Flag $CZECHREPUBLIC; + private static Flag $GERMANY; + private static Flag $DJIBOUTI; + private static Flag $DOMINICA; + private static Flag $DENMARK; + private static Flag $DOMINICANREPUBLIC; + private static Flag $ALGERIA; + private static Flag $ECUADOR; + private static Flag $EGYPT; + private static Flag $ERITREA; + private static Flag $SPAIN; + private static Flag $ESTONIA; + private static Flag $ETHIOPIA; + private static Flag $FINLAND; + private static Flag $FIJI; + private static Flag $FRANCE; + private static Flag $MICRONESIAFEDERATEDSTATESOF; + private static Flag $GABON; + private static Flag $UNITEDKINGDOM; + private static Flag $GEORGIA; + private static Flag $GHANA; + private static Flag $GUINEA; + private static Flag $GAMBIA; + private static Flag $GUINEABISSAU; + private static Flag $EQUATORIALGUINEA; + private static Flag $GREECE; + private static Flag $GRENADA; + private static Flag $GUATEMALA; + private static Flag $GUYANA; + private static Flag $HONDURAS; + private static Flag $CROATIA; + private static Flag $HAITI; + private static Flag $HUNGARY; + private static Flag $INDONESIA; + private static Flag $INDIA; + private static Flag $IRELAND; + private static Flag $IRANISLAMICREPUBLICOF; + private static Flag $IRAQ; + private static Flag $ICELAND; + private static Flag $ISRAEL; + private static Flag $ITALY; + private static Flag $JAMAICA; + private static Flag $JORDAN; + private static Flag $JAPAN; + private static Flag $KAZAKHSTAN; + private static Flag $KENYA; + private static Flag $KYRGYZSTAN; + private static Flag $CAMBODIA; + private static Flag $KIRIBATI; + private static Flag $SAINTKITTSANDNEVIS; + private static Flag $SOUTHKOREA; + private static Flag $KUWAIT; + private static Flag $LAOPEOPLESDEMOCRATICREPUBLIC; + private static Flag $LEBANON; + private static Flag $LIBERIA; + private static Flag $LIBYA; + private static Flag $SAINTLUCIA; + private static Flag $LIECHTENSTEIN; + private static Flag $SRILANKA; + private static Flag $LESOTHO; + private static Flag $LITHUANIA; + private static Flag $LUXEMBOURG; + private static Flag $LATVIA; + private static Flag $MOROCCO; + private static Flag $MONACO; + private static Flag $MOLDOVA; + private static Flag $MADAGASCAR; + private static Flag $MALDIVES; + private static Flag $MEXICO; + private static Flag $MARSHALLISLANDS; + private static Flag $NORTHMACEDONIA; + private static Flag $MALI; + private static Flag $MALTA; + private static Flag $MYANMAR; + private static Flag $MONTENEGRO; + private static Flag $MONGOLIA; + private static Flag $MOZAMBIQUE; + private static Flag $MAURITANIA; + private static Flag $MAURITIUS; + private static Flag $MALAWI; + private static Flag $MALAYSIA; + private static Flag $NAMIBIA; + private static Flag $NIGER; + private static Flag $NIGERIA; + private static Flag $NICARAGUA; + private static Flag $NETHERLANDS; + private static Flag $NORWAY; + private static Flag $NEPAL; + private static Flag $NAURU; + private static Flag $NEWZEALAND; + private static Flag $OMAN; + private static Flag $PAKISTAN; + private static Flag $PANAMA; + private static Flag $PERU; + private static Flag $PHILIPPINES; + private static Flag $PALAU; + private static Flag $PAPUANEWGUINEA; + private static Flag $POLAND; + private static Flag $NORTHKOREA; + private static Flag $PORTUGAL; + private static Flag $PARAGUAY; + private static Flag $QATAR; + private static Flag $ROMANIA; + private static Flag $RUSSIA; + private static Flag $RWANDA; + private static Flag $SAUDIARABIA; + private static Flag $SUDAN; + private static Flag $SENEGAL; + private static Flag $SINGAPORE; + private static Flag $SOLOMONISLANDS; + private static Flag $SIERRALEONE; + private static Flag $ELSALVADOR; + private static Flag $SANMARINO; + private static Flag $SOMALIA; + private static Flag $SERBIA; + private static Flag $SOUTHSUDAN; + private static Flag $SAOTOMEANDPRINCIPE; + private static Flag $SURINAME; + private static Flag $SLOVAKIA; + private static Flag $SLOVENIA; + private static Flag $SWEDEN; + private static Flag $ESWATINI; + private static Flag $SEYCHELLES; + private static Flag $SYRIA; + private static Flag $CHAD; + private static Flag $TOGO; + private static Flag $THAILAND; + private static Flag $TAJIKISTAN; + private static Flag $TURKMENISTAN; + private static Flag $TIMORLESTE; + private static Flag $TONGA; + private static Flag $TRINIDADANDTOBAGO; + private static Flag $TUNISIA; + private static Flag $TURKEY; + private static Flag $TUVALU; + private static Flag $TANZANIA; + private static Flag $UGANDA; + private static Flag $UKRAINE; + private static Flag $URUGUAY; + private static Flag $UNITEDSTATES; + private static Flag $UZBEKISTAN; + private static Flag $VATICANCITY; + private static Flag $SAINTVINCENTANDTHEGRENADINES; + private static Flag $VENEZUELA; + private static Flag $VIETNAM; + private static Flag $VANUATU; + private static Flag $SAMOA; + private static Flag $YEMEN; + private static Flag $SOUTHAFRICA; + private static Flag $ZAMBIA; + private static Flag $ZIMBABWE; + + 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 AFGHANISTAN(): Flag + { + if (!isset(self::$AFGHANISTAN)) { + self::$AFGHANISTAN = new Flag('af'); + } + return self::$AFGHANISTAN; + } + public static function ANGOLA(): Flag + { + if (!isset(self::$ANGOLA)) { + self::$ANGOLA = new Flag('ao'); + } + return self::$ANGOLA; + } + public static function ALBANIA(): Flag + { + if (!isset(self::$ALBANIA)) { + self::$ALBANIA = new Flag('al'); + } + return self::$ALBANIA; + } + public static function ANDORRA(): Flag + { + if (!isset(self::$ANDORRA)) { + self::$ANDORRA = new Flag('ad'); + } + return self::$ANDORRA; + } + public static function UNITEDARABEMIRATES(): Flag + { + if (!isset(self::$UNITEDARABEMIRATES)) { + self::$UNITEDARABEMIRATES = new Flag('ae'); + } + return self::$UNITEDARABEMIRATES; + } + public static function ARGENTINA(): Flag + { + if (!isset(self::$ARGENTINA)) { + self::$ARGENTINA = new Flag('ar'); + } + return self::$ARGENTINA; + } + public static function ARMENIA(): Flag + { + if (!isset(self::$ARMENIA)) { + self::$ARMENIA = new Flag('am'); + } + return self::$ARMENIA; + } + public static function ANTIGUAANDBARBUDA(): Flag + { + if (!isset(self::$ANTIGUAANDBARBUDA)) { + self::$ANTIGUAANDBARBUDA = new Flag('ag'); + } + return self::$ANTIGUAANDBARBUDA; + } + public static function AUSTRALIA(): Flag + { + if (!isset(self::$AUSTRALIA)) { + self::$AUSTRALIA = new Flag('au'); + } + return self::$AUSTRALIA; + } + public static function AUSTRIA(): Flag + { + if (!isset(self::$AUSTRIA)) { + self::$AUSTRIA = new Flag('at'); + } + return self::$AUSTRIA; + } + public static function AZERBAIJAN(): Flag + { + if (!isset(self::$AZERBAIJAN)) { + self::$AZERBAIJAN = new Flag('az'); + } + return self::$AZERBAIJAN; + } + public static function BURUNDI(): Flag + { + if (!isset(self::$BURUNDI)) { + self::$BURUNDI = new Flag('bi'); + } + return self::$BURUNDI; + } + public static function BELGIUM(): Flag + { + if (!isset(self::$BELGIUM)) { + self::$BELGIUM = new Flag('be'); + } + return self::$BELGIUM; + } + public static function BENIN(): Flag + { + if (!isset(self::$BENIN)) { + self::$BENIN = new Flag('bj'); + } + return self::$BENIN; + } + public static function BURKINAFASO(): Flag + { + if (!isset(self::$BURKINAFASO)) { + self::$BURKINAFASO = new Flag('bf'); + } + return self::$BURKINAFASO; + } + public static function BANGLADESH(): Flag + { + if (!isset(self::$BANGLADESH)) { + self::$BANGLADESH = new Flag('bd'); + } + return self::$BANGLADESH; + } + public static function BULGARIA(): Flag + { + if (!isset(self::$BULGARIA)) { + self::$BULGARIA = new Flag('bg'); + } + return self::$BULGARIA; + } + public static function BAHRAIN(): Flag + { + if (!isset(self::$BAHRAIN)) { + self::$BAHRAIN = new Flag('bh'); + } + return self::$BAHRAIN; + } + public static function BAHAMAS(): Flag + { + if (!isset(self::$BAHAMAS)) { + self::$BAHAMAS = new Flag('bs'); + } + return self::$BAHAMAS; + } + public static function BOSNIAANDHERZEGOVINA(): Flag + { + if (!isset(self::$BOSNIAANDHERZEGOVINA)) { + self::$BOSNIAANDHERZEGOVINA = new Flag('ba'); + } + return self::$BOSNIAANDHERZEGOVINA; + } + public static function BELARUS(): Flag + { + if (!isset(self::$BELARUS)) { + self::$BELARUS = new Flag('by'); + } + return self::$BELARUS; + } + public static function BELIZE(): Flag + { + if (!isset(self::$BELIZE)) { + self::$BELIZE = new Flag('bz'); + } + return self::$BELIZE; + } + public static function BOLIVIA(): Flag + { + if (!isset(self::$BOLIVIA)) { + self::$BOLIVIA = new Flag('bo'); + } + return self::$BOLIVIA; + } + public static function BRAZIL(): Flag + { + if (!isset(self::$BRAZIL)) { + self::$BRAZIL = new Flag('br'); + } + return self::$BRAZIL; + } + public static function BARBADOS(): Flag + { + if (!isset(self::$BARBADOS)) { + self::$BARBADOS = new Flag('bb'); + } + return self::$BARBADOS; + } + public static function BRUNEIDARUSSALAM(): Flag + { + if (!isset(self::$BRUNEIDARUSSALAM)) { + self::$BRUNEIDARUSSALAM = new Flag('bn'); + } + return self::$BRUNEIDARUSSALAM; + } + public static function BHUTAN(): Flag + { + if (!isset(self::$BHUTAN)) { + self::$BHUTAN = new Flag('bt'); + } + return self::$BHUTAN; + } + public static function BOTSWANA(): Flag + { + if (!isset(self::$BOTSWANA)) { + self::$BOTSWANA = new Flag('bw'); + } + return self::$BOTSWANA; + } + public static function CENTRALAFRICANREPUBLIC(): Flag + { + if (!isset(self::$CENTRALAFRICANREPUBLIC)) { + self::$CENTRALAFRICANREPUBLIC = new Flag('cf'); + } + return self::$CENTRALAFRICANREPUBLIC; + } + public static function CANADA(): Flag + { + if (!isset(self::$CANADA)) { + self::$CANADA = new Flag('ca'); + } + return self::$CANADA; + } + public static function SWITZERLAND(): Flag + { + if (!isset(self::$SWITZERLAND)) { + self::$SWITZERLAND = new Flag('ch'); + } + return self::$SWITZERLAND; + } + public static function CHILE(): Flag + { + if (!isset(self::$CHILE)) { + self::$CHILE = new Flag('cl'); + } + return self::$CHILE; + } + public static function CHINA(): Flag + { + if (!isset(self::$CHINA)) { + self::$CHINA = new Flag('cn'); + } + return self::$CHINA; + } + public static function CTEDIVOIRE(): Flag + { + if (!isset(self::$CTEDIVOIRE)) { + self::$CTEDIVOIRE = new Flag('ci'); + } + return self::$CTEDIVOIRE; + } + public static function CAMEROON(): Flag + { + if (!isset(self::$CAMEROON)) { + self::$CAMEROON = new Flag('cm'); + } + return self::$CAMEROON; + } + public static function DEMOCRATICREPUBLICOFTHECONGO(): Flag + { + if (!isset(self::$DEMOCRATICREPUBLICOFTHECONGO)) { + self::$DEMOCRATICREPUBLICOFTHECONGO = new Flag('cd'); + } + return self::$DEMOCRATICREPUBLICOFTHECONGO; + } + public static function REPUBLICOFTHECONGO(): Flag + { + if (!isset(self::$REPUBLICOFTHECONGO)) { + self::$REPUBLICOFTHECONGO = new Flag('cg'); + } + return self::$REPUBLICOFTHECONGO; + } + public static function COLOMBIA(): Flag + { + if (!isset(self::$COLOMBIA)) { + self::$COLOMBIA = new Flag('co'); + } + return self::$COLOMBIA; + } + public static function COMOROS(): Flag + { + if (!isset(self::$COMOROS)) { + self::$COMOROS = new Flag('km'); + } + return self::$COMOROS; + } + public static function CAPEVERDE(): Flag + { + if (!isset(self::$CAPEVERDE)) { + self::$CAPEVERDE = new Flag('cv'); + } + return self::$CAPEVERDE; + } + public static function COSTARICA(): Flag + { + if (!isset(self::$COSTARICA)) { + self::$COSTARICA = new Flag('cr'); + } + return self::$COSTARICA; + } + public static function CUBA(): Flag + { + if (!isset(self::$CUBA)) { + self::$CUBA = new Flag('cu'); + } + return self::$CUBA; + } + public static function CYPRUS(): Flag + { + if (!isset(self::$CYPRUS)) { + self::$CYPRUS = new Flag('cy'); + } + return self::$CYPRUS; + } + public static function CZECHREPUBLIC(): Flag + { + if (!isset(self::$CZECHREPUBLIC)) { + self::$CZECHREPUBLIC = new Flag('cz'); + } + return self::$CZECHREPUBLIC; + } + public static function GERMANY(): Flag + { + if (!isset(self::$GERMANY)) { + self::$GERMANY = new Flag('de'); + } + return self::$GERMANY; + } + public static function DJIBOUTI(): Flag + { + if (!isset(self::$DJIBOUTI)) { + self::$DJIBOUTI = new Flag('dj'); + } + return self::$DJIBOUTI; + } + public static function DOMINICA(): Flag + { + if (!isset(self::$DOMINICA)) { + self::$DOMINICA = new Flag('dm'); + } + return self::$DOMINICA; + } + public static function DENMARK(): Flag + { + if (!isset(self::$DENMARK)) { + self::$DENMARK = new Flag('dk'); + } + return self::$DENMARK; + } + public static function DOMINICANREPUBLIC(): Flag + { + if (!isset(self::$DOMINICANREPUBLIC)) { + self::$DOMINICANREPUBLIC = new Flag('do'); + } + return self::$DOMINICANREPUBLIC; + } + public static function ALGERIA(): Flag + { + if (!isset(self::$ALGERIA)) { + self::$ALGERIA = new Flag('dz'); + } + return self::$ALGERIA; + } + public static function ECUADOR(): Flag + { + if (!isset(self::$ECUADOR)) { + self::$ECUADOR = new Flag('ec'); + } + return self::$ECUADOR; + } + public static function EGYPT(): Flag + { + if (!isset(self::$EGYPT)) { + self::$EGYPT = new Flag('eg'); + } + return self::$EGYPT; + } + public static function ERITREA(): Flag + { + if (!isset(self::$ERITREA)) { + self::$ERITREA = new Flag('er'); + } + return self::$ERITREA; + } + public static function SPAIN(): Flag + { + if (!isset(self::$SPAIN)) { + self::$SPAIN = new Flag('es'); + } + return self::$SPAIN; + } + public static function ESTONIA(): Flag + { + if (!isset(self::$ESTONIA)) { + self::$ESTONIA = new Flag('ee'); + } + return self::$ESTONIA; + } + public static function ETHIOPIA(): Flag + { + if (!isset(self::$ETHIOPIA)) { + self::$ETHIOPIA = new Flag('et'); + } + return self::$ETHIOPIA; + } + public static function FINLAND(): Flag + { + if (!isset(self::$FINLAND)) { + self::$FINLAND = new Flag('fi'); + } + return self::$FINLAND; + } + public static function FIJI(): Flag + { + if (!isset(self::$FIJI)) { + self::$FIJI = new Flag('fj'); + } + return self::$FIJI; + } + public static function FRANCE(): Flag + { + if (!isset(self::$FRANCE)) { + self::$FRANCE = new Flag('fr'); + } + return self::$FRANCE; + } + public static function MICRONESIAFEDERATEDSTATESOF(): Flag + { + if (!isset(self::$MICRONESIAFEDERATEDSTATESOF)) { + self::$MICRONESIAFEDERATEDSTATESOF = new Flag('fm'); + } + return self::$MICRONESIAFEDERATEDSTATESOF; + } + public static function GABON(): Flag + { + if (!isset(self::$GABON)) { + self::$GABON = new Flag('ga'); + } + return self::$GABON; + } + public static function UNITEDKINGDOM(): Flag + { + if (!isset(self::$UNITEDKINGDOM)) { + self::$UNITEDKINGDOM = new Flag('gb'); + } + return self::$UNITEDKINGDOM; + } + public static function GEORGIA(): Flag + { + if (!isset(self::$GEORGIA)) { + self::$GEORGIA = new Flag('ge'); + } + return self::$GEORGIA; + } + public static function GHANA(): Flag + { + if (!isset(self::$GHANA)) { + self::$GHANA = new Flag('gh'); + } + return self::$GHANA; + } + public static function GUINEA(): Flag + { + if (!isset(self::$GUINEA)) { + self::$GUINEA = new Flag('gn'); + } + return self::$GUINEA; + } + public static function GAMBIA(): Flag + { + if (!isset(self::$GAMBIA)) { + self::$GAMBIA = new Flag('gm'); + } + return self::$GAMBIA; + } + public static function GUINEABISSAU(): Flag + { + if (!isset(self::$GUINEABISSAU)) { + self::$GUINEABISSAU = new Flag('gw'); + } + return self::$GUINEABISSAU; + } + public static function EQUATORIALGUINEA(): Flag + { + if (!isset(self::$EQUATORIALGUINEA)) { + self::$EQUATORIALGUINEA = new Flag('gq'); + } + return self::$EQUATORIALGUINEA; + } + public static function GREECE(): Flag + { + if (!isset(self::$GREECE)) { + self::$GREECE = new Flag('gr'); + } + return self::$GREECE; + } + public static function GRENADA(): Flag + { + if (!isset(self::$GRENADA)) { + self::$GRENADA = new Flag('gd'); + } + return self::$GRENADA; + } + public static function GUATEMALA(): Flag + { + if (!isset(self::$GUATEMALA)) { + self::$GUATEMALA = new Flag('gt'); + } + return self::$GUATEMALA; + } + public static function GUYANA(): Flag + { + if (!isset(self::$GUYANA)) { + self::$GUYANA = new Flag('gy'); + } + return self::$GUYANA; + } + public static function HONDURAS(): Flag + { + if (!isset(self::$HONDURAS)) { + self::$HONDURAS = new Flag('hn'); + } + return self::$HONDURAS; + } + public static function CROATIA(): Flag + { + if (!isset(self::$CROATIA)) { + self::$CROATIA = new Flag('hr'); + } + return self::$CROATIA; + } + public static function HAITI(): Flag + { + if (!isset(self::$HAITI)) { + self::$HAITI = new Flag('ht'); + } + return self::$HAITI; + } + public static function HUNGARY(): Flag + { + if (!isset(self::$HUNGARY)) { + self::$HUNGARY = new Flag('hu'); + } + return self::$HUNGARY; + } + public static function INDONESIA(): Flag + { + if (!isset(self::$INDONESIA)) { + self::$INDONESIA = new Flag('id'); + } + return self::$INDONESIA; + } + public static function INDIA(): Flag + { + if (!isset(self::$INDIA)) { + self::$INDIA = new Flag('in'); + } + return self::$INDIA; + } + public static function IRELAND(): Flag + { + if (!isset(self::$IRELAND)) { + self::$IRELAND = new Flag('ie'); + } + return self::$IRELAND; + } + public static function IRANISLAMICREPUBLICOF(): Flag + { + if (!isset(self::$IRANISLAMICREPUBLICOF)) { + self::$IRANISLAMICREPUBLICOF = new Flag('ir'); + } + return self::$IRANISLAMICREPUBLICOF; + } + public static function IRAQ(): Flag + { + if (!isset(self::$IRAQ)) { + self::$IRAQ = new Flag('iq'); + } + return self::$IRAQ; + } + public static function ICELAND(): Flag + { + if (!isset(self::$ICELAND)) { + self::$ICELAND = new Flag('is'); + } + return self::$ICELAND; + } + public static function ISRAEL(): Flag + { + if (!isset(self::$ISRAEL)) { + self::$ISRAEL = new Flag('il'); + } + return self::$ISRAEL; + } + public static function ITALY(): Flag + { + if (!isset(self::$ITALY)) { + self::$ITALY = new Flag('it'); + } + return self::$ITALY; + } + public static function JAMAICA(): Flag + { + if (!isset(self::$JAMAICA)) { + self::$JAMAICA = new Flag('jm'); + } + return self::$JAMAICA; + } + public static function JORDAN(): Flag + { + if (!isset(self::$JORDAN)) { + self::$JORDAN = new Flag('jo'); + } + return self::$JORDAN; + } + public static function JAPAN(): Flag + { + if (!isset(self::$JAPAN)) { + self::$JAPAN = new Flag('jp'); + } + return self::$JAPAN; + } + public static function KAZAKHSTAN(): Flag + { + if (!isset(self::$KAZAKHSTAN)) { + self::$KAZAKHSTAN = new Flag('kz'); + } + return self::$KAZAKHSTAN; + } + public static function KENYA(): Flag + { + if (!isset(self::$KENYA)) { + self::$KENYA = new Flag('ke'); + } + return self::$KENYA; + } + public static function KYRGYZSTAN(): Flag + { + if (!isset(self::$KYRGYZSTAN)) { + self::$KYRGYZSTAN = new Flag('kg'); + } + return self::$KYRGYZSTAN; + } + public static function CAMBODIA(): Flag + { + if (!isset(self::$CAMBODIA)) { + self::$CAMBODIA = new Flag('kh'); + } + return self::$CAMBODIA; + } + public static function KIRIBATI(): Flag + { + if (!isset(self::$KIRIBATI)) { + self::$KIRIBATI = new Flag('ki'); + } + return self::$KIRIBATI; + } + public static function SAINTKITTSANDNEVIS(): Flag + { + if (!isset(self::$SAINTKITTSANDNEVIS)) { + self::$SAINTKITTSANDNEVIS = new Flag('kn'); + } + return self::$SAINTKITTSANDNEVIS; + } + public static function SOUTHKOREA(): Flag + { + if (!isset(self::$SOUTHKOREA)) { + self::$SOUTHKOREA = new Flag('kr'); + } + return self::$SOUTHKOREA; + } + public static function KUWAIT(): Flag + { + if (!isset(self::$KUWAIT)) { + self::$KUWAIT = new Flag('kw'); + } + return self::$KUWAIT; + } + public static function LAOPEOPLESDEMOCRATICREPUBLIC(): Flag + { + if (!isset(self::$LAOPEOPLESDEMOCRATICREPUBLIC)) { + self::$LAOPEOPLESDEMOCRATICREPUBLIC = new Flag('la'); + } + return self::$LAOPEOPLESDEMOCRATICREPUBLIC; + } + public static function LEBANON(): Flag + { + if (!isset(self::$LEBANON)) { + self::$LEBANON = new Flag('lb'); + } + return self::$LEBANON; + } + public static function LIBERIA(): Flag + { + if (!isset(self::$LIBERIA)) { + self::$LIBERIA = new Flag('lr'); + } + return self::$LIBERIA; + } + public static function LIBYA(): Flag + { + if (!isset(self::$LIBYA)) { + self::$LIBYA = new Flag('ly'); + } + return self::$LIBYA; + } + public static function SAINTLUCIA(): Flag + { + if (!isset(self::$SAINTLUCIA)) { + self::$SAINTLUCIA = new Flag('lc'); + } + return self::$SAINTLUCIA; + } + public static function LIECHTENSTEIN(): Flag + { + if (!isset(self::$LIECHTENSTEIN)) { + self::$LIECHTENSTEIN = new Flag('li'); + } + return self::$LIECHTENSTEIN; + } + public static function SRILANKA(): Flag + { + if (!isset(self::$SRILANKA)) { + self::$SRILANKA = new Flag('lk'); + } + return self::$SRILANKA; + } + public static function LESOTHO(): Flag + { + if (!isset(self::$LESOTHO)) { + self::$LESOTHO = new Flag('ls'); + } + return self::$LESOTHO; + } + public static function LITHUANIA(): Flag + { + if (!isset(self::$LITHUANIA)) { + self::$LITHUANIA = new Flag('lt'); + } + return self::$LITHUANIA; + } + public static function LUXEMBOURG(): Flag + { + if (!isset(self::$LUXEMBOURG)) { + self::$LUXEMBOURG = new Flag('lu'); + } + return self::$LUXEMBOURG; + } + public static function LATVIA(): Flag + { + if (!isset(self::$LATVIA)) { + self::$LATVIA = new Flag('lv'); + } + return self::$LATVIA; + } + public static function MOROCCO(): Flag + { + if (!isset(self::$MOROCCO)) { + self::$MOROCCO = new Flag('ma'); + } + return self::$MOROCCO; + } + public static function MONACO(): Flag + { + if (!isset(self::$MONACO)) { + self::$MONACO = new Flag('mc'); + } + return self::$MONACO; + } + public static function MOLDOVA(): Flag + { + if (!isset(self::$MOLDOVA)) { + self::$MOLDOVA = new Flag('md'); + } + return self::$MOLDOVA; + } + public static function MADAGASCAR(): Flag + { + if (!isset(self::$MADAGASCAR)) { + self::$MADAGASCAR = new Flag('mg'); + } + return self::$MADAGASCAR; + } + public static function MALDIVES(): Flag + { + if (!isset(self::$MALDIVES)) { + self::$MALDIVES = new Flag('mv'); + } + return self::$MALDIVES; + } + public static function MEXICO(): Flag + { + if (!isset(self::$MEXICO)) { + self::$MEXICO = new Flag('mx'); + } + return self::$MEXICO; + } + public static function MARSHALLISLANDS(): Flag + { + if (!isset(self::$MARSHALLISLANDS)) { + self::$MARSHALLISLANDS = new Flag('mh'); + } + return self::$MARSHALLISLANDS; + } + public static function NORTHMACEDONIA(): Flag + { + if (!isset(self::$NORTHMACEDONIA)) { + self::$NORTHMACEDONIA = new Flag('mk'); + } + return self::$NORTHMACEDONIA; + } + public static function MALI(): Flag + { + if (!isset(self::$MALI)) { + self::$MALI = new Flag('ml'); + } + return self::$MALI; + } + public static function MALTA(): Flag + { + if (!isset(self::$MALTA)) { + self::$MALTA = new Flag('mt'); + } + return self::$MALTA; + } + public static function MYANMAR(): Flag + { + if (!isset(self::$MYANMAR)) { + self::$MYANMAR = new Flag('mm'); + } + return self::$MYANMAR; + } + public static function MONTENEGRO(): Flag + { + if (!isset(self::$MONTENEGRO)) { + self::$MONTENEGRO = new Flag('me'); + } + return self::$MONTENEGRO; + } + public static function MONGOLIA(): Flag + { + if (!isset(self::$MONGOLIA)) { + self::$MONGOLIA = new Flag('mn'); + } + return self::$MONGOLIA; + } + public static function MOZAMBIQUE(): Flag + { + if (!isset(self::$MOZAMBIQUE)) { + self::$MOZAMBIQUE = new Flag('mz'); + } + return self::$MOZAMBIQUE; + } + public static function MAURITANIA(): Flag + { + if (!isset(self::$MAURITANIA)) { + self::$MAURITANIA = new Flag('mr'); + } + return self::$MAURITANIA; + } + public static function MAURITIUS(): Flag + { + if (!isset(self::$MAURITIUS)) { + self::$MAURITIUS = new Flag('mu'); + } + return self::$MAURITIUS; + } + public static function MALAWI(): Flag + { + if (!isset(self::$MALAWI)) { + self::$MALAWI = new Flag('mw'); + } + return self::$MALAWI; + } + public static function MALAYSIA(): Flag + { + if (!isset(self::$MALAYSIA)) { + self::$MALAYSIA = new Flag('my'); + } + return self::$MALAYSIA; + } + public static function NAMIBIA(): Flag + { + if (!isset(self::$NAMIBIA)) { + self::$NAMIBIA = new Flag('na'); + } + return self::$NAMIBIA; + } + public static function NIGER(): Flag + { + if (!isset(self::$NIGER)) { + self::$NIGER = new Flag('ne'); + } + return self::$NIGER; + } + public static function NIGERIA(): Flag + { + if (!isset(self::$NIGERIA)) { + self::$NIGERIA = new Flag('ng'); + } + return self::$NIGERIA; + } + public static function NICARAGUA(): Flag + { + if (!isset(self::$NICARAGUA)) { + self::$NICARAGUA = new Flag('ni'); + } + return self::$NICARAGUA; + } + public static function NETHERLANDS(): Flag + { + if (!isset(self::$NETHERLANDS)) { + self::$NETHERLANDS = new Flag('nl'); + } + return self::$NETHERLANDS; + } + public static function NORWAY(): Flag + { + if (!isset(self::$NORWAY)) { + self::$NORWAY = new Flag('no'); + } + return self::$NORWAY; + } + public static function NEPAL(): Flag + { + if (!isset(self::$NEPAL)) { + self::$NEPAL = new Flag('np'); + } + return self::$NEPAL; + } + public static function NAURU(): Flag + { + if (!isset(self::$NAURU)) { + self::$NAURU = new Flag('nr'); + } + return self::$NAURU; + } + public static function NEWZEALAND(): Flag + { + if (!isset(self::$NEWZEALAND)) { + self::$NEWZEALAND = new Flag('nz'); + } + return self::$NEWZEALAND; + } + public static function OMAN(): Flag + { + if (!isset(self::$OMAN)) { + self::$OMAN = new Flag('om'); + } + return self::$OMAN; + } + public static function PAKISTAN(): Flag + { + if (!isset(self::$PAKISTAN)) { + self::$PAKISTAN = new Flag('pk'); + } + return self::$PAKISTAN; + } + public static function PANAMA(): Flag + { + if (!isset(self::$PANAMA)) { + self::$PANAMA = new Flag('pa'); + } + return self::$PANAMA; + } + public static function PERU(): Flag + { + if (!isset(self::$PERU)) { + self::$PERU = new Flag('pe'); + } + return self::$PERU; + } + public static function PHILIPPINES(): Flag + { + if (!isset(self::$PHILIPPINES)) { + self::$PHILIPPINES = new Flag('ph'); + } + return self::$PHILIPPINES; + } + public static function PALAU(): Flag + { + if (!isset(self::$PALAU)) { + self::$PALAU = new Flag('pw'); + } + return self::$PALAU; + } + public static function PAPUANEWGUINEA(): Flag + { + if (!isset(self::$PAPUANEWGUINEA)) { + self::$PAPUANEWGUINEA = new Flag('pg'); + } + return self::$PAPUANEWGUINEA; + } + public static function POLAND(): Flag + { + if (!isset(self::$POLAND)) { + self::$POLAND = new Flag('pl'); + } + return self::$POLAND; + } + public static function NORTHKOREA(): Flag + { + if (!isset(self::$NORTHKOREA)) { + self::$NORTHKOREA = new Flag('kp'); + } + return self::$NORTHKOREA; + } + public static function PORTUGAL(): Flag + { + if (!isset(self::$PORTUGAL)) { + self::$PORTUGAL = new Flag('pt'); + } + return self::$PORTUGAL; + } + public static function PARAGUAY(): Flag + { + if (!isset(self::$PARAGUAY)) { + self::$PARAGUAY = new Flag('py'); + } + return self::$PARAGUAY; + } + public static function QATAR(): Flag + { + if (!isset(self::$QATAR)) { + self::$QATAR = new Flag('qa'); + } + return self::$QATAR; + } + public static function ROMANIA(): Flag + { + if (!isset(self::$ROMANIA)) { + self::$ROMANIA = new Flag('ro'); + } + return self::$ROMANIA; + } + public static function RUSSIA(): Flag + { + if (!isset(self::$RUSSIA)) { + self::$RUSSIA = new Flag('ru'); + } + return self::$RUSSIA; + } + public static function RWANDA(): Flag + { + if (!isset(self::$RWANDA)) { + self::$RWANDA = new Flag('rw'); + } + return self::$RWANDA; + } + public static function SAUDIARABIA(): Flag + { + if (!isset(self::$SAUDIARABIA)) { + self::$SAUDIARABIA = new Flag('sa'); + } + return self::$SAUDIARABIA; + } + public static function SUDAN(): Flag + { + if (!isset(self::$SUDAN)) { + self::$SUDAN = new Flag('sd'); + } + return self::$SUDAN; + } + public static function SENEGAL(): Flag + { + if (!isset(self::$SENEGAL)) { + self::$SENEGAL = new Flag('sn'); + } + return self::$SENEGAL; + } + public static function SINGAPORE(): Flag + { + if (!isset(self::$SINGAPORE)) { + self::$SINGAPORE = new Flag('sg'); + } + return self::$SINGAPORE; + } + public static function SOLOMONISLANDS(): Flag + { + if (!isset(self::$SOLOMONISLANDS)) { + self::$SOLOMONISLANDS = new Flag('sb'); + } + return self::$SOLOMONISLANDS; + } + public static function SIERRALEONE(): Flag + { + if (!isset(self::$SIERRALEONE)) { + self::$SIERRALEONE = new Flag('sl'); + } + return self::$SIERRALEONE; + } + public static function ELSALVADOR(): Flag + { + if (!isset(self::$ELSALVADOR)) { + self::$ELSALVADOR = new Flag('sv'); + } + return self::$ELSALVADOR; + } + public static function SANMARINO(): Flag + { + if (!isset(self::$SANMARINO)) { + self::$SANMARINO = new Flag('sm'); + } + return self::$SANMARINO; + } + public static function SOMALIA(): Flag + { + if (!isset(self::$SOMALIA)) { + self::$SOMALIA = new Flag('so'); + } + return self::$SOMALIA; + } + public static function SERBIA(): Flag + { + if (!isset(self::$SERBIA)) { + self::$SERBIA = new Flag('rs'); + } + return self::$SERBIA; + } + public static function SOUTHSUDAN(): Flag + { + if (!isset(self::$SOUTHSUDAN)) { + self::$SOUTHSUDAN = new Flag('ss'); + } + return self::$SOUTHSUDAN; + } + public static function SAOTOMEANDPRINCIPE(): Flag + { + if (!isset(self::$SAOTOMEANDPRINCIPE)) { + self::$SAOTOMEANDPRINCIPE = new Flag('st'); + } + return self::$SAOTOMEANDPRINCIPE; + } + public static function SURINAME(): Flag + { + if (!isset(self::$SURINAME)) { + self::$SURINAME = new Flag('sr'); + } + return self::$SURINAME; + } + public static function SLOVAKIA(): Flag + { + if (!isset(self::$SLOVAKIA)) { + self::$SLOVAKIA = new Flag('sk'); + } + return self::$SLOVAKIA; + } + public static function SLOVENIA(): Flag + { + if (!isset(self::$SLOVENIA)) { + self::$SLOVENIA = new Flag('si'); + } + return self::$SLOVENIA; + } + public static function SWEDEN(): Flag + { + if (!isset(self::$SWEDEN)) { + self::$SWEDEN = new Flag('se'); + } + return self::$SWEDEN; + } + public static function ESWATINI(): Flag + { + if (!isset(self::$ESWATINI)) { + self::$ESWATINI = new Flag('sz'); + } + return self::$ESWATINI; + } + public static function SEYCHELLES(): Flag + { + if (!isset(self::$SEYCHELLES)) { + self::$SEYCHELLES = new Flag('sc'); + } + return self::$SEYCHELLES; + } + public static function SYRIA(): Flag + { + if (!isset(self::$SYRIA)) { + self::$SYRIA = new Flag('sy'); + } + return self::$SYRIA; + } + public static function CHAD(): Flag + { + if (!isset(self::$CHAD)) { + self::$CHAD = new Flag('td'); + } + return self::$CHAD; + } + public static function TOGO(): Flag + { + if (!isset(self::$TOGO)) { + self::$TOGO = new Flag('tg'); + } + return self::$TOGO; + } + public static function THAILAND(): Flag + { + if (!isset(self::$THAILAND)) { + self::$THAILAND = new Flag('th'); + } + return self::$THAILAND; + } + public static function TAJIKISTAN(): Flag + { + if (!isset(self::$TAJIKISTAN)) { + self::$TAJIKISTAN = new Flag('tj'); + } + return self::$TAJIKISTAN; + } + public static function TURKMENISTAN(): Flag + { + if (!isset(self::$TURKMENISTAN)) { + self::$TURKMENISTAN = new Flag('tm'); + } + return self::$TURKMENISTAN; + } + public static function TIMORLESTE(): Flag + { + if (!isset(self::$TIMORLESTE)) { + self::$TIMORLESTE = new Flag('tl'); + } + return self::$TIMORLESTE; + } + public static function TONGA(): Flag + { + if (!isset(self::$TONGA)) { + self::$TONGA = new Flag('to'); + } + return self::$TONGA; + } + public static function TRINIDADANDTOBAGO(): Flag + { + if (!isset(self::$TRINIDADANDTOBAGO)) { + self::$TRINIDADANDTOBAGO = new Flag('tt'); + } + return self::$TRINIDADANDTOBAGO; + } + public static function TUNISIA(): Flag + { + if (!isset(self::$TUNISIA)) { + self::$TUNISIA = new Flag('tn'); + } + return self::$TUNISIA; + } + public static function TURKEY(): Flag + { + if (!isset(self::$TURKEY)) { + self::$TURKEY = new Flag('tr'); + } + return self::$TURKEY; + } + public static function TUVALU(): Flag + { + if (!isset(self::$TUVALU)) { + self::$TUVALU = new Flag('tv'); + } + return self::$TUVALU; + } + public static function TANZANIA(): Flag + { + if (!isset(self::$TANZANIA)) { + self::$TANZANIA = new Flag('tz'); + } + return self::$TANZANIA; + } + public static function UGANDA(): Flag + { + if (!isset(self::$UGANDA)) { + self::$UGANDA = new Flag('ug'); + } + return self::$UGANDA; + } + public static function UKRAINE(): Flag + { + if (!isset(self::$UKRAINE)) { + self::$UKRAINE = new Flag('ua'); + } + return self::$UKRAINE; + } + public static function URUGUAY(): Flag + { + if (!isset(self::$URUGUAY)) { + self::$URUGUAY = new Flag('uy'); + } + return self::$URUGUAY; + } + public static function UNITEDSTATES(): Flag + { + if (!isset(self::$UNITEDSTATES)) { + self::$UNITEDSTATES = new Flag('us'); + } + return self::$UNITEDSTATES; + } + public static function UZBEKISTAN(): Flag + { + if (!isset(self::$UZBEKISTAN)) { + self::$UZBEKISTAN = new Flag('uz'); + } + return self::$UZBEKISTAN; + } + public static function VATICANCITY(): Flag + { + if (!isset(self::$VATICANCITY)) { + self::$VATICANCITY = new Flag('va'); + } + return self::$VATICANCITY; + } + public static function SAINTVINCENTANDTHEGRENADINES(): Flag + { + if (!isset(self::$SAINTVINCENTANDTHEGRENADINES)) { + self::$SAINTVINCENTANDTHEGRENADINES = new Flag('vc'); + } + return self::$SAINTVINCENTANDTHEGRENADINES; + } + public static function VENEZUELA(): Flag + { + if (!isset(self::$VENEZUELA)) { + self::$VENEZUELA = new Flag('ve'); + } + return self::$VENEZUELA; + } + public static function VIETNAM(): Flag + { + if (!isset(self::$VIETNAM)) { + self::$VIETNAM = new Flag('vn'); + } + return self::$VIETNAM; + } + public static function VANUATU(): Flag + { + if (!isset(self::$VANUATU)) { + self::$VANUATU = new Flag('vu'); + } + return self::$VANUATU; + } + public static function SAMOA(): Flag + { + if (!isset(self::$SAMOA)) { + self::$SAMOA = new Flag('ws'); + } + return self::$SAMOA; + } + public static function YEMEN(): Flag + { + if (!isset(self::$YEMEN)) { + self::$YEMEN = new Flag('ye'); + } + return self::$YEMEN; + } + public static function SOUTHAFRICA(): Flag + { + if (!isset(self::$SOUTHAFRICA)) { + self::$SOUTHAFRICA = new Flag('za'); + } + return self::$SOUTHAFRICA; + } + public static function ZAMBIA(): Flag + { + if (!isset(self::$ZAMBIA)) { + self::$ZAMBIA = new Flag('zm'); + } + return self::$ZAMBIA; + } + public static function ZIMBABWE(): Flag + { + if (!isset(self::$ZIMBABWE)) { + self::$ZIMBABWE = new Flag('zw'); + } + return self::$ZIMBABWE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/ImageFormat.php b/src/Appwrite/Enums/ImageFormat.php new file mode 100644 index 0000000..9ec15d2 --- /dev/null +++ b/src/Appwrite/Enums/ImageFormat.php @@ -0,0 +1,67 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class ImageFormat implements JsonSerializable +{ + private static ImageFormat $JPG; + private static ImageFormat $JPEG; + private static ImageFormat $GIF; + private static ImageFormat $PNG; + private static ImageFormat $WEBP; + + 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 JPG(): ImageFormat + { + if (!isset(self::$JPG)) { + self::$JPG = new ImageFormat('jpg'); + } + return self::$JPG; + } + public static function JPEG(): ImageFormat + { + if (!isset(self::$JPEG)) { + self::$JPEG = new ImageFormat('jpeg'); + } + return self::$JPEG; + } + public static function GIF(): ImageFormat + { + if (!isset(self::$GIF)) { + self::$GIF = new ImageFormat('gif'); + } + return self::$GIF; + } + public static function PNG(): ImageFormat + { + if (!isset(self::$PNG)) { + self::$PNG = new ImageFormat('png'); + } + return self::$PNG; + } + public static function WEBP(): ImageFormat + { + if (!isset(self::$WEBP)) { + self::$WEBP = new ImageFormat('webp'); + } + return self::$WEBP; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/ImageGravity.php b/src/Appwrite/Enums/ImageGravity.php new file mode 100644 index 0000000..a909cb8 --- /dev/null +++ b/src/Appwrite/Enums/ImageGravity.php @@ -0,0 +1,99 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class ImageGravity implements JsonSerializable +{ + private static ImageGravity $CENTER; + private static ImageGravity $TOPLEFT; + private static ImageGravity $TOP; + private static ImageGravity $TOPRIGHT; + private static ImageGravity $LEFT; + private static ImageGravity $RIGHT; + private static ImageGravity $BOTTOMLEFT; + private static ImageGravity $BOTTOM; + private static ImageGravity $BOTTOMRIGHT; + + 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 CENTER(): ImageGravity + { + if (!isset(self::$CENTER)) { + self::$CENTER = new ImageGravity('center'); + } + return self::$CENTER; + } + public static function TOPLEFT(): ImageGravity + { + if (!isset(self::$TOPLEFT)) { + self::$TOPLEFT = new ImageGravity('top-left'); + } + return self::$TOPLEFT; + } + public static function TOP(): ImageGravity + { + if (!isset(self::$TOP)) { + self::$TOP = new ImageGravity('top'); + } + return self::$TOP; + } + public static function TOPRIGHT(): ImageGravity + { + if (!isset(self::$TOPRIGHT)) { + self::$TOPRIGHT = new ImageGravity('top-right'); + } + return self::$TOPRIGHT; + } + public static function LEFT(): ImageGravity + { + if (!isset(self::$LEFT)) { + self::$LEFT = new ImageGravity('left'); + } + return self::$LEFT; + } + public static function RIGHT(): ImageGravity + { + if (!isset(self::$RIGHT)) { + self::$RIGHT = new ImageGravity('right'); + } + return self::$RIGHT; + } + public static function BOTTOMLEFT(): ImageGravity + { + if (!isset(self::$BOTTOMLEFT)) { + self::$BOTTOMLEFT = new ImageGravity('bottom-left'); + } + return self::$BOTTOMLEFT; + } + public static function BOTTOM(): ImageGravity + { + if (!isset(self::$BOTTOM)) { + self::$BOTTOM = new ImageGravity('bottom'); + } + return self::$BOTTOM; + } + public static function BOTTOMRIGHT(): ImageGravity + { + if (!isset(self::$BOTTOMRIGHT)) { + self::$BOTTOMRIGHT = new ImageGravity('bottom-right'); + } + return self::$BOTTOMRIGHT; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/IndexType.php b/src/Appwrite/Enums/IndexType.php new file mode 100644 index 0000000..fa71d60 --- /dev/null +++ b/src/Appwrite/Enums/IndexType.php @@ -0,0 +1,51 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class IndexType implements JsonSerializable +{ + private static IndexType $KEY; + private static IndexType $FULLTEXT; + private static IndexType $UNIQUE; + + 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 KEY(): IndexType + { + if (!isset(self::$KEY)) { + self::$KEY = new IndexType('key'); + } + return self::$KEY; + } + public static function FULLTEXT(): IndexType + { + if (!isset(self::$FULLTEXT)) { + self::$FULLTEXT = new IndexType('fulltext'); + } + return self::$FULLTEXT; + } + public static function UNIQUE(): IndexType + { + if (!isset(self::$UNIQUE)) { + self::$UNIQUE = new IndexType('unique'); + } + return self::$UNIQUE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/MessagingProviderType.php b/src/Appwrite/Enums/MessagingProviderType.php new file mode 100644 index 0000000..24a8eb0 --- /dev/null +++ b/src/Appwrite/Enums/MessagingProviderType.php @@ -0,0 +1,51 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class MessagingProviderType implements JsonSerializable +{ + private static MessagingProviderType $EMAIL; + private static MessagingProviderType $SMS; + private static MessagingProviderType $PUSH; + + 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 EMAIL(): MessagingProviderType + { + if (!isset(self::$EMAIL)) { + self::$EMAIL = new MessagingProviderType('email'); + } + return self::$EMAIL; + } + public static function SMS(): MessagingProviderType + { + if (!isset(self::$SMS)) { + self::$SMS = new MessagingProviderType('sms'); + } + return self::$SMS; + } + public static function PUSH(): MessagingProviderType + { + if (!isset(self::$PUSH)) { + self::$PUSH = new MessagingProviderType('push'); + } + return self::$PUSH; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Name.php b/src/Appwrite/Enums/Name.php new file mode 100644 index 0000000..564afb3 --- /dev/null +++ b/src/Appwrite/Enums/Name.php @@ -0,0 +1,131 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class Name implements JsonSerializable +{ + private static Name $V1DATABASE; + private static Name $V1DELETES; + private static Name $V1AUDITS; + private static Name $V1MAILS; + private static Name $V1FUNCTIONS; + private static Name $V1USAGE; + private static Name $V1USAGEDUMP; + private static Name $WEBHOOKSV1; + private static Name $V1CERTIFICATES; + private static Name $V1BUILDS; + private static Name $V1MESSAGING; + private static Name $V1MIGRATIONS; + private static Name $HAMSTERV1; + + 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 V1DATABASE(): Name + { + if (!isset(self::$V1DATABASE)) { + self::$V1DATABASE = new Name('v1-database'); + } + return self::$V1DATABASE; + } + public static function V1DELETES(): Name + { + if (!isset(self::$V1DELETES)) { + self::$V1DELETES = new Name('v1-deletes'); + } + return self::$V1DELETES; + } + public static function V1AUDITS(): Name + { + if (!isset(self::$V1AUDITS)) { + self::$V1AUDITS = new Name('v1-audits'); + } + return self::$V1AUDITS; + } + public static function V1MAILS(): Name + { + if (!isset(self::$V1MAILS)) { + self::$V1MAILS = new Name('v1-mails'); + } + return self::$V1MAILS; + } + public static function V1FUNCTIONS(): Name + { + if (!isset(self::$V1FUNCTIONS)) { + self::$V1FUNCTIONS = new Name('v1-functions'); + } + return self::$V1FUNCTIONS; + } + public static function V1USAGE(): Name + { + if (!isset(self::$V1USAGE)) { + self::$V1USAGE = new Name('v1-usage'); + } + return self::$V1USAGE; + } + public static function V1USAGEDUMP(): Name + { + if (!isset(self::$V1USAGEDUMP)) { + self::$V1USAGEDUMP = new Name('v1-usage-dump'); + } + return self::$V1USAGEDUMP; + } + public static function WEBHOOKSV1(): Name + { + if (!isset(self::$WEBHOOKSV1)) { + self::$WEBHOOKSV1 = new Name('webhooksv1'); + } + return self::$WEBHOOKSV1; + } + public static function V1CERTIFICATES(): Name + { + if (!isset(self::$V1CERTIFICATES)) { + self::$V1CERTIFICATES = new Name('v1-certificates'); + } + return self::$V1CERTIFICATES; + } + public static function V1BUILDS(): Name + { + if (!isset(self::$V1BUILDS)) { + self::$V1BUILDS = new Name('v1-builds'); + } + return self::$V1BUILDS; + } + public static function V1MESSAGING(): Name + { + if (!isset(self::$V1MESSAGING)) { + self::$V1MESSAGING = new Name('v1-messaging'); + } + return self::$V1MESSAGING; + } + public static function V1MIGRATIONS(): Name + { + if (!isset(self::$V1MIGRATIONS)) { + self::$V1MIGRATIONS = new Name('v1-migrations'); + } + return self::$V1MIGRATIONS; + } + public static function HAMSTERV1(): Name + { + if (!isset(self::$HAMSTERV1)) { + self::$HAMSTERV1 = new Name('hamsterv1'); + } + return self::$HAMSTERV1; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/OAuthProvider.php b/src/Appwrite/Enums/OAuthProvider.php new file mode 100644 index 0000000..6ee87be --- /dev/null +++ b/src/Appwrite/Enums/OAuthProvider.php @@ -0,0 +1,339 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class OAuthProvider implements JsonSerializable +{ + private static OAuthProvider $AMAZON; + private static OAuthProvider $APPLE; + private static OAuthProvider $AUTH0; + private static OAuthProvider $AUTHENTIK; + private static OAuthProvider $AUTODESK; + private static OAuthProvider $BITBUCKET; + private static OAuthProvider $BITLY; + private static OAuthProvider $BOX; + private static OAuthProvider $DAILYMOTION; + private static OAuthProvider $DISCORD; + private static OAuthProvider $DISQUS; + private static OAuthProvider $DROPBOX; + private static OAuthProvider $ETSY; + private static OAuthProvider $FACEBOOK; + private static OAuthProvider $GITHUB; + private static OAuthProvider $GITLAB; + private static OAuthProvider $GOOGLE; + private static OAuthProvider $LINKEDIN; + private static OAuthProvider $MICROSOFT; + private static OAuthProvider $NOTION; + private static OAuthProvider $OIDC; + private static OAuthProvider $OKTA; + private static OAuthProvider $PAYPAL; + private static OAuthProvider $PAYPALSANDBOX; + private static OAuthProvider $PODIO; + private static OAuthProvider $SALESFORCE; + private static OAuthProvider $SLACK; + private static OAuthProvider $SPOTIFY; + private static OAuthProvider $STRIPE; + private static OAuthProvider $TRADESHIFT; + private static OAuthProvider $TRADESHIFTBOX; + private static OAuthProvider $TWITCH; + private static OAuthProvider $WORDPRESS; + private static OAuthProvider $YAHOO; + private static OAuthProvider $YAMMER; + private static OAuthProvider $YANDEX; + private static OAuthProvider $ZOHO; + private static OAuthProvider $ZOOM; + private static OAuthProvider $MOCK; + + 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 AMAZON(): OAuthProvider + { + if (!isset(self::$AMAZON)) { + self::$AMAZON = new OAuthProvider('amazon'); + } + return self::$AMAZON; + } + public static function APPLE(): OAuthProvider + { + if (!isset(self::$APPLE)) { + self::$APPLE = new OAuthProvider('apple'); + } + return self::$APPLE; + } + public static function AUTH0(): OAuthProvider + { + if (!isset(self::$AUTH0)) { + self::$AUTH0 = new OAuthProvider('auth0'); + } + return self::$AUTH0; + } + public static function AUTHENTIK(): OAuthProvider + { + if (!isset(self::$AUTHENTIK)) { + self::$AUTHENTIK = new OAuthProvider('authentik'); + } + return self::$AUTHENTIK; + } + public static function AUTODESK(): OAuthProvider + { + if (!isset(self::$AUTODESK)) { + self::$AUTODESK = new OAuthProvider('autodesk'); + } + return self::$AUTODESK; + } + public static function BITBUCKET(): OAuthProvider + { + if (!isset(self::$BITBUCKET)) { + self::$BITBUCKET = new OAuthProvider('bitbucket'); + } + return self::$BITBUCKET; + } + public static function BITLY(): OAuthProvider + { + if (!isset(self::$BITLY)) { + self::$BITLY = new OAuthProvider('bitly'); + } + return self::$BITLY; + } + public static function BOX(): OAuthProvider + { + if (!isset(self::$BOX)) { + self::$BOX = new OAuthProvider('box'); + } + return self::$BOX; + } + public static function DAILYMOTION(): OAuthProvider + { + if (!isset(self::$DAILYMOTION)) { + self::$DAILYMOTION = new OAuthProvider('dailymotion'); + } + return self::$DAILYMOTION; + } + public static function DISCORD(): OAuthProvider + { + if (!isset(self::$DISCORD)) { + self::$DISCORD = new OAuthProvider('discord'); + } + return self::$DISCORD; + } + public static function DISQUS(): OAuthProvider + { + if (!isset(self::$DISQUS)) { + self::$DISQUS = new OAuthProvider('disqus'); + } + return self::$DISQUS; + } + public static function DROPBOX(): OAuthProvider + { + if (!isset(self::$DROPBOX)) { + self::$DROPBOX = new OAuthProvider('dropbox'); + } + return self::$DROPBOX; + } + public static function ETSY(): OAuthProvider + { + if (!isset(self::$ETSY)) { + self::$ETSY = new OAuthProvider('etsy'); + } + return self::$ETSY; + } + public static function FACEBOOK(): OAuthProvider + { + if (!isset(self::$FACEBOOK)) { + self::$FACEBOOK = new OAuthProvider('facebook'); + } + return self::$FACEBOOK; + } + public static function GITHUB(): OAuthProvider + { + if (!isset(self::$GITHUB)) { + self::$GITHUB = new OAuthProvider('github'); + } + return self::$GITHUB; + } + public static function GITLAB(): OAuthProvider + { + if (!isset(self::$GITLAB)) { + self::$GITLAB = new OAuthProvider('gitlab'); + } + return self::$GITLAB; + } + public static function GOOGLE(): OAuthProvider + { + if (!isset(self::$GOOGLE)) { + self::$GOOGLE = new OAuthProvider('google'); + } + return self::$GOOGLE; + } + public static function LINKEDIN(): OAuthProvider + { + if (!isset(self::$LINKEDIN)) { + self::$LINKEDIN = new OAuthProvider('linkedin'); + } + return self::$LINKEDIN; + } + public static function MICROSOFT(): OAuthProvider + { + if (!isset(self::$MICROSOFT)) { + self::$MICROSOFT = new OAuthProvider('microsoft'); + } + return self::$MICROSOFT; + } + public static function NOTION(): OAuthProvider + { + if (!isset(self::$NOTION)) { + self::$NOTION = new OAuthProvider('notion'); + } + return self::$NOTION; + } + public static function OIDC(): OAuthProvider + { + if (!isset(self::$OIDC)) { + self::$OIDC = new OAuthProvider('oidc'); + } + return self::$OIDC; + } + public static function OKTA(): OAuthProvider + { + if (!isset(self::$OKTA)) { + self::$OKTA = new OAuthProvider('okta'); + } + return self::$OKTA; + } + public static function PAYPAL(): OAuthProvider + { + if (!isset(self::$PAYPAL)) { + self::$PAYPAL = new OAuthProvider('paypal'); + } + return self::$PAYPAL; + } + public static function PAYPALSANDBOX(): OAuthProvider + { + if (!isset(self::$PAYPALSANDBOX)) { + self::$PAYPALSANDBOX = new OAuthProvider('paypalSandbox'); + } + return self::$PAYPALSANDBOX; + } + public static function PODIO(): OAuthProvider + { + if (!isset(self::$PODIO)) { + self::$PODIO = new OAuthProvider('podio'); + } + return self::$PODIO; + } + public static function SALESFORCE(): OAuthProvider + { + if (!isset(self::$SALESFORCE)) { + self::$SALESFORCE = new OAuthProvider('salesforce'); + } + return self::$SALESFORCE; + } + public static function SLACK(): OAuthProvider + { + if (!isset(self::$SLACK)) { + self::$SLACK = new OAuthProvider('slack'); + } + return self::$SLACK; + } + public static function SPOTIFY(): OAuthProvider + { + if (!isset(self::$SPOTIFY)) { + self::$SPOTIFY = new OAuthProvider('spotify'); + } + return self::$SPOTIFY; + } + public static function STRIPE(): OAuthProvider + { + if (!isset(self::$STRIPE)) { + self::$STRIPE = new OAuthProvider('stripe'); + } + return self::$STRIPE; + } + public static function TRADESHIFT(): OAuthProvider + { + if (!isset(self::$TRADESHIFT)) { + self::$TRADESHIFT = new OAuthProvider('tradeshift'); + } + return self::$TRADESHIFT; + } + public static function TRADESHIFTBOX(): OAuthProvider + { + if (!isset(self::$TRADESHIFTBOX)) { + self::$TRADESHIFTBOX = new OAuthProvider('tradeshiftBox'); + } + return self::$TRADESHIFTBOX; + } + public static function TWITCH(): OAuthProvider + { + if (!isset(self::$TWITCH)) { + self::$TWITCH = new OAuthProvider('twitch'); + } + return self::$TWITCH; + } + public static function WORDPRESS(): OAuthProvider + { + if (!isset(self::$WORDPRESS)) { + self::$WORDPRESS = new OAuthProvider('wordpress'); + } + return self::$WORDPRESS; + } + public static function YAHOO(): OAuthProvider + { + if (!isset(self::$YAHOO)) { + self::$YAHOO = new OAuthProvider('yahoo'); + } + return self::$YAHOO; + } + public static function YAMMER(): OAuthProvider + { + if (!isset(self::$YAMMER)) { + self::$YAMMER = new OAuthProvider('yammer'); + } + return self::$YAMMER; + } + public static function YANDEX(): OAuthProvider + { + if (!isset(self::$YANDEX)) { + self::$YANDEX = new OAuthProvider('yandex'); + } + return self::$YANDEX; + } + public static function ZOHO(): OAuthProvider + { + if (!isset(self::$ZOHO)) { + self::$ZOHO = new OAuthProvider('zoho'); + } + return self::$ZOHO; + } + public static function ZOOM(): OAuthProvider + { + if (!isset(self::$ZOOM)) { + self::$ZOOM = new OAuthProvider('zoom'); + } + return self::$ZOOM; + } + public static function MOCK(): OAuthProvider + { + if (!isset(self::$MOCK)) { + self::$MOCK = new OAuthProvider('mock'); + } + return self::$MOCK; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/PasswordHash.php b/src/Appwrite/Enums/PasswordHash.php new file mode 100644 index 0000000..27d080d --- /dev/null +++ b/src/Appwrite/Enums/PasswordHash.php @@ -0,0 +1,115 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class PasswordHash implements JsonSerializable +{ + private static PasswordHash $SHA1; + private static PasswordHash $SHA224; + private static PasswordHash $SHA256; + private static PasswordHash $SHA384; + private static PasswordHash $SHA512224; + private static PasswordHash $SHA512256; + private static PasswordHash $SHA512; + private static PasswordHash $SHA3224; + private static PasswordHash $SHA3256; + private static PasswordHash $SHA3384; + private static PasswordHash $SHA3512; + + 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 SHA1(): PasswordHash + { + if (!isset(self::$SHA1)) { + self::$SHA1 = new PasswordHash('sha1'); + } + return self::$SHA1; + } + public static function SHA224(): PasswordHash + { + if (!isset(self::$SHA224)) { + self::$SHA224 = new PasswordHash('sha224'); + } + return self::$SHA224; + } + public static function SHA256(): PasswordHash + { + if (!isset(self::$SHA256)) { + self::$SHA256 = new PasswordHash('sha256'); + } + return self::$SHA256; + } + public static function SHA384(): PasswordHash + { + if (!isset(self::$SHA384)) { + self::$SHA384 = new PasswordHash('sha384'); + } + return self::$SHA384; + } + public static function SHA512224(): PasswordHash + { + if (!isset(self::$SHA512224)) { + self::$SHA512224 = new PasswordHash('sha512/224'); + } + return self::$SHA512224; + } + public static function SHA512256(): PasswordHash + { + if (!isset(self::$SHA512256)) { + self::$SHA512256 = new PasswordHash('sha512/256'); + } + return self::$SHA512256; + } + public static function SHA512(): PasswordHash + { + if (!isset(self::$SHA512)) { + self::$SHA512 = new PasswordHash('sha512'); + } + return self::$SHA512; + } + public static function SHA3224(): PasswordHash + { + if (!isset(self::$SHA3224)) { + self::$SHA3224 = new PasswordHash('sha3-224'); + } + return self::$SHA3224; + } + public static function SHA3256(): PasswordHash + { + if (!isset(self::$SHA3256)) { + self::$SHA3256 = new PasswordHash('sha3-256'); + } + return self::$SHA3256; + } + public static function SHA3384(): PasswordHash + { + if (!isset(self::$SHA3384)) { + self::$SHA3384 = new PasswordHash('sha3-384'); + } + return self::$SHA3384; + } + public static function SHA3512(): PasswordHash + { + if (!isset(self::$SHA3512)) { + self::$SHA3512 = new PasswordHash('sha3-512'); + } + return self::$SHA3512; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/RelationMutate.php b/src/Appwrite/Enums/RelationMutate.php new file mode 100644 index 0000000..0357acc --- /dev/null +++ b/src/Appwrite/Enums/RelationMutate.php @@ -0,0 +1,51 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class RelationMutate implements JsonSerializable +{ + private static RelationMutate $CASCADE; + private static RelationMutate $RESTRICT; + private static RelationMutate $SETNULL; + + 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 CASCADE(): RelationMutate + { + if (!isset(self::$CASCADE)) { + self::$CASCADE = new RelationMutate('cascade'); + } + return self::$CASCADE; + } + public static function RESTRICT(): RelationMutate + { + if (!isset(self::$RESTRICT)) { + self::$RESTRICT = new RelationMutate('restrict'); + } + return self::$RESTRICT; + } + public static function SETNULL(): RelationMutate + { + if (!isset(self::$SETNULL)) { + self::$SETNULL = new RelationMutate('setNull'); + } + return self::$SETNULL; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/RelationshipType.php b/src/Appwrite/Enums/RelationshipType.php new file mode 100644 index 0000000..b920b50 --- /dev/null +++ b/src/Appwrite/Enums/RelationshipType.php @@ -0,0 +1,59 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class RelationshipType implements JsonSerializable +{ + private static RelationshipType $ONETOONE; + private static RelationshipType $MANYTOONE; + private static RelationshipType $MANYTOMANY; + private static RelationshipType $ONETOMANY; + + 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 ONETOONE(): RelationshipType + { + if (!isset(self::$ONETOONE)) { + self::$ONETOONE = new RelationshipType('oneToOne'); + } + return self::$ONETOONE; + } + public static function MANYTOONE(): RelationshipType + { + if (!isset(self::$MANYTOONE)) { + self::$MANYTOONE = new RelationshipType('manyToOne'); + } + return self::$MANYTOONE; + } + public static function MANYTOMANY(): RelationshipType + { + if (!isset(self::$MANYTOMANY)) { + self::$MANYTOMANY = new RelationshipType('manyToMany'); + } + return self::$MANYTOMANY; + } + public static function ONETOMANY(): RelationshipType + { + if (!isset(self::$ONETOMANY)) { + self::$ONETOMANY = new RelationshipType('oneToMany'); + } + return self::$ONETOMANY; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php new file mode 100644 index 0000000..2d25a24 --- /dev/null +++ b/src/Appwrite/Enums/Runtime.php @@ -0,0 +1,379 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class Runtime implements JsonSerializable +{ + private static Runtime $NODE145; + private static Runtime $NODE160; + private static Runtime $NODE180; + private static Runtime $NODE190; + private static Runtime $NODE200; + private static Runtime $NODE210; + private static Runtime $PHP80; + private static Runtime $PHP81; + private static Runtime $PHP82; + private static Runtime $PHP83; + private static Runtime $RUBY30; + private static Runtime $RUBY31; + private static Runtime $RUBY32; + private static Runtime $RUBY33; + private static Runtime $PYTHON38; + private static Runtime $PYTHON39; + private static Runtime $PYTHON310; + private static Runtime $PYTHON311; + private static Runtime $PYTHON312; + private static Runtime $DENO140; + private static Runtime $DART215; + private static Runtime $DART216; + private static Runtime $DART217; + private static Runtime $DART218; + private static Runtime $DART30; + private static Runtime $DART31; + private static Runtime $DART33; + private static Runtime $DOTNET31; + private static Runtime $DOTNET60; + private static Runtime $DOTNET70; + private static Runtime $JAVA80; + private static Runtime $JAVA110; + private static Runtime $JAVA170; + private static Runtime $JAVA180; + private static Runtime $JAVA210; + private static Runtime $SWIFT55; + private static Runtime $SWIFT58; + private static Runtime $SWIFT59; + private static Runtime $KOTLIN16; + private static Runtime $KOTLIN18; + private static Runtime $KOTLIN19; + private static Runtime $CPP17; + private static Runtime $CPP20; + private static Runtime $BUN10; + + 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 NODE145(): Runtime + { + if (!isset(self::$NODE145)) { + self::$NODE145 = new Runtime('node-14.5'); + } + return self::$NODE145; + } + public static function NODE160(): Runtime + { + if (!isset(self::$NODE160)) { + self::$NODE160 = new Runtime('node-16.0'); + } + return self::$NODE160; + } + public static function NODE180(): Runtime + { + if (!isset(self::$NODE180)) { + self::$NODE180 = new Runtime('node-18.0'); + } + return self::$NODE180; + } + public static function NODE190(): Runtime + { + if (!isset(self::$NODE190)) { + self::$NODE190 = new Runtime('node-19.0'); + } + return self::$NODE190; + } + public static function NODE200(): Runtime + { + if (!isset(self::$NODE200)) { + self::$NODE200 = new Runtime('node-20.0'); + } + return self::$NODE200; + } + public static function NODE210(): Runtime + { + if (!isset(self::$NODE210)) { + self::$NODE210 = new Runtime('node-21.0'); + } + return self::$NODE210; + } + public static function PHP80(): Runtime + { + if (!isset(self::$PHP80)) { + self::$PHP80 = new Runtime('php-8.0'); + } + return self::$PHP80; + } + public static function PHP81(): Runtime + { + if (!isset(self::$PHP81)) { + self::$PHP81 = new Runtime('php-8.1'); + } + return self::$PHP81; + } + public static function PHP82(): Runtime + { + if (!isset(self::$PHP82)) { + self::$PHP82 = new Runtime('php-8.2'); + } + return self::$PHP82; + } + public static function PHP83(): Runtime + { + if (!isset(self::$PHP83)) { + self::$PHP83 = new Runtime('php-8.3'); + } + return self::$PHP83; + } + public static function RUBY30(): Runtime + { + if (!isset(self::$RUBY30)) { + self::$RUBY30 = new Runtime('ruby-3.0'); + } + return self::$RUBY30; + } + public static function RUBY31(): Runtime + { + if (!isset(self::$RUBY31)) { + self::$RUBY31 = new Runtime('ruby-3.1'); + } + return self::$RUBY31; + } + public static function RUBY32(): Runtime + { + if (!isset(self::$RUBY32)) { + self::$RUBY32 = new Runtime('ruby-3.2'); + } + return self::$RUBY32; + } + public static function RUBY33(): Runtime + { + if (!isset(self::$RUBY33)) { + self::$RUBY33 = new Runtime('ruby-3.3'); + } + return self::$RUBY33; + } + public static function PYTHON38(): Runtime + { + if (!isset(self::$PYTHON38)) { + self::$PYTHON38 = new Runtime('python-3.8'); + } + return self::$PYTHON38; + } + public static function PYTHON39(): Runtime + { + if (!isset(self::$PYTHON39)) { + self::$PYTHON39 = new Runtime('python-3.9'); + } + return self::$PYTHON39; + } + public static function PYTHON310(): Runtime + { + if (!isset(self::$PYTHON310)) { + self::$PYTHON310 = new Runtime('python-3.10'); + } + return self::$PYTHON310; + } + public static function PYTHON311(): Runtime + { + if (!isset(self::$PYTHON311)) { + self::$PYTHON311 = new Runtime('python-3.11'); + } + return self::$PYTHON311; + } + public static function PYTHON312(): Runtime + { + if (!isset(self::$PYTHON312)) { + self::$PYTHON312 = new Runtime('python-3.12'); + } + return self::$PYTHON312; + } + public static function DENO140(): Runtime + { + if (!isset(self::$DENO140)) { + self::$DENO140 = new Runtime('deno-1.40'); + } + return self::$DENO140; + } + public static function DART215(): Runtime + { + if (!isset(self::$DART215)) { + self::$DART215 = new Runtime('dart-2.15'); + } + return self::$DART215; + } + public static function DART216(): Runtime + { + if (!isset(self::$DART216)) { + self::$DART216 = new Runtime('dart-2.16'); + } + return self::$DART216; + } + public static function DART217(): Runtime + { + if (!isset(self::$DART217)) { + self::$DART217 = new Runtime('dart-2.17'); + } + return self::$DART217; + } + public static function DART218(): Runtime + { + if (!isset(self::$DART218)) { + self::$DART218 = new Runtime('dart-2.18'); + } + return self::$DART218; + } + public static function DART30(): Runtime + { + if (!isset(self::$DART30)) { + self::$DART30 = new Runtime('dart-3.0'); + } + return self::$DART30; + } + public static function DART31(): Runtime + { + if (!isset(self::$DART31)) { + self::$DART31 = new Runtime('dart-3.1'); + } + return self::$DART31; + } + public static function DART33(): Runtime + { + if (!isset(self::$DART33)) { + self::$DART33 = new Runtime('dart-3.3'); + } + return self::$DART33; + } + public static function DOTNET31(): Runtime + { + if (!isset(self::$DOTNET31)) { + self::$DOTNET31 = new Runtime('dotnet-3.1'); + } + return self::$DOTNET31; + } + public static function DOTNET60(): Runtime + { + if (!isset(self::$DOTNET60)) { + self::$DOTNET60 = new Runtime('dotnet-6.0'); + } + return self::$DOTNET60; + } + public static function DOTNET70(): Runtime + { + if (!isset(self::$DOTNET70)) { + self::$DOTNET70 = new Runtime('dotnet-7.0'); + } + return self::$DOTNET70; + } + public static function JAVA80(): Runtime + { + if (!isset(self::$JAVA80)) { + self::$JAVA80 = new Runtime('java-8.0'); + } + return self::$JAVA80; + } + public static function JAVA110(): Runtime + { + if (!isset(self::$JAVA110)) { + self::$JAVA110 = new Runtime('java-11.0'); + } + return self::$JAVA110; + } + public static function JAVA170(): Runtime + { + if (!isset(self::$JAVA170)) { + self::$JAVA170 = new Runtime('java-17.0'); + } + return self::$JAVA170; + } + public static function JAVA180(): Runtime + { + if (!isset(self::$JAVA180)) { + self::$JAVA180 = new Runtime('java-18.0'); + } + return self::$JAVA180; + } + public static function JAVA210(): Runtime + { + if (!isset(self::$JAVA210)) { + self::$JAVA210 = new Runtime('java-21.0'); + } + return self::$JAVA210; + } + public static function SWIFT55(): Runtime + { + if (!isset(self::$SWIFT55)) { + self::$SWIFT55 = new Runtime('swift-5.5'); + } + return self::$SWIFT55; + } + public static function SWIFT58(): Runtime + { + if (!isset(self::$SWIFT58)) { + self::$SWIFT58 = new Runtime('swift-5.8'); + } + return self::$SWIFT58; + } + public static function SWIFT59(): Runtime + { + if (!isset(self::$SWIFT59)) { + self::$SWIFT59 = new Runtime('swift-5.9'); + } + return self::$SWIFT59; + } + public static function KOTLIN16(): Runtime + { + if (!isset(self::$KOTLIN16)) { + self::$KOTLIN16 = new Runtime('kotlin-1.6'); + } + return self::$KOTLIN16; + } + public static function KOTLIN18(): Runtime + { + if (!isset(self::$KOTLIN18)) { + self::$KOTLIN18 = new Runtime('kotlin-1.8'); + } + return self::$KOTLIN18; + } + public static function KOTLIN19(): Runtime + { + if (!isset(self::$KOTLIN19)) { + self::$KOTLIN19 = new Runtime('kotlin-1.9'); + } + return self::$KOTLIN19; + } + public static function CPP17(): Runtime + { + if (!isset(self::$CPP17)) { + self::$CPP17 = new Runtime('cpp-17'); + } + return self::$CPP17; + } + public static function CPP20(): Runtime + { + if (!isset(self::$CPP20)) { + self::$CPP20 = new Runtime('cpp-20'); + } + return self::$CPP20; + } + public static function BUN10(): Runtime + { + if (!isset(self::$BUN10)) { + self::$BUN10 = new Runtime('bun-1.0'); + } + return self::$BUN10; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/SmtpEncryption.php b/src/Appwrite/Enums/SmtpEncryption.php new file mode 100644 index 0000000..53b7a04 --- /dev/null +++ b/src/Appwrite/Enums/SmtpEncryption.php @@ -0,0 +1,51 @@ +<?php + +namespace Appwrite\Enums; + +use JsonSerializable; + +class SmtpEncryption implements JsonSerializable +{ + private static SmtpEncryption $NONE; + private static SmtpEncryption $SSL; + private static SmtpEncryption $TLS; + + 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 NONE(): SmtpEncryption + { + if (!isset(self::$NONE)) { + self::$NONE = new SmtpEncryption('none'); + } + return self::$NONE; + } + public static function SSL(): SmtpEncryption + { + if (!isset(self::$SSL)) { + self::$SSL = new SmtpEncryption('ssl'); + } + return self::$SSL; + } + public static function TLS(): SmtpEncryption + { + if (!isset(self::$TLS)) { + self::$TLS = new SmtpEncryption('tls'); + } + return self::$TLS; + } +} \ No newline at end of file diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index 953a532..bf01127 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -2,8 +2,39 @@ namespace Appwrite; -class Query +class Query implements \JsonSerializable { + protected string $method; + protected ?string $attribute; + protected ?array $values; + + public function __construct(string $method, ?string $attribute = null, $values = null) + { + $this->method = $method; + $this->attribute = $attribute; + + if (is_null($values) || is_array($values)) { + $this->values = $values; + } else { + $this->values = [$values]; + } + + } + + public function __toString(): string + { + return json_encode($this->jsonSerialize()); + } + + public function jsonSerialize() + { + return array_filter([ + 'method' => $this->method, + 'attribute' => $this->attribute, + 'values' => $this->values, + ]); + } + /** * Equal * @@ -13,7 +44,7 @@ class Query */ public static function equal(string $attribute, $value): string { - return self::addQuery($attribute, 'equal', $value); + return (new Query('equal', $attribute, $value))->__toString(); } /** @@ -25,7 +56,7 @@ public static function equal(string $attribute, $value): string */ public static function notEqual(string $attribute, $value): string { - return self::addQuery($attribute, 'notEqual', $value); + return (new Query('notEqual', $attribute, $value))->__toString(); } /** @@ -37,7 +68,7 @@ public static function notEqual(string $attribute, $value): string */ public static function lessThan(string $attribute, $value): string { - return self::addQuery($attribute, 'lessThan', $value); + return (new Query('lessThan', $attribute, $value))->__toString(); } /** @@ -49,7 +80,7 @@ public static function lessThan(string $attribute, $value): string */ public static function lessThanEqual(string $attribute, $value): string { - return self::addQuery($attribute, 'lessThanEqual', $value); + return (new Query('lessThanEqual', $attribute, $value))->__toString(); } /** @@ -61,7 +92,7 @@ public static function lessThanEqual(string $attribute, $value): string */ public static function greaterThan(string $attribute, $value): string { - return self::addQuery($attribute, 'greaterThan', $value); + return (new Query('greaterThan', $attribute, $value))->__toString(); } /** @@ -73,7 +104,7 @@ public static function greaterThan(string $attribute, $value): string */ public static function greaterThanEqual(string $attribute, $value): string { - return self::addQuery($attribute, 'greaterThanEqual', $value); + return (new Query('greaterThanEqual', $attribute, $value))->__toString(); } /** @@ -85,7 +116,7 @@ public static function greaterThanEqual(string $attribute, $value): string */ public static function search(string $attribute, string $value): string { - return self::addQuery($attribute, 'search', $value); + return (new Query('search', $attribute, $value))->__toString(); } /** @@ -96,7 +127,7 @@ public static function search(string $attribute, string $value): string */ public static function isNull(string $attribute): string { - return 'isNull("' . $attribute . '")'; + return (new Query('isNull', $attribute, null))->__toString(); } /** @@ -107,7 +138,7 @@ public static function isNull(string $attribute): string */ public static function isNotNull(string $attribute): string { - return 'isNotNull("' . $attribute . '")'; + return (new Query('isNotNull', $attribute, null))->__toString(); } /** @@ -120,10 +151,7 @@ public static function isNotNull(string $attribute): string */ public static function between(string $attribute, $start, $end): string { - $start = self::parseValues($start); - $end = self::parseValues($end); - - return "between(\"{$attribute}\", {$start}, {$end})"; + return (new Query('between', $attribute, [$start, $end]))->__toString(); } /** @@ -135,7 +163,7 @@ public static function between(string $attribute, $start, $end): string */ public static function startsWith(string $attribute, string $value): string { - return self::addQuery($attribute, 'startsWith', $value); + return (new Query('startsWith', $attribute, $value))->__toString(); } /** @@ -147,7 +175,7 @@ public static function startsWith(string $attribute, string $value): string */ public static function endsWith(string $attribute, string $value): string { - return self::addQuery($attribute, 'endsWith', $value); + return (new Query('endsWith', $attribute, $value))->__toString(); } /** @@ -158,7 +186,7 @@ public static function endsWith(string $attribute, string $value): string */ public static function select(array $attributes): string { - return 'select([' . implode(",", array_map(function ($attr) {return '"' . $attr . '"';}, $attributes)) . '])'; + return (new Query('select', null, $attributes))->__toString(); } /** @@ -167,8 +195,9 @@ public static function select(array $attributes): string * @param string $documentId * @return string */ - public static function cursorAfter(string $documentId): string { - return 'cursorAfter("' . $documentId . '")'; + public static function cursorAfter(string $documentId): string + { + return (new Query('cursorAfter', null, $documentId))->__toString(); } /** @@ -177,8 +206,9 @@ public static function cursorAfter(string $documentId): string { * @param string $documentId * @return string */ - public static function cursorBefore(string $documentId): string { - return 'cursorBefore("' . $documentId . '")'; + public static function cursorBefore(string $documentId): string + { + return (new Query('cursorBefore', null, $documentId))->__toString(); } /** @@ -187,8 +217,9 @@ public static function cursorBefore(string $documentId): string { * @param string $attribute * @return string */ - public static function orderAsc(string $attribute): string { - return 'orderAsc("' . $attribute . '")'; + public static function orderAsc(string $attribute): string + { + return (new Query('orderAsc', $attribute, null))->__toString(); } /** @@ -197,8 +228,9 @@ public static function orderAsc(string $attribute): string { * @param string $attribute * @return string */ - public static function orderDesc(string $attribute): string { - return 'orderDesc("' . $attribute . '")'; + public static function orderDesc(string $attribute): string + { + return (new Query('orderDesc', $attribute, null))->__toString(); } /** @@ -207,8 +239,9 @@ public static function orderDesc(string $attribute): string { * @param int $limit * @return string */ - public static function limit(int $limit): string { - return 'limit(' . $limit . ')'; + public static function limit(int $limit): string + { + return (new Query('limit', null, $limit))->__toString(); } /** @@ -217,35 +250,48 @@ public static function limit(int $limit): string { * @param int $offset * @return string */ - public static function offset(int $offset): string { - return 'offset(' . $offset . ')'; + public static function offset(int $offset): string + { + return (new Query('offset', null, $offset))->__toString(); } /** - * Add Query + * Contains * * @param string $attribute - * @param string $method - * @param mixed $value + * @param string $value * @return string */ - private static function addQuery(string $attribute, string $method, $value) + public static function contains(string $attribute, string $value): string { - return is_array($value) ? $method . '("' . $attribute . '", [' . implode(",", array_map(function ($item) {return self::parseValues($item);}, $value)) . '])' : $method . '("' . $attribute . '", [' . self::parseValues($value) . '])'; + return (new Query('contains', $attribute, $value))->__toString(); } /** - * @param mixed $value + * Or + * + * @param array<string> $queries * @return string */ - private static function parseValues($value): string + public static function or(array $queries): string { - if (is_string($value)) { - return '"' . $value . '"'; + foreach ($queries as &$query) { + $query = \json_decode($query, true); } - if (is_bool($value)) { - return $value ? 'true' : 'false'; + return (new Query('or', null, $queries))->__toString(); + } + + /** + * And + * + * @param array<string> $queries + * @return string + */ + public static function and(array $queries): string + { + foreach ($queries as &$query) { + $query = \json_decode($query, true); } - return $value; + return (new Query('and', null, $queries))->__toString(); } } diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 439f38a..0a1a73f 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -6,6 +6,9 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\AuthenticatorType; +use Appwrite\Enums\AuthenticationFactor; +use Appwrite\Enums\OAuthProvider; class Account extends Service { @@ -28,10 +31,69 @@ public function get(): array $apiPath = str_replace([], [], '/account'); $apiParams = []; + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create account + * + * Use this endpoint to allow a new user to register a new account in your + * project. After the user registration completes successfully, you can use + * the + * [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) + * route to start verifying the user email address. To allow the new user to + * login to their new account, you need to create a new [account + * session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). + * + * @param string $userId + * @param string $email + * @param string $password + * @param string $name + * @throws AppwriteException + * @return array + + */ + public function create(string $userId, string $email, string $password, string $name = null): array + { + $apiPath = str_replace([], [], '/account'); - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($email)) { + $apiParams['email'] = $email; + } + if (!is_null($password)) { + $apiParams['password'] = $password; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -66,15 +128,17 @@ public function updateEmail(string $email, string $password): array if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -82,12 +146,12 @@ public function updateEmail(string $email, string $password): array * * Get the list of identities for the currently logged in user. * - * @param string $queries + * @param array $queries * @throws AppwriteException * @return array */ - public function listIdentities(string $queries = null): array + public function listIdentities(array $queries = null): array { $apiPath = str_replace([], [], '/account/identities'); @@ -95,15 +159,18 @@ public function listIdentities(string $queries = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** - * Delete Identity + * Delete identity * * Delete an identity by its unique ID. * @@ -120,10 +187,42 @@ public function deleteIdentity(string $identityId): string if (!isset($identityId)) { throw new AppwriteException('Missing required parameter: "identityId"'); } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create JWT + * + * Use this endpoint to create a JSON Web Token. You can use the resulting JWT + * to authenticate on behalf of the current user when working with the + * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes + * from its creation and will be invalid if the user will logout in that time + * frame. + * + * @throws AppwriteException + * @return array + + */ + public function createJWT(): array + { + $apiPath = str_replace([], [], '/account/jwt'); - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -145,11 +244,329 @@ public function listLogs(array $queries = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update MFA + * + * Enable or disable MFA on an account. + * + * @param bool $mfa + * @throws AppwriteException + * @return array + + */ + public function updateMFA(bool $mfa): array + { + $apiPath = str_replace([], [], '/account/mfa'); + + $apiParams = []; + if (!isset($mfa)) { + throw new AppwriteException('Missing required parameter: "mfa"'); + } + if (!is_null($mfa)) { + $apiParams['mfa'] = $mfa; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Add Authenticator + * + * Add an authenticator app to be used as an MFA factor. Verify the + * authenticator using the [verify + * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) + * method. + * + * @param AuthenticatorType $type + * @throws AppwriteException + * @return array + + */ + public function createMfaAuthenticator(AuthenticatorType $type): array + { + $apiPath = str_replace(['{type}'], [$type], '/account/mfa/authenticators/{type}'); + + $apiParams = []; + if (!isset($type)) { + throw new AppwriteException('Missing required parameter: "type"'); + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Verify Authenticator + * + * Verify an authenticator app after adding it using the [add + * authenticator](/docs/references/cloud/client-web/account#addAuthenticator) + * method. + * + * @param AuthenticatorType $type + * @param string $otp + * @throws AppwriteException + * @return array + + */ + public function updateMfaAuthenticator(AuthenticatorType $type, string $otp): array + { + $apiPath = str_replace(['{type}'], [$type], '/account/mfa/authenticators/{type}'); + + $apiParams = []; + if (!isset($type)) { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (!isset($otp)) { + throw new AppwriteException('Missing required parameter: "otp"'); + } + if (!is_null($otp)) { + $apiParams['otp'] = $otp; + } + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete Authenticator + * + * Delete an authenticator for a user by ID. + * + * @param AuthenticatorType $type + * @param string $otp + * @throws AppwriteException + * @return array + + */ + public function deleteMfaAuthenticator(AuthenticatorType $type, string $otp): array + { + $apiPath = str_replace(['{type}'], [$type], '/account/mfa/authenticators/{type}'); + + $apiParams = []; + if (!isset($type)) { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (!isset($otp)) { + throw new AppwriteException('Missing required parameter: "otp"'); + } + if (!is_null($otp)) { + $apiParams['otp'] = $otp; + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create 2FA Challenge + * + * Begin the process of MFA verification after sign-in. Finish the flow with + * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) + * method. + * + * @param AuthenticationFactor $factor + * @throws AppwriteException + * @return array + + */ + public function createMfaChallenge(AuthenticationFactor $factor): array + { + $apiPath = str_replace([], [], '/account/mfa/challenge'); + + $apiParams = []; + if (!isset($factor)) { + throw new AppwriteException('Missing required parameter: "factor"'); + } + if (!is_null($factor)) { + $apiParams['factor'] = $factor; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * 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 + * the flow, use + * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + * method. + * + * @param string $challengeId + * @param string $otp + * @throws AppwriteException + * @return string + + */ + public function updateMfaChallenge(string $challengeId, string $otp): string + { + $apiPath = str_replace([], [], '/account/mfa/challenge'); + + $apiParams = []; + if (!isset($challengeId)) { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + if (!isset($otp)) { + throw new AppwriteException('Missing required parameter: "otp"'); + } + if (!is_null($challengeId)) { + $apiParams['challengeId'] = $challengeId; + } + if (!is_null($otp)) { + $apiParams['otp'] = $otp; + } + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List Factors + * + * List the factors available on the account to be used as a MFA challange. + * + * @throws AppwriteException + * @return array + + */ + public function listMfaFactors(): array + { + $apiPath = str_replace([], [], '/account/mfa/factors'); + + $apiParams = []; + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get 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. + * + * @throws AppwriteException + * @return array + */ + public function getMfaRecoveryCodes(): array + { + $apiPath = str_replace([], [], '/account/mfa/recovery-codes'); - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * 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 + * authehticator. Recovery codes can be used as a MFA verification type in + * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + * method. + * + * @throws AppwriteException + * @return array + + */ + public function createMfaRecoveryCodes(): array + { + $apiPath = str_replace([], [], '/account/mfa/recovery-codes'); + + $apiParams = []; + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * 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 + * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + * method. An OTP challenge is required to regenreate recovery codes. + * + * @throws AppwriteException + * @return array + + */ + public function updateMfaRecoveryCodes(): array + { + $apiPath = str_replace([], [], '/account/mfa/recovery-codes'); + + $apiParams = []; + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -173,11 +590,14 @@ public function updateName(string $name): array if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -204,15 +624,17 @@ public function updatePassword(string $password, string $oldPassword = null): ar if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($oldPassword)) { $apiParams['oldPassword'] = $oldPassword; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -244,15 +666,17 @@ public function updatePhone(string $phone, string $password): array if (!is_null($phone)) { $apiParams['phone'] = $phone; } - if (!is_null($password)) { $apiParams['password'] = $password; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -269,10 +693,14 @@ public function getPrefs(): array $apiPath = str_replace([], [], '/account/prefs'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -298,11 +726,14 @@ public function updatePrefs(array $prefs): array if (!is_null($prefs)) { $apiParams['prefs'] = $prefs; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -337,15 +768,17 @@ public function createRecovery(string $email, string $url): array if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($url)) { $apiParams['url'] = $url; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -365,12 +798,11 @@ public function createRecovery(string $email, string $url): array * @param string $userId * @param string $secret * @param string $password - * @param string $passwordAgain * @throws AppwriteException * @return array */ - public function updateRecovery(string $userId, string $secret, string $password, string $passwordAgain): array + public function updateRecovery(string $userId, string $secret, string $password): array { $apiPath = str_replace([], [], '/account/recovery'); @@ -384,29 +816,23 @@ public function updateRecovery(string $userId, string $secret, string $password, if (!isset($password)) { throw new AppwriteException('Missing required parameter: "password"'); } - if (!isset($passwordAgain)) { - throw new AppwriteException('Missing required parameter: "passwordAgain"'); - } if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($secret)) { $apiParams['secret'] = $secret; } - if (!is_null($password)) { $apiParams['password'] = $password; } - - if (!is_null($passwordAgain)) { - $apiParams['passwordAgain'] = $passwordAgain; - } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -424,10 +850,14 @@ public function listSessions(): array $apiPath = str_replace([], [], '/account/sessions'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -445,10 +875,207 @@ public function deleteSessions(): string $apiPath = str_replace([], [], '/account/sessions'); $apiParams = []; + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create anonymous session + * + * Use this endpoint to allow a new user to register an anonymous account in + * your project. This route will also create a new session for the user. To + * allow the new user to convert an anonymous account to a normal account, you + * need to update its [email and + * password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) + * or create an [OAuth2 + * session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). + * + * @throws AppwriteException + * @return array - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + */ + public function createAnonymousSession(): array + { + $apiPath = str_replace([], [], '/account/sessions/anonymous'); + + $apiParams = []; + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create email password session + * + * Allow the user to login into their account by providing a valid email and + * password combination. This route will create a new session for the user. + * + * 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). + * + * @param string $email + * @param string $password + * @throws AppwriteException + * @return array + + */ + public function createEmailPasswordSession(string $email, string $password): array + { + $apiPath = str_replace([], [], '/account/sessions/email'); + + $apiParams = []; + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!is_null($email)) { + $apiParams['email'] = $email; + } + if (!is_null($password)) { + $apiParams['password'] = $password; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update magic URL session + * + * Use this endpoint to create a session from token. Provide the **userId** + * and **secret** parameters from the successful response of authentication + * flows initiated by token creation. For example, magic URL and phone login. + * + * @param string $userId + * @param string $secret + * @throws AppwriteException + * @return array + + */ + public function updateMagicURLSession(string $userId, string $secret): array + { + $apiPath = str_replace([], [], '/account/sessions/magic-url'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($secret)) { + throw new AppwriteException('Missing required parameter: "secret"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($secret)) { + $apiParams['secret'] = $secret; + } + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update phone session + * + * Use this endpoint to create a session from token. Provide the **userId** + * and **secret** parameters from the successful response of authentication + * flows initiated by token creation. For example, magic URL and phone login. + * + * @param string $userId + * @param string $secret + * @throws AppwriteException + * @return array + + */ + public function updatePhoneSession(string $userId, string $secret): array + { + $apiPath = str_replace([], [], '/account/sessions/phone'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($secret)) { + throw new AppwriteException('Missing required parameter: "secret"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($secret)) { + $apiParams['secret'] = $secret; + } + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create session + * + * Use this endpoint to create a session from token. Provide the **userId** + * and **secret** parameters from the successful response of authentication + * flows initiated by token creation. For example, magic URL and phone login. + * + * @param string $userId + * @param string $secret + * @throws AppwriteException + * @return array + + */ + public function createSession(string $userId, string $secret): array + { + $apiPath = str_replace([], [], '/account/sessions/token'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($secret)) { + throw new AppwriteException('Missing required parameter: "secret"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($secret)) { + $apiParams['secret'] = $secret; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -470,18 +1097,22 @@ public function getSession(string $sessionId): array if (!isset($sessionId)) { throw new AppwriteException('Missing required parameter: "sessionId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** - * Update OAuth session (refresh tokens) + * Update session * - * Access tokens have limited lifespan and expire to mitigate security risks. - * If session was created using an OAuth provider, this route can be used to - * "refresh" the access token. + * Use this endpoint to extend a session's length. Extending a session is + * useful when session expiry is short. If the session was created using an + * OAuth provider, this endpoint refreshes the access token from the provider. * * @param string $sessionId * @throws AppwriteException @@ -496,10 +1127,14 @@ public function updateSession(string $sessionId): array if (!isset($sessionId)) { throw new AppwriteException('Missing required parameter: "sessionId"'); } - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -524,10 +1159,14 @@ public function deleteSession(string $sessionId): string if (!isset($sessionId)) { throw new AppwriteException('Missing required parameter: "sessionId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -546,10 +1185,226 @@ public function updateStatus(): array $apiPath = str_replace([], [], '/account/status'); $apiParams = []; + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + /** + * Create email token (OTP) + * + * Sends the user an email with a secret key for creating a session. If the + * provided user ID has not be registered, a new user will be created. Use the + * returned user ID and secret and 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 secret sent to the user's email + * is valid for 15 minutes. + * + * 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). + * + * @param string $userId + * @param string $email + * @param bool $phrase + * @throws AppwriteException + * @return array + + */ + public function createEmailToken(string $userId, string $email, bool $phrase = null): array + { + $apiPath = str_replace([], [], '/account/tokens/email'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($email)) { + $apiParams['email'] = $email; + } + if (!is_null($phrase)) { + $apiParams['phrase'] = $phrase; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create magic URL token + * + * 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. + * + * 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). + * + * + * @param string $userId + * @param string $email + * @param string $url + * @param bool $phrase + * @throws AppwriteException + * @return array + + */ + public function createMagicURLToken(string $userId, string $email, string $url = null, bool $phrase = null): array + { + $apiPath = str_replace([], [], '/account/tokens/magic-url'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($email)) { + $apiParams['email'] = $email; + } + if (!is_null($url)) { + $apiParams['url'] = $url; + } + if (!is_null($phrase)) { + $apiParams['phrase'] = $phrase; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create OAuth2 token + * + * Allow the user to login to their account using the OAuth2 provider of their + * choice. Each OAuth2 provider should be enabled from the Appwrite console + * first. Use the success and failure arguments to provide a redirect URL's + * back to your app when login is completed. + * + * If authentication succeeds, `userId` and `secret` of a token will be + * appended to the success URL as query parameters. These can be used to + * create a new session using the [Create + * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) + * endpoint. + * + * 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). + * + * @param OAuthProvider $provider + * @param string $success + * @param string $failure + * @param array $scopes + * @throws AppwriteException + * @return string + + */ + public function createOAuth2Token(OAuthProvider $provider, string $success = null, string $failure = null, array $scopes = null): string + { + $apiPath = str_replace(['{provider}'], [$provider], '/account/tokens/oauth2/{provider}'); + + $apiParams = []; + if (!isset($provider)) { + throw new AppwriteException('Missing required parameter: "provider"'); + } + if (!is_null($success)) { + $apiParams['success'] = $success; + } + if (!is_null($failure)) { + $apiParams['failure'] = $failure; + } + if (!is_null($scopes)) { + $apiParams['scopes'] = $scopes; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams, 'location' + ); + } + + /** + * Create phone token + * + * Sends the user an SMS with a secret key for creating a session. If the + * provided user ID has not be registered, a new user will be created. Use the + * returned user ID and secret and 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 secret sent to the user's phone + * is valid for 15 minutes. + * + * 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). + * + * @param string $userId + * @param string $phone + * @throws AppwriteException + * @return array + + */ + public function createPhoneToken(string $userId, string $phone): array + { + $apiPath = str_replace([], [], '/account/tokens/phone'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($phone)) { + throw new AppwriteException('Missing required parameter: "phone"'); + } + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + if (!is_null($phone)) { + $apiParams['phone'] = $phone; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -587,11 +1442,14 @@ public function createVerification(string $url): array if (!is_null($url)) { $apiParams['url'] = $url; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -622,15 +1480,17 @@ public function updateVerification(string $userId, string $secret): array if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($secret)) { $apiParams['secret'] = $secret; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -654,10 +1514,14 @@ public function createPhoneVerification(): array $apiPath = str_replace([], [], '/account/verification/phone'); $apiParams = []; - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -688,14 +1552,16 @@ public function updatePhoneVerification(string $userId, string $secret): array if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($secret)) { $apiParams['secret'] = $secret; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index e5d602b..10b0ad3 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -6,6 +6,9 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\Browser; +use Appwrite\Enums\CreditCard; +use Appwrite\Enums\Flag; class Avatars extends Service { @@ -28,7 +31,7 @@ public function __construct(Client $client) * image at source quality. If dimensions are not specified, the default size * of image returned is 100x100px. * - * @param string $code + * @param Browser $code * @param int $width * @param int $height * @param int $quality @@ -36,7 +39,7 @@ public function __construct(Client $client) * @return string */ - public function getBrowser(string $code, int $width = null, int $height = null, int $quality = null): string + public function getBrowser(Browser $code, int $width = null, int $height = null, int $quality = null): string { $apiPath = str_replace(['{code}'], [$code], '/avatars/browsers/{code}'); @@ -47,19 +50,20 @@ public function getBrowser(string $code, int $width = null, int $height = null, if (!is_null($width)) { $apiParams['width'] = $width; } - if (!is_null($height)) { $apiParams['height'] = $height; } - if (!is_null($quality)) { $apiParams['quality'] = $quality; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -75,7 +79,7 @@ public function getBrowser(string $code, int $width = null, int $height = null, * of image returned is 100x100px. * * - * @param string $code + * @param CreditCard $code * @param int $width * @param int $height * @param int $quality @@ -83,7 +87,7 @@ public function getBrowser(string $code, int $width = null, int $height = null, * @return string */ - public function getCreditCard(string $code, int $width = null, int $height = null, int $quality = null): string + public function getCreditCard(CreditCard $code, int $width = null, int $height = null, int $quality = null): string { $apiPath = str_replace(['{code}'], [$code], '/avatars/credit-cards/{code}'); @@ -94,19 +98,20 @@ public function getCreditCard(string $code, int $width = null, int $height = nul if (!is_null($width)) { $apiParams['width'] = $width; } - if (!is_null($height)) { $apiParams['height'] = $height; } - if (!is_null($quality)) { $apiParams['quality'] = $quality; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -132,11 +137,14 @@ public function getFavicon(string $url): string if (!is_null($url)) { $apiParams['url'] = $url; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -153,7 +161,7 @@ public function getFavicon(string $url): string * of image returned is 100x100px. * * - * @param string $code + * @param Flag $code * @param int $width * @param int $height * @param int $quality @@ -161,7 +169,7 @@ public function getFavicon(string $url): string * @return string */ - public function getFlag(string $code, int $width = null, int $height = null, int $quality = null): string + public function getFlag(Flag $code, int $width = null, int $height = null, int $quality = null): string { $apiPath = str_replace(['{code}'], [$code], '/avatars/flags/{code}'); @@ -172,19 +180,20 @@ public function getFlag(string $code, int $width = null, int $height = null, int if (!is_null($width)) { $apiParams['width'] = $width; } - if (!is_null($height)) { $apiParams['height'] = $height; } - if (!is_null($quality)) { $apiParams['quality'] = $quality; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -219,19 +228,20 @@ public function getImage(string $url, int $width = null, int $height = null): st if (!is_null($url)) { $apiParams['url'] = $url; } - if (!is_null($width)) { $apiParams['width'] = $width; } - if (!is_null($height)) { $apiParams['height'] = $height; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -270,23 +280,23 @@ public function getInitials(string $name = null, int $width = null, int $height if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($width)) { $apiParams['width'] = $width; } - if (!is_null($height)) { $apiParams['height'] = $height; } - if (!is_null($background)) { $apiParams['background'] = $background; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -315,22 +325,22 @@ public function getQR(string $text, int $size = null, int $margin = null, bool $ if (!is_null($text)) { $apiParams['text'] = $text; } - if (!is_null($size)) { $apiParams['size'] = $size; } - if (!is_null($margin)) { $apiParams['margin'] = $margin; } - if (!is_null($download)) { $apiParams['download'] = $download; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 3503ac3..e1f2a0e 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -6,6 +6,9 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; +use Appwrite\Enums\IndexType; class Databases extends Service { @@ -34,15 +37,17 @@ public function list(array $queries = null, string $search = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -72,19 +77,20 @@ public function create(string $databaseId, string $name, bool $enabled = null): if (!is_null($databaseId)) { $apiParams['databaseId'] = $databaseId; } - if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -106,10 +112,14 @@ public function get(string $databaseId): array if (!isset($databaseId)) { throw new AppwriteException('Missing required parameter: "databaseId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -138,15 +148,17 @@ public function update(string $databaseId, string $name, bool $enabled = null): if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -168,10 +180,14 @@ public function delete(string $databaseId): string if (!isset($databaseId)) { throw new AppwriteException('Missing required parameter: "databaseId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -198,15 +214,17 @@ public function listCollections(string $databaseId, array $queries = null, strin if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -244,27 +262,26 @@ public function createCollection(string $databaseId, string $collectionId, strin if (!is_null($collectionId)) { $apiParams['collectionId'] = $collectionId; } - if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - if (!is_null($documentSecurity)) { $apiParams['documentSecurity'] = $documentSecurity; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -290,10 +307,14 @@ public function getCollection(string $databaseId, string $collectionId): array if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -328,23 +349,23 @@ public function updateCollection(string $databaseId, string $collectionId, strin if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - if (!is_null($documentSecurity)) { $apiParams['documentSecurity'] = $documentSecurity; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -370,15 +391,21 @@ public function deleteCollection(string $databaseId, string $collectionId): stri if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * List attributes * + * List attributes in the collection. + * * @param string $databaseId * @param string $collectionId * @param array $queries @@ -400,11 +427,14 @@ public function listAttributes(string $databaseId, string $collectionId, array $ if (!is_null($queries)) { $apiParams['queries'] = $queries; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -443,28 +473,31 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Update boolean attribute * + * Update a boolean attribute. Changing the `default` value will not update + * already existing documents. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -494,20 +527,24 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Create datetime attribute * + * Create a date time attribute according to the ISO 8601 standard. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -538,28 +575,31 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Update dateTime attribute * + * Update a date time attribute. Changing the `default` value will not update + * already existing documents. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -589,15 +629,17 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -636,23 +678,23 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -691,20 +733,26 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Create enum attribute * + * Create an enumeration attribute. The `elements` param acts as a white-list + * of accepted values for this attribute. + * + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -739,27 +787,26 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($elements)) { $apiParams['elements'] = $elements; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -802,19 +849,20 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st if (!is_null($elements)) { $apiParams['elements'] = $elements; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -856,31 +904,29 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($min)) { $apiParams['min'] = $min; } - if (!is_null($max)) { $apiParams['max'] = $max; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -927,23 +973,23 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($min)) { $apiParams['min'] = $min; } - if (!is_null($max)) { $apiParams['max'] = $max; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -985,31 +1031,29 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($min)) { $apiParams['min'] = $min; } - if (!is_null($max)) { $apiParams['max'] = $max; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1056,23 +1100,23 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($min)) { $apiParams['min'] = $min; } - if (!is_null($max)) { $apiParams['max'] = $max; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1111,23 +1155,23 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1166,15 +1210,17 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1187,16 +1233,16 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri * @param string $databaseId * @param string $collectionId * @param string $relatedCollectionId - * @param string $type + * @param RelationshipType $type * @param bool $twoWay * @param string $key * @param string $twoWayKey - * @param string $onDelete + * @param RelationMutate $onDelete * @throws AppwriteException * @return array */ - public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, string $type, bool $twoWay = null, string $key = null, string $twoWayKey = null, string $onDelete = null): array + public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, bool $twoWay = null, string $key = null, string $twoWayKey = null, RelationMutate $onDelete = null): array { $apiPath = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'); @@ -1216,31 +1262,29 @@ public function createRelationshipAttribute(string $databaseId, string $collecti if (!is_null($relatedCollectionId)) { $apiParams['relatedCollectionId'] = $relatedCollectionId; } - if (!is_null($type)) { $apiParams['type'] = $type; } - if (!is_null($twoWay)) { $apiParams['twoWay'] = $twoWay; } - if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($twoWayKey)) { $apiParams['twoWayKey'] = $twoWayKey; } - if (!is_null($onDelete)) { $apiParams['onDelete'] = $onDelete; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1284,31 +1328,29 @@ public function createStringAttribute(string $databaseId, string $collectionId, if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($size)) { $apiParams['size'] = $size; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - if (!is_null($encrypt)) { $apiParams['encrypt'] = $encrypt; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1347,15 +1389,17 @@ public function updateStringAttribute(string $databaseId, string $collectionId, if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1394,23 +1438,23 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - if (!is_null($xarray)) { $apiParams['array'] = $xarray; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1449,20 +1493,24 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str if (!is_null($required)) { $apiParams['required'] = $required; } - if (!is_null($xdefault)) { $apiParams['default'] = $xdefault; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Get attribute * + * Get attribute by ID. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -1484,15 +1532,21 @@ public function getAttribute(string $databaseId, string $collectionId, string $k if (!isset($key)) { throw new AppwriteException('Missing required parameter: "key"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Delete attribute * + * Deletes an attribute. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -1514,10 +1568,14 @@ public function deleteAttribute(string $databaseId, string $collectionId, string if (!isset($key)) { throw new AppwriteException('Missing required parameter: "key"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1530,12 +1588,12 @@ public function deleteAttribute(string $databaseId, string $collectionId, string * @param string $databaseId * @param string $collectionId * @param string $key - * @param string $onDelete + * @param RelationMutate $onDelete * @throws AppwriteException * @return array */ - public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, string $onDelete = null): array + public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, RelationMutate $onDelete = null): array { $apiPath = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'); @@ -1552,11 +1610,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti if (!is_null($onDelete)) { $apiParams['onDelete'] = $onDelete; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1586,11 +1647,14 @@ public function listDocuments(string $databaseId, string $collectionId, array $q if (!is_null($queries)) { $apiParams['queries'] = $queries; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1630,19 +1694,20 @@ public function createDocument(string $databaseId, string $collectionId, string if (!is_null($documentId)) { $apiParams['documentId'] = $documentId; } - if (!is_null($data)) { $apiParams['data'] = $data; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1676,11 +1741,14 @@ public function getDocument(string $databaseId, string $collectionId, string $do if (!is_null($queries)) { $apiParams['queries'] = $queries; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1715,15 +1783,17 @@ public function updateDocument(string $databaseId, string $collectionId, string if (!is_null($data)) { $apiParams['data'] = $data; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1752,15 +1822,21 @@ public function deleteDocument(string $databaseId, string $collectionId, string if (!isset($documentId)) { throw new AppwriteException('Missing required parameter: "documentId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * List indexes * + * List indexes in the collection. + * * @param string $databaseId * @param string $collectionId * @param array $queries @@ -1782,27 +1858,34 @@ public function listIndexes(string $databaseId, string $collectionId, array $que if (!is_null($queries)) { $apiParams['queries'] = $queries; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Create index * + * Creates an index on the attributes listed. Your index should include all + * the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * * @param string $databaseId * @param string $collectionId * @param string $key - * @param string $type + * @param IndexType $type * @param array $attributes * @param array $orders * @throws AppwriteException * @return array */ - public function createIndex(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders = null): array + public function createIndex(string $databaseId, string $collectionId, string $key, IndexType $type, array $attributes, array $orders = null): array { $apiPath = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); @@ -1825,28 +1908,30 @@ public function createIndex(string $databaseId, string $collectionId, string $ke if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($type)) { $apiParams['type'] = $type; } - if (!is_null($attributes)) { $apiParams['attributes'] = $attributes; } - if (!is_null($orders)) { $apiParams['orders'] = $orders; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Get index * + * Get index by ID. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -1868,15 +1953,21 @@ public function getIndex(string $databaseId, string $collectionId, string $key): if (!isset($key)) { throw new AppwriteException('Missing required parameter: "key"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Delete index * + * Delete an index. + * * @param string $databaseId * @param string $collectionId * @param string $key @@ -1898,9 +1989,13 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke if (!isset($key)) { throw new AppwriteException('Missing required parameter: "key"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 8775ad3..d9bb024 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -6,6 +6,8 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\Runtime; +use Appwrite\Enums\ExecutionMethod; class Functions extends Service { @@ -34,15 +36,17 @@ public function list(array $queries = null, string $search = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -55,7 +59,7 @@ public function list(array $queries = null, string $search = null): array * * @param string $functionId * @param string $name - * @param string $runtime + * @param Runtime $runtime * @param array $execute * @param array $events * @param string $schedule @@ -77,7 +81,7 @@ public function list(array $queries = null, string $search = null): array * @return array */ - public function create(string $functionId, string $name, string $runtime, array $execute = null, array $events = null, string $schedule = null, int $timeout = null, bool $enabled = null, bool $logging = null, string $entrypoint = null, string $commands = null, string $installationId = null, string $providerRepositoryId = null, string $providerBranch = null, bool $providerSilentMode = null, string $providerRootDirectory = null, string $templateRepository = null, string $templateOwner = null, string $templateRootDirectory = null, string $templateBranch = null): array + public function create(string $functionId, string $name, Runtime $runtime, array $execute = null, array $events = null, string $schedule = null, int $timeout = null, bool $enabled = null, bool $logging = null, string $entrypoint = null, string $commands = null, string $installationId = null, string $providerRepositoryId = null, string $providerBranch = null, bool $providerSilentMode = null, string $providerRootDirectory = null, string $templateRepository = null, string $templateOwner = null, string $templateRootDirectory = null, string $templateBranch = null): array { $apiPath = str_replace([], [], '/functions'); @@ -94,87 +98,71 @@ public function create(string $functionId, string $name, string $runtime, array if (!is_null($functionId)) { $apiParams['functionId'] = $functionId; } - if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($runtime)) { $apiParams['runtime'] = $runtime; } - if (!is_null($execute)) { $apiParams['execute'] = $execute; } - if (!is_null($events)) { $apiParams['events'] = $events; } - if (!is_null($schedule)) { $apiParams['schedule'] = $schedule; } - if (!is_null($timeout)) { $apiParams['timeout'] = $timeout; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - if (!is_null($logging)) { $apiParams['logging'] = $logging; } - if (!is_null($entrypoint)) { $apiParams['entrypoint'] = $entrypoint; } - if (!is_null($commands)) { $apiParams['commands'] = $commands; } - if (!is_null($installationId)) { $apiParams['installationId'] = $installationId; } - if (!is_null($providerRepositoryId)) { $apiParams['providerRepositoryId'] = $providerRepositoryId; } - if (!is_null($providerBranch)) { $apiParams['providerBranch'] = $providerBranch; } - if (!is_null($providerSilentMode)) { $apiParams['providerSilentMode'] = $providerSilentMode; } - if (!is_null($providerRootDirectory)) { $apiParams['providerRootDirectory'] = $providerRootDirectory; } - if (!is_null($templateRepository)) { $apiParams['templateRepository'] = $templateRepository; } - if (!is_null($templateOwner)) { $apiParams['templateOwner'] = $templateOwner; } - if (!is_null($templateRootDirectory)) { $apiParams['templateRootDirectory'] = $templateRootDirectory; } - if (!is_null($templateBranch)) { $apiParams['templateBranch'] = $templateBranch; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -191,10 +179,14 @@ public function listRuntimes(): array $apiPath = str_replace([], [], '/functions/runtimes'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -215,10 +207,14 @@ public function get(string $functionId): array if (!isset($functionId)) { throw new AppwriteException('Missing required parameter: "functionId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -228,7 +224,7 @@ public function get(string $functionId): array * * @param string $functionId * @param string $name - * @param string $runtime + * @param Runtime $runtime * @param array $execute * @param array $events * @param string $schedule @@ -246,7 +242,7 @@ public function get(string $functionId): array * @return array */ - public function update(string $functionId, string $name, string $runtime = null, array $execute = null, array $events = null, string $schedule = null, int $timeout = null, bool $enabled = null, bool $logging = null, string $entrypoint = null, string $commands = null, string $installationId = null, string $providerRepositoryId = null, string $providerBranch = null, bool $providerSilentMode = null, string $providerRootDirectory = null): array + public function update(string $functionId, string $name, Runtime $runtime = null, array $execute = null, array $events = null, string $schedule = null, int $timeout = null, bool $enabled = null, bool $logging = null, string $entrypoint = null, string $commands = null, string $installationId = null, string $providerRepositoryId = null, string $providerBranch = null, bool $providerSilentMode = null, string $providerRootDirectory = null): array { $apiPath = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -260,67 +256,56 @@ public function update(string $functionId, string $name, string $runtime = null, if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($runtime)) { $apiParams['runtime'] = $runtime; } - if (!is_null($execute)) { $apiParams['execute'] = $execute; } - if (!is_null($events)) { $apiParams['events'] = $events; } - if (!is_null($schedule)) { $apiParams['schedule'] = $schedule; } - if (!is_null($timeout)) { $apiParams['timeout'] = $timeout; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - if (!is_null($logging)) { $apiParams['logging'] = $logging; } - if (!is_null($entrypoint)) { $apiParams['entrypoint'] = $entrypoint; } - if (!is_null($commands)) { $apiParams['commands'] = $commands; } - if (!is_null($installationId)) { $apiParams['installationId'] = $installationId; } - if (!is_null($providerRepositoryId)) { $apiParams['providerRepositoryId'] = $providerRepositoryId; } - if (!is_null($providerBranch)) { $apiParams['providerBranch'] = $providerBranch; } - if (!is_null($providerSilentMode)) { $apiParams['providerSilentMode'] = $providerSilentMode; } - if (!is_null($providerRootDirectory)) { $apiParams['providerRootDirectory'] = $providerRootDirectory; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -341,10 +326,14 @@ public function delete(string $functionId): string if (!isset($functionId)) { throw new AppwriteException('Missing required parameter: "functionId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -371,15 +360,17 @@ public function listDeployments(string $functionId, array $queries = null, strin if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -422,20 +413,15 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti if (!is_null($entrypoint)) { $apiParams['entrypoint'] = $entrypoint; } - if (!is_null($commands)) { $apiParams['commands'] = $commands; } - if (!is_null($code)) { $apiParams['code'] = $code; } - if (!is_null($activate)) { $apiParams['activate'] = $activate; } - - $size = 0; $mimeType = null; $postedName = null; @@ -532,10 +518,14 @@ public function getDeployment(string $functionId, string $deploymentId): array if (!isset($deploymentId)) { throw new AppwriteException('Missing required parameter: "deploymentId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -562,10 +552,14 @@ public function updateDeployment(string $functionId, string $deploymentId): arra if (!isset($deploymentId)) { throw new AppwriteException('Missing required parameter: "deploymentId"'); } - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -590,10 +584,14 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri if (!isset($deploymentId)) { throw new AppwriteException('Missing required parameter: "deploymentId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -623,10 +621,14 @@ public function createBuild(string $functionId, string $deploymentId, string $bu if (!isset($buildId)) { throw new AppwriteException('Missing required parameter: "buildId"'); } - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -652,10 +654,14 @@ public function downloadDeployment(string $functionId, string $deploymentId): st if (!isset($deploymentId)) { throw new AppwriteException('Missing required parameter: "deploymentId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -682,15 +688,17 @@ public function listExecutions(string $functionId, array $queries = null, string if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -705,13 +713,13 @@ public function listExecutions(string $functionId, array $queries = null, string * @param string $body * @param bool $async * @param string $xpath - * @param string $method + * @param ExecutionMethod $method * @param array $headers * @throws AppwriteException * @return array */ - public function createExecution(string $functionId, string $body = null, bool $async = null, string $xpath = null, string $method = null, array $headers = null): array + public function createExecution(string $functionId, string $body = null, bool $async = null, string $xpath = null, ExecutionMethod $method = null, array $headers = null): array { $apiPath = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -722,27 +730,26 @@ public function createExecution(string $functionId, string $body = null, bool $a if (!is_null($body)) { $apiParams['body'] = $body; } - if (!is_null($async)) { $apiParams['async'] = $async; } - if (!is_null($xpath)) { $apiParams['path'] = $xpath; } - if (!is_null($method)) { $apiParams['method'] = $method; } - if (!is_null($headers)) { $apiParams['headers'] = $headers; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -767,10 +774,14 @@ public function getExecution(string $functionId, string $executionId): array if (!isset($executionId)) { throw new AppwriteException('Missing required parameter: "executionId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -791,10 +802,14 @@ public function listVariables(string $functionId): array if (!isset($functionId)) { throw new AppwriteException('Missing required parameter: "functionId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -827,15 +842,17 @@ public function createVariable(string $functionId, string $key, string $value): if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($value)) { $apiParams['value'] = $value; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -860,10 +877,14 @@ public function getVariable(string $functionId, string $variableId): array if (!isset($variableId)) { throw new AppwriteException('Missing required parameter: "variableId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -896,15 +917,17 @@ public function updateVariable(string $functionId, string $variableId, string $k if (!is_null($key)) { $apiParams['key'] = $key; } - if (!is_null($value)) { $apiParams['value'] = $value; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -929,9 +952,13 @@ public function deleteVariable(string $functionId, string $variableId): string if (!isset($variableId)) { throw new AppwriteException('Missing required parameter: "variableId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Graphql.php b/src/Appwrite/Services/Graphql.php index f06e533..5dfdc0d 100644 --- a/src/Appwrite/Services/Graphql.php +++ b/src/Appwrite/Services/Graphql.php @@ -35,12 +35,15 @@ public function query(array $query): array if (!is_null($query)) { $apiParams['query'] = $query; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'x-sdk-graphql' => 'true', - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'x-sdk-graphql' => 'true', + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -64,11 +67,14 @@ public function mutation(array $query): array if (!is_null($query)) { $apiParams['query'] = $query; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'x-sdk-graphql' => 'true', - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'x-sdk-graphql' => 'true', + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index dc02296..79d3c5b 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -6,6 +6,7 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\Name; class Health extends Service { @@ -28,10 +29,14 @@ public function get(): array $apiPath = str_replace([], [], '/health'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -48,10 +53,14 @@ public function getAntivirus(): array $apiPath = str_replace([], [], '/health/anti-virus'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -69,10 +78,42 @@ public function getCache(): array $apiPath = str_replace([], [], '/health/cache'); $apiParams = []; + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get the SSL certificate for a domain + * + * Get the SSL certificate for a domain + * + * @param string $domain + * @throws AppwriteException + * @return array + + */ + public function getCertificate(string $domain = null): array + { + $apiPath = str_replace([], [], '/health/certificate'); - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + if (!is_null($domain)) { + $apiParams['domain'] = $domain; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -89,10 +130,14 @@ public function getDB(): array $apiPath = str_replace([], [], '/health/db'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -109,10 +154,14 @@ public function getPubSub(): array $apiPath = str_replace([], [], '/health/pubsub'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -130,10 +179,14 @@ public function getQueue(): array $apiPath = str_replace([], [], '/health/queue'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -155,11 +208,14 @@ public function getQueueBuilds(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -182,11 +238,14 @@ public function getQueueCertificates(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -209,15 +268,17 @@ public function getQueueDatabases(string $name = null, int $threshold = null): a if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -239,16 +300,55 @@ public function getQueueDeletes(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get number of failed queue jobs + * + * Returns the amount of failed jobs in a given queue. + * + * + * @param Name $name + * @param int $threshold + * @throws AppwriteException + * @return array + */ + public function getFailedJobs(Name $name, int $threshold = null): array + { + $apiPath = str_replace(['{name}'], [$name], '/health/queue/failed/{name}'); - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** * Get functions queue * + * Get the number of function executions that are waiting to be processed in + * the Appwrite internal queue server. + * * @param int $threshold * @throws AppwriteException * @return array @@ -262,11 +362,14 @@ public function getQueueFunctions(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -288,11 +391,14 @@ public function getQueueLogs(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -314,11 +420,14 @@ public function getQueueMails(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -340,11 +449,14 @@ public function getQueueMessaging(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -366,11 +478,72 @@ public function getQueueMigrations(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get usage queue + * + * Get the number of metrics that are waiting to be processed in the Appwrite + * internal queue server. + * + * @param int $threshold + * @throws AppwriteException + * @return array + + */ + public function getQueueUsage(int $threshold = null): array + { + $apiPath = str_replace([], [], '/health/queue/usage'); + + $apiParams = []; + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get usage dump queue + * + * Get the number of projects containing metrics that are waiting to be + * processed in the Appwrite internal queue server. + * + * @param int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueueUsageDump(int $threshold = null): array + { + $apiPath = str_replace([], [], '/health/queue/usage-dump'); - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -392,11 +565,38 @@ public function getQueueWebhooks(int $threshold = null): array if (!is_null($threshold)) { $apiParams['threshold'] = $threshold; } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + /** + * Get storage + * + * Check the Appwrite storage device is up and connection is successful. + * + * @throws AppwriteException + * @return array - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + */ + public function getStorage(): array + { + $apiPath = str_replace([], [], '/health/storage'); + + $apiParams = []; + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -413,10 +613,14 @@ public function getStorageLocal(): array $apiPath = str_replace([], [], '/health/storage/local'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -439,9 +643,13 @@ public function getTime(): array $apiPath = str_replace([], [], '/health/time'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Locale.php b/src/Appwrite/Services/Locale.php index 4772ef1..0cb7ae7 100644 --- a/src/Appwrite/Services/Locale.php +++ b/src/Appwrite/Services/Locale.php @@ -33,10 +33,14 @@ public function get(): array $apiPath = str_replace([], [], '/locale'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -54,10 +58,14 @@ public function listCodes(): array $apiPath = str_replace([], [], '/locale/codes'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -75,10 +83,14 @@ public function listContinents(): array $apiPath = str_replace([], [], '/locale/continents'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -96,10 +108,14 @@ public function listCountries(): array $apiPath = str_replace([], [], '/locale/countries'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -117,10 +133,14 @@ public function listCountriesEU(): array $apiPath = str_replace([], [], '/locale/countries/eu'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -138,10 +158,14 @@ public function listCountriesPhones(): array $apiPath = str_replace([], [], '/locale/countries/phones'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -160,10 +184,14 @@ public function listCurrencies(): array $apiPath = str_replace([], [], '/locale/currencies'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -181,9 +209,13 @@ public function listLanguages(): array $apiPath = str_replace([], [], '/locale/languages'); $apiParams = []; - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php new file mode 100644 index 0000000..a7eb762 --- /dev/null +++ b/src/Appwrite/Services/Messaging.php @@ -0,0 +1,2249 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\AppwriteException; +use Appwrite\Client; +use Appwrite\Service; +use Appwrite\InputFile; +use Appwrite\Enums\SmtpEncryption; + +class Messaging extends Service +{ + public function __construct(Client $client) + { + $this->client = $client; + } + + /** + * List messages + * + * Get a list of all messages from the current Appwrite project. + * + * @param array $queries + * @param string $search + * @throws AppwriteException + * @return array + + */ + public function listMessages(array $queries = null, string $search = null): array + { + $apiPath = str_replace([], [], '/messaging/messages'); + + $apiParams = []; + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + if (!is_null($search)) { + $apiParams['search'] = $search; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create email + * + * Create a new email message. + * + * @param string $messageId + * @param string $subject + * @param string $content + * @param array $topics + * @param array $users + * @param array $targets + * @param array $cc + * @param array $bcc + * @param array $attachments + * @param bool $draft + * @param bool $html + * @param string $scheduledAt + * @throws AppwriteException + * @return array + + */ + public function createEmail(string $messageId, string $subject, string $content, array $topics = null, array $users = null, array $targets = null, array $cc = null, array $bcc = null, array $attachments = null, bool $draft = null, bool $html = null, string $scheduledAt = null): array + { + $apiPath = str_replace([], [], '/messaging/messages/email'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!isset($subject)) { + throw new AppwriteException('Missing required parameter: "subject"'); + } + if (!isset($content)) { + throw new AppwriteException('Missing required parameter: "content"'); + } + if (!is_null($messageId)) { + $apiParams['messageId'] = $messageId; + } + if (!is_null($subject)) { + $apiParams['subject'] = $subject; + } + if (!is_null($content)) { + $apiParams['content'] = $content; + } + if (!is_null($topics)) { + $apiParams['topics'] = $topics; + } + if (!is_null($users)) { + $apiParams['users'] = $users; + } + if (!is_null($targets)) { + $apiParams['targets'] = $targets; + } + if (!is_null($cc)) { + $apiParams['cc'] = $cc; + } + if (!is_null($bcc)) { + $apiParams['bcc'] = $bcc; + } + if (!is_null($attachments)) { + $apiParams['attachments'] = $attachments; + } + if (!is_null($draft)) { + $apiParams['draft'] = $draft; + } + if (!is_null($html)) { + $apiParams['html'] = $html; + } + if (!is_null($scheduledAt)) { + $apiParams['scheduledAt'] = $scheduledAt; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update email + * + * Update an email message by its unique ID. + * + * + * @param string $messageId + * @param array $topics + * @param array $users + * @param array $targets + * @param string $subject + * @param string $content + * @param bool $draft + * @param bool $html + * @param array $cc + * @param array $bcc + * @param string $scheduledAt + * @throws AppwriteException + * @return array + + */ + public function updateEmail(string $messageId, array $topics = null, array $users = null, array $targets = null, string $subject = null, string $content = null, bool $draft = null, bool $html = null, array $cc = null, array $bcc = null, string $scheduledAt = null): array + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/email/{messageId}'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!is_null($topics)) { + $apiParams['topics'] = $topics; + } + if (!is_null($users)) { + $apiParams['users'] = $users; + } + if (!is_null($targets)) { + $apiParams['targets'] = $targets; + } + if (!is_null($subject)) { + $apiParams['subject'] = $subject; + } + if (!is_null($content)) { + $apiParams['content'] = $content; + } + if (!is_null($draft)) { + $apiParams['draft'] = $draft; + } + if (!is_null($html)) { + $apiParams['html'] = $html; + } + if (!is_null($cc)) { + $apiParams['cc'] = $cc; + } + if (!is_null($bcc)) { + $apiParams['bcc'] = $bcc; + } + if (!is_null($scheduledAt)) { + $apiParams['scheduledAt'] = $scheduledAt; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create push notification + * + * Create a new push notification. + * + * @param string $messageId + * @param string $title + * @param string $body + * @param array $topics + * @param array $users + * @param array $targets + * @param array $data + * @param string $action + * @param string $image + * @param string $icon + * @param string $sound + * @param string $color + * @param string $tag + * @param string $badge + * @param bool $draft + * @param string $scheduledAt + * @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 + { + $apiPath = str_replace([], [], '/messaging/messages/push'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!isset($title)) { + throw new AppwriteException('Missing required parameter: "title"'); + } + if (!isset($body)) { + throw new AppwriteException('Missing required parameter: "body"'); + } + if (!is_null($messageId)) { + $apiParams['messageId'] = $messageId; + } + if (!is_null($title)) { + $apiParams['title'] = $title; + } + if (!is_null($body)) { + $apiParams['body'] = $body; + } + if (!is_null($topics)) { + $apiParams['topics'] = $topics; + } + if (!is_null($users)) { + $apiParams['users'] = $users; + } + if (!is_null($targets)) { + $apiParams['targets'] = $targets; + } + if (!is_null($data)) { + $apiParams['data'] = $data; + } + if (!is_null($action)) { + $apiParams['action'] = $action; + } + if (!is_null($image)) { + $apiParams['image'] = $image; + } + if (!is_null($icon)) { + $apiParams['icon'] = $icon; + } + if (!is_null($sound)) { + $apiParams['sound'] = $sound; + } + if (!is_null($color)) { + $apiParams['color'] = $color; + } + if (!is_null($tag)) { + $apiParams['tag'] = $tag; + } + if (!is_null($badge)) { + $apiParams['badge'] = $badge; + } + if (!is_null($draft)) { + $apiParams['draft'] = $draft; + } + if (!is_null($scheduledAt)) { + $apiParams['scheduledAt'] = $scheduledAt; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update push notification + * + * Update a push notification by its unique ID. + * + * + * @param string $messageId + * @param array $topics + * @param array $users + * @param array $targets + * @param string $title + * @param string $body + * @param array $data + * @param string $action + * @param string $image + * @param string $icon + * @param string $sound + * @param string $color + * @param string $tag + * @param int $badge + * @param bool $draft + * @param string $scheduledAt + * @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 + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/push/{messageId}'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!is_null($topics)) { + $apiParams['topics'] = $topics; + } + if (!is_null($users)) { + $apiParams['users'] = $users; + } + if (!is_null($targets)) { + $apiParams['targets'] = $targets; + } + if (!is_null($title)) { + $apiParams['title'] = $title; + } + if (!is_null($body)) { + $apiParams['body'] = $body; + } + if (!is_null($data)) { + $apiParams['data'] = $data; + } + if (!is_null($action)) { + $apiParams['action'] = $action; + } + if (!is_null($image)) { + $apiParams['image'] = $image; + } + if (!is_null($icon)) { + $apiParams['icon'] = $icon; + } + if (!is_null($sound)) { + $apiParams['sound'] = $sound; + } + if (!is_null($color)) { + $apiParams['color'] = $color; + } + if (!is_null($tag)) { + $apiParams['tag'] = $tag; + } + if (!is_null($badge)) { + $apiParams['badge'] = $badge; + } + if (!is_null($draft)) { + $apiParams['draft'] = $draft; + } + if (!is_null($scheduledAt)) { + $apiParams['scheduledAt'] = $scheduledAt; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create SMS + * + * Create a new SMS message. + * + * @param string $messageId + * @param string $content + * @param array $topics + * @param array $users + * @param array $targets + * @param bool $draft + * @param string $scheduledAt + * @throws AppwriteException + * @return array + + */ + public function createSms(string $messageId, string $content, array $topics = null, array $users = null, array $targets = null, bool $draft = null, string $scheduledAt = null): array + { + $apiPath = str_replace([], [], '/messaging/messages/sms'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!isset($content)) { + throw new AppwriteException('Missing required parameter: "content"'); + } + if (!is_null($messageId)) { + $apiParams['messageId'] = $messageId; + } + if (!is_null($content)) { + $apiParams['content'] = $content; + } + if (!is_null($topics)) { + $apiParams['topics'] = $topics; + } + if (!is_null($users)) { + $apiParams['users'] = $users; + } + if (!is_null($targets)) { + $apiParams['targets'] = $targets; + } + if (!is_null($draft)) { + $apiParams['draft'] = $draft; + } + if (!is_null($scheduledAt)) { + $apiParams['scheduledAt'] = $scheduledAt; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update SMS + * + * Update an email message by its unique ID. + * + * + * @param string $messageId + * @param array $topics + * @param array $users + * @param array $targets + * @param string $content + * @param bool $draft + * @param string $scheduledAt + * @throws AppwriteException + * @return array + + */ + public function updateSms(string $messageId, array $topics = null, array $users = null, array $targets = null, string $content = null, bool $draft = null, string $scheduledAt = null): array + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/sms/{messageId}'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!is_null($topics)) { + $apiParams['topics'] = $topics; + } + if (!is_null($users)) { + $apiParams['users'] = $users; + } + if (!is_null($targets)) { + $apiParams['targets'] = $targets; + } + if (!is_null($content)) { + $apiParams['content'] = $content; + } + if (!is_null($draft)) { + $apiParams['draft'] = $draft; + } + if (!is_null($scheduledAt)) { + $apiParams['scheduledAt'] = $scheduledAt; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get message + * + * Get a message by its unique ID. + * + * + * @param string $messageId + * @throws AppwriteException + * @return array + + */ + public function getMessage(string $messageId): array + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/{messageId}'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete message + * + * Delete a message. If the message is not a draft or scheduled, but has been + * sent, this will not recall the message. + * + * @param string $messageId + * @throws AppwriteException + * @return string + + */ + public function delete(string $messageId): string + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/{messageId}'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List message logs + * + * Get the message activity logs listed by its unique ID. + * + * @param string $messageId + * @param array $queries + * @throws AppwriteException + * @return array + + */ + public function listMessageLogs(string $messageId, array $queries = null): array + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/{messageId}/logs'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List message targets + * + * Get a list of the targets associated with a message. + * + * @param string $messageId + * @param array $queries + * @throws AppwriteException + * @return array + + */ + public function listTargets(string $messageId, array $queries = null): array + { + $apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/{messageId}/targets'); + + $apiParams = []; + if (!isset($messageId)) { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List providers + * + * Get a list of all providers from the current Appwrite project. + * + * @param array $queries + * @param string $search + * @throws AppwriteException + * @return array + + */ + public function listProviders(array $queries = null, string $search = null): array + { + $apiPath = str_replace([], [], '/messaging/providers'); + + $apiParams = []; + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + if (!is_null($search)) { + $apiParams['search'] = $search; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create APNS provider + * + * Create a new Apple Push Notification service provider. + * + * @param string $providerId + * @param string $name + * @param string $authKey + * @param string $authKeyId + * @param string $teamId + * @param string $bundleId + * @param bool $sandbox + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createApnsProvider(string $providerId, string $name, string $authKey = null, string $authKeyId = null, string $teamId = null, string $bundleId = null, bool $sandbox = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/apns'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($authKey)) { + $apiParams['authKey'] = $authKey; + } + if (!is_null($authKeyId)) { + $apiParams['authKeyId'] = $authKeyId; + } + if (!is_null($teamId)) { + $apiParams['teamId'] = $teamId; + } + if (!is_null($bundleId)) { + $apiParams['bundleId'] = $bundleId; + } + if (!is_null($sandbox)) { + $apiParams['sandbox'] = $sandbox; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update APNS provider + * + * Update a Apple Push Notification service provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $authKey + * @param string $authKeyId + * @param string $teamId + * @param string $bundleId + * @param bool $sandbox + * @throws AppwriteException + * @return array + + */ + public function updateApnsProvider(string $providerId, string $name = null, bool $enabled = null, string $authKey = null, string $authKeyId = null, string $teamId = null, string $bundleId = null, bool $sandbox = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/apns/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($authKey)) { + $apiParams['authKey'] = $authKey; + } + if (!is_null($authKeyId)) { + $apiParams['authKeyId'] = $authKeyId; + } + if (!is_null($teamId)) { + $apiParams['teamId'] = $teamId; + } + if (!is_null($bundleId)) { + $apiParams['bundleId'] = $bundleId; + } + if (!is_null($sandbox)) { + $apiParams['sandbox'] = $sandbox; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create FCM provider + * + * Create a new Firebase Cloud Messaging provider. + * + * @param string $providerId + * @param string $name + * @param array $serviceAccountJSON + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createFcmProvider(string $providerId, string $name, array $serviceAccountJSON = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/fcm'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($serviceAccountJSON)) { + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update FCM provider + * + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param array $serviceAccountJSON + * @throws AppwriteException + * @return array + + */ + public function updateFcmProvider(string $providerId, string $name = null, bool $enabled = null, array $serviceAccountJSON = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/fcm/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($serviceAccountJSON)) { + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Mailgun provider + * + * Create a new Mailgun provider. + * + * @param string $providerId + * @param string $name + * @param string $apiKey + * @param string $domain + * @param bool $isEuRegion + * @param string $fromName + * @param string $fromEmail + * @param string $replyToName + * @param string $replyToEmail + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createMailgunProvider(string $providerId, string $name, string $apiKey = null, string $domain = null, bool $isEuRegion = null, string $fromName = null, string $fromEmail = null, string $replyToName = null, string $replyToEmail = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/mailgun'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($domain)) { + $apiParams['domain'] = $domain; + } + if (!is_null($isEuRegion)) { + $apiParams['isEuRegion'] = $isEuRegion; + } + if (!is_null($fromName)) { + $apiParams['fromName'] = $fromName; + } + if (!is_null($fromEmail)) { + $apiParams['fromEmail'] = $fromEmail; + } + if (!is_null($replyToName)) { + $apiParams['replyToName'] = $replyToName; + } + if (!is_null($replyToEmail)) { + $apiParams['replyToEmail'] = $replyToEmail; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Mailgun provider + * + * Update a Mailgun provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param string $apiKey + * @param string $domain + * @param bool $isEuRegion + * @param bool $enabled + * @param string $fromName + * @param string $fromEmail + * @param string $replyToName + * @param string $replyToEmail + * @throws AppwriteException + * @return array + + */ + public function updateMailgunProvider(string $providerId, string $name = null, string $apiKey = null, string $domain = null, bool $isEuRegion = null, bool $enabled = null, string $fromName = null, string $fromEmail = null, string $replyToName = null, string $replyToEmail = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/mailgun/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($domain)) { + $apiParams['domain'] = $domain; + } + if (!is_null($isEuRegion)) { + $apiParams['isEuRegion'] = $isEuRegion; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($fromName)) { + $apiParams['fromName'] = $fromName; + } + if (!is_null($fromEmail)) { + $apiParams['fromEmail'] = $fromEmail; + } + if (!is_null($replyToName)) { + $apiParams['replyToName'] = $replyToName; + } + if (!is_null($replyToEmail)) { + $apiParams['replyToEmail'] = $replyToEmail; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Msg91 provider + * + * Create a new MSG91 provider. + * + * @param string $providerId + * @param string $name + * @param string $from + * @param string $senderId + * @param string $authKey + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createMsg91Provider(string $providerId, string $name, string $from = null, string $senderId = null, string $authKey = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/msg91'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + if (!is_null($senderId)) { + $apiParams['senderId'] = $senderId; + } + if (!is_null($authKey)) { + $apiParams['authKey'] = $authKey; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Msg91 provider + * + * Update a MSG91 provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $senderId + * @param string $authKey + * @param string $from + * @throws AppwriteException + * @return array + + */ + public function updateMsg91Provider(string $providerId, string $name = null, bool $enabled = null, string $senderId = null, string $authKey = null, string $from = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/msg91/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($senderId)) { + $apiParams['senderId'] = $senderId; + } + if (!is_null($authKey)) { + $apiParams['authKey'] = $authKey; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Sendgrid provider + * + * Create a new Sendgrid provider. + * + * @param string $providerId + * @param string $name + * @param string $apiKey + * @param string $fromName + * @param string $fromEmail + * @param string $replyToName + * @param string $replyToEmail + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createSendgridProvider(string $providerId, string $name, string $apiKey = null, string $fromName = null, string $fromEmail = null, string $replyToName = null, string $replyToEmail = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/sendgrid'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($fromName)) { + $apiParams['fromName'] = $fromName; + } + if (!is_null($fromEmail)) { + $apiParams['fromEmail'] = $fromEmail; + } + if (!is_null($replyToName)) { + $apiParams['replyToName'] = $replyToName; + } + if (!is_null($replyToEmail)) { + $apiParams['replyToEmail'] = $replyToEmail; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Sendgrid provider + * + * Update a Sendgrid provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $apiKey + * @param string $fromName + * @param string $fromEmail + * @param string $replyToName + * @param string $replyToEmail + * @throws AppwriteException + * @return array + + */ + public function updateSendgridProvider(string $providerId, string $name = null, bool $enabled = null, string $apiKey = null, string $fromName = null, string $fromEmail = null, string $replyToName = null, string $replyToEmail = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/sendgrid/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($fromName)) { + $apiParams['fromName'] = $fromName; + } + if (!is_null($fromEmail)) { + $apiParams['fromEmail'] = $fromEmail; + } + if (!is_null($replyToName)) { + $apiParams['replyToName'] = $replyToName; + } + if (!is_null($replyToEmail)) { + $apiParams['replyToEmail'] = $replyToEmail; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create SMTP provider + * + * Create a new SMTP provider. + * + * @param string $providerId + * @param string $name + * @param string $host + * @param int $port + * @param string $username + * @param string $password + * @param SmtpEncryption $encryption + * @param bool $autoTLS + * @param string $mailer + * @param string $fromName + * @param string $fromEmail + * @param string $replyToName + * @param string $replyToEmail + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createSmtpProvider(string $providerId, string $name, string $host, int $port = null, string $username = null, string $password = null, SmtpEncryption $encryption = null, bool $autoTLS = null, string $mailer = null, string $fromName = null, string $fromEmail = null, string $replyToName = null, string $replyToEmail = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/smtp'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!isset($host)) { + throw new AppwriteException('Missing required parameter: "host"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($host)) { + $apiParams['host'] = $host; + } + if (!is_null($port)) { + $apiParams['port'] = $port; + } + if (!is_null($username)) { + $apiParams['username'] = $username; + } + if (!is_null($password)) { + $apiParams['password'] = $password; + } + if (!is_null($encryption)) { + $apiParams['encryption'] = $encryption; + } + if (!is_null($autoTLS)) { + $apiParams['autoTLS'] = $autoTLS; + } + if (!is_null($mailer)) { + $apiParams['mailer'] = $mailer; + } + if (!is_null($fromName)) { + $apiParams['fromName'] = $fromName; + } + if (!is_null($fromEmail)) { + $apiParams['fromEmail'] = $fromEmail; + } + if (!is_null($replyToName)) { + $apiParams['replyToName'] = $replyToName; + } + if (!is_null($replyToEmail)) { + $apiParams['replyToEmail'] = $replyToEmail; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update SMTP provider + * + * Update a SMTP provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param string $host + * @param int $port + * @param string $username + * @param string $password + * @param SmtpEncryption $encryption + * @param bool $autoTLS + * @param string $mailer + * @param string $fromName + * @param string $fromEmail + * @param string $replyToName + * @param string $replyToEmail + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function updateSmtpProvider(string $providerId, string $name = null, string $host = null, int $port = null, string $username = null, string $password = null, SmtpEncryption $encryption = null, bool $autoTLS = null, string $mailer = null, string $fromName = null, string $fromEmail = null, string $replyToName = null, string $replyToEmail = null, bool $enabled = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/smtp/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($host)) { + $apiParams['host'] = $host; + } + if (!is_null($port)) { + $apiParams['port'] = $port; + } + if (!is_null($username)) { + $apiParams['username'] = $username; + } + if (!is_null($password)) { + $apiParams['password'] = $password; + } + if (!is_null($encryption)) { + $apiParams['encryption'] = $encryption; + } + if (!is_null($autoTLS)) { + $apiParams['autoTLS'] = $autoTLS; + } + if (!is_null($mailer)) { + $apiParams['mailer'] = $mailer; + } + if (!is_null($fromName)) { + $apiParams['fromName'] = $fromName; + } + if (!is_null($fromEmail)) { + $apiParams['fromEmail'] = $fromEmail; + } + if (!is_null($replyToName)) { + $apiParams['replyToName'] = $replyToName; + } + if (!is_null($replyToEmail)) { + $apiParams['replyToEmail'] = $replyToEmail; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Telesign provider + * + * Create a new Telesign provider. + * + * @param string $providerId + * @param string $name + * @param string $from + * @param string $customerId + * @param string $apiKey + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createTelesignProvider(string $providerId, string $name, string $from = null, string $customerId = null, string $apiKey = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/telesign'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + if (!is_null($customerId)) { + $apiParams['customerId'] = $customerId; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Telesign provider + * + * Update a Telesign provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $customerId + * @param string $apiKey + * @param string $from + * @throws AppwriteException + * @return array + + */ + public function updateTelesignProvider(string $providerId, string $name = null, bool $enabled = null, string $customerId = null, string $apiKey = null, string $from = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/telesign/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($customerId)) { + $apiParams['customerId'] = $customerId; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Textmagic provider + * + * Create a new Textmagic provider. + * + * @param string $providerId + * @param string $name + * @param string $from + * @param string $username + * @param string $apiKey + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createTextmagicProvider(string $providerId, string $name, string $from = null, string $username = null, string $apiKey = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/textmagic'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + if (!is_null($username)) { + $apiParams['username'] = $username; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Textmagic provider + * + * Update a Textmagic provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $username + * @param string $apiKey + * @param string $from + * @throws AppwriteException + * @return array + + */ + public function updateTextmagicProvider(string $providerId, string $name = null, bool $enabled = null, string $username = null, string $apiKey = null, string $from = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/textmagic/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($username)) { + $apiParams['username'] = $username; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Twilio provider + * + * Create a new Twilio provider. + * + * @param string $providerId + * @param string $name + * @param string $from + * @param string $accountSid + * @param string $authToken + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createTwilioProvider(string $providerId, string $name, string $from = null, string $accountSid = null, string $authToken = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/twilio'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + if (!is_null($accountSid)) { + $apiParams['accountSid'] = $accountSid; + } + if (!is_null($authToken)) { + $apiParams['authToken'] = $authToken; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Twilio provider + * + * Update a Twilio provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $accountSid + * @param string $authToken + * @param string $from + * @throws AppwriteException + * @return array + + */ + public function updateTwilioProvider(string $providerId, string $name = null, bool $enabled = null, string $accountSid = null, string $authToken = null, string $from = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/twilio/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($accountSid)) { + $apiParams['accountSid'] = $accountSid; + } + if (!is_null($authToken)) { + $apiParams['authToken'] = $authToken; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create Vonage provider + * + * Create a new Vonage provider. + * + * @param string $providerId + * @param string $name + * @param string $from + * @param string $apiKey + * @param string $apiSecret + * @param bool $enabled + * @throws AppwriteException + * @return array + + */ + public function createVonageProvider(string $providerId, string $name, string $from = null, string $apiKey = null, string $apiSecret = null, bool $enabled = null): array + { + $apiPath = str_replace([], [], '/messaging/providers/vonage'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($apiSecret)) { + $apiParams['apiSecret'] = $apiSecret; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update Vonage provider + * + * Update a Vonage provider by its unique ID. + * + * @param string $providerId + * @param string $name + * @param bool $enabled + * @param string $apiKey + * @param string $apiSecret + * @param string $from + * @throws AppwriteException + * @return array + + */ + public function updateVonageProvider(string $providerId, string $name = null, bool $enabled = null, string $apiKey = null, string $apiSecret = null, string $from = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/vonage/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + if (!is_null($apiKey)) { + $apiParams['apiKey'] = $apiKey; + } + if (!is_null($apiSecret)) { + $apiParams['apiSecret'] = $apiSecret; + } + if (!is_null($from)) { + $apiParams['from'] = $from; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get provider + * + * Get a provider by its unique ID. + * + * + * @param string $providerId + * @throws AppwriteException + * @return array + + */ + public function getProvider(string $providerId): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete provider + * + * Delete a provider by its unique ID. + * + * @param string $providerId + * @throws AppwriteException + * @return string + + */ + public function deleteProvider(string $providerId): string + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/{providerId}'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List provider logs + * + * Get the provider activity logs listed by its unique ID. + * + * @param string $providerId + * @param array $queries + * @throws AppwriteException + * @return array + + */ + public function listProviderLogs(string $providerId, array $queries = null): array + { + $apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/{providerId}/logs'); + + $apiParams = []; + if (!isset($providerId)) { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List subscriber logs + * + * Get the subscriber activity logs listed by its unique ID. + * + * @param string $subscriberId + * @param array $queries + * @throws AppwriteException + * @return array + + */ + public function listSubscriberLogs(string $subscriberId, array $queries = null): array + { + $apiPath = str_replace(['{subscriberId}'], [$subscriberId], '/messaging/subscribers/{subscriberId}/logs'); + + $apiParams = []; + if (!isset($subscriberId)) { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List topics + * + * Get a list of all topics from the current Appwrite project. + * + * @param array $queries + * @param string $search + * @throws AppwriteException + * @return array + + */ + public function listTopics(array $queries = null, string $search = null): array + { + $apiPath = str_replace([], [], '/messaging/topics'); + + $apiParams = []; + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + if (!is_null($search)) { + $apiParams['search'] = $search; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create topic + * + * Create a new topic. + * + * @param string $topicId + * @param string $name + * @param array $subscribe + * @throws AppwriteException + * @return array + + */ + public function createTopic(string $topicId, string $name, array $subscribe = null): array + { + $apiPath = str_replace([], [], '/messaging/topics'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!isset($name)) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (!is_null($topicId)) { + $apiParams['topicId'] = $topicId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($subscribe)) { + $apiParams['subscribe'] = $subscribe; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get topic + * + * Get a topic by its unique ID. + * + * + * @param string $topicId + * @throws AppwriteException + * @return array + + */ + public function getTopic(string $topicId): array + { + $apiPath = str_replace(['{topicId}'], [$topicId], '/messaging/topics/{topicId}'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update topic + * + * Update a topic by its unique ID. + * + * + * @param string $topicId + * @param string $name + * @param array $subscribe + * @throws AppwriteException + * @return array + + */ + public function updateTopic(string $topicId, string $name = null, array $subscribe = null): array + { + $apiPath = str_replace(['{topicId}'], [$topicId], '/messaging/topics/{topicId}'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + if (!is_null($subscribe)) { + $apiParams['subscribe'] = $subscribe; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete topic + * + * Delete a topic by its unique ID. + * + * @param string $topicId + * @throws AppwriteException + * @return string + + */ + public function deleteTopic(string $topicId): string + { + $apiPath = str_replace(['{topicId}'], [$topicId], '/messaging/topics/{topicId}'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List topic logs + * + * Get the topic activity logs listed by its unique ID. + * + * @param string $topicId + * @param array $queries + * @throws AppwriteException + * @return array + + */ + public function listTopicLogs(string $topicId, array $queries = null): array + { + $apiPath = str_replace(['{topicId}'], [$topicId], '/messaging/topics/{topicId}/logs'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List subscribers + * + * Get a list of all subscribers from the current Appwrite project. + * + * @param string $topicId + * @param array $queries + * @param string $search + * @throws AppwriteException + * @return array + + */ + public function listSubscribers(string $topicId, array $queries = null, string $search = null): array + { + $apiPath = str_replace(['{topicId}'], [$topicId], '/messaging/topics/{topicId}/subscribers'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + if (!is_null($search)) { + $apiParams['search'] = $search; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create subscriber + * + * Create a new subscriber. + * + * @param string $topicId + * @param string $subscriberId + * @param string $targetId + * @throws AppwriteException + * @return array + + */ + public function createSubscriber(string $topicId, string $subscriberId, string $targetId): array + { + $apiPath = str_replace(['{topicId}'], [$topicId], '/messaging/topics/{topicId}/subscribers'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!isset($subscriberId)) { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + if (!isset($targetId)) { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + if (!is_null($subscriberId)) { + $apiParams['subscriberId'] = $subscriberId; + } + if (!is_null($targetId)) { + $apiParams['targetId'] = $targetId; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get subscriber + * + * Get a subscriber by its unique ID. + * + * + * @param string $topicId + * @param string $subscriberId + * @throws AppwriteException + * @return array + + */ + public function getSubscriber(string $topicId, string $subscriberId): array + { + $apiPath = str_replace(['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], '/messaging/topics/{topicId}/subscribers/{subscriberId}'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!isset($subscriberId)) { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete subscriber + * + * Delete a subscriber by its unique ID. + * + * @param string $topicId + * @param string $subscriberId + * @throws AppwriteException + * @return string + + */ + public function deleteSubscriber(string $topicId, string $subscriberId): string + { + $apiPath = str_replace(['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], '/messaging/topics/{topicId}/subscribers/{subscriberId}'); + + $apiParams = []; + if (!isset($topicId)) { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (!isset($subscriberId)) { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } +} diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index 29cd745..d129907 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -6,6 +6,9 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\Compression; +use Appwrite\Enums\ImageGravity; +use Appwrite\Enums\ImageFormat; class Storage extends Service { @@ -34,15 +37,17 @@ public function listBuckets(array $queries = null, string $search = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -57,14 +62,14 @@ public function listBuckets(array $queries = null, string $search = null): array * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions - * @param string $compression + * @param Compression $compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function createBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string $compression = null, bool $encryption = null, bool $antivirus = null): array + public function createBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, Compression $compression = null, bool $encryption = null, bool $antivirus = null): array { $apiPath = str_replace([], [], '/storage/buckets'); @@ -78,47 +83,41 @@ public function createBucket(string $bucketId, string $name, array $permissions if (!is_null($bucketId)) { $apiParams['bucketId'] = $bucketId; } - if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - if (!is_null($fileSecurity)) { $apiParams['fileSecurity'] = $fileSecurity; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - if (!is_null($maximumFileSize)) { $apiParams['maximumFileSize'] = $maximumFileSize; } - if (!is_null($allowedFileExtensions)) { $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } - if (!is_null($compression)) { $apiParams['compression'] = $compression; } - if (!is_null($encryption)) { $apiParams['encryption'] = $encryption; } - if (!is_null($antivirus)) { $apiParams['antivirus'] = $antivirus; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -140,10 +139,14 @@ public function getBucket(string $bucketId): array if (!isset($bucketId)) { throw new AppwriteException('Missing required parameter: "bucketId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -158,14 +161,14 @@ public function getBucket(string $bucketId): array * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions - * @param string $compression + * @param Compression $compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function updateBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string $compression = null, bool $encryption = null, bool $antivirus = null): array + public function updateBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, Compression $compression = null, bool $encryption = null, bool $antivirus = null): array { $apiPath = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -179,43 +182,38 @@ public function updateBucket(string $bucketId, string $name, array $permissions if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - if (!is_null($fileSecurity)) { $apiParams['fileSecurity'] = $fileSecurity; } - if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - if (!is_null($maximumFileSize)) { $apiParams['maximumFileSize'] = $maximumFileSize; } - if (!is_null($allowedFileExtensions)) { $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } - if (!is_null($compression)) { $apiParams['compression'] = $compression; } - if (!is_null($encryption)) { $apiParams['encryption'] = $encryption; } - if (!is_null($antivirus)) { $apiParams['antivirus'] = $antivirus; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -236,10 +234,14 @@ public function deleteBucket(string $bucketId): string if (!isset($bucketId)) { throw new AppwriteException('Missing required parameter: "bucketId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -266,15 +268,17 @@ public function listFiles(string $bucketId, array $queries = null, string $searc if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -324,16 +328,12 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ar if (!is_null($fileId)) { $apiParams['fileId'] = $fileId; } - if (!is_null($file)) { $apiParams['file'] = $file; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - - $size = 0; $mimeType = null; $postedName = null; @@ -438,10 +438,14 @@ public function getFile(string $bucketId, string $fileId): array if (!isset($fileId)) { throw new AppwriteException('Missing required parameter: "fileId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -472,15 +476,17 @@ public function updateFile(string $bucketId, string $fileId, string $name = null if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($permissions)) { $apiParams['permissions'] = $permissions; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -506,10 +512,14 @@ public function deleteFile(string $bucketId, string $fileId): string if (!isset($fileId)) { throw new AppwriteException('Missing required parameter: "fileId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -536,10 +546,14 @@ public function getFileDownload(string $bucketId, string $fileId): string if (!isset($fileId)) { throw new AppwriteException('Missing required parameter: "fileId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -555,7 +569,7 @@ public function getFileDownload(string $bucketId, string $fileId): string * @param string $fileId * @param int $width * @param int $height - * @param string $gravity + * @param ImageGravity $gravity * @param int $quality * @param int $borderWidth * @param string $borderColor @@ -563,12 +577,12 @@ public function getFileDownload(string $bucketId, string $fileId): string * @param int $opacity * @param int $rotation * @param string $background - * @param string $output + * @param ImageFormat $output * @throws AppwriteException * @return string */ - public function getFilePreview(string $bucketId, 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 + public function getFilePreview(string $bucketId, string $fileId, int $width = null, int $height = null, ImageGravity $gravity = null, int $quality = null, int $borderWidth = null, string $borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string $background = null, ImageFormat $output = null): string { $apiPath = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/preview'); @@ -582,51 +596,44 @@ public function getFilePreview(string $bucketId, string $fileId, int $width = nu if (!is_null($width)) { $apiParams['width'] = $width; } - if (!is_null($height)) { $apiParams['height'] = $height; } - if (!is_null($gravity)) { $apiParams['gravity'] = $gravity; } - if (!is_null($quality)) { $apiParams['quality'] = $quality; } - if (!is_null($borderWidth)) { $apiParams['borderWidth'] = $borderWidth; } - if (!is_null($borderColor)) { $apiParams['borderColor'] = $borderColor; } - if (!is_null($borderRadius)) { $apiParams['borderRadius'] = $borderRadius; } - if (!is_null($opacity)) { $apiParams['opacity'] = $opacity; } - if (!is_null($rotation)) { $apiParams['rotation'] = $rotation; } - if (!is_null($background)) { $apiParams['background'] = $background; } - if (!is_null($output)) { $apiParams['output'] = $output; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -653,9 +660,13 @@ public function getFileView(string $bucketId, string $fileId): string if (!isset($fileId)) { throw new AppwriteException('Missing required parameter: "fileId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index f444719..8614621 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -34,15 +34,17 @@ public function list(array $queries = null, string $search = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -73,19 +75,20 @@ public function create(string $teamId, string $name, array $roles = null): array if (!is_null($teamId)) { $apiParams['teamId'] = $teamId; } - if (!is_null($name)) { $apiParams['name'] = $name; } - if (!is_null($roles)) { $apiParams['roles'] = $roles; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -106,10 +109,14 @@ public function get(string $teamId): array if (!isset($teamId)) { throw new AppwriteException('Missing required parameter: "teamId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -137,11 +144,14 @@ public function updateName(string $teamId, string $name): array if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -163,10 +173,14 @@ public function delete(string $teamId): string if (!isset($teamId)) { throw new AppwriteException('Missing required parameter: "teamId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -193,15 +207,17 @@ public function listMemberships(string $teamId, array $queries = null, string $s if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -254,31 +270,29 @@ public function createMembership(string $teamId, array $roles, string $email = n if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($phone)) { $apiParams['phone'] = $phone; } - if (!is_null($roles)) { $apiParams['roles'] = $roles; } - if (!is_null($url)) { $apiParams['url'] = $url; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -304,10 +318,14 @@ public function getMembership(string $teamId, string $membershipId): array if (!isset($membershipId)) { throw new AppwriteException('Missing required parameter: "membershipId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -342,11 +360,14 @@ public function updateMembership(string $teamId, string $membershipId, array $ro if (!is_null($roles)) { $apiParams['roles'] = $roles; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -373,10 +394,14 @@ public function deleteMembership(string $teamId, string $membershipId): string if (!isset($membershipId)) { throw new AppwriteException('Missing required parameter: "membershipId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -418,15 +443,17 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($secret)) { $apiParams['secret'] = $secret; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -449,10 +476,14 @@ public function getPrefs(string $teamId): array if (!isset($teamId)) { throw new AppwriteException('Missing required parameter: "teamId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -482,10 +513,13 @@ public function updatePrefs(string $teamId, array $prefs): array if (!is_null($prefs)) { $apiParams['prefs'] = $prefs; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index 3e762df..f386628 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -6,6 +6,9 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\PasswordHash; +use Appwrite\Enums\AuthenticatorType; +use Appwrite\Enums\MessagingProviderType; class Users extends Service { @@ -34,15 +37,17 @@ public function list(array $queries = null, string $search = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -70,27 +75,26 @@ public function create(string $userId, string $email = null, string $phone = nul if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($phone)) { $apiParams['phone'] = $phone; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -126,23 +130,23 @@ public function createArgon2User(string $userId, string $email, string $password if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -178,23 +182,23 @@ public function createBcryptUser(string $userId, string $email, string $password if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -202,13 +206,13 @@ public function createBcryptUser(string $userId, string $email, string $password * * Get identities for all users. * - * @param string $queries + * @param array $queries * @param string $search * @throws AppwriteException * @return array */ - public function listIdentities(string $queries = null, string $search = null): array + public function listIdentities(array $queries = null, string $search = null): array { $apiPath = str_replace([], [], '/users/identities'); @@ -216,19 +220,21 @@ public function listIdentities(string $queries = null, string $search = null): a if (!is_null($queries)) { $apiParams['queries'] = $queries; } - if (!is_null($search)) { $apiParams['search'] = $search; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** - * Delete Identity + * Delete identity * * Delete an identity by its unique ID. * @@ -245,10 +251,14 @@ public function deleteIdentity(string $identityId): string if (!isset($identityId)) { throw new AppwriteException('Missing required parameter: "identityId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -284,23 +294,23 @@ public function createMD5User(string $userId, string $email, string $password, s if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -336,23 +346,23 @@ public function createPHPassUser(string $userId, string $email, string $password if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -408,43 +418,38 @@ public function createScryptUser(string $userId, string $email, string $password if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($passwordSalt)) { $apiParams['passwordSalt'] = $passwordSalt; } - if (!is_null($passwordCpu)) { $apiParams['passwordCpu'] = $passwordCpu; } - if (!is_null($passwordMemory)) { $apiParams['passwordMemory'] = $passwordMemory; } - if (!is_null($passwordParallel)) { $apiParams['passwordParallel'] = $passwordParallel; } - if (!is_null($passwordLength)) { $apiParams['passwordLength'] = $passwordLength; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -493,35 +498,32 @@ public function createScryptModifiedUser(string $userId, string $email, string $ if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($passwordSalt)) { $apiParams['passwordSalt'] = $passwordSalt; } - if (!is_null($passwordSaltSeparator)) { $apiParams['passwordSaltSeparator'] = $passwordSaltSeparator; } - if (!is_null($passwordSignerKey)) { $apiParams['passwordSignerKey'] = $passwordSignerKey; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -535,13 +537,13 @@ public function createScryptModifiedUser(string $userId, string $email, string $ * @param string $userId * @param string $email * @param string $password - * @param string $passwordVersion + * @param PasswordHash $passwordVersion * @param string $name * @throws AppwriteException * @return array */ - public function createSHAUser(string $userId, string $email, string $password, string $passwordVersion = null, string $name = null): array + public function createSHAUser(string $userId, string $email, string $password, PasswordHash $passwordVersion = null, string $name = null): array { $apiPath = str_replace([], [], '/users/sha'); @@ -558,27 +560,26 @@ public function createSHAUser(string $userId, string $email, string $password, s if (!is_null($userId)) { $apiParams['userId'] = $userId; } - if (!is_null($email)) { $apiParams['email'] = $email; } - if (!is_null($password)) { $apiParams['password'] = $password; } - if (!is_null($passwordVersion)) { $apiParams['passwordVersion'] = $passwordVersion; } - if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_POST, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -599,10 +600,14 @@ public function get(string $userId): array if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -628,10 +633,14 @@ public function delete(string $userId): string if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -659,11 +668,14 @@ public function updateEmail(string $userId, string $email): array if (!is_null($email)) { $apiParams['email'] = $email; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -696,11 +708,14 @@ public function updateLabels(string $userId, array $labels): array if (!is_null($labels)) { $apiParams['labels'] = $labels; } - - - return $this->client->call(Client::METHOD_PUT, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -725,11 +740,14 @@ public function listLogs(string $userId, array $queries = null): array if (!is_null($queries)) { $apiParams['queries'] = $queries; } - - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -750,10 +768,202 @@ public function listMemberships(string $userId): array if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + /** + * Update MFA + * + * Enable or disable MFA on a user account. + * + * @param string $userId + * @param bool $mfa + * @throws AppwriteException + * @return array + + */ + public function updateMfa(string $userId, bool $mfa): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/mfa'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($mfa)) { + throw new AppwriteException('Missing required parameter: "mfa"'); + } + if (!is_null($mfa)) { + $apiParams['mfa'] = $mfa; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete Authenticator + * + * Delete an authenticator app. + * + * @param string $userId + * @param AuthenticatorType $type + * @throws AppwriteException + * @return array + + */ + public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): array + { + $apiPath = str_replace(['{userId}', '{type}'], [$userId, $type], '/users/{userId}/mfa/authenticators/{type}'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($type)) { + throw new AppwriteException('Missing required parameter: "type"'); + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List Factors + * + * List the factors available on the account to be used as a MFA challange. + * + * @param string $userId + * @throws AppwriteException + * @return array + + */ + public function listMfaFactors(string $userId): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/mfa/factors'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * 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 + * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + * method. + * + * @param string $userId + * @throws AppwriteException + * @return array + + */ + public function getMfaRecoveryCodes(string $userId): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/mfa/recovery-codes'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * 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 + * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + * method. + * + * @param string $userId + * @throws AppwriteException + * @return array + + */ + public function updateMfaRecoveryCodes(string $userId): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/mfa/recovery-codes'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * 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 + * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + * method by client SDK. + * + * @param string $userId + * @throws AppwriteException + * @return array + + */ + public function createMfaRecoveryCodes(string $userId): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/mfa/recovery-codes'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -781,11 +991,14 @@ public function updateName(string $userId, string $name): array if (!is_null($name)) { $apiParams['name'] = $name; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -813,11 +1026,14 @@ public function updatePassword(string $userId, string $password): array if (!is_null($password)) { $apiParams['password'] = $password; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -845,11 +1061,14 @@ public function updatePhone(string $userId, string $number): array if (!is_null($number)) { $apiParams['number'] = $number; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -870,10 +1089,14 @@ public function getPrefs(string $userId): array if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } - - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -903,11 +1126,14 @@ public function updatePrefs(string $userId, array $prefs): array if (!is_null($prefs)) { $apiParams['prefs'] = $prefs; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -928,10 +1154,47 @@ public function listSessions(string $userId): array if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } - return $this->client->call(Client::METHOD_GET, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + /** + * Create session + * + * Creates a session for a user. Returns an immediately usable session object. + * + * If you want to generate a token for a custom authentication flow, use the + * [POST + * /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) + * endpoint. + * + * @param string $userId + * @throws AppwriteException + * @return array + + */ + public function createSession(string $userId): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -952,10 +1215,14 @@ public function deleteSessions(string $userId): string if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -980,10 +1247,14 @@ public function deleteSession(string $userId, string $sessionId): string if (!isset($sessionId)) { throw new AppwriteException('Missing required parameter: "sessionId"'); } - - return $this->client->call(Client::METHOD_DELETE, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1012,11 +1283,251 @@ public function updateStatus(string $userId, bool $status): array if (!is_null($status)) { $apiParams['status'] = $status; } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * List User Targets + * + * List the messaging targets that are associated with a user. + * + * @param string $userId + * @param array $queries + * @throws AppwriteException + * @return array + + */ + public function listTargets(string $userId, array $queries = null): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/targets'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create User Target + * + * Create a messaging target. + * + * @param string $userId + * @param string $targetId + * @param MessagingProviderType $providerType + * @param string $identifier + * @param string $providerId + * @param string $name + * @throws AppwriteException + * @return array + + */ + public function createTarget(string $userId, string $targetId, MessagingProviderType $providerType, string $identifier, string $providerId = null, string $name = null): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/targets'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($targetId)) { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + if (!isset($providerType)) { + throw new AppwriteException('Missing required parameter: "providerType"'); + } + if (!isset($identifier)) { + throw new AppwriteException('Missing required parameter: "identifier"'); + } + if (!is_null($targetId)) { + $apiParams['targetId'] = $targetId; + } + if (!is_null($providerType)) { + $apiParams['providerType'] = $providerType; + } + if (!is_null($identifier)) { + $apiParams['identifier'] = $identifier; + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Get User Target + * + * Get a user's push notification target by ID. + * + * @param string $userId + * @param string $targetId + * @throws AppwriteException + * @return array + + */ + public function getTarget(string $userId, string $targetId): array + { + $apiPath = str_replace(['{userId}', '{targetId}'], [$userId, $targetId], '/users/{userId}/targets/{targetId}'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($targetId)) { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + return $this->client->call( + Client::METHOD_GET, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Update User target + * + * Update a messaging target. + * + * @param string $userId + * @param string $targetId + * @param string $identifier + * @param string $providerId + * @param string $name + * @throws AppwriteException + * @return array + + */ + public function updateTarget(string $userId, string $targetId, string $identifier = null, string $providerId = null, string $name = null): array + { + $apiPath = str_replace(['{userId}', '{targetId}'], [$userId, $targetId], '/users/{userId}/targets/{targetId}'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($targetId)) { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + if (!is_null($identifier)) { + $apiParams['identifier'] = $identifier; + } + if (!is_null($providerId)) { + $apiParams['providerId'] = $providerId; + } + if (!is_null($name)) { + $apiParams['name'] = $name; + } + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Delete user target + * + * Delete a messaging target. + * + * @param string $userId + * @param string $targetId + * @throws AppwriteException + * @return string + */ + public function deleteTarget(string $userId, string $targetId): string + { + $apiPath = str_replace(['{userId}', '{targetId}'], [$userId, $targetId], '/users/{userId}/targets/{targetId}'); - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($targetId)) { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); + } + + /** + * Create token + * + * Returns a token with a secret key for creating a session. If the provided + * user ID has not be registered, a new user will be created. Use the returned + * user ID and secret and submit a request to the [PUT + * /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) + * endpoint to complete the login process. + * + * @param string $userId + * @param int $length + * @param int $expire + * @throws AppwriteException + * @return array + + */ + public function createToken(string $userId, int $length = null, int $expire = null): array + { + $apiPath = str_replace(['{userId}'], [$userId], '/users/{userId}/tokens'); + + $apiParams = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!is_null($length)) { + $apiParams['length'] = $length; + } + if (!is_null($expire)) { + $apiParams['expire'] = $expire; + } + return $this->client->call( + Client::METHOD_POST, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1044,11 +1555,14 @@ public function updateEmailVerification(string $userId, bool $emailVerification) if (!is_null($emailVerification)) { $apiParams['emailVerification'] = $emailVerification; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } /** @@ -1076,10 +1590,13 @@ public function updatePhoneVerification(string $userId, bool $phoneVerification) if (!is_null($phoneVerification)) { $apiParams['phoneVerification'] = $phoneVerification; } - - - return $this->client->call(Client::METHOD_PATCH, $apiPath, [ - 'content-type' => 'application/json', - ], $apiParams); + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + [ + 'content-type' => 'application/json', + ], + $apiParams + ); } } diff --git a/tests/Appwrite/IDTest.php b/tests/Appwrite/IDTest.php new file mode 100644 index 0000000..4914377 --- /dev/null +++ b/tests/Appwrite/IDTest.php @@ -0,0 +1,15 @@ +<?php + +namespace Appwrite; + +use PHPUnit\Framework\TestCase; + +final class IDTest extends TestCase { + public function testUnique(): void { + $this->assertSame('unique()', ID::unique()); + } + + public function testCustom(): void { + $this->assertSame('custom', ID::custom('custom')); + } +} diff --git a/tests/Appwrite/PermissionTest.php b/tests/Appwrite/PermissionTest.php new file mode 100644 index 0000000..b17958d --- /dev/null +++ b/tests/Appwrite/PermissionTest.php @@ -0,0 +1,27 @@ +<?php + +namespace Appwrite; + +use PHPUnit\Framework\TestCase; + +final class PermissionTest extends TestCase { + public function testRead(): void { + $this->assertSame('read("any")', Permission::read(Role::any())); + } + + public function testWrite(): void { + $this->assertSame('write("any")', Permission::write(Role::any())); + } + + public function testCreate(): void { + $this->assertSame('create("any")', Permission::create(Role::any())); + } + + public function testUpdate(): void { + $this->assertSame('update("any")', Permission::update(Role::any())); + } + + public function testDelete(): void { + $this->assertSame('delete("any")', Permission::delete(Role::any())); + } +} diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php new file mode 100644 index 0000000..bd54d13 --- /dev/null +++ b/tests/Appwrite/QueryTest.php @@ -0,0 +1,149 @@ +<?php + +namespace Appwrite; + +use PHPUnit\Framework\TestCase; + +final class BasicFilterQueryTest { + public $description; + public $value; + public $expectedValues; + + public function __construct(string $description, mixed $value, string $expectedValues) { + $this->description = $description; + $this->value = $value; + $this->expectedValues = $expectedValues; + } +} + +final class QueryTest extends TestCase { + /** + * @var BasicFilterQueryTest[] $tests + */ + private $tests; + + function __construct(string $name) + { + parent::__construct($name); + $this->tests = array( + new BasicFilterQueryTest('with a string', 's', '["s"]'), + new BasicFilterQueryTest('with a integer', 1, '[1]'), + new BasicFilterQueryTest('with a double', 1.2, '[1.2]'), + new BasicFilterQueryTest('with a whole number double', 1.0, '[1]'), + new BasicFilterQueryTest('with a bool', false, '[false]'), + new BasicFilterQueryTest('with a list', ['a', 'b', 'c'], '["a","b","c"]'), + ); + } + + public function testBasicFilterEqual(): void { + foreach($this->tests as $test) { + $this->assertSame( + "equal(\"attr\", $test->expectedValues)", + Query::equal('attr', $test->value), + $test->description, + ); + } + } + + public function testBasicFilterNotEqual(): void { + foreach($this->tests as $test) { + $this->assertSame( + "notEqual(\"attr\", $test->expectedValues)", + Query::notEqual('attr', $test->value), + $test->description, + ); + } + } + + public function testBasicFilterLessThan(): void { + foreach($this->tests as $test) { + $this->assertSame( + "lessThan(\"attr\", $test->expectedValues)", + Query::lessThan('attr', $test->value), + $test->description, + ); + } + } + + public function testBasicFilterLessThanEqual(): void { + foreach($this->tests as $test) { + $this->assertSame( + "lessThanEqual(\"attr\", $test->expectedValues)", + Query::lessThanEqual('attr', $test->value), + $test->description, + ); + } + } + + public function testBasicFilterGreaterThan(): void { + foreach($this->tests as $test) { + $this->assertSame( + "greaterThan(\"attr\", $test->expectedValues)", + Query::greaterThan('attr', $test->value), + $test->description, + ); + } + } + + public function testBasicFilterGreaterThanEqual(): void { + foreach($this->tests as $test) { + $this->assertSame( + "greaterThanEqual(\"attr\", $test->expectedValues)", + Query::greaterThanEqual('attr', $test->value), + $test->description, + ); + } + } + + public function testSearch(): void { + $this->assertSame('search("attr", ["keyword1 keyword2"])', Query::search('attr', 'keyword1 keyword2')); + } + + public function testIsNull(): void { + $this->assertSame('isNull("attr")', Query::isNull('attr')); + } + + public function testIsNotNull(): void { + $this->assertSame('isNotNull("attr")', Query::isNotNull('attr')); + } + + public function testBetweenWithIntegers(): void { + $this->assertSame('between("attr", 1, 2)', Query::between('attr', 1, 2)); + } + + public function testBetweenWithDoubles(): void { + $this->assertSame('between("attr", 1, 2)', Query::between('attr', 1.0, 2.0)); + } + + public function testBetweenWithStrings(): void { + $this->assertSame('between("attr", "a", "z")', Query::between('attr', 'a', 'z')); + } + + public function testSelect(): void { + $this->assertSame('select(["attr1","attr2"])', Query::select(['attr1', 'attr2'])); + } + + public function testOrderAsc(): void { + $this->assertSame('orderAsc("attr")', Query::orderAsc('attr')); + } + + public function testOrderDesc(): void { + $this->assertSame('orderDesc("attr")', Query::orderDesc('attr')); + } + + public function testCursorBefore(): void { + $this->assertSame('cursorBefore("attr")', Query::cursorBefore('attr')); + } + + public function testCursorAfter(): void { + $this->assertSame('cursorAfter("attr")', Query::cursorAfter('attr')); + } + + public function testLimit(): void { + $this->assertSame('limit(1)', Query::limit(1)); + } + + public function testOffset(): void { + $this->assertSame('offset(1)', Query::offset(1)); + } +} diff --git a/tests/Appwrite/RoleTest.php b/tests/Appwrite/RoleTest.php new file mode 100644 index 0000000..f6e0be1 --- /dev/null +++ b/tests/Appwrite/RoleTest.php @@ -0,0 +1,47 @@ +<?php + +namespace Appwrite; + +use PHPUnit\Framework\TestCase; + +final class RoleTest extends TestCase { + public function testAny(): void { + $this->assertSame('any', Role::any()); + } + + public function testUserWithoutStatus(): void { + $this->assertSame('user:custom', Role::user('custom')); + } + + public function testUserWithStatus(): void { + $this->assertSame('user:custom/verified', Role::user('custom', 'verified')); + } + + public function testUsersWithoutStatus(): void { + $this->assertSame('users', Role::users()); + } + + public function testUsersWithStatus(): void { + $this->assertSame('users/verified', Role::users('verified')); + } + + public function testGuests(): void { + $this->assertSame('guests', Role::guests()); + } + + public function testTeamWithoutRole(): void { + $this->assertSame('team:custom', Role::team('custom')); + } + + public function testTeamWithRole(): void { + $this->assertSame('team:custom/owner', Role::team('custom', 'owner')); + } + + public function testMember(): void { + $this->assertSame('member:custom', Role::member('custom')); + } + + public function testLabel(): void { + $this->assertSame('label:admin', Role::label('admin')); + } +} diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php new file mode 100644 index 0000000..e9a3bc0 --- /dev/null +++ b/tests/Appwrite/Services/AccountTest.php @@ -0,0 +1,1157 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class AccountTest extends TestCase { + private $client; + private $account; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->account = new Account($this->client); + } + + public function testMethodGet(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->get( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->create( + "<USER_ID>", + "email@example.com", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmail(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateEmail( + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListIdentities(): void { + + $data = array( + "total" => 5, + "identities" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->listIdentities( + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteIdentity(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->deleteIdentity( + "<IDENTITY_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateJWT(): void { + + $data = array( + "jwt" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createJWT( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListLogs(): void { + + $data = array( + "total" => 5, + "logs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->listLogs( + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMFA(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateMFA( + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMfaAuthenticator(): void { + + $data = array( + "secret" => "1", + "uri" => "1",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createMfaAuthenticator( + "totp" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMfaAuthenticator(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateMfaAuthenticator( + "totp", + "<OTP>" + ); + + $this->assertSame($data, $response); + } + + 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->deleteMfaAuthenticator( + "totp", + "<OTP>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMfaChallenge(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "expire" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createMfaChallenge( + "email" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMfaChallenge(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateMfaChallenge( + "<CHALLENGE_ID>", + "<OTP>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListMfaFactors(): void { + + $data = array( + "totp" => true, + "phone" => true, + "email" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->listMfaFactors( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetMfaRecoveryCodes(): void { + + $data = array( + "recoveryCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->getMfaRecoveryCodes( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMfaRecoveryCodes(): void { + + $data = array( + "recoveryCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createMfaRecoveryCodes( + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMfaRecoveryCodes(): void { + + $data = array( + "recoveryCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateMfaRecoveryCodes( + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateName(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateName( + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePassword(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updatePassword( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePhone(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updatePhone( + "+12065550100", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetPrefs(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->getPrefs( + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePrefs(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updatePrefs( + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRecovery(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createRecovery( + "email@example.com", + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRecovery(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateRecovery( + "<USER_ID>", + "<SECRET>", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListSessions(): void { + + $data = array( + "total" => 5, + "sessions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->listSessions( + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteSessions(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->deleteSessions( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateAnonymousSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createAnonymousSession( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmailPasswordSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createEmailPasswordSession( + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMagicURLSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateMagicURLSession( + "<USER_ID>", + "<SECRET>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePhoneSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updatePhoneSession( + "<USER_ID>", + "<SECRET>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createSession( + "<USER_ID>", + "<SECRET>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->getSession( + "<SESSION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateSession( + "<SESSION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteSession(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->deleteSession( + "<SESSION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateStatus(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateStatus( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmailToken(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createEmailToken( + "<USER_ID>", + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMagicURLToken(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createMagicURLToken( + "<USER_ID>", + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateOAuth2Token(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createOAuth2Token( + "amazon" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePhoneToken(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createPhoneToken( + "<USER_ID>", + "+12065550100" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateVerification(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createVerification( + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateVerification(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateVerification( + "<USER_ID>", + "<SECRET>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePhoneVerification(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createPhoneVerification( + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePhoneVerification(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updatePhoneVerification( + "<USER_ID>", + "<SECRET>" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/AvatarsTest.php b/tests/Appwrite/Services/AvatarsTest.php new file mode 100644 index 0000000..cb2790e --- /dev/null +++ b/tests/Appwrite/Services/AvatarsTest.php @@ -0,0 +1,130 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class AvatarsTest extends TestCase { + private $client; + private $avatars; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->avatars = new Avatars($this->client); + } + + public function testMethodGetBrowser(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getBrowser( + "aa" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetCreditCard(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getCreditCard( + "amex" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFavicon(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getFavicon( + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFlag(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getFlag( + "af" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetImage(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getImage( + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetInitials(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getInitials( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQR(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->avatars->getQR( + "<TEXT>" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php new file mode 100644 index 0000000..cf4f452 --- /dev/null +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -0,0 +1,1006 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class DatabasesTest extends TestCase { + private $client; + private $databases; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->databases = new Databases($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "databases" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->list( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->create( + "<DATABASE_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGet(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->get( + "<DATABASE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->update( + "<DATABASE_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->delete( + "<DATABASE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListCollections(): void { + + $data = array( + "total" => 5, + "collections" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->listCollections( + "<DATABASE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateCollection(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Collection", + "enabled" => true, + "documentSecurity" => true, + "attributes" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createCollection( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetCollection(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Collection", + "enabled" => true, + "documentSecurity" => true, + "attributes" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->getCollection( + "<DATABASE_ID>", + "<COLLECTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateCollection(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Collection", + "enabled" => true, + "documentSecurity" => true, + "attributes" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateCollection( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteCollection(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->deleteCollection( + "<DATABASE_ID>", + "<COLLECTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListAttributes(): void { + + $data = array( + "total" => 5, + "attributes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->listAttributes( + "<DATABASE_ID>", + "<COLLECTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBooleanAttribute(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createBooleanAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateBooleanAttribute(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateBooleanAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateDatetimeAttribute(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createDatetimeAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateDatetimeAttribute(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateDatetimeAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmailAttribute(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createEmailAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmailAttribute(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateEmailAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEnumAttribute(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createEnumAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + array(), + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEnumAttribute(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateEnumAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + array(), + true, + "<DEFAULT>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateFloatAttribute(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createFloatAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateFloatAttribute(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateFloatAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + 1.0, + 1.0, + 1.0 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIntegerAttribute(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createIntegerAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIntegerAttribute(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateIntegerAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + 1, + 1, + 1 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIpAttribute(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createIpAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIpAttribute(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateIpAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRelationshipAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "relatedCollection" => "collection", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createRelationshipAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<RELATED_COLLECTION_ID>", + "oneToOne" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateStringAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createStringAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + 1, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateStringAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateStringAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + "<DEFAULT>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateUrlAttribute(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createUrlAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateUrlAttribute(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateUrlAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + true, + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetAttribute(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->getAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteAttribute(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->deleteAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRelationshipAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "relatedCollection" => "collection", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateRelationshipAttribute( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListDocuments(): void { + + $data = array( + "total" => 5, + "documents" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->listDocuments( + "<DATABASE_ID>", + "<COLLECTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateDocument(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createDocument( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<DOCUMENT_ID>", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetDocument(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->getDocument( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<DOCUMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateDocument(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateDocument( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<DOCUMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteDocument(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->deleteDocument( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "<DOCUMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListIndexes(): void { + + $data = array( + "total" => 5, + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->listIndexes( + "<DATABASE_ID>", + "<COLLECTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIndex(): void { + + $data = array( + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "attributes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createIndex( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "", + "key", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetIndex(): void { + + $data = array( + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "attributes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->getIndex( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteIndex(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->deleteIndex( + "<DATABASE_ID>", + "<COLLECTION_ID>", + "" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php new file mode 100644 index 0000000..797b546 --- /dev/null +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -0,0 +1,568 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class FunctionsTest extends TestCase { + private $client; + private $functions; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->functions = new Functions($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "functions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->list( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "execute" => array(), + "name" => "My Function", + "enabled" => true, + "live" => true, + "logging" => true, + "runtime" => "python-3.8", + "deployment" => "5e5ea5c16897e", + "vars" => array(), + "events" => array(), + "schedule" => "5 4 * * *", + "timeout" => 300, + "entrypoint" => "index.js", + "commands" => "npm install", + "version" => "v2", + "installationId" => "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId" => "appwrite", + "providerBranch" => "main", + "providerRootDirectory" => "functions/helloWorld", + "providerSilentMode" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->create( + "<FUNCTION_ID>", + "<NAME>", + "node-14.5" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListRuntimes(): void { + + $data = array( + "total" => 5, + "runtimes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->listRuntimes( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGet(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "execute" => array(), + "name" => "My Function", + "enabled" => true, + "live" => true, + "logging" => true, + "runtime" => "python-3.8", + "deployment" => "5e5ea5c16897e", + "vars" => array(), + "events" => array(), + "schedule" => "5 4 * * *", + "timeout" => 300, + "entrypoint" => "index.js", + "commands" => "npm install", + "version" => "v2", + "installationId" => "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId" => "appwrite", + "providerBranch" => "main", + "providerRootDirectory" => "functions/helloWorld", + "providerSilentMode" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->get( + "<FUNCTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "execute" => array(), + "name" => "My Function", + "enabled" => true, + "live" => true, + "logging" => true, + "runtime" => "python-3.8", + "deployment" => "5e5ea5c16897e", + "vars" => array(), + "events" => array(), + "schedule" => "5 4 * * *", + "timeout" => 300, + "entrypoint" => "index.js", + "commands" => "npm install", + "version" => "v2", + "installationId" => "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId" => "appwrite", + "providerBranch" => "main", + "providerRootDirectory" => "functions/helloWorld", + "providerSilentMode" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->update( + "<FUNCTION_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->delete( + "<FUNCTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListDeployments(): void { + + $data = array( + "total" => 5, + "deployments" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->listDeployments( + "<FUNCTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateDeployment(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "type" => "vcs", + "resourceId" => "5e5ea6g16897e", + "resourceType" => "functions", + "entrypoint" => "index.js", + "size" => 128, + "buildId" => "5e5ea5c16897e", + "activate" => true, + "status" => "ready", + "buildLogs" => "Compiling source files...", + "buildTime" => 128, + "providerRepositoryName" => "database", + "providerRepositoryOwner" => "utopia", + "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", + "providerBranch" => "0.7.x", + "providerCommitHash" => "7c3f25d", + "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", + "providerCommitAuthor" => "Khushboo Verma", + "providerCommitMessage" => "Update index.js", + "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->createDeployment( + "<FUNCTION_ID>", + InputFile::withData('', "image/png"), + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetDeployment(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "type" => "vcs", + "resourceId" => "5e5ea6g16897e", + "resourceType" => "functions", + "entrypoint" => "index.js", + "size" => 128, + "buildId" => "5e5ea5c16897e", + "activate" => true, + "status" => "ready", + "buildLogs" => "Compiling source files...", + "buildTime" => 128, + "providerRepositoryName" => "database", + "providerRepositoryOwner" => "utopia", + "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", + "providerBranch" => "0.7.x", + "providerCommitHash" => "7c3f25d", + "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", + "providerCommitAuthor" => "Khushboo Verma", + "providerCommitMessage" => "Update index.js", + "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->getDeployment( + "<FUNCTION_ID>", + "<DEPLOYMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateDeployment(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "execute" => array(), + "name" => "My Function", + "enabled" => true, + "live" => true, + "logging" => true, + "runtime" => "python-3.8", + "deployment" => "5e5ea5c16897e", + "vars" => array(), + "events" => array(), + "schedule" => "5 4 * * *", + "timeout" => 300, + "entrypoint" => "index.js", + "commands" => "npm install", + "version" => "v2", + "installationId" => "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId" => "appwrite", + "providerBranch" => "main", + "providerRootDirectory" => "functions/helloWorld", + "providerSilentMode" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->updateDeployment( + "<FUNCTION_ID>", + "<DEPLOYMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteDeployment(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->deleteDeployment( + "<FUNCTION_ID>", + "<DEPLOYMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBuild(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->createBuild( + "<FUNCTION_ID>", + "<DEPLOYMENT_ID>", + "<BUILD_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDownloadDeployment(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->downloadDeployment( + "<FUNCTION_ID>", + "<DEPLOYMENT_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListExecutions(): void { + + $data = array( + "total" => 5, + "executions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->listExecutions( + "<FUNCTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateExecution(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "functionId" => "5e5ea6g16897e", + "trigger" => "http", + "status" => "processing", + "requestMethod" => "GET", + "requestPath" => "/articles?id=5", + "requestHeaders" => array(), + "responseStatusCode" => 200, + "responseBody" => "Developers are awesome.", + "responseHeaders" => array(), + "logs" => "", + "errors" => "", + "duration" => 0.4,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->createExecution( + "<FUNCTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetExecution(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "functionId" => "5e5ea6g16897e", + "trigger" => "http", + "status" => "processing", + "requestMethod" => "GET", + "requestPath" => "/articles?id=5", + "requestHeaders" => array(), + "responseStatusCode" => 200, + "responseBody" => "Developers are awesome.", + "responseHeaders" => array(), + "logs" => "", + "errors" => "", + "duration" => 0.4,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->getExecution( + "<FUNCTION_ID>", + "<EXECUTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListVariables(): void { + + $data = array( + "total" => 5, + "variables" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->listVariables( + "<FUNCTION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateVariable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "API_KEY", + "value" => "myPa\$\$word1", + "resourceType" => "function", + "resourceId" => "myAwesomeFunction",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->createVariable( + "<FUNCTION_ID>", + "<KEY>", + "<VALUE>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetVariable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "API_KEY", + "value" => "myPa\$\$word1", + "resourceType" => "function", + "resourceId" => "myAwesomeFunction",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->getVariable( + "<FUNCTION_ID>", + "<VARIABLE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateVariable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "API_KEY", + "value" => "myPa\$\$word1", + "resourceType" => "function", + "resourceId" => "myAwesomeFunction",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->updateVariable( + "<FUNCTION_ID>", + "<VARIABLE_ID>", + "<KEY>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteVariable(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->functions->deleteVariable( + "<FUNCTION_ID>", + "<VARIABLE_ID>" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/GraphqlTest.php b/tests/Appwrite/Services/GraphqlTest.php new file mode 100644 index 0000000..6c587b8 --- /dev/null +++ b/tests/Appwrite/Services/GraphqlTest.php @@ -0,0 +1,51 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class GraphqlTest extends TestCase { + private $client; + private $graphql; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->graphql = new Graphql($this->client); + } + + public function testMethodQuery(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->graphql->query( + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodMutation(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->graphql->mutation( + array() + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php new file mode 100644 index 0000000..bed4e21 --- /dev/null +++ b/tests/Appwrite/Services/HealthTest.php @@ -0,0 +1,410 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class HealthTest extends TestCase { + private $client; + private $health; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->health = new Health($this->client); + } + + public function testMethodGet(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->get( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetAntivirus(): void { + + $data = array( + "version" => "1.0.0", + "status" => "online",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getAntivirus( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetCache(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getCache( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetCertificate(): void { + + $data = array( + "name" => "/CN=www.google.com", + "subjectSN" => "", + "issuerOrganisation" => "", + "validFrom" => "1704200998", + "validTo" => "1711458597", + "signatureTypeSN" => "RSA-SHA256",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getCertificate( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetDB(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getDB( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetPubSub(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getPubSub( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueue(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueue( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueBuilds(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueBuilds( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueCertificates(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueCertificates( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueDatabases(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueDatabases( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueDeletes(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueDeletes( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFailedJobs(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getFailedJobs( + "v1-database" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueFunctions(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueFunctions( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueLogs(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueLogs( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueMails(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueMails( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueMessaging(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueMessaging( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueMigrations(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueMigrations( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueUsage(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueUsage( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueUsageDump(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueUsageDump( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueWebhooks(): void { + + $data = array( + "size" => 8,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueWebhooks( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetStorage(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getStorage( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetStorageLocal(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getStorageLocal( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTime(): void { + + $data = array( + "remoteTime" => 1639490751, + "localTime" => 1639490844, + "diff" => 93,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getTime( + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/LocaleTest.php b/tests/Appwrite/Services/LocaleTest.php new file mode 100644 index 0000000..6e8f9db --- /dev/null +++ b/tests/Appwrite/Services/LocaleTest.php @@ -0,0 +1,160 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class LocaleTest extends TestCase { + private $client; + private $locale; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->locale = new Locale($this->client); + } + + public function testMethodGet(): void { + + $data = array( + "ip" => "127.0.0.1", + "countryCode" => "US", + "country" => "United States", + "continentCode" => "NA", + "continent" => "North America", + "eu" => true, + "currency" => "USD",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->get( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListCodes(): void { + + $data = array( + "total" => 5, + "localeCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listCodes( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListContinents(): void { + + $data = array( + "total" => 5, + "continents" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listContinents( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListCountries(): void { + + $data = array( + "total" => 5, + "countries" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listCountries( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListCountriesEU(): void { + + $data = array( + "total" => 5, + "countries" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listCountriesEU( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListCountriesPhones(): void { + + $data = array( + "total" => 5, + "phones" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listCountriesPhones( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListCurrencies(): void { + + $data = array( + "total" => 5, + "currencies" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listCurrencies( + ); + + $this->assertSame($data, $response); + } + + public function testMethodListLanguages(): void { + + $data = array( + "total" => 5, + "languages" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->locale->listLanguages( + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/MessagingTest.php b/tests/Appwrite/Services/MessagingTest.php new file mode 100644 index 0000000..49cdac9 --- /dev/null +++ b/tests/Appwrite/Services/MessagingTest.php @@ -0,0 +1,1071 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class MessagingTest extends TestCase { + private $client; + private $messaging; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->messaging = new Messaging($this->client); + } + + public function testMethodListMessages(): void { + + $data = array( + "total" => 5, + "messages" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listMessages( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmail(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createEmail( + "<MESSAGE_ID>", + "<SUBJECT>", + "<CONTENT>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmail(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateEmail( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePush(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createPush( + "<MESSAGE_ID>", + "<TITLE>", + "<BODY>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePush(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updatePush( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSms(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createSms( + "<MESSAGE_ID>", + "<CONTENT>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateSms(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateSms( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetMessage(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "providerType" => "email", + "topics" => array(), + "users" => array(), + "targets" => array(), + "deliveredTotal" => 1, + "data" => array(), + "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->getMessage( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->delete( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListMessageLogs(): void { + + $data = array( + "total" => 5, + "logs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listMessageLogs( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListTargets(): void { + + $data = array( + "total" => 5, + "targets" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listTargets( + "<MESSAGE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListProviders(): void { + + $data = array( + "total" => 5, + "providers" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listProviders( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateApnsProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createApnsProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateApnsProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateApnsProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateFcmProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createFcmProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateFcmProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateFcmProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMailgunProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createMailgunProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMailgunProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateMailgunProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMsg91Provider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createMsg91Provider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMsg91Provider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateMsg91Provider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSendgridProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createSendgridProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateSendgridProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateSendgridProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSmtpProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createSmtpProvider( + "<PROVIDER_ID>", + "<NAME>", + "<HOST>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateSmtpProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateSmtpProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTelesignProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createTelesignProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTelesignProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateTelesignProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTextmagicProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createTextmagicProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTextmagicProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateTextmagicProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTwilioProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createTwilioProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTwilioProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateTwilioProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateVonageProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createVonageProvider( + "<PROVIDER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateVonageProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateVonageProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetProvider(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Mailgun", + "provider" => "mailgun", + "enabled" => true, + "type" => "sms", + "credentials" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->getProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteProvider(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->deleteProvider( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListProviderLogs(): void { + + $data = array( + "total" => 5, + "logs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listProviderLogs( + "<PROVIDER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListSubscriberLogs(): void { + + $data = array( + "total" => 5, + "logs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listSubscriberLogs( + "<SUBSCRIBER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListTopics(): void { + + $data = array( + "total" => 5, + "topics" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listTopics( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTopic(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "events", + "emailTotal" => 100, + "smsTotal" => 100, + "pushTotal" => 100, + "subscribe" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createTopic( + "<TOPIC_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTopic(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "events", + "emailTotal" => 100, + "smsTotal" => 100, + "pushTotal" => 100, + "subscribe" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->getTopic( + "<TOPIC_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTopic(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "events", + "emailTotal" => 100, + "smsTotal" => 100, + "pushTotal" => 100, + "subscribe" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->updateTopic( + "<TOPIC_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteTopic(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->deleteTopic( + "<TOPIC_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListTopicLogs(): void { + + $data = array( + "total" => 5, + "logs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listTopicLogs( + "<TOPIC_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListSubscribers(): void { + + $data = array( + "total" => 5, + "subscribers" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->listSubscribers( + "<TOPIC_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSubscriber(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "targetId" => "259125845563242502", + "target" => array(), + "userId" => "5e5ea5c16897e", + "userName" => "Aegon Targaryen", + "topicId" => "259125845563242502", + "providerType" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->createSubscriber( + "<TOPIC_ID>", + "<SUBSCRIBER_ID>", + "<TARGET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetSubscriber(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "targetId" => "259125845563242502", + "target" => array(), + "userId" => "5e5ea5c16897e", + "userName" => "Aegon Targaryen", + "topicId" => "259125845563242502", + "providerType" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->getSubscriber( + "<TOPIC_ID>", + "<SUBSCRIBER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteSubscriber(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->messaging->deleteSubscriber( + "<TOPIC_ID>", + "<SUBSCRIBER_ID>" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/StorageTest.php b/tests/Appwrite/Services/StorageTest.php new file mode 100644 index 0000000..e6b1923 --- /dev/null +++ b/tests/Appwrite/Services/StorageTest.php @@ -0,0 +1,309 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class StorageTest extends TestCase { + private $client; + private $storage; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->storage = new Storage($this->client); + } + + public function testMethodListBuckets(): void { + + $data = array( + "total" => 5, + "buckets" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->listBuckets( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBucket(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "fileSecurity" => true, + "name" => "Documents", + "enabled" => true, + "maximumFileSize" => 100, + "allowedFileExtensions" => array(), + "compression" => "gzip", + "encryption" => true, + "antivirus" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->createBucket( + "<BUCKET_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetBucket(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "fileSecurity" => true, + "name" => "Documents", + "enabled" => true, + "maximumFileSize" => 100, + "allowedFileExtensions" => array(), + "compression" => "gzip", + "encryption" => true, + "antivirus" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->getBucket( + "<BUCKET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateBucket(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "fileSecurity" => true, + "name" => "Documents", + "enabled" => true, + "maximumFileSize" => 100, + "allowedFileExtensions" => array(), + "compression" => "gzip", + "encryption" => true, + "antivirus" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->updateBucket( + "<BUCKET_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteBucket(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->deleteBucket( + "<BUCKET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListFiles(): void { + + $data = array( + "total" => 5, + "files" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->listFiles( + "<BUCKET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateFile(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "bucketId" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "name" => "Pink.png", + "signature" => "5d529fd02b544198ae075bd57c1762bb", + "mimeType" => "image/png", + "sizeOriginal" => 17890, + "chunksTotal" => 17890, + "chunksUploaded" => 17890,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->createFile( + "<BUCKET_ID>", + "<FILE_ID>", + InputFile::withData('', "image/png") + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFile(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "bucketId" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "name" => "Pink.png", + "signature" => "5d529fd02b544198ae075bd57c1762bb", + "mimeType" => "image/png", + "sizeOriginal" => 17890, + "chunksTotal" => 17890, + "chunksUploaded" => 17890,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->getFile( + "<BUCKET_ID>", + "<FILE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateFile(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "bucketId" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "name" => "Pink.png", + "signature" => "5d529fd02b544198ae075bd57c1762bb", + "mimeType" => "image/png", + "sizeOriginal" => 17890, + "chunksTotal" => 17890, + "chunksUploaded" => 17890,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->updateFile( + "<BUCKET_ID>", + "<FILE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteFile(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->deleteFile( + "<BUCKET_ID>", + "<FILE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFileDownload(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->getFileDownload( + "<BUCKET_ID>", + "<FILE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFilePreview(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->getFilePreview( + "<BUCKET_ID>", + "<FILE_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetFileView(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->storage->getFileView( + "<BUCKET_ID>", + "<FILE_ID>" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/TeamsTest.php b/tests/Appwrite/Services/TeamsTest.php new file mode 100644 index 0000000..d77d0de --- /dev/null +++ b/tests/Appwrite/Services/TeamsTest.php @@ -0,0 +1,311 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class TeamsTest extends TestCase { + private $client; + private $teams; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->teams = new Teams($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "teams" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->list( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "VIP", + "total" => 7, + "prefs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->create( + "<TEAM_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGet(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "VIP", + "total" => 7, + "prefs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->get( + "<TEAM_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateName(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "VIP", + "total" => 7, + "prefs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->updateName( + "<TEAM_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->delete( + "<TEAM_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListMemberships(): void { + + $data = array( + "total" => 5, + "memberships" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->listMemberships( + "<TEAM_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMembership(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "roles" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->createMembership( + "<TEAM_ID>", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetMembership(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "roles" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->getMembership( + "<TEAM_ID>", + "<MEMBERSHIP_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMembership(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "roles" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->updateMembership( + "<TEAM_ID>", + "<MEMBERSHIP_ID>", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteMembership(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->deleteMembership( + "<TEAM_ID>", + "<MEMBERSHIP_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMembershipStatus(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "roles" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->updateMembershipStatus( + "<TEAM_ID>", + "<MEMBERSHIP_ID>", + "<USER_ID>", + "<SECRET>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetPrefs(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->getPrefs( + "<TEAM_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePrefs(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->teams->updatePrefs( + "<TEAM_ID>", + array() + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php new file mode 100644 index 0000000..e71ee56 --- /dev/null +++ b/tests/Appwrite/Services/UsersTest.php @@ -0,0 +1,1090 @@ +<?php + +namespace Appwrite\Services; + +use Appwrite\Client; +use Appwrite\InputFile; +use Mockery; +use PHPUnit\Framework\TestCase; + +final class UsersTest extends TestCase { + private $client; + private $users; + + protected function setUp(): void { + $this->client = Mockery::mock(Client::class); + $this->users = new Users($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "users" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->list( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->create( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateArgon2User(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createArgon2User( + "<USER_ID>", + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBcryptUser(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createBcryptUser( + "<USER_ID>", + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListIdentities(): void { + + $data = array( + "total" => 5, + "identities" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listIdentities( + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteIdentity(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->deleteIdentity( + "<IDENTITY_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMD5User(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createMD5User( + "<USER_ID>", + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePHPassUser(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createPHPassUser( + "<USER_ID>", + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateScryptUser(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createScryptUser( + "<USER_ID>", + "email@example.com", + "password", + "<PASSWORD_SALT>", + 1, + 1, + 1, + 1 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateScryptModifiedUser(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createScryptModifiedUser( + "<USER_ID>", + "email@example.com", + "password", + "<PASSWORD_SALT>", + "<PASSWORD_SALT_SEPARATOR>", + "<PASSWORD_SIGNER_KEY>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSHAUser(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createSHAUser( + "<USER_ID>", + "email@example.com", + "password" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGet(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->get( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->delete( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmail(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateEmail( + "<USER_ID>", + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateLabels(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateLabels( + "<USER_ID>", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodListLogs(): void { + + $data = array( + "total" => 5, + "logs" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listLogs( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListMemberships(): void { + + $data = array( + "total" => 5, + "memberships" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listMemberships( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMfa(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateMfa( + "<USER_ID>", + true + ); + + $this->assertSame($data, $response); + } + + 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->deleteMfaAuthenticator( + "<USER_ID>", + "totp" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListMfaFactors(): void { + + $data = array( + "totp" => true, + "phone" => true, + "email" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listMfaFactors( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetMfaRecoveryCodes(): void { + + $data = array( + "recoveryCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->getMfaRecoveryCodes( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMfaRecoveryCodes(): void { + + $data = array( + "recoveryCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateMfaRecoveryCodes( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMfaRecoveryCodes(): void { + + $data = array( + "recoveryCodes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createMfaRecoveryCodes( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateName(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateName( + "<USER_ID>", + "<NAME>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePassword(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updatePassword( + "<USER_ID>", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePhone(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updatePhone( + "<USER_ID>", + "+12065550100" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetPrefs(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->getPrefs( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePrefs(): void { + + $data = array(); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updatePrefs( + "<USER_ID>", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodListSessions(): void { + + $data = array( + "total" => 5, + "sessions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listSessions( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateSession(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "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 + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createSession( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteSessions(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->deleteSessions( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteSession(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->deleteSession( + "<USER_ID>", + "<SESSION_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateStatus(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateStatus( + "<USER_ID>", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodListTargets(): void { + + $data = array( + "total" => 5, + "targets" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listTargets( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTarget(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Aegon apple token", + "userId" => "259125845563242502", + "providerType" => "email", + "identifier" => "token",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createTarget( + "<USER_ID>", + "<TARGET_ID>", + "email", + "<IDENTIFIER>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTarget(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Aegon apple token", + "userId" => "259125845563242502", + "providerType" => "email", + "identifier" => "token",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->getTarget( + "<USER_ID>", + "<TARGET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTarget(): void { + + $data = array( + "\$id" => "259125845563242502", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "Aegon apple token", + "userId" => "259125845563242502", + "providerType" => "email", + "identifier" => "token",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateTarget( + "<USER_ID>", + "<TARGET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteTarget(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->deleteTarget( + "<USER_ID>", + "<TARGET_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateToken(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->createToken( + "<USER_ID>" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmailVerification(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updateEmailVerification( + "<USER_ID>", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePhoneVerification(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->updatePhoneVerification( + "<USER_ID>", + true + ); + + $this->assertSame($data, $response); + } + +}