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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 22.0.0

* [BREAKING] Raised minimum PHP version from 8.0 to 8.2
* [BREAKING] All service methods now return typed model objects instead of `array`
* Added 142 typed response model classes with `ArraySerializable` trait for backward-compatible array access
* Added `from(string)` factory method to all enums for value-based construction
* Added `Client::getHeaders()` method to retrieve request headers
* Added `dart-3.11` and `flutter-3.41` runtime enum values

## 21.0.0

* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ To install via [Composer](http://getcomposer.org/):
composer require appwrite/appwrite
```

Requires PHP 8.2 or later.


## Getting Started

Expand Down Expand Up @@ -93,4 +95,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github

## License

Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
},
"require": {
"php": ">=8.0.0",
"php": ">=8.2.0",
"ext-curl": "*",
"ext-json": "*"
},
Expand All @@ -25,4 +25,4 @@
"mockery/mockery": "1.6.12"
},
"minimum-stability": "dev"
}
}
2 changes: 1 addition & 1 deletion docs/examples/databases/create-datetime-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ $result = $databases->createDatetimeAttribute(
collectionId: '<COLLECTION_ID>',
key: '',
required: false,
default: '', // optional
default: '2020-10-15T06:38:00.000+00:00', // optional
array: false // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/databases/update-datetime-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ $result = $databases->updateDatetimeAttribute(
collectionId: '<COLLECTION_ID>',
key: '',
required: false,
default: '',
default: '2020-10-15T06:38:00.000+00:00',
newKey: '' // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ $result = $messaging->createEmail(
attachments: [], // optional
draft: false, // optional
html: false, // optional
scheduledAt: '' // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $result = $messaging->createPush(
tag: '<TAG>', // optional
badge: null, // optional
draft: false, // optional
scheduledAt: '', // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional
contentAvailable: false, // optional
critical: false, // optional
priority: MessagePriority::NORMAL() // optional
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-sms.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ $result = $messaging->createSMS(
users: [], // optional
targets: [], // optional
draft: false, // optional
scheduledAt: '' // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ $result = $messaging->updateEmail(
html: false, // optional
cc: [], // optional
bcc: [], // optional
scheduledAt: '', // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional
attachments: [] // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $result = $messaging->updatePush(
tag: '<TAG>', // optional
badge: null, // optional
draft: false, // optional
scheduledAt: '', // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional
contentAvailable: false, // optional
critical: false, // optional
priority: MessagePriority::NORMAL() // optional
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-sms.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ $result = $messaging->updateSMS(
targets: [], // optional
content: '<CONTENT>', // optional
draft: false, // optional
scheduledAt: '' // optional
scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/tablesdb/create-datetime-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ $result = $tablesDB->createDatetimeColumn(
tableId: '<TABLE_ID>',
key: '',
required: false,
default: '', // optional
default: '2020-10-15T06:38:00.000+00:00', // optional
array: false // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/tablesdb/update-datetime-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ $result = $tablesDB->updateDatetimeColumn(
tableId: '<TABLE_ID>',
key: '',
required: false,
default: '',
default: '2020-10-15T06:38:00.000+00:00',
newKey: '' // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/tokens/create-file-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ $tokens = new Tokens($client);
$result = $tokens->createFileToken(
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
expire: '' // optional
expire: '2020-10-15T06:38:00.000+00:00' // optional
);```
2 changes: 1 addition & 1 deletion docs/examples/tokens/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ $tokens = new Tokens($client);

$result = $tokens->update(
tokenId: '<TOKEN_ID>',
expire: '' // optional
expire: '2020-10-15T06:38:00.000+00:00' // optional
);```
3 changes: 2 additions & 1 deletion docs/health.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ GET https://cloud.appwrite.io/v1/health/pubsub
GET https://cloud.appwrite.io/v1/health/queue/audits
```

** Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. **
** Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server.
**

### Parameters

Expand Down
14 changes: 12 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 array $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/21.0.0 ()',
'user-agent' => 'AppwritePHPSDK/22.0.0 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '21.0.0',
'x-sdk-version'=> '22.0.0',
];

/**
Expand Down Expand Up @@ -270,6 +270,16 @@ public function addHeader(string $key, string $value): Client
return $this;
}

/**
* Get the request headers.
*
* @return array
*/
public function getHeaders(): array
{
return $this->headers;
}

/**
* Call
*
Expand Down
11 changes: 10 additions & 1 deletion src/Appwrite/Enums/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@ public static function SSR(): Adapter
}
return self::$SSR;
}
}

public static function from(string $value): self
{
return match ($value) {
'static' => self::STATIC(),
'ssr' => self::SSR(),
default => throw new \InvalidArgumentException('Unknown Adapter value: ' . $value),
};
}
}
14 changes: 13 additions & 1 deletion src/Appwrite/Enums/AttributeStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ public static function FAILED(): AttributeStatus
}
return self::$FAILED;
}
}

public static function from(string $value): self
{
return match ($value) {
'available' => self::AVAILABLE(),
'processing' => self::PROCESSING(),
'deleting' => self::DELETING(),
'stuck' => self::STUCK(),
'failed' => self::FAILED(),
default => throw new \InvalidArgumentException('Unknown AttributeStatus value: ' . $value),
};
}
}
13 changes: 12 additions & 1 deletion src/Appwrite/Enums/AuthenticationFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@ public static function RECOVERYCODE(): AuthenticationFactor
}
return self::$RECOVERYCODE;
}
}

public static function from(string $value): self
{
return match ($value) {
'email' => self::EMAIL(),
'phone' => self::PHONE(),
'totp' => self::TOTP(),
'recoverycode' => self::RECOVERYCODE(),
default => throw new \InvalidArgumentException('Unknown AuthenticationFactor value: ' . $value),
};
}
}
10 changes: 9 additions & 1 deletion src/Appwrite/Enums/AuthenticatorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ public static function TOTP(): AuthenticatorType
}
return self::$TOTP;
}
}

public static function from(string $value): self
{
return match ($value) {
'totp' => self::TOTP(),
default => throw new \InvalidArgumentException('Unknown AuthenticatorType value: ' . $value),
};
}
}
15 changes: 14 additions & 1 deletion src/Appwrite/Enums/BackupServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,17 @@ public static function STORAGE(): BackupServices
}
return self::$STORAGE;
}
}

public static function from(string $value): self
{
return match ($value) {
'databases' => self::DATABASES(),
'tablesdb' => self::TABLESDB(),
'documentsdb' => self::DOCUMENTSDB(),
'vectorsdb' => self::VECTORSDB(),
'functions' => self::FUNCTIONS(),
'storage' => self::STORAGE(),
default => throw new \InvalidArgumentException('Unknown BackupServices value: ' . $value),
};
}
}
23 changes: 22 additions & 1 deletion src/Appwrite/Enums/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,25 @@ public static function OPERANEXT(): Browser
}
return self::$OPERANEXT;
}
}

public static function from(string $value): self
{
return match ($value) {
'aa' => self::AVANTBROWSER(),
'an' => self::ANDROIDWEBVIEWBETA(),
'ch' => self::GOOGLECHROME(),
'ci' => self::GOOGLECHROMEIOS(),
'cm' => self::GOOGLECHROMEMOBILE(),
'cr' => self::CHROMIUM(),
'ff' => self::MOZILLAFIREFOX(),
'sf' => self::SAFARI(),
'mf' => self::MOBILESAFARI(),
'ps' => self::MICROSOFTEDGE(),
'oi' => self::MICROSOFTEDGEIOS(),
'om' => self::OPERAMINI(),
'op' => self::OPERA(),
'on' => self::OPERANEXT(),
default => throw new \InvalidArgumentException('Unknown Browser value: ' . $value),
};
}
}
29 changes: 28 additions & 1 deletion src/Appwrite/Enums/BrowserPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,31 @@ public static function XRSPATIALTRACKING(): BrowserPermission
}
return self::$XRSPATIALTRACKING;
}
}

public static function from(string $value): self
{
return match ($value) {
'geolocation' => self::GEOLOCATION(),
'camera' => self::CAMERA(),
'microphone' => self::MICROPHONE(),
'notifications' => self::NOTIFICATIONS(),
'midi' => self::MIDI(),
'push' => self::PUSH(),
'clipboard-read' => self::CLIPBOARDREAD(),
'clipboard-write' => self::CLIPBOARDWRITE(),
'payment-handler' => self::PAYMENTHANDLER(),
'usb' => self::USB(),
'bluetooth' => self::BLUETOOTH(),
'accelerometer' => self::ACCELEROMETER(),
'gyroscope' => self::GYROSCOPE(),
'magnetometer' => self::MAGNETOMETER(),
'ambient-light-sensor' => self::AMBIENTLIGHTSENSOR(),
'background-sync' => self::BACKGROUNDSYNC(),
'persistent-storage' => self::PERSISTENTSTORAGE(),
'screen-wake-lock' => self::SCREENWAKELOCK(),
'web-share' => self::WEBSHARE(),
'xr-spatial-tracking' => self::XRSPATIALTRACKING(),
default => throw new \InvalidArgumentException('Unknown BrowserPermission value: ' . $value),
};
}
}
Loading