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

## 30.2.2

* Fixed: a response model fills a missing field from its spec default instead of throwing `Missing required field`, so the SDK reads responses from servers that predate the field, such as `File.folder` and `File.key` from Appwrite 1.x

## 30.2.1

* Fixed: requires `utopia-php/client` `^0.6` and imports `Utopia\Client\Client`, so the SDK installs and runs next to client 0.6, which dropped the `Utopia\Client` alias
Expand Down
4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Client
*
*/
protected array $headers = [
'user-agent' => 'AppwritePHPSDK/30.2.1 ()',
'user-agent' => 'AppwritePHPSDK/30.2.2 ()',
'x-sdk-name' => 'PHP',
'x-sdk-platform' => 'server',
'x-sdk-language' => 'php',
'x-sdk-version' => '30.2.1',
'x-sdk-version' => '30.2.2',
];

/**
Expand Down
118 changes: 31 additions & 87 deletions src/Appwrite/Models/ActivityEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,93 +84,37 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('$id', $data)) {
throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.');
}
if (!array_key_exists('actorType', $data)) {
throw new \InvalidArgumentException('Missing required field "actorType" for ' . static::class . '.');
}
if (!array_key_exists('actorId', $data)) {
throw new \InvalidArgumentException('Missing required field "actorId" for ' . static::class . '.');
}
if (!array_key_exists('actorEmail', $data)) {
throw new \InvalidArgumentException('Missing required field "actorEmail" for ' . static::class . '.');
}
if (!array_key_exists('actorName', $data)) {
throw new \InvalidArgumentException('Missing required field "actorName" for ' . static::class . '.');
}
if (!array_key_exists('resourceParent', $data)) {
throw new \InvalidArgumentException('Missing required field "resourceParent" for ' . static::class . '.');
}
if (!array_key_exists('resourceType', $data)) {
throw new \InvalidArgumentException('Missing required field "resourceType" for ' . static::class . '.');
}
if (!array_key_exists('resourceId', $data)) {
throw new \InvalidArgumentException('Missing required field "resourceId" for ' . static::class . '.');
}
if (!array_key_exists('resource', $data)) {
throw new \InvalidArgumentException('Missing required field "resource" for ' . static::class . '.');
}
if (!array_key_exists('event', $data)) {
throw new \InvalidArgumentException('Missing required field "event" for ' . static::class . '.');
}
if (!array_key_exists('userAgent', $data)) {
throw new \InvalidArgumentException('Missing required field "userAgent" for ' . static::class . '.');
}
if (!array_key_exists('ip', $data)) {
throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.');
}
if (!array_key_exists('mode', $data)) {
throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.');
}
if (!array_key_exists('country', $data)) {
throw new \InvalidArgumentException('Missing required field "country" for ' . static::class . '.');
}
if (!array_key_exists('continentCode', $data)) {
throw new \InvalidArgumentException('Missing required field "continentCode" for ' . static::class . '.');
}
if (!array_key_exists('city', $data)) {
throw new \InvalidArgumentException('Missing required field "city" for ' . static::class . '.');
}
if (!array_key_exists('subdivisions', $data)) {
throw new \InvalidArgumentException('Missing required field "subdivisions" for ' . static::class . '.');
}
if (!array_key_exists('isp', $data)) {
throw new \InvalidArgumentException('Missing required field "isp" for ' . static::class . '.');
}
if (!array_key_exists('autonomousSystemNumber', $data)) {
throw new \InvalidArgumentException('Missing required field "autonomousSystemNumber" for ' . static::class . '.');
}
if (!array_key_exists('autonomousSystemOrganization', $data)) {
throw new \InvalidArgumentException('Missing required field "autonomousSystemOrganization" for ' . static::class . '.');
}
if (!array_key_exists('connectionType', $data)) {
throw new \InvalidArgumentException('Missing required field "connectionType" for ' . static::class . '.');
}
if (!array_key_exists('connectionUsageType', $data)) {
throw new \InvalidArgumentException('Missing required field "connectionUsageType" for ' . static::class . '.');
}
if (!array_key_exists('connectionOrganization', $data)) {
throw new \InvalidArgumentException('Missing required field "connectionOrganization" for ' . static::class . '.');
}
if (!array_key_exists('time', $data)) {
throw new \InvalidArgumentException('Missing required field "time" for ' . static::class . '.');
}
if (!array_key_exists('projectId', $data)) {
throw new \InvalidArgumentException('Missing required field "projectId" for ' . static::class . '.');
}
if (!array_key_exists('teamId', $data)) {
throw new \InvalidArgumentException('Missing required field "teamId" for ' . static::class . '.');
}
if (!array_key_exists('hostname', $data)) {
throw new \InvalidArgumentException('Missing required field "hostname" for ' . static::class . '.');
}
if (!array_key_exists('sdk', $data)) {
throw new \InvalidArgumentException('Missing required field "sdk" for ' . static::class . '.');
}
if (!array_key_exists('sdkVersion', $data)) {
throw new \InvalidArgumentException('Missing required field "sdkVersion" for ' . static::class . '.');
}
$data += [
'$id' => "",
'actorType' => "",
'actorId' => "",
'actorEmail' => "",
'actorName' => "",
'resourceParent' => "",
'resourceType' => "",
'resourceId' => "",
'resource' => "",
'event' => "",
'userAgent' => "",
'ip' => "",
'mode' => "",
'country' => "",
'continentCode' => "",
'city' => "",
'subdivisions' => "",
'isp' => "",
'autonomousSystemNumber' => "",
'autonomousSystemOrganization' => "",
'connectionType' => "",
'connectionUsageType' => "",
'connectionOrganization' => "",
'time' => "",
'projectId' => "",
'teamId' => "",
'hostname' => "",
'sdk' => "",
'sdkVersion' => "",
];

return new static(
id: $data['$id'],
Expand Down
7 changes: 4 additions & 3 deletions src/Appwrite/Models/ActivityEventList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('total', $data)) {
throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.');
}
$data += [
'total' => 0,
];

if (!array_key_exists('events', $data)) {
throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.');
}
Expand Down
26 changes: 8 additions & 18 deletions src/Appwrite/Models/AdditionalResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,14 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('name', $data)) {
throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.');
}
if (!array_key_exists('unit', $data)) {
throw new \InvalidArgumentException('Missing required field "unit" for ' . static::class . '.');
}
if (!array_key_exists('currency', $data)) {
throw new \InvalidArgumentException('Missing required field "currency" for ' . static::class . '.');
}
if (!array_key_exists('price', $data)) {
throw new \InvalidArgumentException('Missing required field "price" for ' . static::class . '.');
}
if (!array_key_exists('value', $data)) {
throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.');
}
if (!array_key_exists('invoiceDesc', $data)) {
throw new \InvalidArgumentException('Missing required field "invoiceDesc" for ' . static::class . '.');
}
$data += [
'name' => "",
'unit' => "",
'currency' => "",
'price' => 0,
'value' => 0,
'invoiceDesc' => "",
];

return new static(
name: $data['name'],
Expand Down
18 changes: 6 additions & 12 deletions src/Appwrite/Models/AlgoArgon2.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
if (!array_key_exists('memoryCost', $data)) {
throw new \InvalidArgumentException('Missing required field "memoryCost" for ' . static::class . '.');
}
if (!array_key_exists('timeCost', $data)) {
throw new \InvalidArgumentException('Missing required field "timeCost" for ' . static::class . '.');
}
if (!array_key_exists('threads', $data)) {
throw new \InvalidArgumentException('Missing required field "threads" for ' . static::class . '.');
}
$data += [
'type' => "argon2",
'memoryCost' => 0,
'timeCost' => 0,
'threads' => 0,
];

return new static(
type: $data['type'],
Expand Down
6 changes: 3 additions & 3 deletions src/Appwrite/Models/AlgoBcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
$data += [
'type' => "bcrypt",
];

return new static(
type: $data['type']
Expand Down
6 changes: 3 additions & 3 deletions src/Appwrite/Models/AlgoMd5.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
$data += [
'type' => "md5",
];

return new static(
type: $data['type']
Expand Down
6 changes: 3 additions & 3 deletions src/Appwrite/Models/AlgoPhpass.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
$data += [
'type' => "phpass",
];

return new static(
type: $data['type']
Expand Down
22 changes: 7 additions & 15 deletions src/Appwrite/Models/AlgoScrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,13 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
if (!array_key_exists('costCpu', $data)) {
throw new \InvalidArgumentException('Missing required field "costCpu" for ' . static::class . '.');
}
if (!array_key_exists('costMemory', $data)) {
throw new \InvalidArgumentException('Missing required field "costMemory" for ' . static::class . '.');
}
if (!array_key_exists('costParallel', $data)) {
throw new \InvalidArgumentException('Missing required field "costParallel" for ' . static::class . '.');
}
if (!array_key_exists('length', $data)) {
throw new \InvalidArgumentException('Missing required field "length" for ' . static::class . '.');
}
$data += [
'type' => "scrypt",
'costCpu' => 8,
'costMemory' => 14,
'costParallel' => 1,
'length' => 64,
];

return new static(
type: $data['type'],
Expand Down
18 changes: 6 additions & 12 deletions src/Appwrite/Models/AlgoScryptModified.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
if (!array_key_exists('salt', $data)) {
throw new \InvalidArgumentException('Missing required field "salt" for ' . static::class . '.');
}
if (!array_key_exists('saltSeparator', $data)) {
throw new \InvalidArgumentException('Missing required field "saltSeparator" for ' . static::class . '.');
}
if (!array_key_exists('signerKey', $data)) {
throw new \InvalidArgumentException('Missing required field "signerKey" for ' . static::class . '.');
}
$data += [
'type' => "scryptMod",
'salt' => "",
'saltSeparator' => "",
'signerKey' => "",
];

return new static(
type: $data['type'],
Expand Down
6 changes: 3 additions & 3 deletions src/Appwrite/Models/AlgoSha.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function __construct(
*/
public static function from(array $data): static
{
if (!array_key_exists('type', $data)) {
throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.');
}
$data += [
'type' => "sha",
];

return new static(
type: $data['type']
Expand Down
Loading