diff --git a/README.md b/README.md index 382a055..3fc6168 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # 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.7.4-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.8.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.7.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.8.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) diff --git a/docs/account.md b/docs/account.md index 3383003..5f6cc02 100644 --- a/docs/account.md +++ b/docs/account.md @@ -112,6 +112,33 @@ POST https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} | type | string | **Required** Type of authenticator. Must be `totp` | | +```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#updateMfaAuthenticator) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | **Required** Type of authenticator. Must be `totp` | | + + +```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#createMfaAuthenticator) method. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | **Required** Type of authenticator. | | +| otp | string | Valid verification token. | | + + ```http request PUT https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} ``` @@ -139,6 +166,32 @@ DELETE https://cloud.appwrite.io/v1/account/mfa/authenticators/{type} | type | string | **Required** Type of 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. | | + + +```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`. | | + + ```http request POST https://cloud.appwrite.io/v1/account/mfa/challenge ``` @@ -166,6 +219,27 @@ PUT https://cloud.appwrite.io/v1/account/mfa/challenge | otp | string | Valid verification token. | | +```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. | | + + +```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. ** + + ```http request GET https://cloud.appwrite.io/v1/account/mfa/factors ``` @@ -180,6 +254,20 @@ 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. ** +```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. ** + + +```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. ** + + ```http request POST https://cloud.appwrite.io/v1/account/mfa/recovery-codes ``` @@ -194,6 +282,13 @@ 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. ** +```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. ** + + ```http request PATCH https://cloud.appwrite.io/v1/account/name ``` @@ -415,15 +510,16 @@ PATCH https://cloud.appwrite.io/v1/account/status 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. +** Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. 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). ** +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. | | +| 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. | | | 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. | | @@ -441,7 +537,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about | 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. | | +| 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. | | | 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. | | @@ -479,7 +575,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about | 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. | | +| 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. | | | phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | diff --git a/docs/databases.md b/docs/databases.md index acca9fc..998532a 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -162,7 +162,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection 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: key, type, size, required, array, status, error | [] | @@ -178,7 +178,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -196,7 +196,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -214,7 +214,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute 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. | | @@ -232,7 +232,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -251,7 +251,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -270,18 +270,18 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request 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. +** Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. ** ### Parameters @@ -289,9 +289,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | 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 255 characters long. | | +| elements | array | Array of enum values. | | | 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? | | @@ -309,12 +309,12 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | 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 255 characters long. | | +| elements | array | Updated list of enum values. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -329,12 +329,12 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| min | number | Minimum value to enforce on new documents | | -| max | number | Maximum value to enforce on new documents | | -| default | number | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| min | number | Minimum value. | | +| max | number | Maximum value. | | +| default | number | Default value. Cannot be set when required. | | | array | boolean | Is attribute an array? | | @@ -350,13 +350,13 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| min | number | Minimum value to enforce on new documents | | -| max | number | Maximum value to enforce on new documents | | -| default | number | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| min | number | Minimum value. | | +| max | number | Maximum value. | | +| default | number | Default value. Cannot be set when required. | | +| newKey | string | New Attribute Key. | | ```http request @@ -371,12 +371,12 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| min | integer | Minimum value to enforce on new documents | | -| max | integer | Maximum value to enforce on new documents | | -| default | integer | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -392,13 +392,13 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| min | integer | Minimum value to enforce on new documents | | -| max | integer | Maximum value to enforce on new documents | | -| default | integer | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | ```http request @@ -413,10 +413,10 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| default | string | Default value. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -432,11 +432,11 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| default | string | Default value. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | ```http request @@ -451,8 +451,8 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | -| relatedCollectionId | string | Related Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | +| relatedCollectionId | string | Related Collection ID. | | | type | string | Relation type | | | twoWay | boolean | Is Two Way? | | | key | string | Attribute Key. | | @@ -472,7 +472,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | size | integer | Attribute size for text attributes, in number of characters. | | | required | boolean | Is attribute required? | | @@ -493,12 +493,12 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | size | integer | Maximum size of the string attribute. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -513,7 +513,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -532,11 +532,11 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -550,7 +550,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | @@ -565,7 +565,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | @@ -581,10 +581,10 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | 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). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | onDelete | string | Constraints option | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -623,9 +623,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - -Create new Documents. 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. ** +** Create new Documents. 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. ** ### Parameters @@ -640,9 +638,7 @@ Create new Documents. Before using this route, you should create a new collectio PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - -Create or update Documents. 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. +** Create or update Documents. 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. ** ### Parameters @@ -658,9 +654,7 @@ Create or update Documents. Before using this route, you should create a new col PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - -Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. ** +** Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. ** ### Parameters @@ -676,9 +670,7 @@ Update all documents that match your queries, if no queries are submitted then a DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - -Bulk delete documents using queries, if no queries are passed then all documents are deleted. ** +** Bulk delete documents using queries, if no queries are passed then all documents are deleted. ** ### Parameters @@ -709,9 +701,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` -** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - -Create or update a 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. ** +** Create or update a 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. ** ### Parameters @@ -770,7 +760,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | collectionId | string | **Required** Collection ID. | | | documentId | string | **Required** Document ID. | | | attribute | string | **Required** Attribute key. | | -| value | number | Value to decrement the attribute by. The value must be a number. | 1 | +| value | number | Value to increment the attribute by. The value must be a number. | 1 | | min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | | diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-jwt.md similarity index 100% rename from docs/examples/account/create-j-w-t.md rename to docs/examples/account/create-jwt.md diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-url-token.md similarity index 100% rename from docs/examples/account/create-magic-u-r-l-token.md rename to docs/examples/account/create-magic-url-token.md diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index da3b463..2eb50c3 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -11,6 +11,6 @@ $client = (new Client()) $account = new Account($client); -$result = $account->createMfaAuthenticator( +$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 index faa679f..64471ef 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -10,6 +10,6 @@ $client = (new Client()) $account = new Account($client); -$result = $account->createMfaChallenge( +$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 index 223c95b..031bc4d 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -10,4 +10,4 @@ $client = (new Client()) $account = new Account($client); -$result = $account->createMfaRecoveryCodes(); +$result = $account->createMFARecoveryCodes(); diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth-2-token.md similarity index 100% rename from docs/examples/account/create-o-auth2token.md rename to docs/examples/account/create-o-auth-2-token.md diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 42806f8..524b9b3 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -11,6 +11,6 @@ $client = (new Client()) $account = new Account($client); -$result = $account->deleteMfaAuthenticator( +$result = $account->deleteMFAAuthenticator( type: AuthenticatorType::TOTP() ); \ No newline at end of file diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index bafd6d8..fc5aef2 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -10,4 +10,4 @@ $client = (new Client()) $account = new Account($client); -$result = $account->getMfaRecoveryCodes(); +$result = $account->getMFARecoveryCodes(); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 6756573..f7b6e26 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -10,4 +10,4 @@ $client = (new Client()) $account = new Account($client); -$result = $account->listMfaFactors(); +$result = $account->listMFAFactors(); diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-url-session.md similarity index 100% rename from docs/examples/account/update-magic-u-r-l-session.md rename to docs/examples/account/update-magic-url-session.md diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 6a09d95..8486e88 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -11,7 +11,7 @@ $client = (new Client()) $account = new Account($client); -$result = $account->updateMfaAuthenticator( +$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 index 03ace31..e5821e5 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -10,7 +10,7 @@ $client = (new Client()) $account = new Account($client); -$result = $account->updateMfaChallenge( +$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 index c7ec6cb..f57e490 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -10,4 +10,4 @@ $client = (new Client()) $account = new Account($client); -$result = $account->updateMfaRecoveryCodes(); +$result = $account->updateMFARecoveryCodes(); diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-mfa.md similarity index 100% rename from docs/examples/account/update-m-f-a.md rename to docs/examples/account/update-mfa.md diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-qr.md similarity index 100% rename from docs/examples/avatars/get-q-r.md rename to docs/examples/avatars/get-qr.md diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 40e14af..6464a26 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -6,7 +6,7 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID - ->setKey(''); // Your secret API key + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index fb61d87..9ad4bdf 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -6,7 +6,7 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID - ->setKey(''); // Your secret API key + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 9aeb976..cd11b5e 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -17,5 +17,5 @@ $result = $functions->createExecution( path: '', // optional method: ExecutionMethod::GET(), // optional headers: [], // optional - scheduledAt: '' // optional + scheduledAt: '' // optional ); \ No newline at end of file diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-db.md similarity index 100% rename from docs/examples/health/get-d-b.md rename to docs/examples/health/get-db.md diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-eu.md similarity index 100% rename from docs/examples/locale/list-countries-e-u.md rename to docs/examples/locale/list-countries-eu.md diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index da13d17..2ce4b7f 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->createApnsProvider( +$result = $messaging->createAPNSProvider( providerId: '', name: '', authKey: '', // optional diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index baf72a1..8037c23 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->createFcmProvider( +$result = $messaging->createFCMProvider( providerId: '', name: '', serviceAccountJSON: [], // optional diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg-91-provider.md similarity index 100% rename from docs/examples/messaging/create-msg91provider.md rename to docs/examples/messaging/create-msg-91-provider.md diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 1e2d9ac..50623b5 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->createSms( +$result = $messaging->createSMS( messageId: '', content: '', topics: [], // optional diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 4dcfb3a..017f20c 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->createSmtpProvider( +$result = $messaging->createSMTPProvider( providerId: '', name: '', host: '', diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index 724453b..161a148 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->updateApnsProvider( +$result = $messaging->updateAPNSProvider( providerId: '', name: '', // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 36672f4..0df2b93 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->updateFcmProvider( +$result = $messaging->updateFCMProvider( providerId: '', name: '', // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg-91-provider.md similarity index 100% rename from docs/examples/messaging/update-msg91provider.md rename to docs/examples/messaging/update-msg-91-provider.md diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 730da41..92d3ebb 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->updateSms( +$result = $messaging->updateSMS( messageId: '', topics: [], // optional users: [], // optional diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index a16a630..3bc80d2 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -10,7 +10,7 @@ $client = (new Client()) $messaging = new Messaging($client); -$result = $messaging->updateSmtpProvider( +$result = $messaging->updateSMTPProvider( providerId: '', name: '', // optional host: '', // optional diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md new file mode 100644 index 0000000..5f0a2de --- /dev/null +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createBooleanColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: false, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md new file mode 100644 index 0000000..9ea8e8f --- /dev/null +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md new file mode 100644 index 0000000..64f3a08 --- /dev/null +++ b/docs/examples/tablesdb/create-email-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createEmailColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'email@example.com', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md new file mode 100644 index 0000000..0506a33 --- /dev/null +++ b/docs/examples/tablesdb/create-enum-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md new file mode 100644 index 0000000..65a7f00 --- /dev/null +++ b/docs/examples/tablesdb/create-float-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createFloatColumn( + databaseId: '', + tableId: '', + 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/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md new file mode 100644 index 0000000..1a3fd13 --- /dev/null +++ b/docs/examples/tablesdb/create-index.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createIndex( + databaseId: '', + tableId: '', + key: '', + type: IndexType::KEY(), + columns: [], + orders: [], // optional + lengths: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md new file mode 100644 index 0000000..4bf96e8 --- /dev/null +++ b/docs/examples/tablesdb/create-integer-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createIntegerColumn( + databaseId: '', + tableId: '', + 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/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md new file mode 100644 index 0000000..ab0032e --- /dev/null +++ b/docs/examples/tablesdb/create-ip-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createIpColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md new file mode 100644 index 0000000..031d1fd --- /dev/null +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -0,0 +1,23 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createRelationshipColumn( + databaseId: '', + tableId: '', + relatedTableId: '', + 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/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md new file mode 100644 index 0000000..0002b79 --- /dev/null +++ b/docs/examples/tablesdb/create-row.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createRow( + databaseId: '', + tableId: '', + rowId: '', + data: [], + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md new file mode 100644 index 0000000..0114438 --- /dev/null +++ b/docs/examples/tablesdb/create-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createRows( + databaseId: '', + tableId: '', + rows: [] +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md new file mode 100644 index 0000000..22fc7cc --- /dev/null +++ b/docs/examples/tablesdb/create-string-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createStringColumn( + databaseId: '', + tableId: '', + key: '', + size: 1, + required: false, + default: '', // optional + array: false, // optional + encrypt: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md new file mode 100644 index 0000000..46cf388 --- /dev/null +++ b/docs/examples/tablesdb/create-table.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createTable( + databaseId: '', + tableId: '', + name: '', + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md new file mode 100644 index 0000000..fe25988 --- /dev/null +++ b/docs/examples/tablesdb/create-url-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createUrlColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'https://example.com', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md new file mode 100644 index 0000000..c3c4faa --- /dev/null +++ b/docs/examples/tablesdb/create.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->create( + databaseId: '', + name: '', + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..a58bd71 --- /dev/null +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + value: null, // optional + min: null // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md new file mode 100644 index 0000000..dd99fab --- /dev/null +++ b/docs/examples/tablesdb/delete-column.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->deleteColumn( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md new file mode 100644 index 0000000..1ef346f --- /dev/null +++ b/docs/examples/tablesdb/delete-index.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->deleteIndex( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md new file mode 100644 index 0000000..4ffc112 --- /dev/null +++ b/docs/examples/tablesdb/delete-row.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->deleteRow( + databaseId: '', + tableId: '', + rowId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md new file mode 100644 index 0000000..10a3c87 --- /dev/null +++ b/docs/examples/tablesdb/delete-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->deleteRows( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md new file mode 100644 index 0000000..3cbb35d --- /dev/null +++ b/docs/examples/tablesdb/delete-table.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->deleteTable( + databaseId: '', + tableId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md new file mode 100644 index 0000000..ea996e9 --- /dev/null +++ b/docs/examples/tablesdb/delete.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->delete( + databaseId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md new file mode 100644 index 0000000..d1705a4 --- /dev/null +++ b/docs/examples/tablesdb/get-column.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->getColumn( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md new file mode 100644 index 0000000..0d67648 --- /dev/null +++ b/docs/examples/tablesdb/get-index.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->getIndex( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md new file mode 100644 index 0000000..00ba9b6 --- /dev/null +++ b/docs/examples/tablesdb/get-row.md @@ -0,0 +1,18 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->getRow( + databaseId: '', + tableId: '', + rowId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md new file mode 100644 index 0000000..ee8812f --- /dev/null +++ b/docs/examples/tablesdb/get-table.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->getTable( + databaseId: '', + tableId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md new file mode 100644 index 0000000..07f7098 --- /dev/null +++ b/docs/examples/tablesdb/get.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->get( + databaseId: '' +); \ No newline at end of file diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md new file mode 100644 index 0000000..d72a1e3 --- /dev/null +++ b/docs/examples/tablesdb/increment-row-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + value: null, // optional + max: null // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md new file mode 100644 index 0000000..d12d52d --- /dev/null +++ b/docs/examples/tablesdb/list-columns.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->listColumns( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md new file mode 100644 index 0000000..cb51dbb --- /dev/null +++ b/docs/examples/tablesdb/list-indexes.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->listIndexes( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md new file mode 100644 index 0000000..c3b7137 --- /dev/null +++ b/docs/examples/tablesdb/list-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->listRows( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md new file mode 100644 index 0000000..05f044b --- /dev/null +++ b/docs/examples/tablesdb/list-tables.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->listTables( + databaseId: '', + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md new file mode 100644 index 0000000..c3f97c2 --- /dev/null +++ b/docs/examples/tablesdb/list.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->list( + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md new file mode 100644 index 0000000..0c73516 --- /dev/null +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateBooleanColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: false, + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md new file mode 100644 index 0000000..52213c6 --- /dev/null +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md new file mode 100644 index 0000000..d13de56 --- /dev/null +++ b/docs/examples/tablesdb/update-email-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateEmailColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'email@example.com', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md new file mode 100644 index 0000000..d54c0b3 --- /dev/null +++ b/docs/examples/tablesdb/update-enum-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md new file mode 100644 index 0000000..bb091ab --- /dev/null +++ b/docs/examples/tablesdb/update-float-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateFloatColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md new file mode 100644 index 0000000..2436bc2 --- /dev/null +++ b/docs/examples/tablesdb/update-integer-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateIntegerColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md new file mode 100644 index 0000000..aa97752 --- /dev/null +++ b/docs/examples/tablesdb/update-ip-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateIpColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md new file mode 100644 index 0000000..834dc18 --- /dev/null +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateRelationshipColumn( + databaseId: '', + tableId: '', + key: '', + onDelete: RelationMutate::CASCADE(), // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md new file mode 100644 index 0000000..70e5d15 --- /dev/null +++ b/docs/examples/tablesdb/update-row.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateRow( + databaseId: '', + tableId: '', + rowId: '', + data: [], // optional + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md new file mode 100644 index 0000000..8a67628 --- /dev/null +++ b/docs/examples/tablesdb/update-rows.md @@ -0,0 +1,18 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateRows( + databaseId: '', + tableId: '', + data: [], // optional + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md new file mode 100644 index 0000000..eb1acc1 --- /dev/null +++ b/docs/examples/tablesdb/update-string-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateStringColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + size: 1, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md new file mode 100644 index 0000000..294d8d6 --- /dev/null +++ b/docs/examples/tablesdb/update-table.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateTable( + databaseId: '', + tableId: '', + name: '', + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md new file mode 100644 index 0000000..b64b302 --- /dev/null +++ b/docs/examples/tablesdb/update-url-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateUrlColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'https://example.com', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md new file mode 100644 index 0000000..106b75e --- /dev/null +++ b/docs/examples/tablesdb/update.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->update( + databaseId: '', + name: '', + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md new file mode 100644 index 0000000..235f0e5 --- /dev/null +++ b/docs/examples/tablesdb/upsert-row.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->upsertRow( + databaseId: '', + tableId: '', + rowId: '', + data: [], // optional + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md new file mode 100644 index 0000000..c1890f1 --- /dev/null +++ b/docs/examples/tablesdb/upsert-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->upsertRows( + databaseId: '', + tableId: '', + rows: [] +); \ No newline at end of file diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon-2-user.md similarity index 100% rename from docs/examples/users/create-argon2user.md rename to docs/examples/users/create-argon-2-user.md diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-jwt.md similarity index 100% rename from docs/examples/users/create-j-w-t.md rename to docs/examples/users/create-jwt.md diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-md-5-user.md similarity index 100% rename from docs/examples/users/create-m-d5user.md rename to docs/examples/users/create-md-5-user.md diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 372fb1b..ee96d2e 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -10,6 +10,6 @@ $client = (new Client()) $users = new Users($client); -$result = $users->createMfaRecoveryCodes( +$result = $users->createMFARecoveryCodes( userId: '' ); \ No newline at end of file diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-ph-pass-user.md similarity index 100% rename from docs/examples/users/create-p-h-pass-user.md rename to docs/examples/users/create-ph-pass-user.md diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-sha-user.md similarity index 100% rename from docs/examples/users/create-s-h-a-user.md rename to docs/examples/users/create-sha-user.md diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index 8ef1279..f2f08ec 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -11,7 +11,7 @@ $client = (new Client()) $users = new Users($client); -$result = $users->deleteMfaAuthenticator( +$result = $users->deleteMFAAuthenticator( userId: '', type: AuthenticatorType::TOTP() ); \ 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 index db090fb..7937e6a 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -10,6 +10,6 @@ $client = (new Client()) $users = new Users($client); -$result = $users->getMfaRecoveryCodes( +$result = $users->getMFARecoveryCodes( userId: '' ); \ No newline at end of file diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 6a0088c..5dae790 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -10,6 +10,6 @@ $client = (new Client()) $users = new Users($client); -$result = $users->listMfaFactors( +$result = $users->listMFAFactors( userId: '' ); \ 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 index 75214de..8474755 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -10,6 +10,6 @@ $client = (new Client()) $users = new Users($client); -$result = $users->updateMfaRecoveryCodes( +$result = $users->updateMFARecoveryCodes( userId: '' ); \ No newline at end of file diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 3eda496..c24916a 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -10,7 +10,7 @@ $client = (new Client()) $users = new Users($client); -$result = $users->updateMfa( +$result = $users->updateMFA( userId: '', mfa: false ); \ No newline at end of file diff --git a/docs/messaging.md b/docs/messaging.md index b38c34e..1cc5298 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -146,6 +146,45 @@ POST https://cloud.appwrite.io/v1/messaging/messages/sms | 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. | | +```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. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/messaging/messages/sms/{messageId} +``` + +** Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + ** + +### 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. | | + + ```http request PATCH https://cloud.appwrite.io/v1/messaging/messages/sms/{messageId} ``` @@ -255,6 +294,46 @@ POST https://cloud.appwrite.io/v1/messaging/providers/apns | enabled | boolean | Set as enabled. | | +```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. | | + + +```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. | | + + ```http request PATCH https://cloud.appwrite.io/v1/messaging/providers/apns/{providerId} ``` @@ -291,6 +370,38 @@ POST https://cloud.appwrite.io/v1/messaging/providers/fcm | enabled | boolean | Set as enabled. | | +```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. | | + + +```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. | {} | + + ```http request PATCH https://cloud.appwrite.io/v1/messaging/providers/fcm/{providerId} ``` @@ -453,6 +564,58 @@ POST https://cloud.appwrite.io/v1/messaging/providers/smtp | enabled | boolean | Set as enabled. | | +```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. | | + + +```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. | | + + ```http request PATCH https://cloud.appwrite.io/v1/messaging/providers/smtp/{providerId} ``` diff --git a/docs/tablesdb.md b/docs/tablesdb.md new file mode 100644 index 0000000..4e37b4a --- /dev/null +++ b/docs/tablesdb.md @@ -0,0 +1,847 @@ +# TablesDB Service + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb +``` + +** Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. ** + +### 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 columns: name | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb +``` + +** Create a new Database. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | 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. | | +| name | string | Database name. Max length: 128 chars. | | +| enabled | boolean | Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. | 1 | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId} +``` + +** Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | + + +```http request +PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId} +``` + +** Update a database by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| name | string | Database name. Max length: 128 chars. | | +| enabled | boolean | Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. | 1 | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId} +``` + +** Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables +``` + +** Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database 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 columns: name, enabled, rowSecurity | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables +``` + +** Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | 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. | | +| name | string | Table name. Max length: 128 chars. | | +| permissions | array | An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId} +``` + +** Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | + + +```http request +PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId} +``` + +** Update a table by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| name | string | Table name. Max length: 128 chars. | | +| permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId} +``` + +** Delete a table by its unique ID. Only users with write permissions have access to delete this resource. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns +``` + +** List columns in the table. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table 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 columns: key, type, size, required, array, status, error | [] | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/boolean +``` + +** Create a boolean column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | boolean | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key} +``` + +** Update a boolean column. Changing the `default` value will not update already existing rows. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | boolean | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/datetime +``` + +** Create a date time column according to the ISO 8601 standard. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key} +``` + +** Update a date time column. Changing the `default` value will not update already existing rows. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/email +``` + +** Create an email column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key} +``` + +** Update an email column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/enum +``` + +** Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| elements | array | Array of enum values. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key} +``` + +** Update an enum column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| elements | array | Updated list of enum values. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/float +``` + +** Create a float column. Optionally, minimum and maximum values can be provided. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| min | number | Minimum value | | +| max | number | Maximum value | | +| default | number | Default value. Cannot be set when required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key} +``` + +** Update a float column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| min | number | Minimum value | | +| max | number | Maximum value | | +| default | number | Default value. Cannot be set when required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/integer +``` + +** Create an integer column. Optionally, minimum and maximum values can be provided. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key} +``` + +** Update an integer column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/ip +``` + +** Create IP address column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key} +``` + +** Update an ip column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/relationship +``` + +** Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| relatedTableId | string | Related Table ID. | | +| type | string | Relation type | | +| twoWay | boolean | Is Two Way? | | +| key | string | Column Key. | | +| twoWayKey | string | Two Way Column Key. | | +| onDelete | string | Constraints option | restrict | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/string +``` + +** Create a string column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | Column Key. | | +| size | integer | Column size for text columns, in number of characters. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | +| encrypt | boolean | Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key} +``` + +** Update a string column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| size | integer | Maximum size of the string column. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/url +``` + +** Create a URL column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key} +``` + +** Update an url column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key} +``` + +** Get column by ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key} +``` + +** Deletes a column. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship +``` + +** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| onDelete | string | Constraints option | | +| newKey | string | New Column Key. | | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes +``` + +** List indexes on the table. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| 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 columns: key, type, status, attributes, error | [] | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes +``` + +** Creates an index on the columns listed. Your index should include all the columns you will query in a single request. +Type can be `key`, `fulltext`, or `unique`. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | Index Key. | | +| type | string | Index type. | | +| columns | array | Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. | | +| orders | array | Array of index orders. Maximum of 100 orders are allowed. | [] | +| lengths | array | Length of index. Maximum of 100 | [] | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes/{key} +``` + +** Get index by ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Index Key. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes/{key} +``` + +** Delete an index. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Index Key. | | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows +``` + +** Get a list of all the user's rows in a given table. You can use the query params to filter your results. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). | | +| 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. | [] | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows +``` + +** Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. | | +| rowId | string | Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| data | object | Row data as JSON object. | {} | +| permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows +``` + +** Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. | | +| rows | array | Array of documents data as JSON objects. | [] | + + +```http request +PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows +``` + +** Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rows | array | Array of row data as JSON objects. May contain partial rows. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows +``` + +** Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| data | object | Row data as JSON object. Include only column and value pairs to be updated. | {} | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows +``` + +** Bulk delete rows using queries, if no queries are passed then all rows are deleted. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| 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. | [] | + + +```http request +GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Get a row by its unique ID. This endpoint response returns a JSON object with the row data. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| rowId | string | **Required** Row ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| data | object | Row data as JSON object. Include all required columns of the row to be created or updated. | {} | +| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| data | object | Row data as JSON object. Include only columns and value pairs to be updated. | {} | +| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + +```http request +DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Delete a row by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| rowId | string | **Required** Row ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement +``` + +** Decrement a specific column of a row by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| column | string | **Required** Column key. | | +| value | number | Value to increment the column by. The value must be a number. | 1 | +| min | number | Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment +``` + +** Increment a specific column of a row by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| column | string | **Required** Column key. | | +| value | number | Value to increment the column by. The value must be a number. | 1 | +| max | number | Maximum value for the column. If the current value is greater than this value, an error will be thrown. | | + diff --git a/docs/users.md b/docs/users.md index a31ac8c..cf39ee4 100644 --- a/docs/users.md +++ b/docs/users.md @@ -294,6 +294,34 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/mfa | mfa | boolean | Enable or disable 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. | | + + +```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. | | + + ```http request DELETE https://cloud.appwrite.io/v1/users/{userId}/mfa/authenticators/{type} ``` @@ -321,6 +349,32 @@ GET https://cloud.appwrite.io/v1/users/{userId}/mfa/factors | userId | string | **Required** User ID. | | +```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. | | + + +```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. | | + + ```http request GET https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes ``` @@ -347,6 +401,32 @@ PUT https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes | userId | string | **Required** User ID. | | +```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. | | + + +```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. | | + + ```http request PATCH https://cloud.appwrite.io/v1/users/{userId}/mfa/recovery-codes ``` diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 4288210..5c1c208 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/15.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/16.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '15.1.0', + 'x-sdk-version'=> '16.0.0', ]; /** @@ -49,7 +49,7 @@ class Client */ public function __construct() { - $this->headers['X-Appwrite-Response-Format'] = '1.7.0'; + $this->headers['X-Appwrite-Response-Format'] = '1.8.0'; } diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index a27235a..ab717fd 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -267,6 +267,111 @@ public static function contains(string $attribute, $value): string return (new Query('contains', $attribute, $value))->__toString(); } + /** + * Not Contains + * + * @param string $attribute + * @param mixed $value + * @return string + */ + public static function notContains(string $attribute, $value): string + { + return (new Query('notContains', $attribute, $value))->__toString(); + } + + /** + * Not Search + * + * @param string $attribute + * @param string $value + * @return string + */ + public static function notSearch(string $attribute, string $value): string + { + return (new Query('notSearch', $attribute, $value))->__toString(); + } + + /** + * Not Between + * + * @param string $attribute + * @param string|int|float $start + * @param string|int|float $end + * @return string + */ + public static function notBetween(string $attribute, mixed $start, mixed $end): string + { + return (new Query('notBetween', $attribute, [$start, $end]))->__toString(); + } + + /** + * Not Starts With + * + * @param string $attribute + * @param string $value + * @return string + */ + public static function notStartsWith(string $attribute, string $value): string + { + return (new Query('notStartsWith', $attribute, $value))->__toString(); + } + + /** + * Not Ends With + * + * @param string $attribute + * @param string $value + * @return string + */ + public static function notEndsWith(string $attribute, string $value): string + { + return (new Query('notEndsWith', $attribute, $value))->__toString(); + } + + /** + * Created Before + * + * @param string $value + * @return string + */ + public static function createdBefore(string $value): string + { + return (new Query('createdBefore', null, $value))->__toString(); + } + + /** + * Created After + * + * @param string $value + * @return string + */ + public static function createdAfter(string $value): string + { + return (new Query('createdAfter', null, $value))->__toString(); + } + + /** + * Updated Before + * + * @param string $value + * @return string + */ + public static function updatedBefore(string $value): string + { + return (new Query('updatedBefore', null, $value))->__toString(); + } + + /** + * Updated After + * + * @param string $value + * @return string + */ + public static function updatedAfter(string $value): string + { + return (new Query('updatedAfter', null, $value))->__toString(); + } + /** * Or * diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 13c7d7f..ca28ff4 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -286,6 +286,9 @@ public function updateMFA(bool $mfa): array * @param AuthenticatorType $type * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createMFAAuthenticator` instead. + * @see Account::createMFAAuthenticator */ public function createMfaAuthenticator(AuthenticatorType $type): array { @@ -309,6 +312,38 @@ public function createMfaAuthenticator(AuthenticatorType $type): array ); } + /** + * Add an authenticator app to be used as an MFA factor. Verify the + * authenticator using the [verify + * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) + * method. + * + * @param AuthenticatorType $type + * @throws AppwriteException + * @return array + */ + public function createMFAAuthenticator(AuthenticatorType $type): array + { + $apiPath = str_replace( + ['{type}'], + [$type], + '/account/mfa/authenticators/{type}' + ); + + $apiParams = []; + $apiParams['type'] = $type; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Verify an authenticator app after adding it using the [add * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -318,6 +353,9 @@ public function createMfaAuthenticator(AuthenticatorType $type): array * @param string $otp * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateMFAAuthenticator` instead. + * @see Account::updateMFAAuthenticator */ public function updateMfaAuthenticator(AuthenticatorType $type, string $otp): array { @@ -342,12 +380,48 @@ public function updateMfaAuthenticator(AuthenticatorType $type, string $otp): ar ); } + /** + * Verify an authenticator app after adding it using the [add + * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + * 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 = []; + $apiParams['type'] = $type; + $apiParams['otp'] = $otp; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Delete an authenticator for a user by ID. * * @param AuthenticatorType $type * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteMFAAuthenticator` instead. + * @see Account::deleteMFAAuthenticator */ public function deleteMfaAuthenticator(AuthenticatorType $type): string { @@ -371,6 +445,35 @@ public function deleteMfaAuthenticator(AuthenticatorType $type): string ); } + /** + * Delete an authenticator for a user by ID. + * + * @param AuthenticatorType $type + * @throws AppwriteException + * @return string + */ + public function deleteMFAAuthenticator(AuthenticatorType $type): string + { + $apiPath = str_replace( + ['{type}'], + [$type], + '/account/mfa/authenticators/{type}' + ); + + $apiParams = []; + $apiParams['type'] = $type; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Begin the process of MFA verification after sign-in. Finish the flow with * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -379,6 +482,9 @@ public function deleteMfaAuthenticator(AuthenticatorType $type): string * @param AuthenticationFactor $factor * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createMFAChallenge` instead. + * @see Account::createMFAChallenge */ public function createMfaChallenge(AuthenticationFactor $factor): array { @@ -402,6 +508,37 @@ public function createMfaChallenge(AuthenticationFactor $factor): array ); } + /** + * 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 = []; + $apiParams['factor'] = $factor; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Complete the MFA challenge by providing the one-time password. Finish the * process of MFA verification by providing the one-time password. To begin @@ -413,6 +550,9 @@ public function createMfaChallenge(AuthenticationFactor $factor): array * @param string $otp * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateMFAChallenge` instead. + * @see Account::updateMFAChallenge */ public function updateMfaChallenge(string $challengeId, string $otp): array { @@ -437,11 +577,49 @@ public function updateMfaChallenge(string $challengeId, string $otp): array ); } + /** + * 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 array + */ + public function updateMFAChallenge(string $challengeId, string $otp): array + { + $apiPath = str_replace( + [], + [], + '/account/mfa/challenge' + ); + + $apiParams = []; + $apiParams['challengeId'] = $challengeId; + $apiParams['otp'] = $otp; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * List the factors available on the account to be used as a MFA challange. * * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listMFAFactors` instead. + * @see Account::listMFAFactors */ public function listMfaFactors(): array { @@ -463,6 +641,32 @@ public function listMfaFactors(): array ); } + /** + * 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 = []; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get recovery codes that can be used as backup for MFA flow. Before getting * codes, they must be generated using @@ -471,6 +675,9 @@ public function listMfaFactors(): array * * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getMFARecoveryCodes` instead. + * @see Account::getMFARecoveryCodes */ public function getMfaRecoveryCodes(): array { @@ -492,6 +699,35 @@ public function getMfaRecoveryCodes(): array ); } + /** + * 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' + ); + + $apiParams = []; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Generate recovery codes as backup for MFA flow. It's recommended to * generate and show then immediately after user successfully adds their @@ -501,6 +737,9 @@ public function getMfaRecoveryCodes(): array * * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createMFARecoveryCodes` instead. + * @see Account::createMFARecoveryCodes */ public function createMfaRecoveryCodes(): array { @@ -523,6 +762,37 @@ public function createMfaRecoveryCodes(): array ); } + /** + * 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 = []; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Regenerate recovery codes that can be used as backup for MFA flow. Before * regenerating codes, they must be first generated using @@ -531,6 +801,9 @@ public function createMfaRecoveryCodes(): array * * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateMFARecoveryCodes` instead. + * @see Account::updateMFARecoveryCodes */ public function updateMfaRecoveryCodes(): array { @@ -553,6 +826,36 @@ public function updateMfaRecoveryCodes(): array ); } + /** + * 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 = []; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update currently logged in user account name. * @@ -923,6 +1226,8 @@ public function createEmailPasswordSession(string $email, string $password): arr * @param string $secret * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated. */ public function updateMagicURLSession(string $userId, string $secret): array { @@ -956,6 +1261,8 @@ public function updateMagicURLSession(string $userId, string $secret): array * @param string $secret * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated. */ public function updatePhoneSession(string $userId, string $secret): array { @@ -1137,8 +1444,11 @@ public function updateStatus(): array /** * 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 + * email address has never been used, a **new account is created** using the + * provided `userId`. Otherwise, if the email address is already attached to + * an account, the **user ID is ignored**. Then, the user will receive an + * email with the one-time password. 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. @@ -1146,6 +1456,7 @@ public function updateStatus(): array * 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 diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 19cfdbd..1060a0a 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -25,6 +25,9 @@ public function __construct(Client $client) * @param ?string $search * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `list` instead. + * @see TablesDB::list */ public function list(?array $queries = null, ?string $search = null): array { @@ -63,6 +66,9 @@ public function list(?array $queries = null, ?string $search = null): array * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createDatabase` instead. + * @see TablesDB::createDatabase */ public function create(string $databaseId, string $name, ?bool $enabled = null): array { @@ -98,6 +104,9 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): * @param string $databaseId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `get` instead. + * @see TablesDB::get */ public function get(string $databaseId): array { @@ -128,6 +137,9 @@ public function get(string $databaseId): array * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `update` instead. + * @see TablesDB::update */ public function update(string $databaseId, string $name, ?bool $enabled = null): array { @@ -163,6 +175,9 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): * @param string $databaseId * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `delete` instead. + * @see TablesDB::delete */ public function delete(string $databaseId): string { @@ -195,6 +210,9 @@ public function delete(string $databaseId): string * @param ?string $search * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listTables` instead. + * @see TablesDB::listTables */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null): array { @@ -239,6 +257,9 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createTable` instead. + * @see TablesDB::createTable */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { @@ -284,6 +305,9 @@ public function createCollection(string $databaseId, string $collectionId, strin * @param string $collectionId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getTable` instead. + * @see TablesDB::getTable */ public function getCollection(string $databaseId, string $collectionId): array { @@ -318,6 +342,9 @@ public function getCollection(string $databaseId, string $collectionId): array * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateTable` instead. + * @see TablesDB::updateTable */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { @@ -363,6 +390,9 @@ public function updateCollection(string $databaseId, string $collectionId, strin * @param string $collectionId * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteTable` instead. + * @see TablesDB::deleteTable */ public function deleteCollection(string $databaseId, string $collectionId): string { @@ -395,6 +425,9 @@ public function deleteCollection(string $databaseId, string $collectionId): stri * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listColumns` instead. + * @see TablesDB::listColumns */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -434,6 +467,9 @@ public function listAttributes(string $databaseId, string $collectionId, ?array * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createBooleanColumn` instead. + * @see TablesDB::createBooleanColumn */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array { @@ -480,6 +516,9 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateBooleanColumn` instead. + * @see TablesDB::updateBooleanColumn */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array { @@ -522,6 +561,9 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createDatetimeColumn` instead. + * @see TablesDB::createDatetimeColumn */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -568,6 +610,9 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateDatetimeColumn` instead. + * @see TablesDB::updateDatetimeColumn */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -611,6 +656,9 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createEmailColumn` instead. + * @see TablesDB::createEmailColumn */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -658,6 +706,9 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateEmailColumn` instead. + * @see TablesDB::updateEmailColumn */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -690,8 +741,8 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s } /** - * Create an enumeration attribute. The `elements` param acts as a white-list - * of accepted values for this attribute. + * Create an enum attribute. The `elements` param acts as a white-list of + * accepted values for this attribute. * * * @param string $databaseId @@ -703,6 +754,9 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createEnumColumn` instead. + * @see TablesDB::createEnumColumn */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -752,6 +806,9 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateEnumColumn` instead. + * @see TablesDB::updateEnumColumn */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -799,6 +856,9 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createFloatColumn` instead. + * @see TablesDB::createFloatColumn */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array { @@ -856,6 +916,9 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateFloatColumn` instead. + * @see TablesDB::updateFloatColumn */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array { @@ -910,6 +973,9 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createIntegerColumn` instead. + * @see TablesDB::createIntegerColumn */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array { @@ -967,6 +1033,9 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateIntegerColumn` instead. + * @see TablesDB::updateIntegerColumn */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array { @@ -1018,6 +1087,9 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createIpColumn` instead. + * @see TablesDB::createIpColumn */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -1065,6 +1137,9 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateIpColumn` instead. + * @see TablesDB::updateIpColumn */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -1111,6 +1186,9 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri * @param ?RelationMutate $onDelete * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createRelationshipColumn` instead. + * @see TablesDB::createRelationshipColumn */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array { @@ -1167,6 +1245,9 @@ public function createRelationshipAttribute(string $databaseId, string $collecti * @param ?bool $encrypt * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createStringColumn` instead. + * @see TablesDB::createStringColumn */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array { @@ -1220,6 +1301,9 @@ public function createStringAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateStringColumn` instead. + * @see TablesDB::updateStringColumn */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array { @@ -1267,6 +1351,9 @@ public function updateStringAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createUrlColumn` instead. + * @see TablesDB::createUrlColumn */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -1314,6 +1401,9 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateUrlColumn` instead. + * @see TablesDB::updateUrlColumn */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -1353,6 +1443,9 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str * @param string $key * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. + * @see TablesDB::getColumn */ public function getAttribute(string $databaseId, string $collectionId, string $key): array { @@ -1385,6 +1478,9 @@ public function getAttribute(string $databaseId, string $collectionId, string $k * @param string $key * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteColumn` instead. + * @see TablesDB::deleteColumn */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { @@ -1422,6 +1518,9 @@ public function deleteAttribute(string $databaseId, string $collectionId, string * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRelationshipColumn` instead. + * @see TablesDB::updateRelationshipColumn */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array { @@ -1464,6 +1563,9 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listRows` instead. + * @see TablesDB::listRows */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -1504,6 +1606,9 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ * @param ?array $permissions * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createRow` instead. + * @see TablesDB::createRow */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array { @@ -1535,10 +1640,6 @@ public function createDocument(string $databaseId, string $collectionId, string } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Create new Documents. Before using this route, you should create a new * collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1549,6 +1650,9 @@ public function createDocument(string $databaseId, string $collectionId, string * @param array $documents * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createRows` instead. + * @see TablesDB::createRows */ public function createDocuments(string $databaseId, string $collectionId, array $documents): array { @@ -1575,10 +1679,6 @@ public function createDocuments(string $databaseId, string $collectionId, array } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Create or update Documents. Before using this route, you should create a * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1590,6 +1690,9 @@ public function createDocuments(string $databaseId, string $collectionId, array * @param array $documents * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRows` instead. + * @see TablesDB::upsertRows */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents): array { @@ -1616,10 +1719,6 @@ public function upsertDocuments(string $databaseId, string $collectionId, array } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Update all documents that match your queries, if no queries are submitted * then all documents are updated. You can pass only specific fields to be * updated. @@ -1630,6 +1729,9 @@ public function upsertDocuments(string $databaseId, string $collectionId, array * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRows` instead. + * @see TablesDB::updateRows */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null): array { @@ -1663,10 +1765,6 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Bulk delete documents using queries, if no queries are passed then all * documents are deleted. * @@ -1675,6 +1773,9 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRows` instead. + * @see TablesDB::deleteRows */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -1713,6 +1814,9 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getRow` instead. + * @see TablesDB::getRow */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null): array { @@ -1742,10 +1846,6 @@ public function getDocument(string $databaseId, string $collectionId, string $do } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Create or update a Document. Before using this route, you should create a * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1758,6 +1858,9 @@ public function getDocument(string $databaseId, string $collectionId, string $do * @param ?array $permissions * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRow` instead. + * @see TablesDB::upsertRow */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array { @@ -1799,6 +1902,9 @@ public function upsertDocument(string $databaseId, string $collectionId, string * @param ?array $permissions * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRow` instead. + * @see TablesDB::updateRow */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null): array { @@ -1840,6 +1946,9 @@ public function updateDocument(string $databaseId, string $collectionId, string * @param string $documentId * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRow` instead. + * @see TablesDB::deleteRow */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId): string { @@ -1876,6 +1985,9 @@ public function deleteDocument(string $databaseId, string $collectionId, string * @param ?float $min * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `decrementRowColumn` instead. + * @see TablesDB::decrementRowColumn */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null): array { @@ -1921,6 +2033,9 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio * @param ?float $max * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `incrementRowColumn` instead. + * @see TablesDB::incrementRowColumn */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null): array { @@ -1963,6 +2078,9 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listIndexes` instead. + * @see TablesDB::listIndexes */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -2004,6 +2122,9 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu * @param ?array $lengths * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createIndex` instead. + * @see TablesDB::createIndex */ public function createIndex(string $databaseId, string $collectionId, string $key, IndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): array { @@ -2047,6 +2168,9 @@ public function createIndex(string $databaseId, string $collectionId, string $ke * @param string $key * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getIndex` instead. + * @see TablesDB::getIndex */ public function getIndex(string $databaseId, string $collectionId, string $key): array { @@ -2079,6 +2203,9 @@ public function getIndex(string $databaseId, string $collectionId, string $key): * @param string $key * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteIndex` instead. + * @see TablesDB::deleteIndex */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 70f93fb..3fbebd2 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -470,6 +470,9 @@ public function updatePush(string $messageId, ?array $topics = null, ?array $use * @param ?string $scheduledAt * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createSMS` instead. + * @see Messaging::createSMS */ public function createSms(string $messageId, string $content, ?array $topics = null, ?array $users = null, ?array $targets = null, ?bool $draft = null, ?string $scheduledAt = null): array { @@ -514,6 +517,62 @@ public function createSms(string $messageId, string $content, ?array $topics = n ); } + /** + * 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 = []; + $apiParams['messageId'] = $messageId; + $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; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update an SMS message by its unique ID. This endpoint only works on * messages that are in draft status. Messages that are already processing, @@ -529,6 +588,9 @@ public function createSms(string $messageId, string $content, ?array $topics = n * @param ?string $scheduledAt * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateSMS` instead. + * @see Messaging::updateSMS */ public function updateSms(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $content = null, ?bool $draft = null, ?string $scheduledAt = null): array { @@ -576,6 +638,68 @@ public function updateSms(string $messageId, ?array $topics = null, ?array $user ); } + /** + * Update an SMS message by its unique ID. This endpoint only works on + * messages that are in draft status. Messages that are already processing, + * sent, or failed cannot be updated. + * + * + * @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 = []; + $apiParams['messageId'] = $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; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get a message by its unique ID. * @@ -750,6 +874,9 @@ public function listProviders(?array $queries = null, ?string $search = null): a * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createAPNSProvider` instead. + * @see Messaging::createAPNSProvider */ 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 { @@ -798,6 +925,67 @@ public function createApnsProvider(string $providerId, string $name, ?string $au ); } + /** + * 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 = []; + $apiParams['providerId'] = $providerId; + $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; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update a Apple Push Notification service provider by its unique ID. * @@ -811,6 +999,9 @@ public function createApnsProvider(string $providerId, string $name, ?string $au * @param ?bool $sandbox * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateAPNSProvider` instead. + * @see Messaging::updateAPNSProvider */ 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 { @@ -862,6 +1053,70 @@ public function updateApnsProvider(string $providerId, ?string $name = null, ?bo ); } + /** + * 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 = []; + $apiParams['providerId'] = $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; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a new Firebase Cloud Messaging provider. * @@ -871,6 +1126,9 @@ public function updateApnsProvider(string $providerId, ?string $name = null, ?bo * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createFCMProvider` instead. + * @see Messaging::createFCMProvider */ public function createFcmProvider(string $providerId, string $name, ?array $serviceAccountJSON = null, ?bool $enabled = null): array { @@ -903,6 +1161,47 @@ public function createFcmProvider(string $providerId, string $name, ?array $serv ); } + /** + * 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 = []; + $apiParams['providerId'] = $providerId; + $apiParams['name'] = $name; + + if (!is_null($serviceAccountJSON)) { + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -912,6 +1211,9 @@ public function createFcmProvider(string $providerId, string $name, ?array $serv * @param ?array $serviceAccountJSON * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateFCMProvider` instead. + * @see Messaging::updateFCMProvider */ public function updateFcmProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?array $serviceAccountJSON = null): array { @@ -947,6 +1249,50 @@ public function updateFcmProvider(string $providerId, ?string $name = null, ?boo ); } + /** + * 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 = []; + $apiParams['providerId'] = $providerId; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + if (!is_null($serviceAccountJSON)) { + $apiParams['serviceAccountJSON'] = $serviceAccountJSON; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a new Mailgun provider. * @@ -1341,6 +1687,9 @@ public function updateSendgridProvider(string $providerId, ?string $name = null, * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createSMTPProvider` instead. + * @see Messaging::createSMTPProvider */ 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 { @@ -1410,6 +1759,94 @@ public function createSmtpProvider(string $providerId, string $name, string $hos ); } + /** + * 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 = []; + $apiParams['providerId'] = $providerId; + $apiParams['name'] = $name; + $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; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update a SMTP provider by its unique ID. * @@ -1429,6 +1866,9 @@ public function createSmtpProvider(string $providerId, string $name, string $hos * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateSMTPProvider` instead. + * @see Messaging::updateSMTPProvider */ 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 { @@ -1504,6 +1944,100 @@ public function updateSmtpProvider(string $providerId, ?string $name = null, ?st ); } + /** + * 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 = []; + $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; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a new Telesign provider. * diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php new file mode 100644 index 0000000..59a4254 --- /dev/null +++ b/src/Appwrite/Services/TablesDb.php @@ -0,0 +1,2087 @@ +client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Database. + * + * + * @param string $databaseId + * @param string $name + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function create(string $databaseId, string $name, ?bool $enabled = null): array + { + $apiPath = str_replace( + [], + [], + '/tablesdb' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['name'] = $name; + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a database by its unique ID. This endpoint response returns a JSON + * object with the database metadata. + * + * @param string $databaseId + * @throws AppwriteException + * @return array + */ + public function get(string $databaseId): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a database by its unique ID. + * + * @param string $databaseId + * @param string $name + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function update(string $databaseId, string $name, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['name'] = $name; + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a database by its unique ID. Only API keys with with databases.write + * scope can delete a database. + * + * @param string $databaseId + * @throws AppwriteException + * @return string + */ + public function delete(string $databaseId): string + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a list of all tables that belong to the provided databaseId. You can + * use the search parameter to filter your results. + * + * @param string $databaseId + * @param ?array $queries + * @param ?string $search + * @throws AppwriteException + * @return array + */ + public function listTables(string $databaseId, ?array $queries = null, ?string $search = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}/tables' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($search)) { + $apiParams['search'] = $search; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Table. Before using this route, you should create a new + * database resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $name + * @param ?array $permissions + * @param ?bool $rowSecurity + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/tablesdb/{databaseId}/tables' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['name'] = $name; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($rowSecurity)) { + $apiParams['rowSecurity'] = $rowSecurity; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a table by its unique ID. This endpoint response returns a JSON object + * with the table metadata. + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return array + */ + public function getTable(string $databaseId, string $tableId): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a table by its unique ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $name + * @param ?array $permissions + * @param ?bool $rowSecurity + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function updateTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['name'] = $name; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($rowSecurity)) { + $apiParams['rowSecurity'] = $rowSecurity; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a table by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return string + */ + public function deleteTable(string $databaseId, string $tableId): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List columns in the table. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listColumns(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a boolean column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?bool $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a boolean column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?bool $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a date time column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an email column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an email column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an enumeration column. The `elements` param acts as a white-list of + * accepted values for this column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param array $elements + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['elements'] = $elements; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an enum column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param array $elements + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['elements'] = $elements; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a float column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?float $min + * @param ?float $max + * @param ?float $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a float column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?float $xdefault + * @param ?float $min + * @param ?float $max + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an integer column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?int $min + * @param ?int $max + * @param ?int $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an integer column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?int $xdefault + * @param ?int $min + * @param ?int $max + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create IP address column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an ip column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param string $databaseId + * @param string $tableId + * @param string $relatedTableId + * @param RelationshipType $type + * @param ?bool $twoWay + * @param ?string $key + * @param ?string $twoWayKey + * @param ?RelationMutate $onDelete + * @throws AppwriteException + * @return array + */ + public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['relatedTableId'] = $relatedTableId; + $apiParams['type'] = $type; + + if (!is_null($twoWay)) { + $apiParams['twoWay'] = $twoWay; + } + + if (!is_null($key)) { + $apiParams['key'] = $key; + } + + if (!is_null($twoWayKey)) { + $apiParams['twoWayKey'] = $twoWayKey; + } + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a string column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param int $size + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @param ?bool $encrypt + * @throws AppwriteException + * @return array + */ + public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['size'] = $size; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + if (!is_null($encrypt)) { + $apiParams['encrypt'] = $encrypt; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a string column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?int $size + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($size)) { + $apiParams['size'] = $size; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a URL column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an url column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get column by ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return array + */ + public function getColumn(string $databaseId, string $tableId, string $key): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Deletes a column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return string + */ + public function deleteColumn(string $databaseId, string $tableId, string $key): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param ?RelationMutate $onDelete + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List indexes on the table. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listIndexes(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/indexes' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Creates an index on the columns listed. Your index should include all the + * columns you will query in a single request. + * Type can be `key`, `fulltext`, or `unique`. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param IndexType $type + * @param array $columns + * @param ?array $orders + * @param ?array $lengths + * @throws AppwriteException + * @return array + */ + public function createIndex(string $databaseId, string $tableId, string $key, IndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/indexes' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['type'] = $type; + $apiParams['columns'] = $columns; + + if (!is_null($orders)) { + $apiParams['orders'] = $orders; + } + + if (!is_null($lengths)) { + $apiParams['lengths'] = $lengths; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get index by ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return array + */ + public function getIndex(string $databaseId, string $tableId, string $key): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete an index. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return string + */ + public function deleteIndex(string $databaseId, string $tableId, string $key): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a list of all the user's rows in a given table. You can use the query + * params to filter your results. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listRows(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Row. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['data'] = $data; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create new Rows. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param array $rows + * @throws AppwriteException + * @return array + */ + public function createRows(string $databaseId, string $tableId, array $rows): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rows'] = $rows; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create or update Rows. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * + * @param string $databaseId + * @param string $tableId + * @param array $rows + * @throws AppwriteException + * @return array + */ + public function upsertRows(string $databaseId, string $tableId, array $rows): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rows'] = $rows; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update all rows that match your queries, if no queries are submitted then + * all rows are updated. You can pass only specific fields to be updated. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $data + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Bulk delete rows using queries, if no queries are passed then all rows are + * deleted. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function deleteRows(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object + * with the row data. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create or update a Row. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param ?array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only + * specific fields that will get updated. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param ?array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a row by its unique ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @throws AppwriteException + * @return string + */ + public function deleteRow(string $databaseId, string $tableId, string $rowId): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param string $column + * @param ?float $value + * @param ?float $min + * @throws AppwriteException + * @return array + */ + public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}', '{column}'], + [$databaseId, $tableId, $rowId, $column], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['column'] = $column; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Increment a specific column of a row by a given value. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param string $column + * @param ?float $value + * @param ?float $max + * @throws AppwriteException + * @return array + */ + public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}', '{column}'], + [$databaseId, $tableId, $rowId, $column], + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['column'] = $column; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index e5c2841..f263049 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -725,6 +725,9 @@ public function listMemberships(string $userId, ?array $queries = null, ?string * @param bool $mfa * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateMFA` instead. + * @see Users::updateMFA */ public function updateMfa(string $userId, bool $mfa): array { @@ -749,6 +752,37 @@ public function updateMfa(string $userId, bool $mfa): array ); } + /** + * 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 = []; + $apiParams['userId'] = $userId; + $apiParams['mfa'] = $mfa; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Delete an authenticator app. * @@ -756,6 +790,9 @@ public function updateMfa(string $userId, bool $mfa): array * @param AuthenticatorType $type * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteMFAAuthenticator` instead. + * @see Users::deleteMFAAuthenticator */ public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): string { @@ -780,12 +817,46 @@ public function deleteMfaAuthenticator(string $userId, AuthenticatorType $type): ); } + /** + * Delete an authenticator app. + * + * @param string $userId + * @param AuthenticatorType $type + * @throws AppwriteException + * @return string + */ + public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): string + { + $apiPath = str_replace( + ['{userId}', '{type}'], + [$userId, $type], + '/users/{userId}/mfa/authenticators/{type}' + ); + + $apiParams = []; + $apiParams['userId'] = $userId; + $apiParams['type'] = $type; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * List the factors available on the account to be used as a MFA challange. * * @param string $userId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listMFAFactors` instead. + * @see Users::listMFAFactors */ public function listMfaFactors(string $userId): array { @@ -808,6 +879,34 @@ public function listMfaFactors(string $userId): array ); } + /** + * 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 = []; + $apiParams['userId'] = $userId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get recovery codes that can be used as backup for MFA flow by User ID. * Before getting codes, they must be generated using @@ -817,6 +916,9 @@ public function listMfaFactors(string $userId): array * @param string $userId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getMFARecoveryCodes` instead. + * @see Users::getMFARecoveryCodes */ public function getMfaRecoveryCodes(string $userId): array { @@ -839,6 +941,37 @@ public function getMfaRecoveryCodes(string $userId): array ); } + /** + * 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 = []; + $apiParams['userId'] = $userId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Regenerate recovery codes that can be used as backup for MFA flow by User * ID. Before regenerating codes, they must be first generated using @@ -848,6 +981,9 @@ public function getMfaRecoveryCodes(string $userId): array * @param string $userId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateMFARecoveryCodes` instead. + * @see Users::updateMFARecoveryCodes */ public function updateMfaRecoveryCodes(string $userId): array { @@ -871,6 +1007,38 @@ public function updateMfaRecoveryCodes(string $userId): array ); } + /** + * 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 = []; + $apiParams['userId'] = $userId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery * codes can be used as a MFA verification type in @@ -880,6 +1048,9 @@ public function updateMfaRecoveryCodes(string $userId): array * @param string $userId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createMFARecoveryCodes` instead. + * @see Users::createMFARecoveryCodes */ public function createMfaRecoveryCodes(string $userId): array { @@ -903,6 +1074,38 @@ public function createMfaRecoveryCodes(string $userId): array ); } + /** + * 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 = []; + $apiParams['userId'] = $userId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update the user name by its unique ID. * diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php index bd54d13..a9ac2c3 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -146,4 +146,48 @@ public function testLimit(): void { public function testOffset(): void { $this->assertSame('offset(1)', Query::offset(1)); } + + public function testNotContains(): void { + $this->assertSame('notContains("attr", ["value"])', Query::notContains('attr', 'value')); + } + + public function testNotSearch(): void { + $this->assertSame('notSearch("attr", ["keyword1 keyword2"])', Query::notSearch('attr', 'keyword1 keyword2')); + } + + public function testNotBetweenWithIntegers(): void { + $this->assertSame('notBetween("attr", 1, 2)', Query::notBetween('attr', 1, 2)); + } + + public function testNotBetweenWithDoubles(): void { + $this->assertSame('notBetween("attr", 1, 2)', Query::notBetween('attr', 1.0, 2.0)); + } + + public function testNotBetweenWithStrings(): void { + $this->assertSame('notBetween("attr", "a", "z")', Query::notBetween('attr', 'a', 'z')); + } + + public function testNotStartsWith(): void { + $this->assertSame('notStartsWith("attr", ["prefix"])', Query::notStartsWith('attr', 'prefix')); + } + + public function testNotEndsWith(): void { + $this->assertSame('notEndsWith("attr", ["suffix"])', Query::notEndsWith('attr', 'suffix')); + } + + public function testCreatedBefore(): void { + $this->assertSame('createdBefore("2023-01-01")', Query::createdBefore('2023-01-01')); + } + + public function testCreatedAfter(): void { + $this->assertSame('createdAfter("2023-01-01")', Query::createdAfter('2023-01-01')); + } + + public function testUpdatedBefore(): void { + $this->assertSame('updatedBefore("2023-01-01")', Query::updatedBefore('2023-01-01')); + } + + public function testUpdatedAfter(): void { + $this->assertSame('updatedAfter("2023-01-01")', Query::updatedAfter('2023-01-01')); + } } diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index 8419699..b6a7be5 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -230,6 +230,24 @@ public function testMethodCreateMfaAuthenticator(): void { $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( @@ -263,6 +281,39 @@ public function testMethodUpdateMfaAuthenticator(): void { $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", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodDeleteMfaAuthenticator(): void { $data = ''; @@ -279,6 +330,22 @@ public function testMethodDeleteMfaAuthenticator(): void { $this->assertSame($data, $response); } + public function testMethodDeleteMFAAuthenticator(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->deleteMFAAuthenticator( + "totp" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateMfaChallenge(): void { $data = array( @@ -299,6 +366,26 @@ public function testMethodCreateMfaChallenge(): void { $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 = array( @@ -345,6 +432,52 @@ public function testMethodUpdateMfaChallenge(): void { $this->assertSame($data, $response); } + public function testMethodUpdateMFAChallenge(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5bb8c16897e", + "expire" => "2020-10-15T06:38:00.000+00:00", + "provider" => "email", + "providerUid" => "user@example.com", + "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip" => "127.0.0.1", + "osCode" => "Mac", + "osName" => "Mac", + "osVersion" => "Mac", + "clientType" => "browser", + "clientCode" => "CM", + "clientName" => "Chrome Mobile iOS", + "clientVersion" => "84.0", + "clientEngine" => "WebKit", + "clientEngineVersion" => "605.1.15", + "deviceName" => "smartphone", + "deviceBrand" => "Google", + "deviceModel" => "Nexus 5", + "countryCode" => "US", + "countryName" => "United States", + "current" => true, + "factors" => array(), + "secret" => "5e5bb8c16897e", + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateMFAChallenge( + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodListMfaFactors(): void { $data = array( @@ -364,6 +497,25 @@ public function testMethodListMfaFactors(): void { $this->assertSame($data, $response); } + public function testMethodListMFAFactors(): void { + + $data = array( + "totp" => true, + "phone" => true, + "email" => true, + "recoveryCode" => 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( @@ -380,6 +532,22 @@ public function testMethodGetMfaRecoveryCodes(): void { $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( @@ -396,6 +564,22 @@ public function testMethodCreateMfaRecoveryCodes(): void { $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( @@ -412,6 +596,22 @@ public function testMethodUpdateMfaRecoveryCodes(): void { $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( diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index e870542..b11271f 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -40,7 +40,8 @@ public function testMethodCreate(): void { "name" => "My Database", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "enabled" => true,); + "enabled" => true, + "type" => "legacy",); $this->client @@ -62,7 +63,8 @@ public function testMethodGet(): void { "name" => "My Database", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "enabled" => true,); + "enabled" => true, + "type" => "legacy",); $this->client @@ -83,7 +85,8 @@ public function testMethodUpdate(): void { "name" => "My Database", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "enabled" => true,); + "enabled" => true, + "type" => "legacy",); $this->client @@ -1135,14 +1138,15 @@ public function testMethodListIndexes(): void { public function testMethodCreateIndex(): void { $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "key" => "index1", "type" => "primary", "status" => "available", "error" => "string", "attributes" => array(), - "lengths" => array(), - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + "lengths" => array(),); $this->client @@ -1163,14 +1167,15 @@ public function testMethodCreateIndex(): void { public function testMethodGetIndex(): void { $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "key" => "index1", "type" => "primary", "status" => "available", "error" => "string", "attributes" => array(), - "lengths" => array(), - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + "lengths" => array(),); $this->client diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index c92a32c..e3f7b91 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -610,6 +610,7 @@ public function testMethodCreateExecution(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "\$permissions" => array(), "functionId" => "5e5ea6g16897e", + "deploymentId" => "5e5ea5c16897e", "trigger" => "http", "status" => "processing", "requestMethod" => "GET", @@ -642,6 +643,7 @@ public function testMethodGetExecution(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "\$permissions" => array(), "functionId" => "5e5ea6g16897e", + "deploymentId" => "5e5ea5c16897e", "trigger" => "http", "status" => "processing", "requestMethod" => "GET", diff --git a/tests/Appwrite/Services/MessagingTest.php b/tests/Appwrite/Services/MessagingTest.php index f447883..1c37cdf 100644 --- a/tests/Appwrite/Services/MessagingTest.php +++ b/tests/Appwrite/Services/MessagingTest.php @@ -166,6 +166,33 @@ public function testMethodCreateSms(): void { $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( + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateSms(): void { $data = array( @@ -192,6 +219,32 @@ public function testMethodUpdateSms(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodGetMessage(): void { $data = array( @@ -312,6 +365,31 @@ public function testMethodCreateApnsProvider(): void { $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( + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateApnsProvider(): void { $data = array( @@ -336,6 +414,30 @@ public function testMethodUpdateApnsProvider(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateFcmProvider(): void { $data = array( @@ -361,6 +463,31 @@ public function testMethodCreateFcmProvider(): void { $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( + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateFcmProvider(): void { $data = array( @@ -385,6 +512,30 @@ public function testMethodUpdateFcmProvider(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateMailgunProvider(): void { $data = array( @@ -558,6 +709,32 @@ public function testMethodCreateSmtpProvider(): void { $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( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateSmtpProvider(): void { $data = array( @@ -582,6 +759,30 @@ public function testMethodUpdateSmtpProvider(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateTelesignProvider(): void { $data = array( diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 2d287de..4768471 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -616,6 +616,7 @@ public function testMethodGetLog(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "\$permissions" => array(), "functionId" => "5e5ea6g16897e", + "deploymentId" => "5e5ea5c16897e", "trigger" => "http", "status" => "processing", "requestMethod" => "GET", diff --git a/tests/Appwrite/Services/TablesDbTest.php b/tests/Appwrite/Services/TablesDbTest.php new file mode 100644 index 0000000..6a47bea --- /dev/null +++ b/tests/Appwrite/Services/TablesDbTest.php @@ -0,0 +1,1211 @@ +client = Mockery::mock(Client::class); + $this->tablesDB = new TablesDB($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "databases" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->list( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true, + "type" => "legacy",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->create( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGet(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true, + "type" => "legacy",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->get( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "My Database", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "enabled" => true, + "type" => "legacy",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->update( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->delete( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListTables(): void { + + $data = array( + "total" => 5, + "tables" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listTables( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateTable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createTable( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetTable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getTable( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTable(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateTable( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteTable(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteTable( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListColumns(): void { + + $data = array( + "total" => 5, + "columns" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listColumns( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBooleanColumn(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createBooleanColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateBooleanColumn(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateBooleanColumn( + "", + "", + "", + true, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateDatetimeColumn(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createDatetimeColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateDatetimeColumn(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateDatetimeColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmailColumn(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createEmailColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmailColumn(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateEmailColumn( + "", + "", + "", + true, + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEnumColumn(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createEnumColumn( + "", + "", + "", + array(), + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEnumColumn(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateEnumColumn( + "", + "", + "", + array(), + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateFloatColumn(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createFloatColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateFloatColumn(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateFloatColumn( + "", + "", + "", + true, + 1.0 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIntegerColumn(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createIntegerColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIntegerColumn(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateIntegerColumn( + "", + "", + "", + true, + 1 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIpColumn(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createIpColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIpColumn(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateIpColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRelationshipColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createRelationshipColumn( + "", + "", + "", + "oneToOne" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateStringColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createStringColumn( + "", + "", + "", + 1, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateStringColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateStringColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateUrlColumn(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createUrlColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateUrlColumn(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateUrlColumn( + "", + "", + "", + true, + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetColumn(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteColumn(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRelationshipColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListIndexes(): void { + + $data = array( + "total" => 5, + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listIndexes( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIndex(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "columns" => array(), + "lengths" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createIndex( + "", + "", + "", + "key", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetIndex(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "columns" => array(), + "lengths" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getIndex( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteIndex(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteIndex( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->listRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createRow( + "", + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createRows( + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpsertRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->upsertRows( + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->getRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpsertRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->upsertRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteRow(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->deleteRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDecrementRowColumn(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->decrementRowColumn( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodIncrementRowColumn(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->incrementRowColumn( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index abbe31e..db74cd6 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -544,6 +544,39 @@ public function testMethodUpdateMfa(): void { $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( + "", + true + ); + + $this->assertSame($data, $response); + } + public function testMethodDeleteMfaAuthenticator(): void { $data = ''; @@ -561,6 +594,23 @@ public function testMethodDeleteMfaAuthenticator(): void { $this->assertSame($data, $response); } + public function testMethodDeleteMFAAuthenticator(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->deleteMFAAuthenticator( + "", + "totp" + ); + + $this->assertSame($data, $response); + } + public function testMethodListMfaFactors(): void { $data = array( @@ -581,6 +631,26 @@ public function testMethodListMfaFactors(): void { $this->assertSame($data, $response); } + public function testMethodListMFAFactors(): void { + + $data = array( + "totp" => true, + "phone" => true, + "email" => true, + "recoveryCode" => true,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->users->listMFAFactors( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodGetMfaRecoveryCodes(): void { $data = array( @@ -598,6 +668,23 @@ public function testMethodGetMfaRecoveryCodes(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateMfaRecoveryCodes(): void { $data = array( @@ -615,6 +702,23 @@ public function testMethodUpdateMfaRecoveryCodes(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateMfaRecoveryCodes(): void { $data = array( @@ -632,6 +736,23 @@ public function testMethodCreateMfaRecoveryCodes(): void { $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( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateName(): void { $data = array(