Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite PHP SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-1.5.6-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)
Expand Down
4 changes: 2 additions & 2 deletions docs/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ PATCH https://cloud.appwrite.io/v1/account/mfa
POST https://cloud.appwrite.io/v1/account/mfa/authenticators/{type}
```

** Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method. **
** 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

Expand All @@ -126,7 +126,7 @@ POST https://cloud.appwrite.io/v1/account/mfa/authenticators/{type}
PUT https://cloud.appwrite.io/v1/account/mfa/authenticators/{type}
```

** Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. **
** Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add **

### Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/avatars.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| code | string | **Required** Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro. | |
| code | string | **Required** Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro. | |
| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 100 |
| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 100 |
| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 |
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/messaging/update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ $result = $messaging->updateEmail(
html: false, // optional
cc: [], // optional
bcc: [], // optional
scheduledAt: '' // optional
scheduledAt: '', // optional
attachments: [] // optional
);
7 changes: 4 additions & 3 deletions docs/messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ POST https://cloud.appwrite.io/v1/messaging/messages/email
| targets | array | List of Targets IDs. | [] |
| cc | array | Array of target IDs to be added as CC. | [] |
| bcc | array | Array of target IDs to be added as BCC. | [] |
| attachments | array | Array of compound bucket IDs to file IDs to be attached to the email. | [] |
| attachments | array | Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. | [] |
| draft | boolean | Is message a draft | |
| html | boolean | Is content of type HTML | |
| scheduledAt | string | Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. | |
Expand Down Expand Up @@ -64,6 +64,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/messages/email/{messageId}
| cc | array | Array of target IDs to be added as CC. | |
| bcc | array | Array of target IDs to be added as BCC. | |
| scheduledAt | string | Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. | |
| attachments | array | Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. | |

## Create push notification

Expand All @@ -85,7 +86,7 @@ POST https://cloud.appwrite.io/v1/messaging/messages/push
| targets | array | List of Targets IDs. | [] |
| data | object | Additional Data for push notification. | {} |
| action | string | Action for push notification. | |
| image | string | Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. | |
| image | string | Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. | |
| icon | string | Icon for push notification. Available only for Android and Web Platform. | |
| sound | string | Sound for push notification. Available only for Android and IOS Platform. | |
| color | string | Color for push notification. Available only for Android Platform. | |
Expand Down Expand Up @@ -115,7 +116,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/messages/push/{messageId}
| body | string | Body for push notification. | |
| data | object | Additional Data for push notification. | {} |
| action | string | Action for push notification. | |
| image | string | Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. | |
| image | string | Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. | |
| icon | string | Icon for push notification. Available only for Android and Web platforms. | |
| sound | string | Sound for push notification. Available only for Android and iOS platforms. | |
| color | string | Color for push notification. Available only for Android platforms. | |
Expand Down
3 changes: 2 additions & 1 deletion docs/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ DELETE https://cloud.appwrite.io/v1/users/{userId}/targets/{targetId}
POST https://cloud.appwrite.io/v1/users/{userId}/tokens
```

** Returns a token with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) endpoint to complete the login process. **
** Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process.
**

### Parameters

Expand Down
4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client
*/
protected $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/11.0.1 ()',
'user-agent' => 'AppwritePHPSDK/11.0.2 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '11.0.1',
'x-sdk-version'=> '11.0.2',
];

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Appwrite/Enums/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreditCard implements JsonSerializable
private static CreditCard $AMERICANEXPRESS;
private static CreditCard $ARGENCARD;
private static CreditCard $CABAL;
private static CreditCard $CONSOSUD;
private static CreditCard $CENCOSUD;
private static CreditCard $DINERSCLUB;
private static CreditCard $DISCOVER;
private static CreditCard $ELO;
Expand Down Expand Up @@ -61,12 +61,12 @@ public static function CABAL(): CreditCard
}
return self::$CABAL;
}
public static function CONSOSUD(): CreditCard
public static function CENCOSUD(): CreditCard
{
if (!isset(self::$CONSOSUD)) {
self::$CONSOSUD = new CreditCard('censosud');
if (!isset(self::$CENCOSUD)) {
self::$CENCOSUD = new CreditCard('cencosud');
}
return self::$CONSOSUD;
return self::$CENCOSUD;
}
public static function DINERSCLUB(): CreditCard
{
Expand Down
8 changes: 8 additions & 0 deletions src/Appwrite/Enums/Flag.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Flag implements JsonSerializable
private static Flag $PALAU;
private static Flag $PAPUANEWGUINEA;
private static Flag $POLAND;
private static Flag $FRENCHPOLYNESIA;
private static Flag $NORTHKOREA;
private static Flag $PORTUGAL;
private static Flag $PARAGUAY;
Expand Down Expand Up @@ -1205,6 +1206,13 @@ public static function POLAND(): Flag
}
return self::$POLAND;
}
public static function FRENCHPOLYNESIA(): Flag
{
if (!isset(self::$FRENCHPOLYNESIA)) {
self::$FRENCHPOLYNESIA = new Flag('pf');
}
return self::$FRENCHPOLYNESIA;
}
public static function NORTHKOREA(): Flag
{
if (!isset(self::$NORTHKOREA)) {
Expand Down
8 changes: 8 additions & 0 deletions src/Appwrite/Enums/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Runtime implements JsonSerializable
private static Runtime $PYTHON310;
private static Runtime $PYTHON311;
private static Runtime $PYTHON312;
private static Runtime $PYTHONML311;
private static Runtime $DENO140;
private static Runtime $DART215;
private static Runtime $DART216;
Expand Down Expand Up @@ -201,6 +202,13 @@ public static function PYTHON312(): Runtime
}
return self::$PYTHON312;
}
public static function PYTHONML311(): Runtime
{
if (!isset(self::$PYTHONML311)) {
self::$PYTHONML311 = new Runtime('python-ml-3.11');
}
return self::$PYTHONML311;
}
public static function DENO140(): Runtime
{
if (!isset(self::$DENO140)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Appwrite/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ public static function offset(int $offset): string
* Contains
*
* @param string $attribute
* @param string $value
* @param mixed $value
* @return string
*/
public static function contains(string $attribute, string $value): string
public static function contains(string $attribute, $value): string
{
return (new Query('contains', $attribute, $value))->__toString();
}
Expand Down
10 changes: 5 additions & 5 deletions src/Appwrite/Services/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function updateMFA(bool $mfa): 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#verifyAuthenticator)
* authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
* method.
*
* @param AuthenticatorType $type
Expand Down Expand Up @@ -320,8 +320,8 @@ public function createMfaAuthenticator(AuthenticatorType $type): array
* Verify Authenticator
*
* Verify an authenticator app after adding it using the [add
* authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
* method.
* authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
* method. add
*
* @param AuthenticatorType $type
* @param string $otp
Expand Down Expand Up @@ -361,10 +361,10 @@ public function updateMfaAuthenticator(AuthenticatorType $type, string $otp): ar
* @param AuthenticatorType $type
* @param string $otp
* @throws AppwriteException
* @return array
* @return string

*/
public function deleteMfaAuthenticator(AuthenticatorType $type, string $otp): array
public function deleteMfaAuthenticator(AuthenticatorType $type, string $otp): string
{
$apiPath = str_replace(['{type}'], [$type], '/account/mfa/authenticators/{type}');

Expand Down
6 changes: 5 additions & 1 deletion src/Appwrite/Services/Messaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ public function createEmail(string $messageId, string $subject, string $content,
* @param array $cc
* @param array $bcc
* @param string $scheduledAt
* @param array $attachments
* @throws AppwriteException
* @return array

*/
public function updateEmail(string $messageId, array $topics = null, array $users = null, array $targets = null, string $subject = null, string $content = null, bool $draft = null, bool $html = null, array $cc = null, array $bcc = null, string $scheduledAt = null): array
public function updateEmail(string $messageId, array $topics = null, array $users = null, array $targets = null, string $subject = null, string $content = null, bool $draft = null, bool $html = null, array $cc = null, array $bcc = null, string $scheduledAt = null, array $attachments = null): array
{
$apiPath = str_replace(['{messageId}'], [$messageId], '/messaging/messages/email/{messageId}');

Expand Down Expand Up @@ -187,6 +188,9 @@ public function updateEmail(string $messageId, array $topics = null, array $user
if (!is_null($scheduledAt)) {
$apiParams['scheduledAt'] = $scheduledAt;
}
if (!is_null($attachments)) {
$apiParams['attachments'] = $attachments;
}
return $this->client->call(
Client::METHOD_PATCH,
$apiPath,
Expand Down
8 changes: 4 additions & 4 deletions src/Appwrite/Services/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -1493,11 +1493,11 @@ public function deleteTarget(string $userId, string $targetId): string
/**
* Create token
*
* Returns a token with a secret key for creating a session. If the provided
* user ID has not be registered, a new user will be created. Use the returned
* user ID and secret and submit a request to the [PUT
* /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession)
* Returns a token with a secret key for creating a session. Use the user ID
* and secret and submit a request to the [PUT
* /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
* endpoint to complete the login process.
*
*
* @param string $userId
* @param int $length
Expand Down
28 changes: 10 additions & 18 deletions tests/Appwrite/Services/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,23 +265,7 @@ public function testMethodUpdateMfaAuthenticator(): void {

public function testMethodDeleteMfaAuthenticator(): void {

$data = array(
"\$id" => "5e5ea5c16897e",
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
"name" => "John Doe",
"registration" => "2020-10-15T06:38:00.000+00:00",
"status" => true,
"labels" => array(),
"passwordUpdate" => "2020-10-15T06:38:00.000+00:00",
"email" => "john@appwrite.io",
"phone" => "+4930901820",
"emailVerification" => true,
"phoneVerification" => true,
"mfa" => true,
"prefs" => array(),
"targets" => array(),
"accessedAt" => "2020-10-15T06:38:00.000+00:00",);
$data = '';


$this->client
Expand Down Expand Up @@ -338,7 +322,8 @@ public function testMethodListMfaFactors(): void {
$data = array(
"totp" => true,
"phone" => true,
"email" => true,);
"email" => true,
"recoveryCode" => true,);


$this->client
Expand Down Expand Up @@ -627,6 +612,7 @@ public function testMethodCreateAnonymousSession(): 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",
Expand Down Expand Up @@ -670,6 +656,7 @@ public function testMethodCreateEmailPasswordSession(): 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",
Expand Down Expand Up @@ -715,6 +702,7 @@ public function testMethodUpdateMagicURLSession(): 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",
Expand Down Expand Up @@ -760,6 +748,7 @@ public function testMethodUpdatePhoneSession(): 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",
Expand Down Expand Up @@ -805,6 +794,7 @@ public function testMethodCreateSession(): 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",
Expand Down Expand Up @@ -850,6 +840,7 @@ public function testMethodGetSession(): 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",
Expand Down Expand Up @@ -894,6 +885,7 @@ public function testMethodUpdateSession(): 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",
Expand Down
4 changes: 3 additions & 1 deletion tests/Appwrite/Services/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ public function testMethodListMfaFactors(): void {
$data = array(
"totp" => true,
"phone" => true,
"email" => true,);
"email" => true,
"recoveryCode" => true,);


$this->client
Expand Down Expand Up @@ -785,6 +786,7 @@ public function testMethodCreateSession(): 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",
Expand Down