diff --git a/CHANGELOG.md b/CHANGELOG.md index bde6f64..9c18a87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 98d59f3..4719250 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -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', ]; /** diff --git a/src/Appwrite/Models/ActivityEvent.php b/src/Appwrite/Models/ActivityEvent.php index f1af42c..8bc1f62 100644 --- a/src/Appwrite/Models/ActivityEvent.php +++ b/src/Appwrite/Models/ActivityEvent.php @@ -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'], diff --git a/src/Appwrite/Models/ActivityEventList.php b/src/Appwrite/Models/ActivityEventList.php index 191d993..8fd4741 100644 --- a/src/Appwrite/Models/ActivityEventList.php +++ b/src/Appwrite/Models/ActivityEventList.php @@ -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 . '.'); } diff --git a/src/Appwrite/Models/AdditionalResource.php b/src/Appwrite/Models/AdditionalResource.php index 532bf02..daaabbf 100644 --- a/src/Appwrite/Models/AdditionalResource.php +++ b/src/Appwrite/Models/AdditionalResource.php @@ -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'], diff --git a/src/Appwrite/Models/AlgoArgon2.php b/src/Appwrite/Models/AlgoArgon2.php index c5acb0a..4b07065 100644 --- a/src/Appwrite/Models/AlgoArgon2.php +++ b/src/Appwrite/Models/AlgoArgon2.php @@ -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'], diff --git a/src/Appwrite/Models/AlgoBcrypt.php b/src/Appwrite/Models/AlgoBcrypt.php index a2a916b..34e048a 100644 --- a/src/Appwrite/Models/AlgoBcrypt.php +++ b/src/Appwrite/Models/AlgoBcrypt.php @@ -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'] diff --git a/src/Appwrite/Models/AlgoMd5.php b/src/Appwrite/Models/AlgoMd5.php index 3abcce4..4466b61 100644 --- a/src/Appwrite/Models/AlgoMd5.php +++ b/src/Appwrite/Models/AlgoMd5.php @@ -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'] diff --git a/src/Appwrite/Models/AlgoPhpass.php b/src/Appwrite/Models/AlgoPhpass.php index 9ce1b08..97d43b9 100644 --- a/src/Appwrite/Models/AlgoPhpass.php +++ b/src/Appwrite/Models/AlgoPhpass.php @@ -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'] diff --git a/src/Appwrite/Models/AlgoScrypt.php b/src/Appwrite/Models/AlgoScrypt.php index fd2e3e3..b87365b 100644 --- a/src/Appwrite/Models/AlgoScrypt.php +++ b/src/Appwrite/Models/AlgoScrypt.php @@ -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'], diff --git a/src/Appwrite/Models/AlgoScryptModified.php b/src/Appwrite/Models/AlgoScryptModified.php index 20e306e..a4ba21b 100644 --- a/src/Appwrite/Models/AlgoScryptModified.php +++ b/src/Appwrite/Models/AlgoScryptModified.php @@ -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'], diff --git a/src/Appwrite/Models/AlgoSha.php b/src/Appwrite/Models/AlgoSha.php index 6966121..6bf6c9b 100644 --- a/src/Appwrite/Models/AlgoSha.php +++ b/src/Appwrite/Models/AlgoSha.php @@ -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'] diff --git a/src/Appwrite/Models/App.php b/src/Appwrite/Models/App.php index 78e5c79..24d11d5 100644 --- a/src/Appwrite/Models/App.php +++ b/src/Appwrite/Models/App.php @@ -78,81 +78,34 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('description', $data)) { - throw new \InvalidArgumentException('Missing required field "description" for ' . static::class . '.'); - } - if (!array_key_exists('clientUri', $data)) { - throw new \InvalidArgumentException('Missing required field "clientUri" for ' . static::class . '.'); - } - if (!array_key_exists('logoUri', $data)) { - throw new \InvalidArgumentException('Missing required field "logoUri" for ' . static::class . '.'); - } - if (!array_key_exists('privacyPolicyUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "privacyPolicyUrl" for ' . static::class . '.'); - } - if (!array_key_exists('termsUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "termsUrl" for ' . static::class . '.'); - } - if (!array_key_exists('contacts', $data)) { - throw new \InvalidArgumentException('Missing required field "contacts" for ' . static::class . '.'); - } - if (!array_key_exists('tagline', $data)) { - throw new \InvalidArgumentException('Missing required field "tagline" for ' . static::class . '.'); - } - if (!array_key_exists('tags', $data)) { - throw new \InvalidArgumentException('Missing required field "tags" for ' . static::class . '.'); - } - if (!array_key_exists('labels', $data)) { - throw new \InvalidArgumentException('Missing required field "labels" for ' . static::class . '.'); - } - if (!array_key_exists('images', $data)) { - throw new \InvalidArgumentException('Missing required field "images" for ' . static::class . '.'); - } - if (!array_key_exists('supportUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "supportUrl" for ' . static::class . '.'); - } - if (!array_key_exists('dataDeletionUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "dataDeletionUrl" for ' . static::class . '.'); - } - if (!array_key_exists('redirectUris', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectUris" for ' . static::class . '.'); - } - if (!array_key_exists('postLogoutRedirectUris', $data)) { - throw new \InvalidArgumentException('Missing required field "postLogoutRedirectUris" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('deviceFlow', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceFlow" for ' . static::class . '.'); - } - if (!array_key_exists('teamId', $data)) { - throw new \InvalidArgumentException('Missing required field "teamId" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('installationScopes', $data)) { - throw new \InvalidArgumentException('Missing required field "installationScopes" for ' . static::class . '.'); - } - if (!array_key_exists('installationRedirectUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "installationRedirectUrl" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'description' => "", + 'clientUri' => "", + 'logoUri' => "", + 'privacyPolicyUrl' => "", + 'termsUrl' => "", + 'contacts' => [], + 'tagline' => "", + 'tags' => [], + 'labels' => [], + 'images' => [], + 'supportUrl' => "", + 'dataDeletionUrl' => "", + 'redirectUris' => [], + 'postLogoutRedirectUris' => [], + 'enabled' => true, + 'type' => "confidential", + 'deviceFlow' => false, + 'teamId' => "", + 'userId' => "", + 'installationScopes' => [], + 'installationRedirectUrl' => "", + ]; + if (!array_key_exists('secrets', $data)) { throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AppInstallation.php b/src/Appwrite/Models/AppInstallation.php index ccb07f6..8d19f61 100644 --- a/src/Appwrite/Models/AppInstallation.php +++ b/src/Appwrite/Models/AppInstallation.php @@ -46,33 +46,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('teamId', $data)) { - throw new \InvalidArgumentException('Missing required field "teamId" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - if (!array_key_exists('authorizationDetails', $data)) { - throw new \InvalidArgumentException('Missing required field "authorizationDetails" for ' . static::class . '.'); - } - if (!array_key_exists('createdById', $data)) { - throw new \InvalidArgumentException('Missing required field "createdById" for ' . static::class . '.'); - } - if (!array_key_exists('createdByName', $data)) { - throw new \InvalidArgumentException('Missing required field "createdByName" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'appId' => "", + 'teamId' => "", + 'scopes' => [], + 'authorizationDetails' => [], + 'createdById' => "", + 'createdByName' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/AppInstallationList.php b/src/Appwrite/Models/AppInstallationList.php index 9c03edc..cd5c339 100644 --- a/src/Appwrite/Models/AppInstallationList.php +++ b/src/Appwrite/Models/AppInstallationList.php @@ -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('installations', $data)) { throw new \InvalidArgumentException('Missing required field "installations" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AppKey.php b/src/Appwrite/Models/AppKey.php index 49a4433..9d73e0d 100644 --- a/src/Appwrite/Models/AppKey.php +++ b/src/Appwrite/Models/AppKey.php @@ -44,30 +44,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('hint', $data)) { - throw new \InvalidArgumentException('Missing required field "hint" for ' . static::class . '.'); - } - if (!array_key_exists('createdById', $data)) { - throw new \InvalidArgumentException('Missing required field "createdById" for ' . static::class . '.'); - } - if (!array_key_exists('createdByName', $data)) { - throw new \InvalidArgumentException('Missing required field "createdByName" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'appId' => "", + 'secret' => "", + 'hint' => "", + 'createdById' => "", + 'createdByName' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/AppKeyList.php b/src/Appwrite/Models/AppKeyList.php index 47febab..25f9edf 100644 --- a/src/Appwrite/Models/AppKeyList.php +++ b/src/Appwrite/Models/AppKeyList.php @@ -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('keys', $data)) { throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AppScope.php b/src/Appwrite/Models/AppScope.php index 2c34b67..c79879f 100644 --- a/src/Appwrite/Models/AppScope.php +++ b/src/Appwrite/Models/AppScope.php @@ -36,21 +36,13 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('value', $data)) { - throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.'); - } - if (!array_key_exists('description', $data)) { - throw new \InvalidArgumentException('Missing required field "description" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('category', $data)) { - throw new \InvalidArgumentException('Missing required field "category" for ' . static::class . '.'); - } - if (!array_key_exists('deprecated', $data)) { - throw new \InvalidArgumentException('Missing required field "deprecated" for ' . static::class . '.'); - } + $data += [ + 'value' => "", + 'description' => "", + 'type' => "", + 'category' => "", + 'deprecated' => false, + ]; return new static( value: $data['value'], diff --git a/src/Appwrite/Models/AppScopeList.php b/src/Appwrite/Models/AppScopeList.php index 09bf0e4..7ccaf66 100644 --- a/src/Appwrite/Models/AppScopeList.php +++ b/src/Appwrite/Models/AppScopeList.php @@ -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('scopes', $data)) { throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AppSecret.php b/src/Appwrite/Models/AppSecret.php index 60d74c0..c2259a7 100644 --- a/src/Appwrite/Models/AppSecret.php +++ b/src/Appwrite/Models/AppSecret.php @@ -44,30 +44,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('hint', $data)) { - throw new \InvalidArgumentException('Missing required field "hint" for ' . static::class . '.'); - } - if (!array_key_exists('createdById', $data)) { - throw new \InvalidArgumentException('Missing required field "createdById" for ' . static::class . '.'); - } - if (!array_key_exists('createdByName', $data)) { - throw new \InvalidArgumentException('Missing required field "createdByName" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'appId' => "", + 'secret' => "", + 'hint' => "", + 'createdById' => "", + 'createdByName' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/AppSecretList.php b/src/Appwrite/Models/AppSecretList.php index fe95210..eae43eb 100644 --- a/src/Appwrite/Models/AppSecretList.php +++ b/src/Appwrite/Models/AppSecretList.php @@ -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('secrets', $data)) { throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AppSecretPlaintext.php b/src/Appwrite/Models/AppSecretPlaintext.php index 3e44cd9..1f6e6b5 100644 --- a/src/Appwrite/Models/AppSecretPlaintext.php +++ b/src/Appwrite/Models/AppSecretPlaintext.php @@ -44,30 +44,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('hint', $data)) { - throw new \InvalidArgumentException('Missing required field "hint" for ' . static::class . '.'); - } - if (!array_key_exists('createdById', $data)) { - throw new \InvalidArgumentException('Missing required field "createdById" for ' . static::class . '.'); - } - if (!array_key_exists('createdByName', $data)) { - throw new \InvalidArgumentException('Missing required field "createdByName" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'appId' => "", + 'secret' => "", + 'hint' => "", + 'createdById' => "", + 'createdByName' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/AppsList.php b/src/Appwrite/Models/AppsList.php index 0825820..4b02831 100644 --- a/src/Appwrite/Models/AppsList.php +++ b/src/Appwrite/Models/AppsList.php @@ -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('apps', $data)) { throw new \InvalidArgumentException('Missing required field "apps" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AttributeBigint.php b/src/Appwrite/Models/AttributeBigint.php index d82efa6..18fcf88 100644 --- a/src/Appwrite/Models/AttributeBigint.php +++ b/src/Appwrite/Models/AttributeBigint.php @@ -50,27 +50,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeBoolean.php b/src/Appwrite/Models/AttributeBoolean.php index 0f07ede..2772154 100644 --- a/src/Appwrite/Models/AttributeBoolean.php +++ b/src/Appwrite/Models/AttributeBoolean.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeDatetime.php b/src/Appwrite/Models/AttributeDatetime.php index f5bdb09..89a3da8 100644 --- a/src/Appwrite/Models/AttributeDatetime.php +++ b/src/Appwrite/Models/AttributeDatetime.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } if (!array_key_exists('format', $data)) { throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AttributeEmail.php b/src/Appwrite/Models/AttributeEmail.php index 40c7713..659961e 100644 --- a/src/Appwrite/Models/AttributeEmail.php +++ b/src/Appwrite/Models/AttributeEmail.php @@ -48,30 +48,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "email", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeEnum.php b/src/Appwrite/Models/AttributeEnum.php index 2e78704..d2d8431 100644 --- a/src/Appwrite/Models/AttributeEnum.php +++ b/src/Appwrite/Models/AttributeEnum.php @@ -50,33 +50,22 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "enum", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } if (!array_key_exists('elements', $data)) { throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeFloat.php b/src/Appwrite/Models/AttributeFloat.php index 70dd498..84ca820 100644 --- a/src/Appwrite/Models/AttributeFloat.php +++ b/src/Appwrite/Models/AttributeFloat.php @@ -50,27 +50,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeInteger.php b/src/Appwrite/Models/AttributeInteger.php index 096bb3a..3c4a9f3 100644 --- a/src/Appwrite/Models/AttributeInteger.php +++ b/src/Appwrite/Models/AttributeInteger.php @@ -50,27 +50,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeIp.php b/src/Appwrite/Models/AttributeIp.php index f4b8cd2..0254fee 100644 --- a/src/Appwrite/Models/AttributeIp.php +++ b/src/Appwrite/Models/AttributeIp.php @@ -48,30 +48,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "ip", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeLine.php b/src/Appwrite/Models/AttributeLine.php index c0b86b2..7985b28 100644 --- a/src/Appwrite/Models/AttributeLine.php +++ b/src/Appwrite/Models/AttributeLine.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeList.php b/src/Appwrite/Models/AttributeList.php index 851af79..0dd3e89 100644 --- a/src/Appwrite/Models/AttributeList.php +++ b/src/Appwrite/Models/AttributeList.php @@ -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('attributes', $data)) { throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/AttributeLongtext.php b/src/Appwrite/Models/AttributeLongtext.php index ca6cdc7..15e3fcd 100644 --- a/src/Appwrite/Models/AttributeLongtext.php +++ b/src/Appwrite/Models/AttributeLongtext.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeMediumtext.php b/src/Appwrite/Models/AttributeMediumtext.php index e036957..d66da29 100644 --- a/src/Appwrite/Models/AttributeMediumtext.php +++ b/src/Appwrite/Models/AttributeMediumtext.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeObject.php b/src/Appwrite/Models/AttributeObject.php index 9675c7d..f1e5e5a 100644 --- a/src/Appwrite/Models/AttributeObject.php +++ b/src/Appwrite/Models/AttributeObject.php @@ -44,27 +44,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributePoint.php b/src/Appwrite/Models/AttributePoint.php index 36d4bac..94f85fd 100644 --- a/src/Appwrite/Models/AttributePoint.php +++ b/src/Appwrite/Models/AttributePoint.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributePolygon.php b/src/Appwrite/Models/AttributePolygon.php index 6416edd..9005ded 100644 --- a/src/Appwrite/Models/AttributePolygon.php +++ b/src/Appwrite/Models/AttributePolygon.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeRelationship.php b/src/Appwrite/Models/AttributeRelationship.php index 3ccb2c3..f23f771 100644 --- a/src/Appwrite/Models/AttributeRelationship.php +++ b/src/Appwrite/Models/AttributeRelationship.php @@ -56,45 +56,26 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'relationType' => "", + 'twoWay' => false, + 'twoWayKey' => "", + 'onDelete' => "restrict", + 'side' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } if (!array_key_exists('relatedCollection', $data)) { throw new \InvalidArgumentException('Missing required field "relatedCollection" for ' . static::class . '.'); } - if (!array_key_exists('relationType', $data)) { - throw new \InvalidArgumentException('Missing required field "relationType" for ' . static::class . '.'); - } - if (!array_key_exists('twoWay', $data)) { - throw new \InvalidArgumentException('Missing required field "twoWay" for ' . static::class . '.'); - } - if (!array_key_exists('twoWayKey', $data)) { - throw new \InvalidArgumentException('Missing required field "twoWayKey" for ' . static::class . '.'); - } - if (!array_key_exists('onDelete', $data)) { - throw new \InvalidArgumentException('Missing required field "onDelete" for ' . static::class . '.'); - } - if (!array_key_exists('side', $data)) { - throw new \InvalidArgumentException('Missing required field "side" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeString.php b/src/Appwrite/Models/AttributeString.php index 51b7469..85e1d4a 100644 --- a/src/Appwrite/Models/AttributeString.php +++ b/src/Appwrite/Models/AttributeString.php @@ -50,30 +50,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'size' => 0, + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeText.php b/src/Appwrite/Models/AttributeText.php index 5efc568..0917a27 100644 --- a/src/Appwrite/Models/AttributeText.php +++ b/src/Appwrite/Models/AttributeText.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeUrl.php b/src/Appwrite/Models/AttributeUrl.php index 3396b69..0e518b9 100644 --- a/src/Appwrite/Models/AttributeUrl.php +++ b/src/Appwrite/Models/AttributeUrl.php @@ -48,30 +48,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "url", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeVarchar.php b/src/Appwrite/Models/AttributeVarchar.php index cb8e085..d624f74 100644 --- a/src/Appwrite/Models/AttributeVarchar.php +++ b/src/Appwrite/Models/AttributeVarchar.php @@ -50,30 +50,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'size' => 0, + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeVector.php b/src/Appwrite/Models/AttributeVector.php index 782068a..a0f547f 100644 --- a/src/Appwrite/Models/AttributeVector.php +++ b/src/Appwrite/Models/AttributeVector.php @@ -46,30 +46,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'size' => 0, + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/BackupArchive.php b/src/Appwrite/Models/BackupArchive.php index f70d7a9..44422c2 100644 --- a/src/Appwrite/Models/BackupArchive.php +++ b/src/Appwrite/Models/BackupArchive.php @@ -50,30 +50,21 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('policyId', $data)) { - throw new \InvalidArgumentException('Missing required field "policyId" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'policyId' => "", + 'status' => "", + 'migrationId' => "", + ]; + if (!array_key_exists('size', $data)) { throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } if (!array_key_exists('startedAt', $data)) { throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); } - if (!array_key_exists('migrationId', $data)) { - throw new \InvalidArgumentException('Missing required field "migrationId" for ' . static::class . '.'); - } if (!array_key_exists('services', $data)) { throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/BackupArchiveList.php b/src/Appwrite/Models/BackupArchiveList.php index 635f8cc..49691da 100644 --- a/src/Appwrite/Models/BackupArchiveList.php +++ b/src/Appwrite/Models/BackupArchiveList.php @@ -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('archives', $data)) { throw new \InvalidArgumentException('Missing required field "archives" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/BackupPolicy.php b/src/Appwrite/Models/BackupPolicy.php index 1ccc459..790139c 100644 --- a/src/Appwrite/Models/BackupPolicy.php +++ b/src/Appwrite/Models/BackupPolicy.php @@ -50,36 +50,23 @@ 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('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'name' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'retention' => 1, + 'schedule' => "0 * * * *", + 'type' => "full", + 'enabled' => false, + ]; + if (!array_key_exists('services', $data)) { throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); } if (!array_key_exists('resources', $data)) { throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); } - if (!array_key_exists('retention', $data)) { - throw new \InvalidArgumentException('Missing required field "retention" for ' . static::class . '.'); - } - if (!array_key_exists('schedule', $data)) { - throw new \InvalidArgumentException('Missing required field "schedule" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/BackupPolicyList.php b/src/Appwrite/Models/BackupPolicyList.php index 0cc3171..f27fe91 100644 --- a/src/Appwrite/Models/BackupPolicyList.php +++ b/src/Appwrite/Models/BackupPolicyList.php @@ -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('policies', $data)) { throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/BackupRestoration.php b/src/Appwrite/Models/BackupRestoration.php index 7e43ad0..c6581f6 100644 --- a/src/Appwrite/Models/BackupRestoration.php +++ b/src/Appwrite/Models/BackupRestoration.php @@ -48,39 +48,26 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('archiveId', $data)) { - throw new \InvalidArgumentException('Missing required field "archiveId" for ' . static::class . '.'); - } - if (!array_key_exists('policyId', $data)) { - throw new \InvalidArgumentException('Missing required field "policyId" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'archiveId' => "", + 'policyId' => "", + 'status' => "", + 'migrationId' => "", + 'options' => [], + ]; + if (!array_key_exists('startedAt', $data)) { throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); } - if (!array_key_exists('migrationId', $data)) { - throw new \InvalidArgumentException('Missing required field "migrationId" for ' . static::class . '.'); - } if (!array_key_exists('services', $data)) { throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); } if (!array_key_exists('resources', $data)) { throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); } - if (!array_key_exists('options', $data)) { - throw new \InvalidArgumentException('Missing required field "options" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/BackupRestorationList.php b/src/Appwrite/Models/BackupRestorationList.php index 707421f..6d7f13d 100644 --- a/src/Appwrite/Models/BackupRestorationList.php +++ b/src/Appwrite/Models/BackupRestorationList.php @@ -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('restorations', $data)) { throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php index f7a61a7..3c4d2a1 100644 --- a/src/Appwrite/Models/BillingPlan.php +++ b/src/Appwrite/Models/BillingPlan.php @@ -174,198 +174,81 @@ 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('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('desc', $data)) { - throw new \InvalidArgumentException('Missing required field "desc" for ' . static::class . '.'); - } - if (!array_key_exists('order', $data)) { - throw new \InvalidArgumentException('Missing required field "order" for ' . static::class . '.'); - } - if (!array_key_exists('price', $data)) { - throw new \InvalidArgumentException('Missing required field "price" for ' . static::class . '.'); - } - if (!array_key_exists('trial', $data)) { - throw new \InvalidArgumentException('Missing required field "trial" for ' . static::class . '.'); - } - if (!array_key_exists('bandwidth', $data)) { - throw new \InvalidArgumentException('Missing required field "bandwidth" for ' . static::class . '.'); - } - if (!array_key_exists('storage', $data)) { - throw new \InvalidArgumentException('Missing required field "storage" for ' . static::class . '.'); - } - if (!array_key_exists('imageTransformations', $data)) { - throw new \InvalidArgumentException('Missing required field "imageTransformations" for ' . static::class . '.'); - } - if (!array_key_exists('screenshotsGenerated', $data)) { - throw new \InvalidArgumentException('Missing required field "screenshotsGenerated" for ' . static::class . '.'); - } - if (!array_key_exists('webhooks', $data)) { - throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); - } - if (!array_key_exists('wafRules', $data)) { - throw new \InvalidArgumentException('Missing required field "wafRules" for ' . static::class . '.'); - } - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - if (!array_key_exists('platforms', $data)) { - throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); - } - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - if (!array_key_exists('teams', $data)) { - throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); - } - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - if (!array_key_exists('databasesReads', $data)) { - throw new \InvalidArgumentException('Missing required field "databasesReads" for ' . static::class . '.'); - } - if (!array_key_exists('databasesWrites', $data)) { - throw new \InvalidArgumentException('Missing required field "databasesWrites" for ' . static::class . '.'); - } - if (!array_key_exists('databasesBatchSize', $data)) { - throw new \InvalidArgumentException('Missing required field "databasesBatchSize" for ' . static::class . '.'); - } - if (!array_key_exists('buckets', $data)) { - throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); - } - if (!array_key_exists('fileSize', $data)) { - throw new \InvalidArgumentException('Missing required field "fileSize" for ' . static::class . '.'); - } - if (!array_key_exists('functions', $data)) { - throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); - } - if (!array_key_exists('sites', $data)) { - throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); - } - if (!array_key_exists('executions', $data)) { - throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); - } - if (!array_key_exists('executionsRetentionCount', $data)) { - throw new \InvalidArgumentException('Missing required field "executionsRetentionCount" for ' . static::class . '.'); - } - if (!array_key_exists('GBHours', $data)) { - throw new \InvalidArgumentException('Missing required field "GBHours" for ' . static::class . '.'); - } - if (!array_key_exists('realtime', $data)) { - throw new \InvalidArgumentException('Missing required field "realtime" for ' . static::class . '.'); - } - if (!array_key_exists('realtimeMessages', $data)) { - throw new \InvalidArgumentException('Missing required field "realtimeMessages" for ' . static::class . '.'); - } - if (!array_key_exists('messages', $data)) { - throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); - } - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - if (!array_key_exists('authPhone', $data)) { - throw new \InvalidArgumentException('Missing required field "authPhone" for ' . static::class . '.'); - } - if (!array_key_exists('domains', $data)) { - throw new \InvalidArgumentException('Missing required field "domains" for ' . static::class . '.'); - } - if (!array_key_exists('usageLogs', $data)) { - throw new \InvalidArgumentException('Missing required field "usageLogs" for ' . static::class . '.'); - } - if (!array_key_exists('projectInactivityDays', $data)) { - throw new \InvalidArgumentException('Missing required field "projectInactivityDays" for ' . static::class . '.'); - } - if (!array_key_exists('alertLimit', $data)) { - throw new \InvalidArgumentException('Missing required field "alertLimit" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'name' => "", + 'desc' => "", + 'order' => 0, + 'price' => 0, + 'trial' => 0, + 'bandwidth' => 0, + 'storage' => 0, + 'imageTransformations' => 0, + 'screenshotsGenerated' => 0, + 'webhooks' => 0, + 'wafRules' => 0, + 'projects' => 0, + 'platforms' => 0, + 'users' => 0, + 'teams' => 0, + 'databases' => 0, + 'databasesReads' => 0, + 'databasesWrites' => 0, + 'databasesBatchSize' => 0, + 'buckets' => 0, + 'fileSize' => 0, + 'functions' => 0, + 'sites' => 0, + 'executions' => 0, + 'executionsRetentionCount' => 1000, + 'GBHours' => 0, + 'realtime' => 0, + 'realtimeMessages' => 0, + 'messages' => 0, + 'topics' => 0, + 'authPhone' => 0, + 'domains' => 0, + 'usageLogs' => 0, + 'projectInactivityDays' => 0, + 'alertLimit' => 80, + 'budgetCapEnabled' => false, + 'customSmtp' => false, + 'emailBranding' => false, + 'requiresPaymentMethod' => true, + 'requiresBillingAddress' => false, + 'isAvailable' => true, + 'selfService' => true, + 'premiumSupport' => true, + 'budgeting' => true, + 'supportsMockNumbers' => true, + 'supportsOrganizationRoles' => true, + 'supportsCredits' => false, + 'supportsDedicatedDatabases' => false, + 'supportsDisposableEmailValidation' => false, + 'supportsCanonicalEmailValidation' => false, + 'supportsFreeEmailValidation' => false, + 'supportsCorporateEmailValidation' => false, + 'supportsProjectSpecificRoles' => false, + 'usagePerProject' => true, + 'deploymentSize' => 0, + 'buildSize' => 0, + 'functionsIntervalMinimum' => 0, + 'databasesAllowEncrypt' => false, + 'databaseComputeCredit' => 0, + ]; + if (!array_key_exists('usage', $data)) { throw new \InvalidArgumentException('Missing required field "usage" for ' . static::class . '.'); } if (!array_key_exists('addons', $data)) { throw new \InvalidArgumentException('Missing required field "addons" for ' . static::class . '.'); } - if (!array_key_exists('budgetCapEnabled', $data)) { - throw new \InvalidArgumentException('Missing required field "budgetCapEnabled" for ' . static::class . '.'); - } - if (!array_key_exists('customSmtp', $data)) { - throw new \InvalidArgumentException('Missing required field "customSmtp" for ' . static::class . '.'); - } - if (!array_key_exists('emailBranding', $data)) { - throw new \InvalidArgumentException('Missing required field "emailBranding" for ' . static::class . '.'); - } - if (!array_key_exists('requiresPaymentMethod', $data)) { - throw new \InvalidArgumentException('Missing required field "requiresPaymentMethod" for ' . static::class . '.'); - } - if (!array_key_exists('requiresBillingAddress', $data)) { - throw new \InvalidArgumentException('Missing required field "requiresBillingAddress" for ' . static::class . '.'); - } - if (!array_key_exists('isAvailable', $data)) { - throw new \InvalidArgumentException('Missing required field "isAvailable" for ' . static::class . '.'); - } - if (!array_key_exists('selfService', $data)) { - throw new \InvalidArgumentException('Missing required field "selfService" for ' . static::class . '.'); - } - if (!array_key_exists('premiumSupport', $data)) { - throw new \InvalidArgumentException('Missing required field "premiumSupport" for ' . static::class . '.'); - } - if (!array_key_exists('budgeting', $data)) { - throw new \InvalidArgumentException('Missing required field "budgeting" for ' . static::class . '.'); - } - if (!array_key_exists('supportsMockNumbers', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsMockNumbers" for ' . static::class . '.'); - } - if (!array_key_exists('supportsOrganizationRoles', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsOrganizationRoles" for ' . static::class . '.'); - } - if (!array_key_exists('supportsCredits', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsCredits" for ' . static::class . '.'); - } - if (!array_key_exists('supportsDedicatedDatabases', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsDedicatedDatabases" for ' . static::class . '.'); - } - if (!array_key_exists('supportsDisposableEmailValidation', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsDisposableEmailValidation" for ' . static::class . '.'); - } - if (!array_key_exists('supportsCanonicalEmailValidation', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsCanonicalEmailValidation" for ' . static::class . '.'); - } - if (!array_key_exists('supportsFreeEmailValidation', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsFreeEmailValidation" for ' . static::class . '.'); - } - if (!array_key_exists('supportsCorporateEmailValidation', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsCorporateEmailValidation" for ' . static::class . '.'); - } - if (!array_key_exists('supportsProjectSpecificRoles', $data)) { - throw new \InvalidArgumentException('Missing required field "supportsProjectSpecificRoles" for ' . static::class . '.'); - } - if (!array_key_exists('usagePerProject', $data)) { - throw new \InvalidArgumentException('Missing required field "usagePerProject" for ' . static::class . '.'); - } if (!array_key_exists('supportedAddons', $data)) { throw new \InvalidArgumentException('Missing required field "supportedAddons" for ' . static::class . '.'); } - if (!array_key_exists('deploymentSize', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentSize" for ' . static::class . '.'); - } - if (!array_key_exists('buildSize', $data)) { - throw new \InvalidArgumentException('Missing required field "buildSize" for ' . static::class . '.'); - } - if (!array_key_exists('functionsIntervalMinimum', $data)) { - throw new \InvalidArgumentException('Missing required field "functionsIntervalMinimum" for ' . static::class . '.'); - } - if (!array_key_exists('databasesAllowEncrypt', $data)) { - throw new \InvalidArgumentException('Missing required field "databasesAllowEncrypt" for ' . static::class . '.'); - } if (!array_key_exists('group', $data)) { throw new \InvalidArgumentException('Missing required field "group" for ' . static::class . '.'); } - if (!array_key_exists('databaseComputeCredit', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseComputeCredit" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/BillingPlanAddonDetails.php b/src/Appwrite/Models/BillingPlanAddonDetails.php index cc972f3..c30690a 100644 --- a/src/Appwrite/Models/BillingPlanAddonDetails.php +++ b/src/Appwrite/Models/BillingPlanAddonDetails.php @@ -42,27 +42,15 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('supported', $data)) { - throw new \InvalidArgumentException('Missing required field "supported" for ' . static::class . '.'); - } - if (!array_key_exists('planIncluded', $data)) { - throw new \InvalidArgumentException('Missing required field "planIncluded" for ' . static::class . '.'); - } - if (!array_key_exists('limit', $data)) { - throw new \InvalidArgumentException('Missing required field "limit" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" 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 += [ + 'supported' => false, + 'planIncluded' => 0, + 'limit' => 0, + 'type' => "numeric", + 'price' => 0, + 'value' => 0, + 'invoiceDesc' => "", + ]; return new static( supported: $data['supported'], diff --git a/src/Appwrite/Models/BillingPlanSupportedAddons.php b/src/Appwrite/Models/BillingPlanSupportedAddons.php index 0ecbe7b..d83da8f 100644 --- a/src/Appwrite/Models/BillingPlanSupportedAddons.php +++ b/src/Appwrite/Models/BillingPlanSupportedAddons.php @@ -32,15 +32,11 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('baa', $data)) { - throw new \InvalidArgumentException('Missing required field "baa" for ' . static::class . '.'); - } - if (!array_key_exists('premiumGeoDB', $data)) { - throw new \InvalidArgumentException('Missing required field "premiumGeoDB" for ' . static::class . '.'); - } - if (!array_key_exists('premiumGeoDBOrg', $data)) { - throw new \InvalidArgumentException('Missing required field "premiumGeoDBOrg" for ' . static::class . '.'); - } + $data += [ + 'baa' => false, + 'premiumGeoDB' => false, + 'premiumGeoDBOrg' => false, + ]; return new static( baa: $data['baa'], diff --git a/src/Appwrite/Models/Block.php b/src/Appwrite/Models/Block.php index 16f0841..f40cb57 100644 --- a/src/Appwrite/Models/Block.php +++ b/src/Appwrite/Models/Block.php @@ -48,18 +48,13 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" 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('mode', $data)) { - throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); - } + $data += [ + '$createdAt' => "", + 'resourceType' => "", + 'resourceId' => "", + 'mode' => "full", + ]; + if (!array_key_exists('projectName', $data)) { throw new \InvalidArgumentException('Missing required field "projectName" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Bucket.php b/src/Appwrite/Models/Bucket.php index b358993..68c69dc 100644 --- a/src/Appwrite/Models/Bucket.php +++ b/src/Appwrite/Models/Bucket.php @@ -54,48 +54,22 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('fileSecurity', $data)) { - throw new \InvalidArgumentException('Missing required field "fileSecurity" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('maximumFileSize', $data)) { - throw new \InvalidArgumentException('Missing required field "maximumFileSize" for ' . static::class . '.'); - } - if (!array_key_exists('allowedFileExtensions', $data)) { - throw new \InvalidArgumentException('Missing required field "allowedFileExtensions" for ' . static::class . '.'); - } - if (!array_key_exists('compression', $data)) { - throw new \InvalidArgumentException('Missing required field "compression" for ' . static::class . '.'); - } - if (!array_key_exists('encryption', $data)) { - throw new \InvalidArgumentException('Missing required field "encryption" for ' . static::class . '.'); - } - if (!array_key_exists('antivirus', $data)) { - throw new \InvalidArgumentException('Missing required field "antivirus" for ' . static::class . '.'); - } - if (!array_key_exists('transformations', $data)) { - throw new \InvalidArgumentException('Missing required field "transformations" for ' . static::class . '.'); - } - if (!array_key_exists('totalSize', $data)) { - throw new \InvalidArgumentException('Missing required field "totalSize" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + '$permissions' => [], + 'fileSecurity' => false, + 'name' => "", + 'enabled' => true, + 'maximumFileSize' => 0, + 'allowedFileExtensions' => [], + 'compression' => "", + 'encryption' => true, + 'antivirus' => true, + 'transformations' => true, + 'totalSize' => 0, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/BucketList.php b/src/Appwrite/Models/BucketList.php index c94dc2e..4ee13e8 100644 --- a/src/Appwrite/Models/BucketList.php +++ b/src/Appwrite/Models/BucketList.php @@ -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('buckets', $data)) { throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Collection.php b/src/Appwrite/Models/Collection.php index de2e791..34e1ff9 100644 --- a/src/Appwrite/Models/Collection.php +++ b/src/Appwrite/Models/Collection.php @@ -50,42 +50,27 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'databaseId' => "", + 'name' => "", + 'enabled' => true, + 'documentSecurity' => false, + 'bytesMax' => 0, + 'bytesUsed' => 0, + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('documentSecurity', $data)) { - throw new \InvalidArgumentException('Missing required field "documentSecurity" for ' . static::class . '.'); - } if (!array_key_exists('attributes', $data)) { throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); } if (!array_key_exists('indexes', $data)) { throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); } - if (!array_key_exists('bytesMax', $data)) { - throw new \InvalidArgumentException('Missing required field "bytesMax" for ' . static::class . '.'); - } - if (!array_key_exists('bytesUsed', $data)) { - throw new \InvalidArgumentException('Missing required field "bytesUsed" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/CollectionList.php b/src/Appwrite/Models/CollectionList.php index 3617db9..435e41a 100644 --- a/src/Appwrite/Models/CollectionList.php +++ b/src/Appwrite/Models/CollectionList.php @@ -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('collections', $data)) { throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ColumnBigint.php b/src/Appwrite/Models/ColumnBigint.php index 34e70cf..6a00d25 100644 --- a/src/Appwrite/Models/ColumnBigint.php +++ b/src/Appwrite/Models/ColumnBigint.php @@ -50,27 +50,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnBoolean.php b/src/Appwrite/Models/ColumnBoolean.php index 7bbc030..c1eb7db 100644 --- a/src/Appwrite/Models/ColumnBoolean.php +++ b/src/Appwrite/Models/ColumnBoolean.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnDatetime.php b/src/Appwrite/Models/ColumnDatetime.php index 7eb241b..d7be453 100644 --- a/src/Appwrite/Models/ColumnDatetime.php +++ b/src/Appwrite/Models/ColumnDatetime.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } if (!array_key_exists('format', $data)) { throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ColumnEmail.php b/src/Appwrite/Models/ColumnEmail.php index f24369e..77fca40 100644 --- a/src/Appwrite/Models/ColumnEmail.php +++ b/src/Appwrite/Models/ColumnEmail.php @@ -48,30 +48,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "email", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnEnum.php b/src/Appwrite/Models/ColumnEnum.php index 925a656..f9c4c45 100644 --- a/src/Appwrite/Models/ColumnEnum.php +++ b/src/Appwrite/Models/ColumnEnum.php @@ -50,33 +50,22 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "enum", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } if (!array_key_exists('elements', $data)) { throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnFloat.php b/src/Appwrite/Models/ColumnFloat.php index c446e11..47ba330 100644 --- a/src/Appwrite/Models/ColumnFloat.php +++ b/src/Appwrite/Models/ColumnFloat.php @@ -50,27 +50,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnIndex.php b/src/Appwrite/Models/ColumnIndex.php index 2ef80f4..db54527 100644 --- a/src/Appwrite/Models/ColumnIndex.php +++ b/src/Appwrite/Models/ColumnIndex.php @@ -46,33 +46,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - if (!array_key_exists('lengths', $data)) { - throw new \InvalidArgumentException('Missing required field "lengths" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'key' => "", + 'type' => "", + 'status' => "", + 'error' => "", + 'columns' => [], + 'lengths' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ColumnIndexList.php b/src/Appwrite/Models/ColumnIndexList.php index a5107ea..b5eaf07 100644 --- a/src/Appwrite/Models/ColumnIndexList.php +++ b/src/Appwrite/Models/ColumnIndexList.php @@ -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('indexes', $data)) { throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ColumnInteger.php b/src/Appwrite/Models/ColumnInteger.php index e0bb270..bab1fa8 100644 --- a/src/Appwrite/Models/ColumnInteger.php +++ b/src/Appwrite/Models/ColumnInteger.php @@ -50,27 +50,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnIp.php b/src/Appwrite/Models/ColumnIp.php index a9d00a0..8770703 100644 --- a/src/Appwrite/Models/ColumnIp.php +++ b/src/Appwrite/Models/ColumnIp.php @@ -48,30 +48,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "ip", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnLine.php b/src/Appwrite/Models/ColumnLine.php index 93b337c..980652f 100644 --- a/src/Appwrite/Models/ColumnLine.php +++ b/src/Appwrite/Models/ColumnLine.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnList.php b/src/Appwrite/Models/ColumnList.php index 2c513f5..108ff6a 100644 --- a/src/Appwrite/Models/ColumnList.php +++ b/src/Appwrite/Models/ColumnList.php @@ -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('columns', $data)) { throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ColumnLongtext.php b/src/Appwrite/Models/ColumnLongtext.php index 7017212..19c5126 100644 --- a/src/Appwrite/Models/ColumnLongtext.php +++ b/src/Appwrite/Models/ColumnLongtext.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnMediumtext.php b/src/Appwrite/Models/ColumnMediumtext.php index 9bea0bb..2f31acd 100644 --- a/src/Appwrite/Models/ColumnMediumtext.php +++ b/src/Appwrite/Models/ColumnMediumtext.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnPoint.php b/src/Appwrite/Models/ColumnPoint.php index 92671a5..f8045d1 100644 --- a/src/Appwrite/Models/ColumnPoint.php +++ b/src/Appwrite/Models/ColumnPoint.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnPolygon.php b/src/Appwrite/Models/ColumnPolygon.php index 293e5df..5bf4414 100644 --- a/src/Appwrite/Models/ColumnPolygon.php +++ b/src/Appwrite/Models/ColumnPolygon.php @@ -46,27 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnRelationship.php b/src/Appwrite/Models/ColumnRelationship.php index 71ce577..527001f 100644 --- a/src/Appwrite/Models/ColumnRelationship.php +++ b/src/Appwrite/Models/ColumnRelationship.php @@ -56,45 +56,26 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'relationType' => "", + 'twoWay' => false, + 'twoWayKey' => "", + 'onDelete' => "restrict", + 'side' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } if (!array_key_exists('relatedTable', $data)) { throw new \InvalidArgumentException('Missing required field "relatedTable" for ' . static::class . '.'); } - if (!array_key_exists('relationType', $data)) { - throw new \InvalidArgumentException('Missing required field "relationType" for ' . static::class . '.'); - } - if (!array_key_exists('twoWay', $data)) { - throw new \InvalidArgumentException('Missing required field "twoWay" for ' . static::class . '.'); - } - if (!array_key_exists('twoWayKey', $data)) { - throw new \InvalidArgumentException('Missing required field "twoWayKey" for ' . static::class . '.'); - } - if (!array_key_exists('onDelete', $data)) { - throw new \InvalidArgumentException('Missing required field "onDelete" for ' . static::class . '.'); - } - if (!array_key_exists('side', $data)) { - throw new \InvalidArgumentException('Missing required field "side" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnString.php b/src/Appwrite/Models/ColumnString.php index 11e3fc9..2e00758 100644 --- a/src/Appwrite/Models/ColumnString.php +++ b/src/Appwrite/Models/ColumnString.php @@ -50,30 +50,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'size' => 0, + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnText.php b/src/Appwrite/Models/ColumnText.php index d8c265b..867b158 100644 --- a/src/Appwrite/Models/ColumnText.php +++ b/src/Appwrite/Models/ColumnText.php @@ -48,27 +48,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnUrl.php b/src/Appwrite/Models/ColumnUrl.php index a2c66da..7ab8b11 100644 --- a/src/Appwrite/Models/ColumnUrl.php +++ b/src/Appwrite/Models/ColumnUrl.php @@ -48,30 +48,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'format' => "url", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('format', $data)) { - throw new \InvalidArgumentException('Missing required field "format" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnVarchar.php b/src/Appwrite/Models/ColumnVarchar.php index bb9ac36..74ce172 100644 --- a/src/Appwrite/Models/ColumnVarchar.php +++ b/src/Appwrite/Models/ColumnVarchar.php @@ -50,30 +50,19 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'type' => "", + 'error' => "", + 'required' => false, + '$createdAt' => "", + '$updatedAt' => "", + 'size' => 0, + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('required', $data)) { - throw new \InvalidArgumentException('Missing required field "required" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/Continent.php b/src/Appwrite/Models/Continent.php index 3b0084d..c02a715 100644 --- a/src/Appwrite/Models/Continent.php +++ b/src/Appwrite/Models/Continent.php @@ -30,12 +30,10 @@ 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('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } + $data += [ + 'name' => "", + 'code' => "", + ]; return new static( name: $data['name'], diff --git a/src/Appwrite/Models/ContinentList.php b/src/Appwrite/Models/ContinentList.php index fdcc170..3af1651 100644 --- a/src/Appwrite/Models/ContinentList.php +++ b/src/Appwrite/Models/ContinentList.php @@ -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('continents', $data)) { throw new \InvalidArgumentException('Missing required field "continents" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Country.php b/src/Appwrite/Models/Country.php index e41c058..b0157fe 100644 --- a/src/Appwrite/Models/Country.php +++ b/src/Appwrite/Models/Country.php @@ -30,12 +30,10 @@ 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('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } + $data += [ + 'name' => "", + 'code' => "", + ]; return new static( name: $data['name'], diff --git a/src/Appwrite/Models/CountryList.php b/src/Appwrite/Models/CountryList.php index ae208f0..0a9210a 100644 --- a/src/Appwrite/Models/CountryList.php +++ b/src/Appwrite/Models/CountryList.php @@ -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('countries', $data)) { throw new \InvalidArgumentException('Missing required field "countries" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Currency.php b/src/Appwrite/Models/Currency.php index 87ee856..7d0afd3 100644 --- a/src/Appwrite/Models/Currency.php +++ b/src/Appwrite/Models/Currency.php @@ -40,27 +40,15 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('symbol', $data)) { - throw new \InvalidArgumentException('Missing required field "symbol" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('symbolNative', $data)) { - throw new \InvalidArgumentException('Missing required field "symbolNative" for ' . static::class . '.'); - } - if (!array_key_exists('decimalDigits', $data)) { - throw new \InvalidArgumentException('Missing required field "decimalDigits" for ' . static::class . '.'); - } - if (!array_key_exists('rounding', $data)) { - throw new \InvalidArgumentException('Missing required field "rounding" for ' . static::class . '.'); - } - if (!array_key_exists('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } - if (!array_key_exists('namePlural', $data)) { - throw new \InvalidArgumentException('Missing required field "namePlural" for ' . static::class . '.'); - } + $data += [ + 'symbol' => "", + 'name' => "", + 'symbolNative' => "", + 'decimalDigits' => 0, + 'rounding' => 0, + 'code' => "", + 'namePlural' => "", + ]; return new static( symbol: $data['symbol'], diff --git a/src/Appwrite/Models/CurrencyList.php b/src/Appwrite/Models/CurrencyList.php index 718ebae..d2b33e3 100644 --- a/src/Appwrite/Models/CurrencyList.php +++ b/src/Appwrite/Models/CurrencyList.php @@ -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('currencies', $data)) { throw new \InvalidArgumentException('Missing required field "currencies" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Database.php b/src/Appwrite/Models/Database.php index 62382d9..bd3a45e 100644 --- a/src/Appwrite/Models/Database.php +++ b/src/Appwrite/Models/Database.php @@ -59,24 +59,14 @@ 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('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'name' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'enabled' => true, + 'type' => "legacy", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DatabaseList.php b/src/Appwrite/Models/DatabaseList.php index 2f10944..86fb346 100644 --- a/src/Appwrite/Models/DatabaseList.php +++ b/src/Appwrite/Models/DatabaseList.php @@ -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('databases', $data)) { throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DatabaseMigration.php b/src/Appwrite/Models/DatabaseMigration.php index 3e2cce0..0ef8132 100644 --- a/src/Appwrite/Models/DatabaseMigration.php +++ b/src/Appwrite/Models/DatabaseMigration.php @@ -60,57 +60,25 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('projectId', $data)) { - throw new \InvalidArgumentException('Missing required field "projectId" for ' . static::class . '.'); - } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('specification', $data)) { - throw new \InvalidArgumentException('Missing required field "specification" for ' . static::class . '.'); - } - if (!array_key_exists('phase', $data)) { - throw new \InvalidArgumentException('Missing required field "phase" for ' . static::class . '.'); - } - if (!array_key_exists('attempt', $data)) { - throw new \InvalidArgumentException('Missing required field "attempt" for ' . static::class . '.'); - } - if (!array_key_exists('lastError', $data)) { - throw new \InvalidArgumentException('Missing required field "lastError" for ' . static::class . '.'); - } - if (!array_key_exists('lagDocuments', $data)) { - throw new \InvalidArgumentException('Missing required field "lagDocuments" for ' . static::class . '.'); - } - if (!array_key_exists('changelogWatermark', $data)) { - throw new \InvalidArgumentException('Missing required field "changelogWatermark" for ' . static::class . '.'); - } - if (!array_key_exists('verifiedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "verifiedAt" for ' . static::class . '.'); - } - if (!array_key_exists('cutoverAt', $data)) { - throw new \InvalidArgumentException('Missing required field "cutoverAt" for ' . static::class . '.'); - } - if (!array_key_exists('soakUntil', $data)) { - throw new \InvalidArgumentException('Missing required field "soakUntil" for ' . static::class . '.'); - } - if (!array_key_exists('autoCutover', $data)) { - throw new \InvalidArgumentException('Missing required field "autoCutover" for ' . static::class . '.'); - } - if (!array_key_exists('cutoverRequested', $data)) { - throw new \InvalidArgumentException('Missing required field "cutoverRequested" for ' . static::class . '.'); - } - if (!array_key_exists('paused', $data)) { - throw new \InvalidArgumentException('Missing required field "paused" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'projectId' => "", + 'databaseId' => "", + 'specification' => "", + 'phase' => "pending", + 'attempt' => 0, + 'lastError' => "", + 'lagDocuments' => 0, + 'changelogWatermark' => 0, + 'verifiedAt' => "", + 'cutoverAt' => "", + 'soakUntil' => "", + 'autoCutover' => true, + 'cutoverRequested' => false, + 'paused' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DatabaseMigrationList.php b/src/Appwrite/Models/DatabaseMigrationList.php index 2fa2cfb..ae2528d 100644 --- a/src/Appwrite/Models/DatabaseMigrationList.php +++ b/src/Appwrite/Models/DatabaseMigrationList.php @@ -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('migrations', $data)) { throw new \InvalidArgumentException('Missing required field "migrations" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DatabaseStatus.php b/src/Appwrite/Models/DatabaseStatus.php index f259755..6fdaf14 100644 --- a/src/Appwrite/Models/DatabaseStatus.php +++ b/src/Appwrite/Models/DatabaseStatus.php @@ -54,36 +54,21 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('health', $data)) { - throw new \InvalidArgumentException('Missing required field "health" for ' . static::class . '.'); - } - if (!array_key_exists('ready', $data)) { - throw new \InvalidArgumentException('Missing required field "ready" for ' . static::class . '.'); - } - if (!array_key_exists('engine', $data)) { - throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); - } - if (!array_key_exists('version', $data)) { - throw new \InvalidArgumentException('Missing required field "version" for ' . static::class . '.'); - } - if (!array_key_exists('uptime', $data)) { - throw new \InvalidArgumentException('Missing required field "uptime" for ' . static::class . '.'); - } + $data += [ + 'health' => "unknown", + 'ready' => false, + 'engine' => "postgresql", + 'version' => "", + 'uptime' => 0, + 'syncMode' => "async", + 'syncDegraded' => false, + 'syncAcknowledgements' => 0, + 'syncStandbyCount' => 0, + ]; + if (!array_key_exists('connections', $data)) { throw new \InvalidArgumentException('Missing required field "connections" for ' . static::class . '.'); } - if (!array_key_exists('syncMode', $data)) { - throw new \InvalidArgumentException('Missing required field "syncMode" for ' . static::class . '.'); - } - if (!array_key_exists('syncDegraded', $data)) { - throw new \InvalidArgumentException('Missing required field "syncDegraded" for ' . static::class . '.'); - } - if (!array_key_exists('syncAcknowledgements', $data)) { - throw new \InvalidArgumentException('Missing required field "syncAcknowledgements" for ' . static::class . '.'); - } - if (!array_key_exists('syncStandbyCount', $data)) { - throw new \InvalidArgumentException('Missing required field "syncStandbyCount" for ' . static::class . '.'); - } if (!array_key_exists('replicas', $data)) { throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DatabaseStatusConnections.php b/src/Appwrite/Models/DatabaseStatusConnections.php index f0862f3..cf2e8a9 100644 --- a/src/Appwrite/Models/DatabaseStatusConnections.php +++ b/src/Appwrite/Models/DatabaseStatusConnections.php @@ -30,12 +30,10 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('current', $data)) { - throw new \InvalidArgumentException('Missing required field "current" for ' . static::class . '.'); - } - if (!array_key_exists('max', $data)) { - throw new \InvalidArgumentException('Missing required field "max" for ' . static::class . '.'); - } + $data += [ + 'current' => 0, + 'max' => 100, + ]; return new static( current: $data['current'], diff --git a/src/Appwrite/Models/DatabaseStatusReplica.php b/src/Appwrite/Models/DatabaseStatusReplica.php index b313589..607036f 100644 --- a/src/Appwrite/Models/DatabaseStatusReplica.php +++ b/src/Appwrite/Models/DatabaseStatusReplica.php @@ -36,15 +36,11 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('index', $data)) { - throw new \InvalidArgumentException('Missing required field "index" for ' . static::class . '.'); - } - if (!array_key_exists('role', $data)) { - throw new \InvalidArgumentException('Missing required field "role" for ' . static::class . '.'); - } - if (!array_key_exists('healthy', $data)) { - throw new \InvalidArgumentException('Missing required field "healthy" for ' . static::class . '.'); - } + $data += [ + 'index' => 0, + 'role' => "unknown", + 'healthy' => false, + ]; return new static( index: $data['index'], diff --git a/src/Appwrite/Models/DatabaseStatusVolume.php b/src/Appwrite/Models/DatabaseStatusVolume.php index a0f6aed..c3666b3 100644 --- a/src/Appwrite/Models/DatabaseStatusVolume.php +++ b/src/Appwrite/Models/DatabaseStatusVolume.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('path', $data)) { - throw new \InvalidArgumentException('Missing required field "path" for ' . static::class . '.'); - } - if (!array_key_exists('usedPercent', $data)) { - throw new \InvalidArgumentException('Missing required field "usedPercent" for ' . static::class . '.'); - } - if (!array_key_exists('available', $data)) { - throw new \InvalidArgumentException('Missing required field "available" for ' . static::class . '.'); - } - if (!array_key_exists('mounted', $data)) { - throw new \InvalidArgumentException('Missing required field "mounted" for ' . static::class . '.'); - } + $data += [ + 'path' => "", + 'usedPercent' => "0%", + 'available' => "0GB", + 'mounted' => false, + ]; return new static( path: $data['path'], diff --git a/src/Appwrite/Models/DedicatedDatabase.php b/src/Appwrite/Models/DedicatedDatabase.php index 28ad149..2b0f84e 100644 --- a/src/Appwrite/Models/DedicatedDatabase.php +++ b/src/Appwrite/Models/DedicatedDatabase.php @@ -124,147 +124,64 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('projectId', $data)) { - throw new \InvalidArgumentException('Missing required field "projectId" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'projectId' => "", + 'name' => "", + 'version' => "", + 'specification' => "", + 'backend' => "", + 'hostname' => "", + 'connectionUser' => "", + 'connectionPassword' => "", + 'connectionString' => "", + 'ssl' => false, + 'status' => "provisioning", + 'containerStatus' => "", + 'lifecycleState' => "", + 'idleTimeoutMinutes' => 15, + 'cpu' => 500, + 'memory' => 512, + 'storage' => 10, + 'storageClass' => "ssd", + 'storageMaxGb' => 0, + 'nodePool' => "", + 'replicas' => 0, + 'syncMode' => "", + 'networkMaxConnections' => 100, + 'networkIdleTimeoutSeconds' => 900, + 'networkIPAllowlist' => [], + 'backupEnabled' => true, + 'pitr' => true, + 'pitrRetentionDays' => 7, + 'storageAutoscaling' => true, + 'storageAutoscalingThresholdPercent' => 85, + 'storageAutoscalingMaxGb' => 0, + 'maintenanceWindowDay' => "sun", + 'maintenanceWindowHourUtc' => 3, + 'metricsEnabled' => false, + 'sqlApiEnabled' => true, + 'sqlApiAllowedStatements' => ["SELECT", "INSERT", "UPDATE", "DELETE"], + 'sqlApiMaxRows' => 10000, + 'sqlApiMaxBytes' => 10485760, + 'sqlApiTimeoutSeconds' => 30, + 'error' => "", + ]; + if (!array_key_exists('api', $data)) { throw new \InvalidArgumentException('Missing required field "api" for ' . static::class . '.'); } if (!array_key_exists('engine', $data)) { throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); } - if (!array_key_exists('version', $data)) { - throw new \InvalidArgumentException('Missing required field "version" for ' . static::class . '.'); - } - if (!array_key_exists('specification', $data)) { - throw new \InvalidArgumentException('Missing required field "specification" for ' . static::class . '.'); - } - if (!array_key_exists('backend', $data)) { - throw new \InvalidArgumentException('Missing required field "backend" for ' . static::class . '.'); - } - if (!array_key_exists('hostname', $data)) { - throw new \InvalidArgumentException('Missing required field "hostname" for ' . static::class . '.'); - } if (!array_key_exists('connectionPort', $data)) { throw new \InvalidArgumentException('Missing required field "connectionPort" for ' . static::class . '.'); } - if (!array_key_exists('connectionUser', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionUser" for ' . static::class . '.'); - } - if (!array_key_exists('connectionPassword', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionPassword" for ' . static::class . '.'); - } if (!array_key_exists('credentialGeneration', $data)) { throw new \InvalidArgumentException('Missing required field "credentialGeneration" for ' . static::class . '.'); } - if (!array_key_exists('connectionString', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionString" for ' . static::class . '.'); - } - if (!array_key_exists('ssl', $data)) { - throw new \InvalidArgumentException('Missing required field "ssl" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('containerStatus', $data)) { - throw new \InvalidArgumentException('Missing required field "containerStatus" for ' . static::class . '.'); - } - if (!array_key_exists('lifecycleState', $data)) { - throw new \InvalidArgumentException('Missing required field "lifecycleState" for ' . static::class . '.'); - } - if (!array_key_exists('idleTimeoutMinutes', $data)) { - throw new \InvalidArgumentException('Missing required field "idleTimeoutMinutes" for ' . static::class . '.'); - } - if (!array_key_exists('cpu', $data)) { - throw new \InvalidArgumentException('Missing required field "cpu" for ' . static::class . '.'); - } - if (!array_key_exists('memory', $data)) { - throw new \InvalidArgumentException('Missing required field "memory" for ' . static::class . '.'); - } - if (!array_key_exists('storage', $data)) { - throw new \InvalidArgumentException('Missing required field "storage" for ' . static::class . '.'); - } - if (!array_key_exists('storageClass', $data)) { - throw new \InvalidArgumentException('Missing required field "storageClass" for ' . static::class . '.'); - } - if (!array_key_exists('storageMaxGb', $data)) { - throw new \InvalidArgumentException('Missing required field "storageMaxGb" for ' . static::class . '.'); - } - if (!array_key_exists('nodePool', $data)) { - throw new \InvalidArgumentException('Missing required field "nodePool" for ' . static::class . '.'); - } - if (!array_key_exists('replicas', $data)) { - throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); - } - if (!array_key_exists('syncMode', $data)) { - throw new \InvalidArgumentException('Missing required field "syncMode" for ' . static::class . '.'); - } - if (!array_key_exists('networkMaxConnections', $data)) { - throw new \InvalidArgumentException('Missing required field "networkMaxConnections" for ' . static::class . '.'); - } - if (!array_key_exists('networkIdleTimeoutSeconds', $data)) { - throw new \InvalidArgumentException('Missing required field "networkIdleTimeoutSeconds" for ' . static::class . '.'); - } - if (!array_key_exists('networkIPAllowlist', $data)) { - throw new \InvalidArgumentException('Missing required field "networkIPAllowlist" for ' . static::class . '.'); - } - if (!array_key_exists('backupEnabled', $data)) { - throw new \InvalidArgumentException('Missing required field "backupEnabled" for ' . static::class . '.'); - } - if (!array_key_exists('pitr', $data)) { - throw new \InvalidArgumentException('Missing required field "pitr" for ' . static::class . '.'); - } - if (!array_key_exists('pitrRetentionDays', $data)) { - throw new \InvalidArgumentException('Missing required field "pitrRetentionDays" for ' . static::class . '.'); - } - if (!array_key_exists('storageAutoscaling', $data)) { - throw new \InvalidArgumentException('Missing required field "storageAutoscaling" for ' . static::class . '.'); - } - if (!array_key_exists('storageAutoscalingThresholdPercent', $data)) { - throw new \InvalidArgumentException('Missing required field "storageAutoscalingThresholdPercent" for ' . static::class . '.'); - } - if (!array_key_exists('storageAutoscalingMaxGb', $data)) { - throw new \InvalidArgumentException('Missing required field "storageAutoscalingMaxGb" for ' . static::class . '.'); - } - if (!array_key_exists('maintenanceWindowDay', $data)) { - throw new \InvalidArgumentException('Missing required field "maintenanceWindowDay" for ' . static::class . '.'); - } - if (!array_key_exists('maintenanceWindowHourUtc', $data)) { - throw new \InvalidArgumentException('Missing required field "maintenanceWindowHourUtc" for ' . static::class . '.'); - } - if (!array_key_exists('metricsEnabled', $data)) { - throw new \InvalidArgumentException('Missing required field "metricsEnabled" for ' . static::class . '.'); - } - if (!array_key_exists('sqlApiEnabled', $data)) { - throw new \InvalidArgumentException('Missing required field "sqlApiEnabled" for ' . static::class . '.'); - } - if (!array_key_exists('sqlApiAllowedStatements', $data)) { - throw new \InvalidArgumentException('Missing required field "sqlApiAllowedStatements" for ' . static::class . '.'); - } - if (!array_key_exists('sqlApiMaxRows', $data)) { - throw new \InvalidArgumentException('Missing required field "sqlApiMaxRows" for ' . static::class . '.'); - } - if (!array_key_exists('sqlApiMaxBytes', $data)) { - throw new \InvalidArgumentException('Missing required field "sqlApiMaxBytes" for ' . static::class . '.'); - } - if (!array_key_exists('sqlApiTimeoutSeconds', $data)) { - throw new \InvalidArgumentException('Missing required field "sqlApiTimeoutSeconds" for ' . static::class . '.'); - } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DedicatedDatabaseBackup.php b/src/Appwrite/Models/DedicatedDatabaseBackup.php index 81e70d2..20efb50 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackup.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackup.php @@ -60,42 +60,20 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('projectId', $data)) { - throw new \InvalidArgumentException('Missing required field "projectId" for ' . static::class . '.'); - } - if (!array_key_exists('policyId', $data)) { - throw new \InvalidArgumentException('Missing required field "policyId" for ' . static::class . '.'); - } - if (!array_key_exists('trigger', $data)) { - throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('requestedType', $data)) { - throw new \InvalidArgumentException('Missing required field "requestedType" for ' . static::class . '.'); - } - if (!array_key_exists('fallbackReason', $data)) { - throw new \InvalidArgumentException('Missing required field "fallbackReason" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('sizeBytes', $data)) { - throw new \InvalidArgumentException('Missing required field "sizeBytes" for ' . static::class . '.'); - } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'databaseId' => "", + 'projectId' => "", + 'policyId' => "", + 'trigger' => "manual", + 'type' => "full", + 'requestedType' => "", + 'fallbackReason' => "", + 'status' => "pending", + 'sizeBytes' => 0, + 'error' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DedicatedDatabaseBackupList.php b/src/Appwrite/Models/DedicatedDatabaseBackupList.php index 079ee9b..fb6b022 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackupList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackupList.php @@ -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('backups', $data)) { throw new \InvalidArgumentException('Missing required field "backups" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBackupStorage.php b/src/Appwrite/Models/DedicatedDatabaseBackupStorage.php index 6b5e881..a9cafba 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackupStorage.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackupStorage.php @@ -36,21 +36,13 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('provider', $data)) { - throw new \InvalidArgumentException('Missing required field "provider" for ' . static::class . '.'); - } - if (!array_key_exists('bucket', $data)) { - throw new \InvalidArgumentException('Missing required field "bucket" for ' . static::class . '.'); - } - if (!array_key_exists('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } - if (!array_key_exists('prefix', $data)) { - throw new \InvalidArgumentException('Missing required field "prefix" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } + $data += [ + 'provider' => "", + 'bucket' => "", + 'region' => "", + 'prefix' => "backups/", + 'endpoint' => "", + ]; return new static( provider: $data['provider'], diff --git a/src/Appwrite/Models/DedicatedDatabaseBranch.php b/src/Appwrite/Models/DedicatedDatabaseBranch.php index 2e20e40..4770462 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranch.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranch.php @@ -50,42 +50,23 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('branchId', $data)) { - throw new \InvalidArgumentException('Missing required field "branchId" for ' . static::class . '.'); - } - if (!array_key_exists('branchName', $data)) { - throw new \InvalidArgumentException('Missing required field "branchName" for ' . static::class . '.'); - } - if (!array_key_exists('namespace', $data)) { - throw new \InvalidArgumentException('Missing required field "namespace" for ' . static::class . '.'); - } - if (!array_key_exists('expiresAt', $data)) { - throw new \InvalidArgumentException('Missing required field "expiresAt" for ' . static::class . '.'); - } - if (!array_key_exists('host', $data)) { - throw new \InvalidArgumentException('Missing required field "host" for ' . static::class . '.'); - } + $data += [ + 'branchId' => "", + 'branchName' => "", + 'namespace' => "", + 'expiresAt' => 0, + 'host' => "", + 'database' => "", + 'username' => "", + 'password' => "", + 'ssl' => false, + 'engine' => "", + 'connectionString' => "", + ]; + if (!array_key_exists('port', $data)) { throw new \InvalidArgumentException('Missing required field "port" for ' . static::class . '.'); } - if (!array_key_exists('database', $data)) { - throw new \InvalidArgumentException('Missing required field "database" for ' . static::class . '.'); - } - if (!array_key_exists('username', $data)) { - throw new \InvalidArgumentException('Missing required field "username" for ' . static::class . '.'); - } - if (!array_key_exists('password', $data)) { - throw new \InvalidArgumentException('Missing required field "password" for ' . static::class . '.'); - } - if (!array_key_exists('ssl', $data)) { - throw new \InvalidArgumentException('Missing required field "ssl" for ' . static::class . '.'); - } - if (!array_key_exists('engine', $data)) { - throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); - } - if (!array_key_exists('connectionString', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionString" for ' . static::class . '.'); - } return new static( branchId: $data['branchId'], diff --git a/src/Appwrite/Models/DedicatedDatabaseBranchList.php b/src/Appwrite/Models/DedicatedDatabaseBranchList.php index ad45dbb..4212a97 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranchList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranchList.php @@ -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('branches', $data)) { throw new \InvalidArgumentException('Missing required field "branches" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabaseExecution.php b/src/Appwrite/Models/DedicatedDatabaseExecution.php index ac2add7..12e5407 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExecution.php +++ b/src/Appwrite/Models/DedicatedDatabaseExecution.php @@ -38,24 +38,17 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('rows', $data)) { - throw new \InvalidArgumentException('Missing required field "rows" for ' . static::class . '.'); - } - if (!array_key_exists('rowCount', $data)) { - throw new \InvalidArgumentException('Missing required field "rowCount" for ' . static::class . '.'); - } + $data += [ + 'rows' => [], + 'rowCount' => 0, + 'durationMs' => 0, + 'truncated' => false, + 'bytes' => 0, + ]; + if (!array_key_exists('columns', $data)) { throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); } - if (!array_key_exists('durationMs', $data)) { - throw new \InvalidArgumentException('Missing required field "durationMs" for ' . static::class . '.'); - } - if (!array_key_exists('truncated', $data)) { - throw new \InvalidArgumentException('Missing required field "truncated" for ' . static::class . '.'); - } - if (!array_key_exists('bytes', $data)) { - throw new \InvalidArgumentException('Missing required field "bytes" for ' . static::class . '.'); - } return new static( rows: $data['rows'], diff --git a/src/Appwrite/Models/DedicatedDatabaseExecutionColumn.php b/src/Appwrite/Models/DedicatedDatabaseExecutionColumn.php index 5ad74e1..74c1c36 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExecutionColumn.php +++ b/src/Appwrite/Models/DedicatedDatabaseExecutionColumn.php @@ -30,12 +30,10 @@ 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('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + 'name' => "", + 'type' => "", + ]; return new static( name: $data['name'], diff --git a/src/Appwrite/Models/DedicatedDatabaseExtensions.php b/src/Appwrite/Models/DedicatedDatabaseExtensions.php index 6647bf5..b153213 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExtensions.php +++ b/src/Appwrite/Models/DedicatedDatabaseExtensions.php @@ -32,12 +32,11 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('installed', $data)) { - throw new \InvalidArgumentException('Missing required field "installed" for ' . static::class . '.'); - } - if (!array_key_exists('available', $data)) { - throw new \InvalidArgumentException('Missing required field "available" for ' . static::class . '.'); - } + $data += [ + 'installed' => [], + 'available' => [], + ]; + if (!array_key_exists('metadata', $data)) { throw new \InvalidArgumentException('Missing required field "metadata" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabaseList.php b/src/Appwrite/Models/DedicatedDatabaseList.php index 8c3c246..a9784de 100644 --- a/src/Appwrite/Models/DedicatedDatabaseList.php +++ b/src/Appwrite/Models/DedicatedDatabaseList.php @@ -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('databases', $data)) { throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabaseMember.php b/src/Appwrite/Models/DedicatedDatabaseMember.php index 990c909..c8be722 100644 --- a/src/Appwrite/Models/DedicatedDatabaseMember.php +++ b/src/Appwrite/Models/DedicatedDatabaseMember.php @@ -36,15 +36,11 @@ 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('role', $data)) { - throw new \InvalidArgumentException('Missing required field "role" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'role' => "unknown", + 'status' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DedicatedDatabaseOperation.php b/src/Appwrite/Models/DedicatedDatabaseOperation.php index 228f5b5..035dfc5 100644 --- a/src/Appwrite/Models/DedicatedDatabaseOperation.php +++ b/src/Appwrite/Models/DedicatedDatabaseOperation.php @@ -48,30 +48,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('attempts', $data)) { - throw new \InvalidArgumentException('Missing required field "attempts" for ' . static::class . '.'); - } - if (!array_key_exists('errorCode', $data)) { - throw new \InvalidArgumentException('Missing required field "errorCode" for ' . static::class . '.'); - } - if (!array_key_exists('errorMessage', $data)) { - throw new \InvalidArgumentException('Missing required field "errorMessage" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'databaseId' => "", + 'type' => "", + 'status' => "", + 'attempts' => 0, + 'errorCode' => "", + 'errorMessage' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DedicatedDatabaseOperationList.php b/src/Appwrite/Models/DedicatedDatabaseOperationList.php index 9802ab1..7710285 100644 --- a/src/Appwrite/Models/DedicatedDatabaseOperationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseOperationList.php @@ -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('operations', $data)) { throw new \InvalidArgumentException('Missing required field "operations" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabasePITRWindows.php b/src/Appwrite/Models/DedicatedDatabasePITRWindows.php index adb5bfc..e16d3ab 100644 --- a/src/Appwrite/Models/DedicatedDatabasePITRWindows.php +++ b/src/Appwrite/Models/DedicatedDatabasePITRWindows.php @@ -30,12 +30,10 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('earliest', $data)) { - throw new \InvalidArgumentException('Missing required field "earliest" for ' . static::class . '.'); - } - if (!array_key_exists('latest', $data)) { - throw new \InvalidArgumentException('Missing required field "latest" for ' . static::class . '.'); - } + $data += [ + 'earliest' => "", + 'latest' => "", + ]; return new static( earliest: $data['earliest'], diff --git a/src/Appwrite/Models/DedicatedDatabasePooler.php b/src/Appwrite/Models/DedicatedDatabasePooler.php index 0bcc77d..f0998f5 100644 --- a/src/Appwrite/Models/DedicatedDatabasePooler.php +++ b/src/Appwrite/Models/DedicatedDatabasePooler.php @@ -46,36 +46,18 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('mode', $data)) { - throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); - } - if (!array_key_exists('maxConnections', $data)) { - throw new \InvalidArgumentException('Missing required field "maxConnections" for ' . static::class . '.'); - } - if (!array_key_exists('defaultPoolSize', $data)) { - throw new \InvalidArgumentException('Missing required field "defaultPoolSize" for ' . static::class . '.'); - } - if (!array_key_exists('port', $data)) { - throw new \InvalidArgumentException('Missing required field "port" for ' . static::class . '.'); - } - if (!array_key_exists('readWriteSplitting', $data)) { - throw new \InvalidArgumentException('Missing required field "readWriteSplitting" for ' . static::class . '.'); - } - if (!array_key_exists('poolerCpuRequest', $data)) { - throw new \InvalidArgumentException('Missing required field "poolerCpuRequest" for ' . static::class . '.'); - } - if (!array_key_exists('poolerCpuLimit', $data)) { - throw new \InvalidArgumentException('Missing required field "poolerCpuLimit" for ' . static::class . '.'); - } - if (!array_key_exists('poolerMemoryRequest', $data)) { - throw new \InvalidArgumentException('Missing required field "poolerMemoryRequest" for ' . static::class . '.'); - } - if (!array_key_exists('poolerMemoryLimit', $data)) { - throw new \InvalidArgumentException('Missing required field "poolerMemoryLimit" for ' . static::class . '.'); - } + $data += [ + 'enabled' => false, + 'mode' => "transaction", + 'maxConnections' => 100, + 'defaultPoolSize' => 20, + 'port' => 6432, + 'readWriteSplitting' => false, + 'poolerCpuRequest' => "", + 'poolerCpuLimit' => "", + 'poolerMemoryRequest' => "", + 'poolerMemoryLimit' => "", + ]; return new static( enabled: $data['enabled'], diff --git a/src/Appwrite/Models/DedicatedDatabaseReplicas.php b/src/Appwrite/Models/DedicatedDatabaseReplicas.php index 512864b..563630f 100644 --- a/src/Appwrite/Models/DedicatedDatabaseReplicas.php +++ b/src/Appwrite/Models/DedicatedDatabaseReplicas.php @@ -42,21 +42,14 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('replicas', $data)) { - throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); - } - if (!array_key_exists('syncMode', $data)) { - throw new \InvalidArgumentException('Missing required field "syncMode" for ' . static::class . '.'); - } - if (!array_key_exists('syncDegraded', $data)) { - throw new \InvalidArgumentException('Missing required field "syncDegraded" for ' . static::class . '.'); - } - if (!array_key_exists('syncAcknowledgements', $data)) { - throw new \InvalidArgumentException('Missing required field "syncAcknowledgements" for ' . static::class . '.'); - } - if (!array_key_exists('syncStandbyCount', $data)) { - throw new \InvalidArgumentException('Missing required field "syncStandbyCount" for ' . static::class . '.'); - } + $data += [ + 'replicas' => 0, + 'syncMode' => "async", + 'syncDegraded' => false, + 'syncAcknowledgements' => 0, + 'syncStandbyCount' => 0, + ]; + if (!array_key_exists('members', $data)) { throw new \InvalidArgumentException('Missing required field "members" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabaseRestoration.php b/src/Appwrite/Models/DedicatedDatabaseRestoration.php index 9866762..0292702 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestoration.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestoration.php @@ -50,30 +50,22 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'databaseId' => "", + 'projectId' => "", + 'type' => "backup", + 'status' => "pending", + 'error' => "", + ]; + if (!array_key_exists('sourceDatabaseId', $data)) { throw new \InvalidArgumentException('Missing required field "sourceDatabaseId" for ' . static::class . '.'); } - if (!array_key_exists('projectId', $data)) { - throw new \InvalidArgumentException('Missing required field "projectId" for ' . static::class . '.'); - } if (!array_key_exists('backupId', $data)) { throw new \InvalidArgumentException('Missing required field "backupId" for ' . static::class . '.'); } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } if (!array_key_exists('targetTime', $data)) { throw new \InvalidArgumentException('Missing required field "targetTime" for ' . static::class . '.'); } @@ -83,9 +75,6 @@ public static function from(array $data): static if (!array_key_exists('completedAt', $data)) { throw new \InvalidArgumentException('Missing required field "completedAt" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php index daf3405..b4491a4 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php @@ -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('restorations', $data)) { throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecification.php b/src/Appwrite/Models/DedicatedDatabaseSpecification.php index d73bc7e..1768bfd 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecification.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecification.php @@ -44,33 +44,17 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('slug', $data)) { - throw new \InvalidArgumentException('Missing required field "slug" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('price', $data)) { - throw new \InvalidArgumentException('Missing required field "price" for ' . static::class . '.'); - } - if (!array_key_exists('cpu', $data)) { - throw new \InvalidArgumentException('Missing required field "cpu" for ' . static::class . '.'); - } - if (!array_key_exists('memory', $data)) { - throw new \InvalidArgumentException('Missing required field "memory" for ' . static::class . '.'); - } - if (!array_key_exists('maxConnections', $data)) { - throw new \InvalidArgumentException('Missing required field "maxConnections" for ' . static::class . '.'); - } - if (!array_key_exists('includedStorage', $data)) { - throw new \InvalidArgumentException('Missing required field "includedStorage" for ' . static::class . '.'); - } - if (!array_key_exists('includedBandwidth', $data)) { - throw new \InvalidArgumentException('Missing required field "includedBandwidth" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + 'slug' => "", + 'name' => "", + 'price' => 0, + 'cpu' => 0, + 'memory' => 0, + 'maxConnections' => 0, + 'includedStorage' => 0, + 'includedBandwidth' => 0, + 'enabled' => false, + ]; return new static( slug: $data['slug'], diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php index a223990..9ac1206 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php @@ -32,12 +32,13 @@ public function __construct( */ public static function from(array $data): static { + $data += [ + 'total' => 0, + ]; + if (!array_key_exists('specifications', $data)) { throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); } - if (!array_key_exists('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } if (!array_key_exists('pricing', $data)) { throw new \InvalidArgumentException('Missing required field "pricing" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Deployment.php b/src/Appwrite/Models/Deployment.php index b4d00c6..c009925 100644 --- a/src/Appwrite/Models/Deployment.php +++ b/src/Appwrite/Models/Deployment.php @@ -82,87 +82,38 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('resourceId', $data)) { - throw new \InvalidArgumentException('Missing required field "resourceId" for ' . static::class . '.'); - } - if (!array_key_exists('resourceType', $data)) { - throw new \InvalidArgumentException('Missing required field "resourceType" for ' . static::class . '.'); - } - if (!array_key_exists('entrypoint', $data)) { - throw new \InvalidArgumentException('Missing required field "entrypoint" for ' . static::class . '.'); - } - if (!array_key_exists('sourceSize', $data)) { - throw new \InvalidArgumentException('Missing required field "sourceSize" for ' . static::class . '.'); - } - if (!array_key_exists('buildSize', $data)) { - throw new \InvalidArgumentException('Missing required field "buildSize" for ' . static::class . '.'); - } - if (!array_key_exists('totalSize', $data)) { - throw new \InvalidArgumentException('Missing required field "totalSize" for ' . static::class . '.'); - } - if (!array_key_exists('buildId', $data)) { - throw new \InvalidArgumentException('Missing required field "buildId" for ' . static::class . '.'); - } - if (!array_key_exists('activate', $data)) { - throw new \InvalidArgumentException('Missing required field "activate" for ' . static::class . '.'); - } - if (!array_key_exists('screenshotLight', $data)) { - throw new \InvalidArgumentException('Missing required field "screenshotLight" for ' . static::class . '.'); - } - if (!array_key_exists('screenshotDark', $data)) { - throw new \InvalidArgumentException('Missing required field "screenshotDark" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'type' => "", + 'resourceId' => "", + 'resourceType' => "", + 'entrypoint' => "", + 'sourceSize' => 0, + 'buildSize' => 0, + 'totalSize' => 0, + 'buildId' => "", + 'activate' => false, + 'screenshotLight' => "", + 'screenshotDark' => "", + 'buildLogs' => "", + 'buildDuration' => 0, + 'providerRepositoryName' => "", + 'providerRepositoryOwner' => "", + 'providerRepositoryUrl' => "", + 'providerCommitHash' => "", + 'providerCommitAuthorUrl' => "", + 'providerCommitAuthor' => "", + 'providerCommitMessage' => "", + 'providerCommitUrl' => "", + 'providerBranch' => "", + 'providerBranchUrl' => "", + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('buildLogs', $data)) { - throw new \InvalidArgumentException('Missing required field "buildLogs" for ' . static::class . '.'); - } - if (!array_key_exists('buildDuration', $data)) { - throw new \InvalidArgumentException('Missing required field "buildDuration" for ' . static::class . '.'); - } - if (!array_key_exists('providerRepositoryName', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRepositoryName" for ' . static::class . '.'); - } - if (!array_key_exists('providerRepositoryOwner', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRepositoryOwner" for ' . static::class . '.'); - } - if (!array_key_exists('providerRepositoryUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRepositoryUrl" for ' . static::class . '.'); - } - if (!array_key_exists('providerCommitHash', $data)) { - throw new \InvalidArgumentException('Missing required field "providerCommitHash" for ' . static::class . '.'); - } - if (!array_key_exists('providerCommitAuthorUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "providerCommitAuthorUrl" for ' . static::class . '.'); - } - if (!array_key_exists('providerCommitAuthor', $data)) { - throw new \InvalidArgumentException('Missing required field "providerCommitAuthor" for ' . static::class . '.'); - } - if (!array_key_exists('providerCommitMessage', $data)) { - throw new \InvalidArgumentException('Missing required field "providerCommitMessage" for ' . static::class . '.'); - } - if (!array_key_exists('providerCommitUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "providerCommitUrl" for ' . static::class . '.'); - } - if (!array_key_exists('providerBranch', $data)) { - throw new \InvalidArgumentException('Missing required field "providerBranch" for ' . static::class . '.'); - } - if (!array_key_exists('providerBranchUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "providerBranchUrl" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/DeploymentList.php b/src/Appwrite/Models/DeploymentList.php index 843c077..84e99d1 100644 --- a/src/Appwrite/Models/DeploymentList.php +++ b/src/Appwrite/Models/DeploymentList.php @@ -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('deployments', $data)) { throw new \InvalidArgumentException('Missing required field "deployments" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Document.php b/src/Appwrite/Models/Document.php index c02e196..b0cf5b9 100644 --- a/src/Appwrite/Models/Document.php +++ b/src/Appwrite/Models/Document.php @@ -42,24 +42,15 @@ 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('$sequence', $data)) { - throw new \InvalidArgumentException('Missing required field "$sequence" for ' . static::class . '.'); - } - if (!array_key_exists('$collectionId', $data)) { - throw new \InvalidArgumentException('Missing required field "$collectionId" for ' . static::class . '.'); - } - if (!array_key_exists('$databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "$databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$sequence' => "", + '$collectionId' => "", + '$databaseId' => "", + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/DocumentList.php b/src/Appwrite/Models/DocumentList.php index 23dfcea..8a34e49 100644 --- a/src/Appwrite/Models/DocumentList.php +++ b/src/Appwrite/Models/DocumentList.php @@ -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('documents', $data)) { throw new \InvalidArgumentException('Missing required field "documents" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/EmailTemplate.php b/src/Appwrite/Models/EmailTemplate.php index 6af65e2..ddf5354 100644 --- a/src/Appwrite/Models/EmailTemplate.php +++ b/src/Appwrite/Models/EmailTemplate.php @@ -42,30 +42,16 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('templateId', $data)) { - throw new \InvalidArgumentException('Missing required field "templateId" for ' . static::class . '.'); - } - if (!array_key_exists('locale', $data)) { - throw new \InvalidArgumentException('Missing required field "locale" for ' . static::class . '.'); - } - if (!array_key_exists('message', $data)) { - throw new \InvalidArgumentException('Missing required field "message" for ' . static::class . '.'); - } - if (!array_key_exists('senderName', $data)) { - throw new \InvalidArgumentException('Missing required field "senderName" for ' . static::class . '.'); - } - if (!array_key_exists('senderEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "senderEmail" for ' . static::class . '.'); - } - if (!array_key_exists('replyToEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "replyToEmail" for ' . static::class . '.'); - } - if (!array_key_exists('replyToName', $data)) { - throw new \InvalidArgumentException('Missing required field "replyToName" for ' . static::class . '.'); - } - if (!array_key_exists('subject', $data)) { - throw new \InvalidArgumentException('Missing required field "subject" for ' . static::class . '.'); - } + $data += [ + 'templateId' => "", + 'locale' => "", + 'message' => "", + 'senderName' => "", + 'senderEmail' => "", + 'replyToEmail' => "", + 'replyToName' => "", + 'subject' => "", + ]; return new static( templateId: $data['templateId'], diff --git a/src/Appwrite/Models/EmailTemplateList.php b/src/Appwrite/Models/EmailTemplateList.php index 0c2df1e..934220a 100644 --- a/src/Appwrite/Models/EmailTemplateList.php +++ b/src/Appwrite/Models/EmailTemplateList.php @@ -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('templates', $data)) { throw new \InvalidArgumentException('Missing required field "templates" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Embedding.php b/src/Appwrite/Models/Embedding.php index b68d820..161d29e 100644 --- a/src/Appwrite/Models/Embedding.php +++ b/src/Appwrite/Models/Embedding.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('model', $data)) { - throw new \InvalidArgumentException('Missing required field "model" for ' . static::class . '.'); - } - if (!array_key_exists('dimension', $data)) { - throw new \InvalidArgumentException('Missing required field "dimension" for ' . static::class . '.'); - } - if (!array_key_exists('embedding', $data)) { - throw new \InvalidArgumentException('Missing required field "embedding" for ' . static::class . '.'); - } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } + $data += [ + 'model' => "", + 'dimension' => 0, + 'embedding' => [], + 'error' => "", + ]; return new static( model: $data['model'], diff --git a/src/Appwrite/Models/EmbeddingList.php b/src/Appwrite/Models/EmbeddingList.php index 029d802..dde35f2 100644 --- a/src/Appwrite/Models/EmbeddingList.php +++ b/src/Appwrite/Models/EmbeddingList.php @@ -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('embeddings', $data)) { throw new \InvalidArgumentException('Missing required field "embeddings" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/EphemeralKey.php b/src/Appwrite/Models/EphemeralKey.php index a3823c4..0709c91 100644 --- a/src/Appwrite/Models/EphemeralKey.php +++ b/src/Appwrite/Models/EphemeralKey.php @@ -44,30 +44,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'expire' => "", + 'scopes' => [], + 'secret' => "", + 'accessedAt' => "", + ]; + if (!array_key_exists('sdks', $data)) { throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Execution.php b/src/Appwrite/Models/Execution.php index b95fab1..8ac7d6f 100644 --- a/src/Appwrite/Models/Execution.php +++ b/src/Appwrite/Models/Execution.php @@ -68,60 +68,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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'resourceId' => "", + 'resourceType' => "functions", + 'deploymentId' => "", + 'requestMethod' => "", + 'requestPath' => "", + 'responseStatusCode' => 0, + 'responseBody' => "", + 'logs' => "", + 'errors' => "", + 'duration' => 0, + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } - if (!array_key_exists('resourceId', $data)) { - throw new \InvalidArgumentException('Missing required field "resourceId" for ' . static::class . '.'); - } - if (!array_key_exists('resourceType', $data)) { - throw new \InvalidArgumentException('Missing required field "resourceType" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentId', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentId" for ' . static::class . '.'); - } if (!array_key_exists('trigger', $data)) { throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); } if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('requestMethod', $data)) { - throw new \InvalidArgumentException('Missing required field "requestMethod" for ' . static::class . '.'); - } - if (!array_key_exists('requestPath', $data)) { - throw new \InvalidArgumentException('Missing required field "requestPath" for ' . static::class . '.'); - } if (!array_key_exists('requestHeaders', $data)) { throw new \InvalidArgumentException('Missing required field "requestHeaders" for ' . static::class . '.'); } - if (!array_key_exists('responseStatusCode', $data)) { - throw new \InvalidArgumentException('Missing required field "responseStatusCode" for ' . static::class . '.'); - } - if (!array_key_exists('responseBody', $data)) { - throw new \InvalidArgumentException('Missing required field "responseBody" for ' . static::class . '.'); - } if (!array_key_exists('responseHeaders', $data)) { throw new \InvalidArgumentException('Missing required field "responseHeaders" for ' . static::class . '.'); } - if (!array_key_exists('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } - if (!array_key_exists('errors', $data)) { - throw new \InvalidArgumentException('Missing required field "errors" for ' . static::class . '.'); - } - if (!array_key_exists('duration', $data)) { - throw new \InvalidArgumentException('Missing required field "duration" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ExecutionList.php b/src/Appwrite/Models/ExecutionList.php index e2b8e14..ee91c28 100644 --- a/src/Appwrite/Models/ExecutionList.php +++ b/src/Appwrite/Models/ExecutionList.php @@ -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('executions', $data)) { throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/File.php b/src/Appwrite/Models/File.php index 2430452..7a0e989 100644 --- a/src/Appwrite/Models/File.php +++ b/src/Appwrite/Models/File.php @@ -58,54 +58,24 @@ 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('bucketId', $data)) { - throw new \InvalidArgumentException('Missing required field "bucketId" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('folder', $data)) { - throw new \InvalidArgumentException('Missing required field "folder" for ' . static::class . '.'); - } - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('signature', $data)) { - throw new \InvalidArgumentException('Missing required field "signature" for ' . static::class . '.'); - } - if (!array_key_exists('mimeType', $data)) { - throw new \InvalidArgumentException('Missing required field "mimeType" for ' . static::class . '.'); - } - if (!array_key_exists('sizeOriginal', $data)) { - throw new \InvalidArgumentException('Missing required field "sizeOriginal" for ' . static::class . '.'); - } - if (!array_key_exists('sizeActual', $data)) { - throw new \InvalidArgumentException('Missing required field "sizeActual" for ' . static::class . '.'); - } - if (!array_key_exists('chunksTotal', $data)) { - throw new \InvalidArgumentException('Missing required field "chunksTotal" for ' . static::class . '.'); - } - if (!array_key_exists('chunksUploaded', $data)) { - throw new \InvalidArgumentException('Missing required field "chunksUploaded" for ' . static::class . '.'); - } - if (!array_key_exists('encryption', $data)) { - throw new \InvalidArgumentException('Missing required field "encryption" for ' . static::class . '.'); - } - if (!array_key_exists('compression', $data)) { - throw new \InvalidArgumentException('Missing required field "compression" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'bucketId' => "", + '$createdAt' => "", + '$updatedAt' => "", + '$permissions' => [], + 'name' => "", + 'folder' => "", + 'key' => "", + 'signature' => "", + 'mimeType' => "", + 'sizeOriginal' => 0, + 'sizeActual' => 0, + 'chunksTotal' => 0, + 'chunksUploaded' => 0, + 'encryption' => false, + 'compression' => "none", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/FileList.php b/src/Appwrite/Models/FileList.php index 178e2d6..f934a39 100644 --- a/src/Appwrite/Models/FileList.php +++ b/src/Appwrite/Models/FileList.php @@ -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('files', $data)) { throw new \InvalidArgumentException('Missing required field "files" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Framework.php b/src/Appwrite/Models/Framework.php index ea4376e..7c3efaf 100644 --- a/src/Appwrite/Models/Framework.php +++ b/src/Appwrite/Models/Framework.php @@ -36,15 +36,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('buildRuntime', $data)) { - throw new \InvalidArgumentException('Missing required field "buildRuntime" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'name' => "", + 'buildRuntime' => "", + ]; + if (!array_key_exists('runtimes', $data)) { throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/FrameworkAdapter.php b/src/Appwrite/Models/FrameworkAdapter.php index 82727ba..d4e8d01 100644 --- a/src/Appwrite/Models/FrameworkAdapter.php +++ b/src/Appwrite/Models/FrameworkAdapter.php @@ -36,18 +36,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('installCommand', $data)) { - throw new \InvalidArgumentException('Missing required field "installCommand" for ' . static::class . '.'); - } - if (!array_key_exists('buildCommand', $data)) { - throw new \InvalidArgumentException('Missing required field "buildCommand" for ' . static::class . '.'); - } - if (!array_key_exists('outputDirectory', $data)) { - throw new \InvalidArgumentException('Missing required field "outputDirectory" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'installCommand' => "", + 'buildCommand' => "", + 'outputDirectory' => "", + ]; return new static( key: $data['key'], diff --git a/src/Appwrite/Models/FrameworkList.php b/src/Appwrite/Models/FrameworkList.php index becb9ef..8188732 100644 --- a/src/Appwrite/Models/FrameworkList.php +++ b/src/Appwrite/Models/FrameworkList.php @@ -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('frameworks', $data)) { throw new \InvalidArgumentException('Missing required field "frameworks" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/FunctionList.php b/src/Appwrite/Models/FunctionList.php index 6127a13..e5f38db 100644 --- a/src/Appwrite/Models/FunctionList.php +++ b/src/Appwrite/Models/FunctionList.php @@ -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('functions', $data)) { throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/FunctionModel.php b/src/Appwrite/Models/FunctionModel.php index c661b8b..a6fbc21 100644 --- a/src/Appwrite/Models/FunctionModel.php +++ b/src/Appwrite/Models/FunctionModel.php @@ -92,102 +92,43 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('execute', $data)) { - throw new \InvalidArgumentException('Missing required field "execute" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('live', $data)) { - throw new \InvalidArgumentException('Missing required field "live" for ' . static::class . '.'); - } - if (!array_key_exists('logging', $data)) { - throw new \InvalidArgumentException('Missing required field "logging" for ' . static::class . '.'); - } - if (!array_key_exists('runtime', $data)) { - throw new \InvalidArgumentException('Missing required field "runtime" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentRetention', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentRetention" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentId', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentId" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentCreatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentCreatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('latestDeploymentId', $data)) { - throw new \InvalidArgumentException('Missing required field "latestDeploymentId" for ' . static::class . '.'); - } - if (!array_key_exists('latestDeploymentCreatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "latestDeploymentCreatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('latestDeploymentStatus', $data)) { - throw new \InvalidArgumentException('Missing required field "latestDeploymentStatus" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'execute' => [], + 'name' => "", + 'enabled' => true, + 'live' => true, + 'logging' => true, + 'runtime' => "", + 'deploymentRetention' => 0, + 'deploymentId' => "", + 'deploymentCreatedAt' => "", + 'latestDeploymentId' => "", + 'latestDeploymentCreatedAt' => "", + 'latestDeploymentStatus' => "", + 'scopes' => [], + 'events' => [], + 'schedule' => "", + 'timeout' => 15, + 'entrypoint' => "", + 'commands' => "", + 'version' => "v5", + 'installationId' => "", + 'providerRepositoryId' => "", + 'providerBranch' => "", + 'providerRootDirectory' => "", + 'providerSilentMode' => false, + 'providerBranches' => [], + 'providerPaths' => [], + 'buildSpecification' => "s-1vcpu-512mb", + 'runtimeSpecification' => "s-1vcpu-512mb", + ]; + if (!array_key_exists('vars', $data)) { throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); } - if (!array_key_exists('events', $data)) { - throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.'); - } - if (!array_key_exists('schedule', $data)) { - throw new \InvalidArgumentException('Missing required field "schedule" for ' . static::class . '.'); - } - if (!array_key_exists('timeout', $data)) { - throw new \InvalidArgumentException('Missing required field "timeout" for ' . static::class . '.'); - } - if (!array_key_exists('entrypoint', $data)) { - throw new \InvalidArgumentException('Missing required field "entrypoint" for ' . static::class . '.'); - } - if (!array_key_exists('commands', $data)) { - throw new \InvalidArgumentException('Missing required field "commands" for ' . static::class . '.'); - } - if (!array_key_exists('version', $data)) { - throw new \InvalidArgumentException('Missing required field "version" for ' . static::class . '.'); - } - if (!array_key_exists('installationId', $data)) { - throw new \InvalidArgumentException('Missing required field "installationId" for ' . static::class . '.'); - } - if (!array_key_exists('providerRepositoryId', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRepositoryId" for ' . static::class . '.'); - } - if (!array_key_exists('providerBranch', $data)) { - throw new \InvalidArgumentException('Missing required field "providerBranch" for ' . static::class . '.'); - } - if (!array_key_exists('providerRootDirectory', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRootDirectory" for ' . static::class . '.'); - } - if (!array_key_exists('providerSilentMode', $data)) { - throw new \InvalidArgumentException('Missing required field "providerSilentMode" for ' . static::class . '.'); - } - if (!array_key_exists('providerBranches', $data)) { - throw new \InvalidArgumentException('Missing required field "providerBranches" for ' . static::class . '.'); - } - if (!array_key_exists('providerPaths', $data)) { - throw new \InvalidArgumentException('Missing required field "providerPaths" for ' . static::class . '.'); - } - if (!array_key_exists('buildSpecification', $data)) { - throw new \InvalidArgumentException('Missing required field "buildSpecification" for ' . static::class . '.'); - } - if (!array_key_exists('runtimeSpecification', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimeSpecification" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Headers.php b/src/Appwrite/Models/Headers.php index 548d7cf..a7573ae 100644 --- a/src/Appwrite/Models/Headers.php +++ b/src/Appwrite/Models/Headers.php @@ -30,12 +30,10 @@ 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('value', $data)) { - throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.'); - } + $data += [ + 'name' => "", + 'value' => "", + ]; return new static( name: $data['name'], diff --git a/src/Appwrite/Models/Identity.php b/src/Appwrite/Models/Identity.php index 7ce5e10..82b4c28 100644 --- a/src/Appwrite/Models/Identity.php +++ b/src/Appwrite/Models/Identity.php @@ -46,36 +46,18 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('provider', $data)) { - throw new \InvalidArgumentException('Missing required field "provider" for ' . static::class . '.'); - } - if (!array_key_exists('providerUid', $data)) { - throw new \InvalidArgumentException('Missing required field "providerUid" for ' . static::class . '.'); - } - if (!array_key_exists('providerEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "providerEmail" for ' . static::class . '.'); - } - if (!array_key_exists('providerAccessToken', $data)) { - throw new \InvalidArgumentException('Missing required field "providerAccessToken" for ' . static::class . '.'); - } - if (!array_key_exists('providerAccessTokenExpiry', $data)) { - throw new \InvalidArgumentException('Missing required field "providerAccessTokenExpiry" for ' . static::class . '.'); - } - if (!array_key_exists('providerRefreshToken', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRefreshToken" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'userId' => "", + 'provider' => "", + 'providerUid' => "", + 'providerEmail' => "", + 'providerAccessToken' => "", + 'providerAccessTokenExpiry' => "", + 'providerRefreshToken' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/IdentityList.php b/src/Appwrite/Models/IdentityList.php index f5b571b..f16cced 100644 --- a/src/Appwrite/Models/IdentityList.php +++ b/src/Appwrite/Models/IdentityList.php @@ -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('identities', $data)) { throw new \InvalidArgumentException('Missing required field "identities" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Index.php b/src/Appwrite/Models/Index.php index 4fb538a..ce47bac 100644 --- a/src/Appwrite/Models/Index.php +++ b/src/Appwrite/Models/Index.php @@ -48,33 +48,20 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'key' => "", + 'type' => "", + 'error' => "", + 'attributes' => [], + 'lengths' => [], + ]; + if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('error', $data)) { - throw new \InvalidArgumentException('Missing required field "error" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('lengths', $data)) { - throw new \InvalidArgumentException('Missing required field "lengths" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/IndexList.php b/src/Appwrite/Models/IndexList.php index 37a7c03..4f2fbb8 100644 --- a/src/Appwrite/Models/IndexList.php +++ b/src/Appwrite/Models/IndexList.php @@ -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('indexes', $data)) { throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Insight.php b/src/Appwrite/Models/Insight.php index 0692f83..b5b50f9 100644 --- a/src/Appwrite/Models/Insight.php +++ b/src/Appwrite/Models/Insight.php @@ -60,45 +60,22 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('reportId', $data)) { - throw new \InvalidArgumentException('Missing required field "reportId" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('severity', $data)) { - throw new \InvalidArgumentException('Missing required field "severity" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" 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('parentResourceType', $data)) { - throw new \InvalidArgumentException('Missing required field "parentResourceType" for ' . static::class . '.'); - } - if (!array_key_exists('parentResourceId', $data)) { - throw new \InvalidArgumentException('Missing required field "parentResourceId" for ' . static::class . '.'); - } - if (!array_key_exists('title', $data)) { - throw new \InvalidArgumentException('Missing required field "title" for ' . static::class . '.'); - } - if (!array_key_exists('summary', $data)) { - throw new \InvalidArgumentException('Missing required field "summary" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'reportId' => "", + 'type' => "", + 'severity' => "info", + 'status' => "active", + 'resourceType' => "", + 'resourceId' => "", + 'parentResourceType' => "", + 'parentResourceId' => "", + 'title' => "", + 'summary' => "", + ]; + if (!array_key_exists('ctas', $data)) { throw new \InvalidArgumentException('Missing required field "ctas" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/InsightCTA.php b/src/Appwrite/Models/InsightCTA.php index 303aae5..4513aba 100644 --- a/src/Appwrite/Models/InsightCTA.php +++ b/src/Appwrite/Models/InsightCTA.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('label', $data)) { - throw new \InvalidArgumentException('Missing required field "label" for ' . static::class . '.'); - } - if (!array_key_exists('service', $data)) { - throw new \InvalidArgumentException('Missing required field "service" for ' . static::class . '.'); - } - if (!array_key_exists('method', $data)) { - throw new \InvalidArgumentException('Missing required field "method" for ' . static::class . '.'); - } - if (!array_key_exists('params', $data)) { - throw new \InvalidArgumentException('Missing required field "params" for ' . static::class . '.'); - } + $data += [ + 'label' => "", + 'service' => "", + 'method' => "", + 'params' => [], + ]; return new static( label: $data['label'], diff --git a/src/Appwrite/Models/InsightList.php b/src/Appwrite/Models/InsightList.php index c535a6e..dfa3e4a 100644 --- a/src/Appwrite/Models/InsightList.php +++ b/src/Appwrite/Models/InsightList.php @@ -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('insights', $data)) { throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Jwt.php b/src/Appwrite/Models/Jwt.php index 6c544ee..461f1fc 100644 --- a/src/Appwrite/Models/Jwt.php +++ b/src/Appwrite/Models/Jwt.php @@ -28,9 +28,9 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('jwt', $data)) { - throw new \InvalidArgumentException('Missing required field "jwt" for ' . static::class . '.'); - } + $data += [ + 'jwt' => "", + ]; return new static( jwt: $data['jwt'] diff --git a/src/Appwrite/Models/Key.php b/src/Appwrite/Models/Key.php index 3f957a1..216deb8 100644 --- a/src/Appwrite/Models/Key.php +++ b/src/Appwrite/Models/Key.php @@ -44,30 +44,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'expire' => "", + 'scopes' => [], + 'secret' => "", + 'accessedAt' => "", + ]; + if (!array_key_exists('sdks', $data)) { throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/KeyList.php b/src/Appwrite/Models/KeyList.php index e17d476..042450f 100644 --- a/src/Appwrite/Models/KeyList.php +++ b/src/Appwrite/Models/KeyList.php @@ -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('keys', $data)) { throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Language.php b/src/Appwrite/Models/Language.php index 8c3b18b..51c8a8d 100644 --- a/src/Appwrite/Models/Language.php +++ b/src/Appwrite/Models/Language.php @@ -32,15 +32,11 @@ 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('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } - if (!array_key_exists('nativeName', $data)) { - throw new \InvalidArgumentException('Missing required field "nativeName" for ' . static::class . '.'); - } + $data += [ + 'name' => "", + 'code' => "", + 'nativeName' => "", + ]; return new static( name: $data['name'], diff --git a/src/Appwrite/Models/LanguageList.php b/src/Appwrite/Models/LanguageList.php index fb46cae..6a57c4b 100644 --- a/src/Appwrite/Models/LanguageList.php +++ b/src/Appwrite/Models/LanguageList.php @@ -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('languages', $data)) { throw new \InvalidArgumentException('Missing required field "languages" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Locale.php b/src/Appwrite/Models/Locale.php index 55c2ba9..247a85f 100644 --- a/src/Appwrite/Models/Locale.php +++ b/src/Appwrite/Models/Locale.php @@ -62,27 +62,15 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('ip', $data)) { - throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.'); - } - if (!array_key_exists('countryCode', $data)) { - throw new \InvalidArgumentException('Missing required field "countryCode" 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('continent', $data)) { - throw new \InvalidArgumentException('Missing required field "continent" for ' . static::class . '.'); - } - if (!array_key_exists('eu', $data)) { - throw new \InvalidArgumentException('Missing required field "eu" for ' . static::class . '.'); - } - if (!array_key_exists('currency', $data)) { - throw new \InvalidArgumentException('Missing required field "currency" for ' . static::class . '.'); - } + $data += [ + 'ip' => "", + 'countryCode' => "", + 'country' => "", + 'continentCode' => "", + 'continent' => "", + 'eu' => false, + 'currency' => "", + ]; return new static( ip: $data['ip'], diff --git a/src/Appwrite/Models/LocaleCode.php b/src/Appwrite/Models/LocaleCode.php index 4469904..2b44c41 100644 --- a/src/Appwrite/Models/LocaleCode.php +++ b/src/Appwrite/Models/LocaleCode.php @@ -30,12 +30,10 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + 'code' => "", + 'name' => "", + ]; return new static( code: $data['code'], diff --git a/src/Appwrite/Models/LocaleCodeList.php b/src/Appwrite/Models/LocaleCodeList.php index c2b2a62..59223a6 100644 --- a/src/Appwrite/Models/LocaleCodeList.php +++ b/src/Appwrite/Models/LocaleCodeList.php @@ -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('localeCodes', $data)) { throw new \InvalidArgumentException('Missing required field "localeCodes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Membership.php b/src/Appwrite/Models/Membership.php index 0887a74..f3d01d2 100644 --- a/src/Appwrite/Models/Membership.php +++ b/src/Appwrite/Models/Membership.php @@ -56,51 +56,23 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('userEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "userEmail" for ' . static::class . '.'); - } - if (!array_key_exists('userPhone', $data)) { - throw new \InvalidArgumentException('Missing required field "userPhone" for ' . static::class . '.'); - } - if (!array_key_exists('teamId', $data)) { - throw new \InvalidArgumentException('Missing required field "teamId" for ' . static::class . '.'); - } - if (!array_key_exists('teamName', $data)) { - throw new \InvalidArgumentException('Missing required field "teamName" for ' . static::class . '.'); - } - if (!array_key_exists('invited', $data)) { - throw new \InvalidArgumentException('Missing required field "invited" for ' . static::class . '.'); - } - if (!array_key_exists('joined', $data)) { - throw new \InvalidArgumentException('Missing required field "joined" for ' . static::class . '.'); - } - if (!array_key_exists('confirm', $data)) { - throw new \InvalidArgumentException('Missing required field "confirm" for ' . static::class . '.'); - } - if (!array_key_exists('mfa', $data)) { - throw new \InvalidArgumentException('Missing required field "mfa" for ' . static::class . '.'); - } - if (!array_key_exists('userAccessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "userAccessedAt" for ' . static::class . '.'); - } - if (!array_key_exists('roles', $data)) { - throw new \InvalidArgumentException('Missing required field "roles" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'userId' => "", + 'userName' => "", + 'userEmail' => "", + 'userPhone' => "", + 'teamId' => "", + 'teamName' => "", + 'invited' => "", + 'joined' => "", + 'confirm' => false, + 'mfa' => false, + 'userAccessedAt' => "", + 'roles' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/MembershipList.php b/src/Appwrite/Models/MembershipList.php index 713ff2c..4852916 100644 --- a/src/Appwrite/Models/MembershipList.php +++ b/src/Appwrite/Models/MembershipList.php @@ -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('memberships', $data)) { throw new \InvalidArgumentException('Missing required field "memberships" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Message.php b/src/Appwrite/Models/Message.php index 0a2d84b..267901b 100644 --- a/src/Appwrite/Models/Message.php +++ b/src/Appwrite/Models/Message.php @@ -54,18 +54,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('providerType', $data)) { - throw new \InvalidArgumentException('Missing required field "providerType" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'providerType' => "", + 'deliveredTotal' => 0, + 'data' => [], + 'status' => "draft", + ]; + if (!array_key_exists('topics', $data)) { throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); } @@ -75,15 +73,6 @@ public static function from(array $data): static if (!array_key_exists('targets', $data)) { throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); } - if (!array_key_exists('deliveredTotal', $data)) { - throw new \InvalidArgumentException('Missing required field "deliveredTotal" for ' . static::class . '.'); - } - if (!array_key_exists('data', $data)) { - throw new \InvalidArgumentException('Missing required field "data" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/MessageList.php b/src/Appwrite/Models/MessageList.php index de50511..ea36b3e 100644 --- a/src/Appwrite/Models/MessageList.php +++ b/src/Appwrite/Models/MessageList.php @@ -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('messages', $data)) { throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/MfaChallenge.php b/src/Appwrite/Models/MfaChallenge.php index cf630a6..ea24047 100644 --- a/src/Appwrite/Models/MfaChallenge.php +++ b/src/Appwrite/Models/MfaChallenge.php @@ -34,18 +34,12 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'expire' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/MfaChallengeSecret.php b/src/Appwrite/Models/MfaChallengeSecret.php index d2eabe8..18615db 100644 --- a/src/Appwrite/Models/MfaChallengeSecret.php +++ b/src/Appwrite/Models/MfaChallengeSecret.php @@ -36,21 +36,13 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'expire' => "", + 'code' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/MfaFactors.php b/src/Appwrite/Models/MfaFactors.php index 638840d..5b16ccf 100644 --- a/src/Appwrite/Models/MfaFactors.php +++ b/src/Appwrite/Models/MfaFactors.php @@ -36,21 +36,13 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('totp', $data)) { - throw new \InvalidArgumentException('Missing required field "totp" for ' . static::class . '.'); - } - if (!array_key_exists('phone', $data)) { - throw new \InvalidArgumentException('Missing required field "phone" for ' . static::class . '.'); - } - if (!array_key_exists('email', $data)) { - throw new \InvalidArgumentException('Missing required field "email" for ' . static::class . '.'); - } - if (!array_key_exists('recoveryCode', $data)) { - throw new \InvalidArgumentException('Missing required field "recoveryCode" for ' . static::class . '.'); - } - if (!array_key_exists('custom', $data)) { - throw new \InvalidArgumentException('Missing required field "custom" for ' . static::class . '.'); - } + $data += [ + 'totp' => false, + 'phone' => false, + 'email' => false, + 'recoveryCode' => false, + 'custom' => false, + ]; return new static( totp: $data['totp'], diff --git a/src/Appwrite/Models/MfaRecoveryCodes.php b/src/Appwrite/Models/MfaRecoveryCodes.php index ea9e553..e9ce803 100644 --- a/src/Appwrite/Models/MfaRecoveryCodes.php +++ b/src/Appwrite/Models/MfaRecoveryCodes.php @@ -28,9 +28,9 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('recoveryCodes', $data)) { - throw new \InvalidArgumentException('Missing required field "recoveryCodes" for ' . static::class . '.'); - } + $data += [ + 'recoveryCodes' => [], + ]; return new static( recoveryCodes: $data['recoveryCodes'] diff --git a/src/Appwrite/Models/MfaType.php b/src/Appwrite/Models/MfaType.php index f409759..65ba2e2 100644 --- a/src/Appwrite/Models/MfaType.php +++ b/src/Appwrite/Models/MfaType.php @@ -30,12 +30,10 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('uri', $data)) { - throw new \InvalidArgumentException('Missing required field "uri" for ' . static::class . '.'); - } + $data += [ + 'secret' => "", + 'uri' => "", + ]; return new static( secret: $data['secret'], diff --git a/src/Appwrite/Models/MockNumber.php b/src/Appwrite/Models/MockNumber.php index 1ef7999..21eab3d 100644 --- a/src/Appwrite/Models/MockNumber.php +++ b/src/Appwrite/Models/MockNumber.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('number', $data)) { - throw new \InvalidArgumentException('Missing required field "number" for ' . static::class . '.'); - } - if (!array_key_exists('otp', $data)) { - throw new \InvalidArgumentException('Missing required field "otp" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + 'number' => "", + 'otp' => "", + '$createdAt' => "", + '$updatedAt' => "", + ]; return new static( number: $data['number'], diff --git a/src/Appwrite/Models/MockNumberList.php b/src/Appwrite/Models/MockNumberList.php index 106ce4e..6029162 100644 --- a/src/Appwrite/Models/MockNumberList.php +++ b/src/Appwrite/Models/MockNumberList.php @@ -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('mockNumbers', $data)) { throw new \InvalidArgumentException('Missing required field "mockNumbers" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/OAuth2Amazon.php b/src/Appwrite/Models/OAuth2Amazon.php index 35884ef..8731981 100644 --- a/src/Appwrite/Models/OAuth2Amazon.php +++ b/src/Appwrite/Models/OAuth2Amazon.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Apple.php b/src/Appwrite/Models/OAuth2Apple.php index 778fed6..b885f0a 100644 --- a/src/Appwrite/Models/OAuth2Apple.php +++ b/src/Appwrite/Models/OAuth2Apple.php @@ -38,24 +38,14 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('serviceId', $data)) { - throw new \InvalidArgumentException('Missing required field "serviceId" for ' . static::class . '.'); - } - if (!array_key_exists('keyId', $data)) { - throw new \InvalidArgumentException('Missing required field "keyId" for ' . static::class . '.'); - } - if (!array_key_exists('teamId', $data)) { - throw new \InvalidArgumentException('Missing required field "teamId" for ' . static::class . '.'); - } - if (!array_key_exists('p8File', $data)) { - throw new \InvalidArgumentException('Missing required field "p8File" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'serviceId' => "", + 'keyId' => "", + 'teamId' => "", + 'p8File' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Appwrite.php b/src/Appwrite/Models/OAuth2Appwrite.php index 4c9c322..83d6c4b 100644 --- a/src/Appwrite/Models/OAuth2Appwrite.php +++ b/src/Appwrite/Models/OAuth2Appwrite.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Auth0.php b/src/Appwrite/Models/OAuth2Auth0.php index 0c47d14..46fe409 100644 --- a/src/Appwrite/Models/OAuth2Auth0.php +++ b/src/Appwrite/Models/OAuth2Auth0.php @@ -36,21 +36,13 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'endpoint' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Authentik.php b/src/Appwrite/Models/OAuth2Authentik.php index 2cc6a7d..92ad773 100644 --- a/src/Appwrite/Models/OAuth2Authentik.php +++ b/src/Appwrite/Models/OAuth2Authentik.php @@ -36,21 +36,13 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'endpoint' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Autodesk.php b/src/Appwrite/Models/OAuth2Autodesk.php index 5be4ac9..507431e 100644 --- a/src/Appwrite/Models/OAuth2Autodesk.php +++ b/src/Appwrite/Models/OAuth2Autodesk.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Bitbucket.php b/src/Appwrite/Models/OAuth2Bitbucket.php index bef81cf..be7dd75 100644 --- a/src/Appwrite/Models/OAuth2Bitbucket.php +++ b/src/Appwrite/Models/OAuth2Bitbucket.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'key' => "", + 'secret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Bitly.php b/src/Appwrite/Models/OAuth2Bitly.php index c315fbe..a2301f5 100644 --- a/src/Appwrite/Models/OAuth2Bitly.php +++ b/src/Appwrite/Models/OAuth2Bitly.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Box.php b/src/Appwrite/Models/OAuth2Box.php index 92adcd4..453b4e0 100644 --- a/src/Appwrite/Models/OAuth2Box.php +++ b/src/Appwrite/Models/OAuth2Box.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Cloudflare.php b/src/Appwrite/Models/OAuth2Cloudflare.php index 1d5e973..5048788 100644 --- a/src/Appwrite/Models/OAuth2Cloudflare.php +++ b/src/Appwrite/Models/OAuth2Cloudflare.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Dailymotion.php b/src/Appwrite/Models/OAuth2Dailymotion.php index 4fa4009..9845c93 100644 --- a/src/Appwrite/Models/OAuth2Dailymotion.php +++ b/src/Appwrite/Models/OAuth2Dailymotion.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('apiKey', $data)) { - throw new \InvalidArgumentException('Missing required field "apiKey" for ' . static::class . '.'); - } - if (!array_key_exists('apiSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "apiSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'apiKey' => "", + 'apiSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Discord.php b/src/Appwrite/Models/OAuth2Discord.php index 7b99a73..25a1794 100644 --- a/src/Appwrite/Models/OAuth2Discord.php +++ b/src/Appwrite/Models/OAuth2Discord.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Disqus.php b/src/Appwrite/Models/OAuth2Disqus.php index 0556012..47fd835 100644 --- a/src/Appwrite/Models/OAuth2Disqus.php +++ b/src/Appwrite/Models/OAuth2Disqus.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('publicKey', $data)) { - throw new \InvalidArgumentException('Missing required field "publicKey" for ' . static::class . '.'); - } - if (!array_key_exists('secretKey', $data)) { - throw new \InvalidArgumentException('Missing required field "secretKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'publicKey' => "", + 'secretKey' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Dropbox.php b/src/Appwrite/Models/OAuth2Dropbox.php index af477a6..695d689 100644 --- a/src/Appwrite/Models/OAuth2Dropbox.php +++ b/src/Appwrite/Models/OAuth2Dropbox.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('appKey', $data)) { - throw new \InvalidArgumentException('Missing required field "appKey" for ' . static::class . '.'); - } - if (!array_key_exists('appSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "appSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'appKey' => "", + 'appSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Etsy.php b/src/Appwrite/Models/OAuth2Etsy.php index 5b8242d..85d3a74 100644 --- a/src/Appwrite/Models/OAuth2Etsy.php +++ b/src/Appwrite/Models/OAuth2Etsy.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('keyString', $data)) { - throw new \InvalidArgumentException('Missing required field "keyString" for ' . static::class . '.'); - } - if (!array_key_exists('sharedSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "sharedSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'keyString' => "", + 'sharedSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Facebook.php b/src/Appwrite/Models/OAuth2Facebook.php index f391223..fc5f643 100644 --- a/src/Appwrite/Models/OAuth2Facebook.php +++ b/src/Appwrite/Models/OAuth2Facebook.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('appSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "appSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'appId' => "", + 'appSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Figma.php b/src/Appwrite/Models/OAuth2Figma.php index d3ee4b8..56854bb 100644 --- a/src/Appwrite/Models/OAuth2Figma.php +++ b/src/Appwrite/Models/OAuth2Figma.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2FusionAuth.php b/src/Appwrite/Models/OAuth2FusionAuth.php index 98c639b..4f5bb66 100644 --- a/src/Appwrite/Models/OAuth2FusionAuth.php +++ b/src/Appwrite/Models/OAuth2FusionAuth.php @@ -36,21 +36,13 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'endpoint' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Github.php b/src/Appwrite/Models/OAuth2Github.php index e9e939c..f8d91ef 100644 --- a/src/Appwrite/Models/OAuth2Github.php +++ b/src/Appwrite/Models/OAuth2Github.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Gitlab.php b/src/Appwrite/Models/OAuth2Gitlab.php index 8dd6302..7108b5d 100644 --- a/src/Appwrite/Models/OAuth2Gitlab.php +++ b/src/Appwrite/Models/OAuth2Gitlab.php @@ -36,21 +36,13 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('applicationId', $data)) { - throw new \InvalidArgumentException('Missing required field "applicationId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'applicationId' => "", + 'secret' => "", + 'endpoint' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Google.php b/src/Appwrite/Models/OAuth2Google.php index 687f946..a4f0a51 100644 --- a/src/Appwrite/Models/OAuth2Google.php +++ b/src/Appwrite/Models/OAuth2Google.php @@ -38,21 +38,13 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('prompt', $data)) { - throw new \InvalidArgumentException('Missing required field "prompt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'prompt' => ["consent"], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2HuggingFace.php b/src/Appwrite/Models/OAuth2HuggingFace.php index 44f6e01..9ae7711 100644 --- a/src/Appwrite/Models/OAuth2HuggingFace.php +++ b/src/Appwrite/Models/OAuth2HuggingFace.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Keycloak.php b/src/Appwrite/Models/OAuth2Keycloak.php index 4c149ca..62bad59 100644 --- a/src/Appwrite/Models/OAuth2Keycloak.php +++ b/src/Appwrite/Models/OAuth2Keycloak.php @@ -38,24 +38,14 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } - if (!array_key_exists('realmName', $data)) { - throw new \InvalidArgumentException('Missing required field "realmName" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'endpoint' => "", + 'realmName' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Kick.php b/src/Appwrite/Models/OAuth2Kick.php index e9bcba0..fa893a4 100644 --- a/src/Appwrite/Models/OAuth2Kick.php +++ b/src/Appwrite/Models/OAuth2Kick.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Linkedin.php b/src/Appwrite/Models/OAuth2Linkedin.php index 109d947..694e4ca 100644 --- a/src/Appwrite/Models/OAuth2Linkedin.php +++ b/src/Appwrite/Models/OAuth2Linkedin.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('primaryClientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "primaryClientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'primaryClientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Microsoft.php b/src/Appwrite/Models/OAuth2Microsoft.php index 4de9c59..5be06bc 100644 --- a/src/Appwrite/Models/OAuth2Microsoft.php +++ b/src/Appwrite/Models/OAuth2Microsoft.php @@ -36,21 +36,13 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('applicationId', $data)) { - throw new \InvalidArgumentException('Missing required field "applicationId" for ' . static::class . '.'); - } - if (!array_key_exists('applicationSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "applicationSecret" for ' . static::class . '.'); - } - if (!array_key_exists('tenant', $data)) { - throw new \InvalidArgumentException('Missing required field "tenant" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'applicationId' => "", + 'applicationSecret' => "", + 'tenant' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Notion.php b/src/Appwrite/Models/OAuth2Notion.php index 055b538..a55d3e7 100644 --- a/src/Appwrite/Models/OAuth2Notion.php +++ b/src/Appwrite/Models/OAuth2Notion.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('oauthClientId', $data)) { - throw new \InvalidArgumentException('Missing required field "oauthClientId" for ' . static::class . '.'); - } - if (!array_key_exists('oauthClientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "oauthClientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'oauthClientId' => "", + 'oauthClientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Oidc.php b/src/Appwrite/Models/OAuth2Oidc.php index f202101..3f4a32f 100644 --- a/src/Appwrite/Models/OAuth2Oidc.php +++ b/src/Appwrite/Models/OAuth2Oidc.php @@ -48,33 +48,17 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('wellKnownURL', $data)) { - throw new \InvalidArgumentException('Missing required field "wellKnownURL" for ' . static::class . '.'); - } - if (!array_key_exists('authorizationURL', $data)) { - throw new \InvalidArgumentException('Missing required field "authorizationURL" for ' . static::class . '.'); - } - if (!array_key_exists('tokenURL', $data)) { - throw new \InvalidArgumentException('Missing required field "tokenURL" for ' . static::class . '.'); - } - if (!array_key_exists('userInfoURL', $data)) { - throw new \InvalidArgumentException('Missing required field "userInfoURL" for ' . static::class . '.'); - } - if (!array_key_exists('prompt', $data)) { - throw new \InvalidArgumentException('Missing required field "prompt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'wellKnownURL' => "", + 'authorizationURL' => "", + 'tokenURL' => "", + 'userInfoURL' => "", + 'prompt' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Okta.php b/src/Appwrite/Models/OAuth2Okta.php index d2a252e..c43c638 100644 --- a/src/Appwrite/Models/OAuth2Okta.php +++ b/src/Appwrite/Models/OAuth2Okta.php @@ -38,24 +38,14 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } - if (!array_key_exists('domain', $data)) { - throw new \InvalidArgumentException('Missing required field "domain" for ' . static::class . '.'); - } - if (!array_key_exists('authorizationServerId', $data)) { - throw new \InvalidArgumentException('Missing required field "authorizationServerId" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + 'domain' => "", + 'authorizationServerId' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Paypal.php b/src/Appwrite/Models/OAuth2Paypal.php index db84e72..226724b 100644 --- a/src/Appwrite/Models/OAuth2Paypal.php +++ b/src/Appwrite/Models/OAuth2Paypal.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('secretKey', $data)) { - throw new \InvalidArgumentException('Missing required field "secretKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'secretKey' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Podio.php b/src/Appwrite/Models/OAuth2Podio.php index edecdfc..0e3c3ea 100644 --- a/src/Appwrite/Models/OAuth2Podio.php +++ b/src/Appwrite/Models/OAuth2Podio.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2ProviderList.php b/src/Appwrite/Models/OAuth2ProviderList.php index fb40014..bd2607b 100644 --- a/src/Appwrite/Models/OAuth2ProviderList.php +++ b/src/Appwrite/Models/OAuth2ProviderList.php @@ -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('providers', $data)) { throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/OAuth2Resend.php b/src/Appwrite/Models/OAuth2Resend.php index 5e741b9..3f695ff 100644 --- a/src/Appwrite/Models/OAuth2Resend.php +++ b/src/Appwrite/Models/OAuth2Resend.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Salesforce.php b/src/Appwrite/Models/OAuth2Salesforce.php index 02244d4..fd51b59 100644 --- a/src/Appwrite/Models/OAuth2Salesforce.php +++ b/src/Appwrite/Models/OAuth2Salesforce.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('customerKey', $data)) { - throw new \InvalidArgumentException('Missing required field "customerKey" for ' . static::class . '.'); - } - if (!array_key_exists('customerSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "customerSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'customerKey' => "", + 'customerSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Slack.php b/src/Appwrite/Models/OAuth2Slack.php index b53be94..069ab8d 100644 --- a/src/Appwrite/Models/OAuth2Slack.php +++ b/src/Appwrite/Models/OAuth2Slack.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Spotify.php b/src/Appwrite/Models/OAuth2Spotify.php index b03ad82..770dd7d 100644 --- a/src/Appwrite/Models/OAuth2Spotify.php +++ b/src/Appwrite/Models/OAuth2Spotify.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Stripe.php b/src/Appwrite/Models/OAuth2Stripe.php index d9fb9a2..08a80be 100644 --- a/src/Appwrite/Models/OAuth2Stripe.php +++ b/src/Appwrite/Models/OAuth2Stripe.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('apiSecretKey', $data)) { - throw new \InvalidArgumentException('Missing required field "apiSecretKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'apiSecretKey' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Tradeshift.php b/src/Appwrite/Models/OAuth2Tradeshift.php index d5becb0..16e5108 100644 --- a/src/Appwrite/Models/OAuth2Tradeshift.php +++ b/src/Appwrite/Models/OAuth2Tradeshift.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('oauth2ClientId', $data)) { - throw new \InvalidArgumentException('Missing required field "oauth2ClientId" for ' . static::class . '.'); - } - if (!array_key_exists('oauth2ClientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "oauth2ClientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'oauth2ClientId' => "", + 'oauth2ClientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Twitch.php b/src/Appwrite/Models/OAuth2Twitch.php index d931eac..e1f9b74 100644 --- a/src/Appwrite/Models/OAuth2Twitch.php +++ b/src/Appwrite/Models/OAuth2Twitch.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2WordPress.php b/src/Appwrite/Models/OAuth2WordPress.php index ce0d76f..70ad1eb 100644 --- a/src/Appwrite/Models/OAuth2WordPress.php +++ b/src/Appwrite/Models/OAuth2WordPress.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2X.php b/src/Appwrite/Models/OAuth2X.php index f197b67..1e31a1e 100644 --- a/src/Appwrite/Models/OAuth2X.php +++ b/src/Appwrite/Models/OAuth2X.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('customerKey', $data)) { - throw new \InvalidArgumentException('Missing required field "customerKey" for ' . static::class . '.'); - } - if (!array_key_exists('secretKey', $data)) { - throw new \InvalidArgumentException('Missing required field "secretKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'customerKey' => "", + 'secretKey' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Yahoo.php b/src/Appwrite/Models/OAuth2Yahoo.php index 1250e72..6cade4b 100644 --- a/src/Appwrite/Models/OAuth2Yahoo.php +++ b/src/Appwrite/Models/OAuth2Yahoo.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Yandex.php b/src/Appwrite/Models/OAuth2Yandex.php index 7610224..a16d5e3 100644 --- a/src/Appwrite/Models/OAuth2Yandex.php +++ b/src/Appwrite/Models/OAuth2Yandex.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Zoho.php b/src/Appwrite/Models/OAuth2Zoho.php index 47dfabf..354c071 100644 --- a/src/Appwrite/Models/OAuth2Zoho.php +++ b/src/Appwrite/Models/OAuth2Zoho.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/OAuth2Zoom.php b/src/Appwrite/Models/OAuth2Zoom.php index 21ebd86..e083033 100644 --- a/src/Appwrite/Models/OAuth2Zoom.php +++ b/src/Appwrite/Models/OAuth2Zoom.php @@ -34,18 +34,12 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('clientId', $data)) { - throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); - } - if (!array_key_exists('clientSecret', $data)) { - throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + 'clientId' => "", + 'clientSecret' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Oauth2Approve.php b/src/Appwrite/Models/Oauth2Approve.php index 38e866b..5b043a2 100644 --- a/src/Appwrite/Models/Oauth2Approve.php +++ b/src/Appwrite/Models/Oauth2Approve.php @@ -28,9 +28,9 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('redirectUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectUrl" for ' . static::class . '.'); - } + $data += [ + 'redirectUrl' => "", + ]; return new static( redirectUrl: $data['redirectUrl'] diff --git a/src/Appwrite/Models/Oauth2Authorize.php b/src/Appwrite/Models/Oauth2Authorize.php index e5d9957..a81b101 100644 --- a/src/Appwrite/Models/Oauth2Authorize.php +++ b/src/Appwrite/Models/Oauth2Authorize.php @@ -30,12 +30,10 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('grantId', $data)) { - throw new \InvalidArgumentException('Missing required field "grantId" for ' . static::class . '.'); - } - if (!array_key_exists('redirectUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectUrl" for ' . static::class . '.'); - } + $data += [ + 'grantId' => "", + 'redirectUrl' => "", + ]; return new static( grantId: $data['grantId'], diff --git a/src/Appwrite/Models/Oauth2Consent.php b/src/Appwrite/Models/Oauth2Consent.php index 22b11a0..16ddf7c 100644 --- a/src/Appwrite/Models/Oauth2Consent.php +++ b/src/Appwrite/Models/Oauth2Consent.php @@ -46,36 +46,18 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('cimdUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "cimdUrl" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - if (!array_key_exists('authorizationDetails', $data)) { - throw new \InvalidArgumentException('Missing required field "authorizationDetails" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'userId' => "", + 'appId' => "", + 'cimdUrl' => "", + 'scopes' => [], + 'resources' => [], + 'authorizationDetails' => "[]", + 'expire' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Oauth2ConsentList.php b/src/Appwrite/Models/Oauth2ConsentList.php index f53d6af..5b83a17 100644 --- a/src/Appwrite/Models/Oauth2ConsentList.php +++ b/src/Appwrite/Models/Oauth2ConsentList.php @@ -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('consents', $data)) { throw new \InvalidArgumentException('Missing required field "consents" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Oauth2ConsentToken.php b/src/Appwrite/Models/Oauth2ConsentToken.php index cb708cb..6b52722 100644 --- a/src/Appwrite/Models/Oauth2ConsentToken.php +++ b/src/Appwrite/Models/Oauth2ConsentToken.php @@ -48,39 +48,19 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('consentId', $data)) { - throw new \InvalidArgumentException('Missing required field "consentId" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('cimdUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "cimdUrl" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - if (!array_key_exists('authorizationDetails', $data)) { - throw new \InvalidArgumentException('Missing required field "authorizationDetails" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'consentId' => "", + 'userId' => "", + 'appId' => "", + 'cimdUrl' => "", + 'scopes' => [], + 'resources' => [], + 'authorizationDetails' => "[]", + 'expire' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Oauth2ConsentTokenList.php b/src/Appwrite/Models/Oauth2ConsentTokenList.php index a86ff2d..0a0a7bb 100644 --- a/src/Appwrite/Models/Oauth2ConsentTokenList.php +++ b/src/Appwrite/Models/Oauth2ConsentTokenList.php @@ -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('tokens', $data)) { throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Oauth2DeviceAuthorization.php b/src/Appwrite/Models/Oauth2DeviceAuthorization.php index f8dd64b..ff08bd8 100644 --- a/src/Appwrite/Models/Oauth2DeviceAuthorization.php +++ b/src/Appwrite/Models/Oauth2DeviceAuthorization.php @@ -38,24 +38,14 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('device_code', $data)) { - throw new \InvalidArgumentException('Missing required field "device_code" for ' . static::class . '.'); - } - if (!array_key_exists('user_code', $data)) { - throw new \InvalidArgumentException('Missing required field "user_code" for ' . static::class . '.'); - } - if (!array_key_exists('verification_uri', $data)) { - throw new \InvalidArgumentException('Missing required field "verification_uri" for ' . static::class . '.'); - } - if (!array_key_exists('verification_uri_complete', $data)) { - throw new \InvalidArgumentException('Missing required field "verification_uri_complete" for ' . static::class . '.'); - } - if (!array_key_exists('expires_in', $data)) { - throw new \InvalidArgumentException('Missing required field "expires_in" for ' . static::class . '.'); - } - if (!array_key_exists('interval', $data)) { - throw new \InvalidArgumentException('Missing required field "interval" for ' . static::class . '.'); - } + $data += [ + 'device_code' => "", + 'user_code' => "", + 'verification_uri' => "", + 'verification_uri_complete' => "", + 'expires_in' => 0, + 'interval' => 0, + ]; return new static( deviceCode: $data['device_code'], diff --git a/src/Appwrite/Models/Oauth2Grant.php b/src/Appwrite/Models/Oauth2Grant.php index 0d0991c..c4a8c13 100644 --- a/src/Appwrite/Models/Oauth2Grant.php +++ b/src/Appwrite/Models/Oauth2Grant.php @@ -50,42 +50,20 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - if (!array_key_exists('authorizationDetails', $data)) { - throw new \InvalidArgumentException('Missing required field "authorizationDetails" for ' . static::class . '.'); - } - if (!array_key_exists('prompt', $data)) { - throw new \InvalidArgumentException('Missing required field "prompt" for ' . static::class . '.'); - } - if (!array_key_exists('redirectUri', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectUri" for ' . static::class . '.'); - } - if (!array_key_exists('authTime', $data)) { - throw new \InvalidArgumentException('Missing required field "authTime" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'userId' => "", + 'appId' => "", + 'scopes' => [], + 'resources' => [], + 'authorizationDetails' => "[]", + 'prompt' => "", + 'redirectUri' => "", + 'authTime' => 0, + 'expire' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Oauth2Organization.php b/src/Appwrite/Models/Oauth2Organization.php index d251fa2..25ebc74 100644 --- a/src/Appwrite/Models/Oauth2Organization.php +++ b/src/Appwrite/Models/Oauth2Organization.php @@ -28,9 +28,9 @@ 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 . '.'); - } + $data += [ + '$id' => "", + ]; return new static( id: $data['$id'] diff --git a/src/Appwrite/Models/Oauth2OrganizationList.php b/src/Appwrite/Models/Oauth2OrganizationList.php index e7ca686..6549f55 100644 --- a/src/Appwrite/Models/Oauth2OrganizationList.php +++ b/src/Appwrite/Models/Oauth2OrganizationList.php @@ -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('organizations', $data)) { throw new \InvalidArgumentException('Missing required field "organizations" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Oauth2PAR.php b/src/Appwrite/Models/Oauth2PAR.php index 07b2131..2bf9d6c 100644 --- a/src/Appwrite/Models/Oauth2PAR.php +++ b/src/Appwrite/Models/Oauth2PAR.php @@ -30,12 +30,10 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('request_uri', $data)) { - throw new \InvalidArgumentException('Missing required field "request_uri" for ' . static::class . '.'); - } - if (!array_key_exists('expires_in', $data)) { - throw new \InvalidArgumentException('Missing required field "expires_in" for ' . static::class . '.'); - } + $data += [ + 'request_uri' => "", + 'expires_in' => 0, + ]; return new static( requestUri: $data['request_uri'], diff --git a/src/Appwrite/Models/Oauth2Project.php b/src/Appwrite/Models/Oauth2Project.php index 3919e54..6f3c8a1 100644 --- a/src/Appwrite/Models/Oauth2Project.php +++ b/src/Appwrite/Models/Oauth2Project.php @@ -32,15 +32,11 @@ 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('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } - if (!array_key_exists('endpoint', $data)) { - throw new \InvalidArgumentException('Missing required field "endpoint" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'region' => "", + 'endpoint' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Oauth2ProjectList.php b/src/Appwrite/Models/Oauth2ProjectList.php index b4aa53b..111dda8 100644 --- a/src/Appwrite/Models/Oauth2ProjectList.php +++ b/src/Appwrite/Models/Oauth2ProjectList.php @@ -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('projects', $data)) { throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Oauth2Reject.php b/src/Appwrite/Models/Oauth2Reject.php index 0db9819..78f3d0d 100644 --- a/src/Appwrite/Models/Oauth2Reject.php +++ b/src/Appwrite/Models/Oauth2Reject.php @@ -28,9 +28,9 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('redirectUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectUrl" for ' . static::class . '.'); - } + $data += [ + 'redirectUrl' => "", + ]; return new static( redirectUrl: $data['redirectUrl'] diff --git a/src/Appwrite/Models/Oauth2Token.php b/src/Appwrite/Models/Oauth2Token.php index 53f0add..f6d66df 100644 --- a/src/Appwrite/Models/Oauth2Token.php +++ b/src/Appwrite/Models/Oauth2Token.php @@ -40,21 +40,13 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('access_token', $data)) { - throw new \InvalidArgumentException('Missing required field "access_token" for ' . static::class . '.'); - } - if (!array_key_exists('token_type', $data)) { - throw new \InvalidArgumentException('Missing required field "token_type" for ' . static::class . '.'); - } - if (!array_key_exists('expires_in', $data)) { - throw new \InvalidArgumentException('Missing required field "expires_in" for ' . static::class . '.'); - } - if (!array_key_exists('refresh_token', $data)) { - throw new \InvalidArgumentException('Missing required field "refresh_token" for ' . static::class . '.'); - } - if (!array_key_exists('scope', $data)) { - throw new \InvalidArgumentException('Missing required field "scope" for ' . static::class . '.'); - } + $data += [ + 'access_token' => "", + 'token_type' => "Bearer", + 'expires_in' => 0, + 'refresh_token' => "", + 'scope' => "", + ]; return new static( accessToken: $data['access_token'], diff --git a/src/Appwrite/Models/Organization.php b/src/Appwrite/Models/Organization.php index 92160ce..569bc18 100644 --- a/src/Appwrite/Models/Organization.php +++ b/src/Appwrite/Models/Organization.php @@ -96,39 +96,28 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'total' => 0, + 'budgetAlerts' => [75], + 'billingPlan' => "tier-0", + 'billingPlanId' => "tier-0", + 'billingEmail' => "", + 'status' => "draft", + 'markedForDeletion' => false, + 'platform' => "appwrite", + 'projects' => [], + ]; + if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } - if (!array_key_exists('budgetAlerts', $data)) { - throw new \InvalidArgumentException('Missing required field "budgetAlerts" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlan', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlan" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlanId', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlanId" for ' . static::class . '.'); - } if (!array_key_exists('billingPlanDetails', $data)) { throw new \InvalidArgumentException('Missing required field "billingPlanDetails" for ' . static::class . '.'); } - if (!array_key_exists('billingEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "billingEmail" for ' . static::class . '.'); - } if (!array_key_exists('billingStartDate', $data)) { throw new \InvalidArgumentException('Missing required field "billingStartDate" for ' . static::class . '.'); } @@ -150,18 +139,6 @@ public static function from(array $data): static if (!array_key_exists('paymentMethodId', $data)) { throw new \InvalidArgumentException('Missing required field "paymentMethodId" for ' . static::class . '.'); } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('markedForDeletion', $data)) { - throw new \InvalidArgumentException('Missing required field "markedForDeletion" for ' . static::class . '.'); - } - if (!array_key_exists('platform', $data)) { - throw new \InvalidArgumentException('Missing required field "platform" for ' . static::class . '.'); - } - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Phone.php b/src/Appwrite/Models/Phone.php index 1c99fe9..33db24d 100644 --- a/src/Appwrite/Models/Phone.php +++ b/src/Appwrite/Models/Phone.php @@ -32,15 +32,11 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('code', $data)) { - throw new \InvalidArgumentException('Missing required field "code" for ' . static::class . '.'); - } - if (!array_key_exists('countryCode', $data)) { - throw new \InvalidArgumentException('Missing required field "countryCode" for ' . static::class . '.'); - } - if (!array_key_exists('countryName', $data)) { - throw new \InvalidArgumentException('Missing required field "countryName" for ' . static::class . '.'); - } + $data += [ + 'code' => "", + 'countryCode' => "", + 'countryName' => "", + ]; return new static( code: $data['code'], diff --git a/src/Appwrite/Models/PhoneList.php b/src/Appwrite/Models/PhoneList.php index 76d7227..ac80248 100644 --- a/src/Appwrite/Models/PhoneList.php +++ b/src/Appwrite/Models/PhoneList.php @@ -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('phones', $data)) { throw new \InvalidArgumentException('Missing required field "phones" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/PlatformAndroid.php b/src/Appwrite/Models/PlatformAndroid.php index 48ace53..1b80957 100644 --- a/src/Appwrite/Models/PlatformAndroid.php +++ b/src/Appwrite/Models/PlatformAndroid.php @@ -40,24 +40,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'applicationId' => "", + ]; + if (!array_key_exists('type', $data)) { throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); } - if (!array_key_exists('applicationId', $data)) { - throw new \InvalidArgumentException('Missing required field "applicationId" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PlatformApple.php b/src/Appwrite/Models/PlatformApple.php index 610f815..773bb4e 100644 --- a/src/Appwrite/Models/PlatformApple.php +++ b/src/Appwrite/Models/PlatformApple.php @@ -40,24 +40,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'bundleIdentifier' => "", + ]; + if (!array_key_exists('type', $data)) { throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); } - if (!array_key_exists('bundleIdentifier', $data)) { - throw new \InvalidArgumentException('Missing required field "bundleIdentifier" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PlatformLinux.php b/src/Appwrite/Models/PlatformLinux.php index 64f3b0d..22fc618 100644 --- a/src/Appwrite/Models/PlatformLinux.php +++ b/src/Appwrite/Models/PlatformLinux.php @@ -40,24 +40,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'packageName' => "", + ]; + if (!array_key_exists('type', $data)) { throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); } - if (!array_key_exists('packageName', $data)) { - throw new \InvalidArgumentException('Missing required field "packageName" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PlatformList.php b/src/Appwrite/Models/PlatformList.php index 50513f5..c8d64a4 100644 --- a/src/Appwrite/Models/PlatformList.php +++ b/src/Appwrite/Models/PlatformList.php @@ -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('platforms', $data)) { throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/PlatformWeb.php b/src/Appwrite/Models/PlatformWeb.php index 4f9d78a..7be1459 100644 --- a/src/Appwrite/Models/PlatformWeb.php +++ b/src/Appwrite/Models/PlatformWeb.php @@ -40,24 +40,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'hostname' => "", + ]; + if (!array_key_exists('type', $data)) { throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); } - if (!array_key_exists('hostname', $data)) { - throw new \InvalidArgumentException('Missing required field "hostname" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PlatformWindows.php b/src/Appwrite/Models/PlatformWindows.php index 107f771..a3a7bec 100644 --- a/src/Appwrite/Models/PlatformWindows.php +++ b/src/Appwrite/Models/PlatformWindows.php @@ -40,24 +40,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'packageIdentifierName' => "", + ]; + if (!array_key_exists('type', $data)) { throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); } - if (!array_key_exists('packageIdentifierName', $data)) { - throw new \InvalidArgumentException('Missing required field "packageIdentifierName" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyDenyAliasedEmail.php b/src/Appwrite/Models/PolicyDenyAliasedEmail.php index 977ceb6..b427b06 100644 --- a/src/Appwrite/Models/PolicyDenyAliasedEmail.php +++ b/src/Appwrite/Models/PolicyDenyAliasedEmail.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyDenyCorporateEmail.php b/src/Appwrite/Models/PolicyDenyCorporateEmail.php index e756f82..9894760 100644 --- a/src/Appwrite/Models/PolicyDenyCorporateEmail.php +++ b/src/Appwrite/Models/PolicyDenyCorporateEmail.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyDenyDisposableEmail.php b/src/Appwrite/Models/PolicyDenyDisposableEmail.php index 6fdb54e..c5cd5cb 100644 --- a/src/Appwrite/Models/PolicyDenyDisposableEmail.php +++ b/src/Appwrite/Models/PolicyDenyDisposableEmail.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyDenyFreeEmail.php b/src/Appwrite/Models/PolicyDenyFreeEmail.php index 3db8231..9426454 100644 --- a/src/Appwrite/Models/PolicyDenyFreeEmail.php +++ b/src/Appwrite/Models/PolicyDenyFreeEmail.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyList.php b/src/Appwrite/Models/PolicyList.php index f05ed52..a1599a4 100644 --- a/src/Appwrite/Models/PolicyList.php +++ b/src/Appwrite/Models/PolicyList.php @@ -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('policies', $data)) { throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/PolicyMembershipPrivacy.php b/src/Appwrite/Models/PolicyMembershipPrivacy.php index db8ec85..a625a12 100644 --- a/src/Appwrite/Models/PolicyMembershipPrivacy.php +++ b/src/Appwrite/Models/PolicyMembershipPrivacy.php @@ -40,27 +40,15 @@ 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('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "userEmail" for ' . static::class . '.'); - } - if (!array_key_exists('userPhone', $data)) { - throw new \InvalidArgumentException('Missing required field "userPhone" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('userMFA', $data)) { - throw new \InvalidArgumentException('Missing required field "userMFA" for ' . static::class . '.'); - } - if (!array_key_exists('userAccessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "userAccessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'userId' => false, + 'userEmail' => false, + 'userPhone' => false, + 'userName' => false, + 'userMFA' => false, + 'userAccessedAt' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyMfaFactors.php b/src/Appwrite/Models/PolicyMfaFactors.php index e6eecd6..ce2938a 100644 --- a/src/Appwrite/Models/PolicyMfaFactors.php +++ b/src/Appwrite/Models/PolicyMfaFactors.php @@ -36,21 +36,13 @@ 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('totp', $data)) { - throw new \InvalidArgumentException('Missing required field "totp" for ' . static::class . '.'); - } - if (!array_key_exists('email', $data)) { - throw new \InvalidArgumentException('Missing required field "email" for ' . static::class . '.'); - } - if (!array_key_exists('phone', $data)) { - throw new \InvalidArgumentException('Missing required field "phone" for ' . static::class . '.'); - } - if (!array_key_exists('custom', $data)) { - throw new \InvalidArgumentException('Missing required field "custom" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'totp' => true, + 'email' => true, + 'phone' => true, + 'custom' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyPasswordDictionary.php b/src/Appwrite/Models/PolicyPasswordDictionary.php index 4b1c34c..32a1ff6 100644 --- a/src/Appwrite/Models/PolicyPasswordDictionary.php +++ b/src/Appwrite/Models/PolicyPasswordDictionary.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyPasswordHistory.php b/src/Appwrite/Models/PolicyPasswordHistory.php index d59a9f9..d08a174 100644 --- a/src/Appwrite/Models/PolicyPasswordHistory.php +++ b/src/Appwrite/Models/PolicyPasswordHistory.php @@ -30,12 +30,10 @@ 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('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'total' => 0, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyPasswordPersonalData.php b/src/Appwrite/Models/PolicyPasswordPersonalData.php index aad948c..919a032 100644 --- a/src/Appwrite/Models/PolicyPasswordPersonalData.php +++ b/src/Appwrite/Models/PolicyPasswordPersonalData.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyPasswordStrength.php b/src/Appwrite/Models/PolicyPasswordStrength.php index 4974faf..d03d93a 100644 --- a/src/Appwrite/Models/PolicyPasswordStrength.php +++ b/src/Appwrite/Models/PolicyPasswordStrength.php @@ -38,24 +38,14 @@ 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('min', $data)) { - throw new \InvalidArgumentException('Missing required field "min" for ' . static::class . '.'); - } - if (!array_key_exists('uppercase', $data)) { - throw new \InvalidArgumentException('Missing required field "uppercase" for ' . static::class . '.'); - } - if (!array_key_exists('lowercase', $data)) { - throw new \InvalidArgumentException('Missing required field "lowercase" for ' . static::class . '.'); - } - if (!array_key_exists('number', $data)) { - throw new \InvalidArgumentException('Missing required field "number" for ' . static::class . '.'); - } - if (!array_key_exists('symbols', $data)) { - throw new \InvalidArgumentException('Missing required field "symbols" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicySessionAlert.php b/src/Appwrite/Models/PolicySessionAlert.php index 0b4126f..8d59d21 100644 --- a/src/Appwrite/Models/PolicySessionAlert.php +++ b/src/Appwrite/Models/PolicySessionAlert.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicySessionDuration.php b/src/Appwrite/Models/PolicySessionDuration.php index d37938b..2dba845 100644 --- a/src/Appwrite/Models/PolicySessionDuration.php +++ b/src/Appwrite/Models/PolicySessionDuration.php @@ -30,12 +30,10 @@ 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('duration', $data)) { - throw new \InvalidArgumentException('Missing required field "duration" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'duration' => 31536000, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicySessionInvalidation.php b/src/Appwrite/Models/PolicySessionInvalidation.php index 27ab89a..c139d5b 100644 --- a/src/Appwrite/Models/PolicySessionInvalidation.php +++ b/src/Appwrite/Models/PolicySessionInvalidation.php @@ -30,12 +30,10 @@ 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('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'enabled' => true, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicySessionLimit.php b/src/Appwrite/Models/PolicySessionLimit.php index 94d8775..49c5b44 100644 --- a/src/Appwrite/Models/PolicySessionLimit.php +++ b/src/Appwrite/Models/PolicySessionLimit.php @@ -30,12 +30,10 @@ 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('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'total' => 0, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PolicyUserLimit.php b/src/Appwrite/Models/PolicyUserLimit.php index abc120e..a5b645e 100644 --- a/src/Appwrite/Models/PolicyUserLimit.php +++ b/src/Appwrite/Models/PolicyUserLimit.php @@ -30,12 +30,10 @@ 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('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'total' => 0, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PostgresExtension.php b/src/Appwrite/Models/PostgresExtension.php index 84c15d2..1f5dee2 100644 --- a/src/Appwrite/Models/PostgresExtension.php +++ b/src/Appwrite/Models/PostgresExtension.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('description', $data)) { - throw new \InvalidArgumentException('Missing required field "description" for ' . static::class . '.'); - } - if (!array_key_exists('category', $data)) { - throw new \InvalidArgumentException('Missing required field "category" for ' . static::class . '.'); - } + $data += [ + 'key' => "", + 'name' => "", + 'description' => "", + 'category' => "", + ]; return new static( key: $data['key'], diff --git a/src/Appwrite/Models/Presence.php b/src/Appwrite/Models/Presence.php index 676f8fa..95ae696 100644 --- a/src/Appwrite/Models/Presence.php +++ b/src/Appwrite/Models/Presence.php @@ -44,24 +44,17 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'userId' => "", + 'source' => "", + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('source', $data)) { - throw new \InvalidArgumentException('Missing required field "source" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PresenceList.php b/src/Appwrite/Models/PresenceList.php index 7f35fe9..c363e10 100644 --- a/src/Appwrite/Models/PresenceList.php +++ b/src/Appwrite/Models/PresenceList.php @@ -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('presences', $data)) { throw new \InvalidArgumentException('Missing required field "presences" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Program.php b/src/Appwrite/Models/Program.php index a2e8f6f..8a1f2bd 100644 --- a/src/Appwrite/Models/Program.php +++ b/src/Appwrite/Models/Program.php @@ -44,33 +44,17 @@ 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('title', $data)) { - throw new \InvalidArgumentException('Missing required field "title" for ' . static::class . '.'); - } - if (!array_key_exists('description', $data)) { - throw new \InvalidArgumentException('Missing required field "description" for ' . static::class . '.'); - } - if (!array_key_exists('tag', $data)) { - throw new \InvalidArgumentException('Missing required field "tag" for ' . static::class . '.'); - } - if (!array_key_exists('icon', $data)) { - throw new \InvalidArgumentException('Missing required field "icon" for ' . static::class . '.'); - } - if (!array_key_exists('url', $data)) { - throw new \InvalidArgumentException('Missing required field "url" for ' . static::class . '.'); - } - if (!array_key_exists('active', $data)) { - throw new \InvalidArgumentException('Missing required field "active" for ' . static::class . '.'); - } - if (!array_key_exists('external', $data)) { - throw new \InvalidArgumentException('Missing required field "external" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlanId', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlanId" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'title' => "", + 'description' => "", + 'tag' => "", + 'icon' => "", + 'url' => "", + 'active' => true, + 'external' => true, + 'billingPlanId' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index d8f551a..9898e6a 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -118,72 +118,34 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('teamId', $data)) { - throw new \InvalidArgumentException('Missing required field "teamId" for ' . static::class . '.'); - } - if (!array_key_exists('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'teamId' => "", + 'region' => "fra", + 'smtpEnabled' => false, + 'smtpSenderName' => "", + 'smtpSenderEmail' => "", + 'smtpReplyToName' => "", + 'smtpReplyToEmail' => "", + 'smtpHost' => "", + 'smtpPort' => 0, + 'smtpUsername' => "", + 'smtpPassword' => "", + 'smtpSecure' => "", + 'pingCount' => 0, + 'pingedAt' => "", + 'labels' => [], + 'status' => "active", + 'onboarding' => [], + 'consoleAccessedAt' => "", + ]; + if (!array_key_exists('devKeys', $data)) { throw new \InvalidArgumentException('Missing required field "devKeys" for ' . static::class . '.'); } - if (!array_key_exists('smtpEnabled', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpEnabled" for ' . static::class . '.'); - } - if (!array_key_exists('smtpSenderName', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpSenderName" for ' . static::class . '.'); - } - if (!array_key_exists('smtpSenderEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpSenderEmail" for ' . static::class . '.'); - } - if (!array_key_exists('smtpReplyToName', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpReplyToName" for ' . static::class . '.'); - } - if (!array_key_exists('smtpReplyToEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpReplyToEmail" for ' . static::class . '.'); - } - if (!array_key_exists('smtpHost', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpHost" for ' . static::class . '.'); - } - if (!array_key_exists('smtpPort', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpPort" for ' . static::class . '.'); - } - if (!array_key_exists('smtpUsername', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpUsername" for ' . static::class . '.'); - } - if (!array_key_exists('smtpPassword', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpPassword" for ' . static::class . '.'); - } - if (!array_key_exists('smtpSecure', $data)) { - throw new \InvalidArgumentException('Missing required field "smtpSecure" for ' . static::class . '.'); - } - if (!array_key_exists('pingCount', $data)) { - throw new \InvalidArgumentException('Missing required field "pingCount" for ' . static::class . '.'); - } - if (!array_key_exists('pingedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "pingedAt" for ' . static::class . '.'); - } - if (!array_key_exists('labels', $data)) { - throw new \InvalidArgumentException('Missing required field "labels" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('onboarding', $data)) { - throw new \InvalidArgumentException('Missing required field "onboarding" for ' . static::class . '.'); - } if (!array_key_exists('authMethods', $data)) { throw new \InvalidArgumentException('Missing required field "authMethods" for ' . static::class . '.'); } @@ -196,9 +158,6 @@ public static function from(array $data): static if (!array_key_exists('blocks', $data)) { throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.'); } - if (!array_key_exists('consoleAccessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "consoleAccessedAt" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ProjectAuthMethod.php b/src/Appwrite/Models/ProjectAuthMethod.php index 28759de..44aef67 100644 --- a/src/Appwrite/Models/ProjectAuthMethod.php +++ b/src/Appwrite/Models/ProjectAuthMethod.php @@ -32,12 +32,13 @@ public function __construct( */ public static function from(array $data): static { + $data += [ + 'enabled' => true, + ]; + if (!array_key_exists('$id', $data)) { throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } return new static( id: static::hydrateTypedValue(ProjectAuthMethodId::class, $data['$id']), diff --git a/src/Appwrite/Models/ProjectList.php b/src/Appwrite/Models/ProjectList.php index ec34ea0..f726144 100644 --- a/src/Appwrite/Models/ProjectList.php +++ b/src/Appwrite/Models/ProjectList.php @@ -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('projects', $data)) { throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ProjectProtocol.php b/src/Appwrite/Models/ProjectProtocol.php index 285292b..0804bb7 100644 --- a/src/Appwrite/Models/ProjectProtocol.php +++ b/src/Appwrite/Models/ProjectProtocol.php @@ -32,12 +32,13 @@ public function __construct( */ public static function from(array $data): static { + $data += [ + 'enabled' => true, + ]; + if (!array_key_exists('$id', $data)) { throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } return new static( id: static::hydrateTypedValue(ProjectProtocolId::class, $data['$id']), diff --git a/src/Appwrite/Models/ProjectService.php b/src/Appwrite/Models/ProjectService.php index e1fd286..9f215ab 100644 --- a/src/Appwrite/Models/ProjectService.php +++ b/src/Appwrite/Models/ProjectService.php @@ -32,12 +32,13 @@ public function __construct( */ public static function from(array $data): static { + $data += [ + 'enabled' => true, + ]; + if (!array_key_exists('$id', $data)) { throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } return new static( id: static::hydrateTypedValue(ProjectServiceId::class, $data['$id']), diff --git a/src/Appwrite/Models/Provider.php b/src/Appwrite/Models/Provider.php index a0bd611..382c504 100644 --- a/src/Appwrite/Models/Provider.php +++ b/src/Appwrite/Models/Provider.php @@ -44,30 +44,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('provider', $data)) { - throw new \InvalidArgumentException('Missing required field "provider" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('credentials', $data)) { - throw new \InvalidArgumentException('Missing required field "credentials" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'provider' => "", + 'enabled' => true, + 'type' => "", + 'credentials' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ProviderList.php b/src/Appwrite/Models/ProviderList.php index 6a13de5..68bbeb5 100644 --- a/src/Appwrite/Models/ProviderList.php +++ b/src/Appwrite/Models/ProviderList.php @@ -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('providers', $data)) { throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ProxyInvalidation.php b/src/Appwrite/Models/ProxyInvalidation.php index d40cde5..21b206a 100644 --- a/src/Appwrite/Models/ProxyInvalidation.php +++ b/src/Appwrite/Models/ProxyInvalidation.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('domain', $data)) { - throw new \InvalidArgumentException('Missing required field "domain" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('reference', $data)) { - throw new \InvalidArgumentException('Missing required field "reference" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } + $data += [ + 'domain' => "", + 'type' => "", + 'reference' => "", + 'status' => "", + ]; return new static( domain: $data['domain'], diff --git a/src/Appwrite/Models/ProxyRule.php b/src/Appwrite/Models/ProxyRule.php index 948ec1d..cc9f758 100644 --- a/src/Appwrite/Models/ProxyRule.php +++ b/src/Appwrite/Models/ProxyRule.php @@ -59,45 +59,22 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('domain', $data)) { - throw new \InvalidArgumentException('Missing required field "domain" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('trigger', $data)) { - throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); - } - if (!array_key_exists('redirectUrl', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectUrl" for ' . static::class . '.'); - } - if (!array_key_exists('redirectStatusCode', $data)) { - throw new \InvalidArgumentException('Missing required field "redirectStatusCode" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentId', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentId" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentResourceId', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentResourceId" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentVcsProviderBranch', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentVcsProviderBranch" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'domain' => "", + 'type' => "", + 'trigger' => "", + 'redirectUrl' => "", + 'redirectStatusCode' => 301, + 'deploymentId' => "", + 'deploymentResourceId' => "", + 'deploymentVcsProviderBranch' => "", + 'status' => "unverified", + 'logs' => "", + ]; + if (!array_key_exists('renewAt', $data)) { throw new \InvalidArgumentException('Missing required field "renewAt" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ProxyRuleList.php b/src/Appwrite/Models/ProxyRuleList.php index c86f84a..413058a 100644 --- a/src/Appwrite/Models/ProxyRuleList.php +++ b/src/Appwrite/Models/ProxyRuleList.php @@ -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('rules', $data)) { throw new \InvalidArgumentException('Missing required field "rules" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Report.php b/src/Appwrite/Models/Report.php index 3b09e61..8ecd43f 100644 --- a/src/Appwrite/Models/Report.php +++ b/src/Appwrite/Models/Report.php @@ -50,36 +50,19 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('appId', $data)) { - throw new \InvalidArgumentException('Missing required field "appId" for ' . static::class . '.'); - } - if (!array_key_exists('type', $data)) { - throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); - } - if (!array_key_exists('title', $data)) { - throw new \InvalidArgumentException('Missing required field "title" for ' . static::class . '.'); - } - if (!array_key_exists('summary', $data)) { - throw new \InvalidArgumentException('Missing required field "summary" for ' . static::class . '.'); - } - if (!array_key_exists('targetType', $data)) { - throw new \InvalidArgumentException('Missing required field "targetType" for ' . static::class . '.'); - } - if (!array_key_exists('target', $data)) { - throw new \InvalidArgumentException('Missing required field "target" for ' . static::class . '.'); - } - if (!array_key_exists('categories', $data)) { - throw new \InvalidArgumentException('Missing required field "categories" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'appId' => "", + 'type' => "", + 'title' => "", + 'summary' => "", + 'targetType' => "", + 'target' => "", + 'categories' => [], + ]; + if (!array_key_exists('insights', $data)) { throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ReportList.php b/src/Appwrite/Models/ReportList.php index 839cea7..ea32a52 100644 --- a/src/Appwrite/Models/ReportList.php +++ b/src/Appwrite/Models/ReportList.php @@ -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('reports', $data)) { throw new \InvalidArgumentException('Missing required field "reports" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/ResourceToken.php b/src/Appwrite/Models/ResourceToken.php index 76b380d..409cd33 100644 --- a/src/Appwrite/Models/ResourceToken.php +++ b/src/Appwrite/Models/ResourceToken.php @@ -40,27 +40,15 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('resourceId', $data)) { - throw new \InvalidArgumentException('Missing required field "resourceId" for ' . static::class . '.'); - } - if (!array_key_exists('resourceType', $data)) { - throw new \InvalidArgumentException('Missing required field "resourceType" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'resourceId' => "", + 'resourceType' => "", + 'expire' => "", + 'secret' => "", + 'accessedAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ResourceTokenList.php b/src/Appwrite/Models/ResourceTokenList.php index be6b50e..2b9b188 100644 --- a/src/Appwrite/Models/ResourceTokenList.php +++ b/src/Appwrite/Models/ResourceTokenList.php @@ -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('tokens', $data)) { throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Row.php b/src/Appwrite/Models/Row.php index 45aaf8a..d37ab8a 100644 --- a/src/Appwrite/Models/Row.php +++ b/src/Appwrite/Models/Row.php @@ -42,24 +42,15 @@ 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('$sequence', $data)) { - throw new \InvalidArgumentException('Missing required field "$sequence" for ' . static::class . '.'); - } - if (!array_key_exists('$tableId', $data)) { - throw new \InvalidArgumentException('Missing required field "$tableId" for ' . static::class . '.'); - } - if (!array_key_exists('$databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "$databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$sequence' => "", + '$tableId' => "", + '$databaseId' => "", + '$createdAt' => "", + '$updatedAt' => "", + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/RowList.php b/src/Appwrite/Models/RowList.php index 4eff1c5..f5194b8 100644 --- a/src/Appwrite/Models/RowList.php +++ b/src/Appwrite/Models/RowList.php @@ -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('rows', $data)) { throw new \InvalidArgumentException('Missing required field "rows" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Runtime.php b/src/Appwrite/Models/Runtime.php index 349f5ea..6b51ebe 100644 --- a/src/Appwrite/Models/Runtime.php +++ b/src/Appwrite/Models/Runtime.php @@ -42,27 +42,16 @@ 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('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('version', $data)) { - throw new \InvalidArgumentException('Missing required field "version" for ' . static::class . '.'); - } - if (!array_key_exists('base', $data)) { - throw new \InvalidArgumentException('Missing required field "base" for ' . static::class . '.'); - } - if (!array_key_exists('image', $data)) { - throw new \InvalidArgumentException('Missing required field "image" for ' . static::class . '.'); - } - if (!array_key_exists('logo', $data)) { - throw new \InvalidArgumentException('Missing required field "logo" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'key' => "", + 'name' => "", + 'version' => "", + 'base' => "", + 'image' => "", + 'logo' => "", + ]; + if (!array_key_exists('supports', $data)) { throw new \InvalidArgumentException('Missing required field "supports" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/RuntimeList.php b/src/Appwrite/Models/RuntimeList.php index 071c8df..32baecf 100644 --- a/src/Appwrite/Models/RuntimeList.php +++ b/src/Appwrite/Models/RuntimeList.php @@ -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('runtimes', $data)) { throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Session.php b/src/Appwrite/Models/Session.php index c4eba76..2374f0f 100644 --- a/src/Appwrite/Models/Session.php +++ b/src/Appwrite/Models/Session.php @@ -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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('provider', $data)) { - throw new \InvalidArgumentException('Missing required field "provider" for ' . static::class . '.'); - } - if (!array_key_exists('providerUid', $data)) { - throw new \InvalidArgumentException('Missing required field "providerUid" for ' . static::class . '.'); - } - if (!array_key_exists('providerAccessToken', $data)) { - throw new \InvalidArgumentException('Missing required field "providerAccessToken" for ' . static::class . '.'); - } - if (!array_key_exists('providerAccessTokenExpiry', $data)) { - throw new \InvalidArgumentException('Missing required field "providerAccessTokenExpiry" for ' . static::class . '.'); - } - if (!array_key_exists('providerRefreshToken', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRefreshToken" for ' . static::class . '.'); - } - if (!array_key_exists('ip', $data)) { - throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.'); - } - if (!array_key_exists('osCode', $data)) { - throw new \InvalidArgumentException('Missing required field "osCode" for ' . static::class . '.'); - } - if (!array_key_exists('osName', $data)) { - throw new \InvalidArgumentException('Missing required field "osName" for ' . static::class . '.'); - } - if (!array_key_exists('osVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "osVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientType', $data)) { - throw new \InvalidArgumentException('Missing required field "clientType" for ' . static::class . '.'); - } - if (!array_key_exists('clientCode', $data)) { - throw new \InvalidArgumentException('Missing required field "clientCode" for ' . static::class . '.'); - } - if (!array_key_exists('clientName', $data)) { - throw new \InvalidArgumentException('Missing required field "clientName" for ' . static::class . '.'); - } - if (!array_key_exists('clientVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngine', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngine" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngineVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngineVersion" for ' . static::class . '.'); - } - if (!array_key_exists('deviceName', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceName" for ' . static::class . '.'); - } - if (!array_key_exists('deviceBrand', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceBrand" for ' . static::class . '.'); - } - if (!array_key_exists('deviceModel', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceModel" for ' . static::class . '.'); - } - if (!array_key_exists('countryCode', $data)) { - throw new \InvalidArgumentException('Missing required field "countryCode" for ' . static::class . '.'); - } - if (!array_key_exists('countryName', $data)) { - throw new \InvalidArgumentException('Missing required field "countryName" for ' . static::class . '.'); - } - if (!array_key_exists('current', $data)) { - throw new \InvalidArgumentException('Missing required field "current" for ' . static::class . '.'); - } - if (!array_key_exists('factors', $data)) { - throw new \InvalidArgumentException('Missing required field "factors" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('mfaUpdatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "mfaUpdatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'userId' => "", + 'expire' => "", + 'provider' => "", + 'providerUid' => "", + 'providerAccessToken' => "", + 'providerAccessTokenExpiry' => "", + 'providerRefreshToken' => "", + 'ip' => "", + 'osCode' => "", + 'osName' => "", + 'osVersion' => "", + 'clientType' => "", + 'clientCode' => "", + 'clientName' => "", + 'clientVersion' => "", + 'clientEngine' => "", + 'clientEngineVersion' => "", + 'deviceName' => "", + 'deviceBrand' => "", + 'deviceModel' => "", + 'countryCode' => "", + 'countryName' => "", + 'current' => false, + 'factors' => [], + 'secret' => "", + 'mfaUpdatedAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/SessionList.php b/src/Appwrite/Models/SessionList.php index c006f1a..33e062c 100644 --- a/src/Appwrite/Models/SessionList.php +++ b/src/Appwrite/Models/SessionList.php @@ -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('sessions', $data)) { throw new \InvalidArgumentException('Missing required field "sessions" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Site.php b/src/Appwrite/Models/Site.php index 5adb208..671bb5d 100644 --- a/src/Appwrite/Models/Site.php +++ b/src/Appwrite/Models/Site.php @@ -96,105 +96,44 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('live', $data)) { - throw new \InvalidArgumentException('Missing required field "live" for ' . static::class . '.'); - } - if (!array_key_exists('logging', $data)) { - throw new \InvalidArgumentException('Missing required field "logging" for ' . static::class . '.'); - } - if (!array_key_exists('framework', $data)) { - throw new \InvalidArgumentException('Missing required field "framework" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentRetention', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentRetention" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentId', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentId" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentCreatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentCreatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentScreenshotLight', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentScreenshotLight" for ' . static::class . '.'); - } - if (!array_key_exists('deploymentScreenshotDark', $data)) { - throw new \InvalidArgumentException('Missing required field "deploymentScreenshotDark" for ' . static::class . '.'); - } - if (!array_key_exists('latestDeploymentId', $data)) { - throw new \InvalidArgumentException('Missing required field "latestDeploymentId" for ' . static::class . '.'); - } - if (!array_key_exists('latestDeploymentCreatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "latestDeploymentCreatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('latestDeploymentStatus', $data)) { - throw new \InvalidArgumentException('Missing required field "latestDeploymentStatus" for ' . static::class . '.'); - } - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'enabled' => true, + 'live' => true, + 'logging' => true, + 'framework' => "", + 'deploymentRetention' => 0, + 'deploymentId' => "", + 'deploymentCreatedAt' => "", + 'deploymentScreenshotLight' => "", + 'deploymentScreenshotDark' => "", + 'latestDeploymentId' => "", + 'latestDeploymentCreatedAt' => "", + 'latestDeploymentStatus' => "", + 'scopes' => [], + 'timeout' => 15, + 'installCommand' => "", + 'buildCommand' => "", + 'startCommand' => "", + 'outputDirectory' => "", + 'installationId' => "", + 'providerRepositoryId' => "", + 'providerBranch' => "", + 'providerRootDirectory' => "", + 'providerSilentMode' => false, + 'providerBranches' => [], + 'providerPaths' => [], + 'buildSpecification' => "s-1vcpu-512mb", + 'runtimeSpecification' => "s-1vcpu-512mb", + 'buildRuntime' => "", + ]; + if (!array_key_exists('vars', $data)) { throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); } - if (!array_key_exists('timeout', $data)) { - throw new \InvalidArgumentException('Missing required field "timeout" for ' . static::class . '.'); - } - if (!array_key_exists('installCommand', $data)) { - throw new \InvalidArgumentException('Missing required field "installCommand" for ' . static::class . '.'); - } - if (!array_key_exists('buildCommand', $data)) { - throw new \InvalidArgumentException('Missing required field "buildCommand" for ' . static::class . '.'); - } - if (!array_key_exists('startCommand', $data)) { - throw new \InvalidArgumentException('Missing required field "startCommand" for ' . static::class . '.'); - } - if (!array_key_exists('outputDirectory', $data)) { - throw new \InvalidArgumentException('Missing required field "outputDirectory" for ' . static::class . '.'); - } - if (!array_key_exists('installationId', $data)) { - throw new \InvalidArgumentException('Missing required field "installationId" for ' . static::class . '.'); - } - if (!array_key_exists('providerRepositoryId', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRepositoryId" for ' . static::class . '.'); - } - if (!array_key_exists('providerBranch', $data)) { - throw new \InvalidArgumentException('Missing required field "providerBranch" for ' . static::class . '.'); - } - if (!array_key_exists('providerRootDirectory', $data)) { - throw new \InvalidArgumentException('Missing required field "providerRootDirectory" for ' . static::class . '.'); - } - if (!array_key_exists('providerSilentMode', $data)) { - throw new \InvalidArgumentException('Missing required field "providerSilentMode" for ' . static::class . '.'); - } - if (!array_key_exists('providerBranches', $data)) { - throw new \InvalidArgumentException('Missing required field "providerBranches" for ' . static::class . '.'); - } - if (!array_key_exists('providerPaths', $data)) { - throw new \InvalidArgumentException('Missing required field "providerPaths" for ' . static::class . '.'); - } - if (!array_key_exists('buildSpecification', $data)) { - throw new \InvalidArgumentException('Missing required field "buildSpecification" for ' . static::class . '.'); - } - if (!array_key_exists('runtimeSpecification', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimeSpecification" for ' . static::class . '.'); - } - if (!array_key_exists('buildRuntime', $data)) { - throw new \InvalidArgumentException('Missing required field "buildRuntime" for ' . static::class . '.'); - } if (!array_key_exists('adapter', $data)) { throw new \InvalidArgumentException('Missing required field "adapter" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/SiteList.php b/src/Appwrite/Models/SiteList.php index 371d171..e3b32b4 100644 --- a/src/Appwrite/Models/SiteList.php +++ b/src/Appwrite/Models/SiteList.php @@ -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('sites', $data)) { throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Specification.php b/src/Appwrite/Models/Specification.php index 0790b19..8ffeacc 100644 --- a/src/Appwrite/Models/Specification.php +++ b/src/Appwrite/Models/Specification.php @@ -34,18 +34,12 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('memory', $data)) { - throw new \InvalidArgumentException('Missing required field "memory" for ' . static::class . '.'); - } - if (!array_key_exists('cpus', $data)) { - throw new \InvalidArgumentException('Missing required field "cpus" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('slug', $data)) { - throw new \InvalidArgumentException('Missing required field "slug" for ' . static::class . '.'); - } + $data += [ + 'memory' => 0, + 'cpus' => 0, + 'enabled' => false, + 'slug' => "", + ]; return new static( memory: $data['memory'], diff --git a/src/Appwrite/Models/SpecificationList.php b/src/Appwrite/Models/SpecificationList.php index d699c84..e48fade 100644 --- a/src/Appwrite/Models/SpecificationList.php +++ b/src/Appwrite/Models/SpecificationList.php @@ -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('specifications', $data)) { throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Subscriber.php b/src/Appwrite/Models/Subscriber.php index 7efd6f0..f476805 100644 --- a/src/Appwrite/Models/Subscriber.php +++ b/src/Appwrite/Models/Subscriber.php @@ -44,33 +44,20 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('targetId', $data)) { - throw new \InvalidArgumentException('Missing required field "targetId" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'targetId' => "", + 'userId' => "", + 'userName' => "", + 'topicId' => "", + 'providerType' => "", + ]; + if (!array_key_exists('target', $data)) { throw new \InvalidArgumentException('Missing required field "target" for ' . static::class . '.'); } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('topicId', $data)) { - throw new \InvalidArgumentException('Missing required field "topicId" for ' . static::class . '.'); - } - if (!array_key_exists('providerType', $data)) { - throw new \InvalidArgumentException('Missing required field "providerType" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/SubscriberList.php b/src/Appwrite/Models/SubscriberList.php index 03b3c32..705cb0b 100644 --- a/src/Appwrite/Models/SubscriberList.php +++ b/src/Appwrite/Models/SubscriberList.php @@ -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('subscribers', $data)) { throw new \InvalidArgumentException('Missing required field "subscribers" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Table.php b/src/Appwrite/Models/Table.php index dce6d3a..4986958 100644 --- a/src/Appwrite/Models/Table.php +++ b/src/Appwrite/Models/Table.php @@ -50,42 +50,27 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'databaseId' => "", + 'name' => "", + 'enabled' => true, + 'rowSecurity' => false, + 'bytesMax' => 0, + 'bytesUsed' => 0, + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('rowSecurity', $data)) { - throw new \InvalidArgumentException('Missing required field "rowSecurity" for ' . static::class . '.'); - } if (!array_key_exists('columns', $data)) { throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); } if (!array_key_exists('indexes', $data)) { throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); } - if (!array_key_exists('bytesMax', $data)) { - throw new \InvalidArgumentException('Missing required field "bytesMax" for ' . static::class . '.'); - } - if (!array_key_exists('bytesUsed', $data)) { - throw new \InvalidArgumentException('Missing required field "bytesUsed" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/TableList.php b/src/Appwrite/Models/TableList.php index 994c11e..c6352fb 100644 --- a/src/Appwrite/Models/TableList.php +++ b/src/Appwrite/Models/TableList.php @@ -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('tables', $data)) { throw new \InvalidArgumentException('Missing required field "tables" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Target.php b/src/Appwrite/Models/Target.php index 00a4dec..e25e4f5 100644 --- a/src/Appwrite/Models/Target.php +++ b/src/Appwrite/Models/Target.php @@ -44,30 +44,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('providerType', $data)) { - throw new \InvalidArgumentException('Missing required field "providerType" for ' . static::class . '.'); - } - if (!array_key_exists('identifier', $data)) { - throw new \InvalidArgumentException('Missing required field "identifier" for ' . static::class . '.'); - } - if (!array_key_exists('expired', $data)) { - throw new \InvalidArgumentException('Missing required field "expired" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'userId' => "", + 'providerType' => "", + 'identifier' => "", + 'expired' => false, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/TargetList.php b/src/Appwrite/Models/TargetList.php index fe5c10a..8596f11 100644 --- a/src/Appwrite/Models/TargetList.php +++ b/src/Appwrite/Models/TargetList.php @@ -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('targets', $data)) { throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Team.php b/src/Appwrite/Models/Team.php index 463418c..cea7901 100644 --- a/src/Appwrite/Models/Team.php +++ b/src/Appwrite/Models/Team.php @@ -38,21 +38,14 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'total' => 0, + ]; + if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/TeamList.php b/src/Appwrite/Models/TeamList.php index 02e2b53..8c75339 100644 --- a/src/Appwrite/Models/TeamList.php +++ b/src/Appwrite/Models/TeamList.php @@ -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('teams', $data)) { throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Token.php b/src/Appwrite/Models/Token.php index 2056faa..d16f668 100644 --- a/src/Appwrite/Models/Token.php +++ b/src/Appwrite/Models/Token.php @@ -38,24 +38,14 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('phrase', $data)) { - throw new \InvalidArgumentException('Missing required field "phrase" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'secret' => "", + 'expire' => "", + 'phrase' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Topic.php b/src/Appwrite/Models/Topic.php index caa2fcf..fbf0239 100644 --- a/src/Appwrite/Models/Topic.php +++ b/src/Appwrite/Models/Topic.php @@ -42,30 +42,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('emailTotal', $data)) { - throw new \InvalidArgumentException('Missing required field "emailTotal" for ' . static::class . '.'); - } - if (!array_key_exists('smsTotal', $data)) { - throw new \InvalidArgumentException('Missing required field "smsTotal" for ' . static::class . '.'); - } - if (!array_key_exists('pushTotal', $data)) { - throw new \InvalidArgumentException('Missing required field "pushTotal" for ' . static::class . '.'); - } - if (!array_key_exists('subscribe', $data)) { - throw new \InvalidArgumentException('Missing required field "subscribe" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'emailTotal' => 0, + 'smsTotal' => 0, + 'pushTotal' => 0, + 'subscribe' => ["users"], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/TopicList.php b/src/Appwrite/Models/TopicList.php index 9cfdc2e..4ba8696 100644 --- a/src/Appwrite/Models/TopicList.php +++ b/src/Appwrite/Models/TopicList.php @@ -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('topics', $data)) { throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Transaction.php b/src/Appwrite/Models/Transaction.php index ff65aa5..085038c 100644 --- a/src/Appwrite/Models/Transaction.php +++ b/src/Appwrite/Models/Transaction.php @@ -38,24 +38,14 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('operations', $data)) { - throw new \InvalidArgumentException('Missing required field "operations" for ' . static::class . '.'); - } - if (!array_key_exists('expiresAt', $data)) { - throw new \InvalidArgumentException('Missing required field "expiresAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'status' => "pending", + 'operations' => 0, + 'expiresAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/TransactionList.php b/src/Appwrite/Models/TransactionList.php index 539e435..7e17740 100644 --- a/src/Appwrite/Models/TransactionList.php +++ b/src/Appwrite/Models/TransactionList.php @@ -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('transactions', $data)) { throw new \InvalidArgumentException('Missing required field "transactions" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/User.php b/src/Appwrite/Models/User.php index da0157c..33fd99e 100644 --- a/src/Appwrite/Models/User.php +++ b/src/Appwrite/Models/User.php @@ -78,54 +78,29 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('registration', $data)) { - throw new \InvalidArgumentException('Missing required field "registration" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - if (!array_key_exists('labels', $data)) { - throw new \InvalidArgumentException('Missing required field "labels" for ' . static::class . '.'); - } - if (!array_key_exists('passwordUpdate', $data)) { - throw new \InvalidArgumentException('Missing required field "passwordUpdate" for ' . static::class . '.'); - } - if (!array_key_exists('email', $data)) { - throw new \InvalidArgumentException('Missing required field "email" for ' . static::class . '.'); - } - if (!array_key_exists('phone', $data)) { - throw new \InvalidArgumentException('Missing required field "phone" for ' . static::class . '.'); - } - if (!array_key_exists('emailVerification', $data)) { - throw new \InvalidArgumentException('Missing required field "emailVerification" for ' . static::class . '.'); - } - if (!array_key_exists('phoneVerification', $data)) { - throw new \InvalidArgumentException('Missing required field "phoneVerification" for ' . static::class . '.'); - } - if (!array_key_exists('mfa', $data)) { - throw new \InvalidArgumentException('Missing required field "mfa" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'registration' => "", + 'status' => true, + 'labels' => [], + 'passwordUpdate' => "", + 'email' => "", + 'phone' => "", + 'emailVerification' => false, + 'phoneVerification' => false, + 'mfa' => false, + 'accessedAt' => "", + ]; + if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } if (!array_key_exists('targets', $data)) { throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/UserList.php b/src/Appwrite/Models/UserList.php index fb77b47..8c4d99d 100644 --- a/src/Appwrite/Models/UserList.php +++ b/src/Appwrite/Models/UserList.php @@ -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('users', $data)) { throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Variable.php b/src/Appwrite/Models/Variable.php index 8fe97fa..1f9cf83 100644 --- a/src/Appwrite/Models/Variable.php +++ b/src/Appwrite/Models/Variable.php @@ -42,30 +42,16 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('key', $data)) { - throw new \InvalidArgumentException('Missing required field "key" for ' . static::class . '.'); - } - if (!array_key_exists('value', $data)) { - throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" 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 . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'key' => "", + 'value' => "", + 'secret' => false, + 'resourceType' => "", + 'resourceId' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/VariableList.php b/src/Appwrite/Models/VariableList.php index 9522d7c..698af61 100644 --- a/src/Appwrite/Models/VariableList.php +++ b/src/Appwrite/Models/VariableList.php @@ -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('variables', $data)) { throw new \InvalidArgumentException('Missing required field "variables" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/VectorsdbCollection.php b/src/Appwrite/Models/VectorsdbCollection.php index 512dc08..38e5ec6 100644 --- a/src/Appwrite/Models/VectorsdbCollection.php +++ b/src/Appwrite/Models/VectorsdbCollection.php @@ -52,45 +52,28 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'databaseId' => "", + 'name' => "", + 'enabled' => true, + 'documentSecurity' => false, + 'bytesMax' => 0, + 'bytesUsed' => 0, + 'dimension' => 0, + ]; + if (!array_key_exists('$permissions', $data)) { throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); } - if (!array_key_exists('databaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "databaseId" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('documentSecurity', $data)) { - throw new \InvalidArgumentException('Missing required field "documentSecurity" for ' . static::class . '.'); - } if (!array_key_exists('attributes', $data)) { throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); } if (!array_key_exists('indexes', $data)) { throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); } - if (!array_key_exists('bytesMax', $data)) { - throw new \InvalidArgumentException('Missing required field "bytesMax" for ' . static::class . '.'); - } - if (!array_key_exists('bytesUsed', $data)) { - throw new \InvalidArgumentException('Missing required field "bytesUsed" for ' . static::class . '.'); - } - if (!array_key_exists('dimension', $data)) { - throw new \InvalidArgumentException('Missing required field "dimension" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/VectorsdbCollectionList.php b/src/Appwrite/Models/VectorsdbCollectionList.php index a7f870f..e5c2c05 100644 --- a/src/Appwrite/Models/VectorsdbCollectionList.php +++ b/src/Appwrite/Models/VectorsdbCollectionList.php @@ -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('collections', $data)) { throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/Webhook.php b/src/Appwrite/Models/Webhook.php index 0c8c585..9f1bef9 100644 --- a/src/Appwrite/Models/Webhook.php +++ b/src/Appwrite/Models/Webhook.php @@ -52,45 +52,21 @@ 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('$createdAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); - } - if (!array_key_exists('$updatedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); - } - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('url', $data)) { - throw new \InvalidArgumentException('Missing required field "url" for ' . static::class . '.'); - } - if (!array_key_exists('events', $data)) { - throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.'); - } - if (!array_key_exists('tls', $data)) { - throw new \InvalidArgumentException('Missing required field "tls" for ' . static::class . '.'); - } - if (!array_key_exists('authUsername', $data)) { - throw new \InvalidArgumentException('Missing required field "authUsername" for ' . static::class . '.'); - } - if (!array_key_exists('authPassword', $data)) { - throw new \InvalidArgumentException('Missing required field "authPassword" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('enabled', $data)) { - throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); - } - if (!array_key_exists('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } - if (!array_key_exists('attempts', $data)) { - throw new \InvalidArgumentException('Missing required field "attempts" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'url' => "", + 'events' => [], + 'tls' => true, + 'authUsername' => "", + 'authPassword' => "", + 'secret' => "", + 'enabled' => true, + 'logs' => "", + 'attempts' => 0, + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/WebhookList.php b/src/Appwrite/Models/WebhookList.php index c402119..dafb70d 100644 --- a/src/Appwrite/Models/WebhookList.php +++ b/src/Appwrite/Models/WebhookList.php @@ -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('webhooks', $data)) { throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); }