From e5787aeaff4477316fdfaa77dc895ab913d1c81a Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 12 Oct 2026 13:50:11 +0100 Subject: [PATCH 1/2] fix: fill a missing model field from its spec default Models threw Missing required field when a server omitted a field it predates, so 28+ could not read a file from a 1.x server (File.folder and File.key arrived in 2.0). Required fields with a spec default are now filled from it before the checks, as appwrite/sdk-generator#2005 generates. Fields without a default still throw, and a present value always wins. --- CHANGELOG.md | 4 + src/Appwrite/Client.php | 4 +- src/Appwrite/Models/ActivityEvent.php | 118 +++------ src/Appwrite/Models/ActivityEventList.php | 7 +- src/Appwrite/Models/AdditionalResource.php | 26 +- src/Appwrite/Models/AlgoArgon2.php | 18 +- src/Appwrite/Models/AlgoBcrypt.php | 6 +- src/Appwrite/Models/AlgoMd5.php | 6 +- src/Appwrite/Models/AlgoPhpass.php | 6 +- src/Appwrite/Models/AlgoScrypt.php | 22 +- src/Appwrite/Models/AlgoScryptModified.php | 18 +- src/Appwrite/Models/AlgoSha.php | 6 +- src/Appwrite/Models/App.php | 103 ++------ src/Appwrite/Models/AppInstallation.php | 38 +-- src/Appwrite/Models/AppInstallationList.php | 7 +- src/Appwrite/Models/AppKey.php | 34 +-- src/Appwrite/Models/AppKeyList.php | 7 +- src/Appwrite/Models/AppScope.php | 22 +- src/Appwrite/Models/AppScopeList.php | 7 +- src/Appwrite/Models/AppSecret.php | 34 +-- src/Appwrite/Models/AppSecretList.php | 7 +- src/Appwrite/Models/AppSecretPlaintext.php | 34 +-- src/Appwrite/Models/AppsList.php | 7 +- src/Appwrite/Models/AttributeBigint.php | 27 +- src/Appwrite/Models/AttributeBoolean.php | 27 +- src/Appwrite/Models/AttributeDatetime.php | 27 +- src/Appwrite/Models/AttributeEmail.php | 31 +-- src/Appwrite/Models/AttributeEnum.php | 31 +-- src/Appwrite/Models/AttributeFloat.php | 27 +- src/Appwrite/Models/AttributeInteger.php | 27 +- src/Appwrite/Models/AttributeIp.php | 31 +-- src/Appwrite/Models/AttributeLine.php | 27 +- src/Appwrite/Models/AttributeList.php | 7 +- src/Appwrite/Models/AttributeLongtext.php | 27 +- src/Appwrite/Models/AttributeMediumtext.php | 27 +- src/Appwrite/Models/AttributeObject.php | 27 +- src/Appwrite/Models/AttributePoint.php | 27 +- src/Appwrite/Models/AttributePolygon.php | 27 +- src/Appwrite/Models/AttributeRelationship.php | 47 +--- src/Appwrite/Models/AttributeString.php | 31 +-- src/Appwrite/Models/AttributeText.php | 27 +- src/Appwrite/Models/AttributeUrl.php | 31 +-- src/Appwrite/Models/AttributeVarchar.php | 31 +-- src/Appwrite/Models/AttributeVector.php | 31 +-- src/Appwrite/Models/BackupArchive.php | 27 +- src/Appwrite/Models/BackupArchiveList.php | 7 +- src/Appwrite/Models/BackupPolicy.php | 35 +-- src/Appwrite/Models/BackupPolicyList.php | 7 +- src/Appwrite/Models/BackupRestoration.php | 35 +-- src/Appwrite/Models/BackupRestorationList.php | 7 +- src/Appwrite/Models/BillingPlan.php | 243 +++++------------- .../Models/BillingPlanAddonDetails.php | 30 +-- .../Models/BillingPlanSupportedAddons.php | 14 +- src/Appwrite/Models/Block.php | 19 +- src/Appwrite/Models/Bucket.php | 58 ++--- src/Appwrite/Models/BucketList.php | 7 +- src/Appwrite/Models/Collection.php | 39 +-- src/Appwrite/Models/CollectionList.php | 7 +- src/Appwrite/Models/ColumnBigint.php | 27 +- src/Appwrite/Models/ColumnBoolean.php | 27 +- src/Appwrite/Models/ColumnDatetime.php | 27 +- src/Appwrite/Models/ColumnEmail.php | 31 +-- src/Appwrite/Models/ColumnEnum.php | 31 +-- src/Appwrite/Models/ColumnFloat.php | 27 +- src/Appwrite/Models/ColumnIndex.php | 38 +-- src/Appwrite/Models/ColumnIndexList.php | 7 +- src/Appwrite/Models/ColumnInteger.php | 27 +- src/Appwrite/Models/ColumnIp.php | 31 +-- src/Appwrite/Models/ColumnLine.php | 27 +- src/Appwrite/Models/ColumnList.php | 7 +- src/Appwrite/Models/ColumnLongtext.php | 27 +- src/Appwrite/Models/ColumnMediumtext.php | 27 +- src/Appwrite/Models/ColumnPoint.php | 27 +- src/Appwrite/Models/ColumnPolygon.php | 27 +- src/Appwrite/Models/ColumnRelationship.php | 47 +--- src/Appwrite/Models/ColumnString.php | 31 +-- src/Appwrite/Models/ColumnText.php | 27 +- src/Appwrite/Models/ColumnUrl.php | 31 +-- src/Appwrite/Models/ColumnVarchar.php | 31 +-- src/Appwrite/Models/Continent.php | 10 +- src/Appwrite/Models/ContinentList.php | 7 +- src/Appwrite/Models/Country.php | 10 +- src/Appwrite/Models/CountryList.php | 7 +- src/Appwrite/Models/Currency.php | 30 +-- src/Appwrite/Models/CurrencyList.php | 7 +- src/Appwrite/Models/Database.php | 26 +- src/Appwrite/Models/DatabaseList.php | 7 +- src/Appwrite/Models/DatabaseMigration.php | 70 ++--- src/Appwrite/Models/DatabaseMigrationList.php | 7 +- src/Appwrite/Models/DatabaseStatus.php | 39 +-- .../Models/DatabaseStatusConnections.php | 10 +- src/Appwrite/Models/DatabaseStatusReplica.php | 14 +- src/Appwrite/Models/DatabaseStatusVolume.php | 18 +- src/Appwrite/Models/DedicatedDatabase.php | 175 ++++--------- .../Models/DedicatedDatabaseBackup.php | 50 +--- .../Models/DedicatedDatabaseBackupList.php | 7 +- .../Models/DedicatedDatabaseBackupStorage.php | 22 +- .../Models/DedicatedDatabaseBranch.php | 47 +--- .../Models/DedicatedDatabaseBranchList.php | 7 +- .../Models/DedicatedDatabaseExecution.php | 23 +- .../DedicatedDatabaseExecutionColumn.php | 10 +- .../Models/DedicatedDatabaseExtensions.php | 11 +- src/Appwrite/Models/DedicatedDatabaseList.php | 7 +- .../Models/DedicatedDatabaseMember.php | 14 +- .../Models/DedicatedDatabaseOperation.php | 34 +-- .../Models/DedicatedDatabaseOperationList.php | 7 +- .../Models/DedicatedDatabasePITRWindows.php | 10 +- .../Models/DedicatedDatabasePooler.php | 42 +-- .../Models/DedicatedDatabaseReplicas.php | 23 +- .../Models/DedicatedDatabaseRestoration.php | 31 +-- .../DedicatedDatabaseRestorationList.php | 7 +- .../Models/DedicatedDatabaseSpecification.php | 38 +-- .../DedicatedDatabaseSpecificationList.php | 7 +- src/Appwrite/Models/Deployment.php | 107 +++----- src/Appwrite/Models/DeploymentList.php | 7 +- src/Appwrite/Models/Document.php | 27 +- src/Appwrite/Models/DocumentList.php | 7 +- src/Appwrite/Models/EmailTemplate.php | 34 +-- src/Appwrite/Models/EmailTemplateList.php | 7 +- src/Appwrite/Models/Embedding.php | 18 +- src/Appwrite/Models/EmbeddingList.php | 7 +- src/Appwrite/Models/EphemeralKey.php | 35 +-- src/Appwrite/Models/Execution.php | 55 ++-- src/Appwrite/Models/ExecutionList.php | 7 +- src/Appwrite/Models/File.php | 66 ++--- src/Appwrite/Models/FileList.php | 7 +- src/Appwrite/Models/Framework.php | 15 +- src/Appwrite/Models/FrameworkAdapter.php | 18 +- src/Appwrite/Models/FrameworkList.php | 7 +- src/Appwrite/Models/FunctionList.php | 7 +- src/Appwrite/Models/FunctionModel.php | 127 +++------ src/Appwrite/Models/Headers.php | 10 +- src/Appwrite/Models/Identity.php | 42 +-- src/Appwrite/Models/IdentityList.php | 7 +- src/Appwrite/Models/Index.php | 35 +-- src/Appwrite/Models/IndexList.php | 7 +- src/Appwrite/Models/Insight.php | 55 ++-- src/Appwrite/Models/InsightCTA.php | 18 +- src/Appwrite/Models/InsightList.php | 7 +- src/Appwrite/Models/Jwt.php | 6 +- src/Appwrite/Models/Key.php | 35 +-- src/Appwrite/Models/KeyList.php | 7 +- src/Appwrite/Models/Language.php | 14 +- src/Appwrite/Models/LanguageList.php | 7 +- src/Appwrite/Models/Locale.php | 30 +-- src/Appwrite/Models/LocaleCode.php | 10 +- src/Appwrite/Models/LocaleCodeList.php | 7 +- src/Appwrite/Models/Membership.php | 62 ++--- src/Appwrite/Models/MembershipList.php | 7 +- src/Appwrite/Models/Message.php | 31 +-- src/Appwrite/Models/MessageList.php | 7 +- src/Appwrite/Models/MfaChallenge.php | 18 +- src/Appwrite/Models/MfaChallengeSecret.php | 22 +- src/Appwrite/Models/MfaFactors.php | 22 +- src/Appwrite/Models/MfaRecoveryCodes.php | 6 +- src/Appwrite/Models/MfaType.php | 10 +- src/Appwrite/Models/MockNumber.php | 18 +- src/Appwrite/Models/MockNumberList.php | 7 +- src/Appwrite/Models/OAuth2Amazon.php | 18 +- src/Appwrite/Models/OAuth2Apple.php | 26 +- src/Appwrite/Models/OAuth2Appwrite.php | 18 +- src/Appwrite/Models/OAuth2Auth0.php | 22 +- src/Appwrite/Models/OAuth2Authentik.php | 22 +- src/Appwrite/Models/OAuth2Autodesk.php | 18 +- src/Appwrite/Models/OAuth2Bitbucket.php | 18 +- src/Appwrite/Models/OAuth2Bitly.php | 18 +- src/Appwrite/Models/OAuth2Box.php | 18 +- src/Appwrite/Models/OAuth2Cloudflare.php | 18 +- src/Appwrite/Models/OAuth2Dailymotion.php | 18 +- src/Appwrite/Models/OAuth2Discord.php | 18 +- src/Appwrite/Models/OAuth2Disqus.php | 18 +- src/Appwrite/Models/OAuth2Dropbox.php | 18 +- src/Appwrite/Models/OAuth2Etsy.php | 18 +- src/Appwrite/Models/OAuth2Facebook.php | 18 +- src/Appwrite/Models/OAuth2Figma.php | 18 +- src/Appwrite/Models/OAuth2FusionAuth.php | 22 +- src/Appwrite/Models/OAuth2Github.php | 18 +- src/Appwrite/Models/OAuth2Gitlab.php | 22 +- src/Appwrite/Models/OAuth2Google.php | 22 +- src/Appwrite/Models/OAuth2HuggingFace.php | 18 +- src/Appwrite/Models/OAuth2Keycloak.php | 26 +- src/Appwrite/Models/OAuth2Kick.php | 18 +- src/Appwrite/Models/OAuth2Linkedin.php | 18 +- src/Appwrite/Models/OAuth2Microsoft.php | 22 +- src/Appwrite/Models/OAuth2Notion.php | 18 +- src/Appwrite/Models/OAuth2Oidc.php | 38 +-- src/Appwrite/Models/OAuth2Okta.php | 26 +- src/Appwrite/Models/OAuth2Paypal.php | 18 +- src/Appwrite/Models/OAuth2Podio.php | 18 +- src/Appwrite/Models/OAuth2ProviderList.php | 7 +- src/Appwrite/Models/OAuth2Resend.php | 18 +- src/Appwrite/Models/OAuth2Salesforce.php | 18 +- src/Appwrite/Models/OAuth2Slack.php | 18 +- src/Appwrite/Models/OAuth2Spotify.php | 18 +- src/Appwrite/Models/OAuth2Stripe.php | 18 +- src/Appwrite/Models/OAuth2Tradeshift.php | 18 +- src/Appwrite/Models/OAuth2Twitch.php | 18 +- src/Appwrite/Models/OAuth2WordPress.php | 18 +- src/Appwrite/Models/OAuth2X.php | 18 +- src/Appwrite/Models/OAuth2Yahoo.php | 18 +- src/Appwrite/Models/OAuth2Yandex.php | 18 +- src/Appwrite/Models/OAuth2Zoho.php | 18 +- src/Appwrite/Models/OAuth2Zoom.php | 18 +- src/Appwrite/Models/Oauth2Approve.php | 6 +- src/Appwrite/Models/Oauth2Authorize.php | 10 +- src/Appwrite/Models/Oauth2Consent.php | 42 +-- src/Appwrite/Models/Oauth2ConsentList.php | 7 +- src/Appwrite/Models/Oauth2ConsentToken.php | 46 +--- .../Models/Oauth2ConsentTokenList.php | 7 +- .../Models/Oauth2DeviceAuthorization.php | 26 +- src/Appwrite/Models/Oauth2Grant.php | 50 +--- src/Appwrite/Models/Oauth2Organization.php | 6 +- .../Models/Oauth2OrganizationList.php | 7 +- src/Appwrite/Models/Oauth2PAR.php | 10 +- src/Appwrite/Models/Oauth2Project.php | 14 +- src/Appwrite/Models/Oauth2ProjectList.php | 7 +- src/Appwrite/Models/Oauth2Reject.php | 6 +- src/Appwrite/Models/Oauth2Token.php | 22 +- src/Appwrite/Models/Organization.php | 55 ++-- src/Appwrite/Models/Phone.php | 14 +- src/Appwrite/Models/PhoneList.php | 7 +- src/Appwrite/Models/PlatformAndroid.php | 23 +- src/Appwrite/Models/PlatformApple.php | 23 +- src/Appwrite/Models/PlatformLinux.php | 23 +- src/Appwrite/Models/PlatformList.php | 7 +- src/Appwrite/Models/PlatformWeb.php | 23 +- src/Appwrite/Models/PlatformWindows.php | 23 +- .../Models/PolicyDenyAliasedEmail.php | 10 +- .../Models/PolicyDenyCorporateEmail.php | 10 +- .../Models/PolicyDenyDisposableEmail.php | 10 +- src/Appwrite/Models/PolicyDenyFreeEmail.php | 10 +- src/Appwrite/Models/PolicyList.php | 7 +- .../Models/PolicyMembershipPrivacy.php | 30 +-- src/Appwrite/Models/PolicyMfaFactors.php | 22 +- .../Models/PolicyPasswordDictionary.php | 10 +- src/Appwrite/Models/PolicyPasswordHistory.php | 10 +- .../Models/PolicyPasswordPersonalData.php | 10 +- .../Models/PolicyPasswordStrength.php | 26 +- src/Appwrite/Models/PolicySessionAlert.php | 10 +- src/Appwrite/Models/PolicySessionDuration.php | 10 +- .../Models/PolicySessionInvalidation.php | 10 +- src/Appwrite/Models/PolicySessionLimit.php | 10 +- src/Appwrite/Models/PolicyUserLimit.php | 10 +- src/Appwrite/Models/PostgresExtension.php | 18 +- src/Appwrite/Models/Presence.php | 23 +- src/Appwrite/Models/PresenceList.php | 7 +- src/Appwrite/Models/Program.php | 38 +-- src/Appwrite/Models/Project.php | 91 ++----- src/Appwrite/Models/ProjectAuthMethod.php | 7 +- src/Appwrite/Models/ProjectList.php | 7 +- src/Appwrite/Models/ProjectProtocol.php | 7 +- src/Appwrite/Models/ProjectService.php | 7 +- src/Appwrite/Models/Provider.php | 34 +-- src/Appwrite/Models/ProviderList.php | 7 +- src/Appwrite/Models/ProxyInvalidation.php | 18 +- src/Appwrite/Models/ProxyRule.php | 55 ++-- src/Appwrite/Models/ProxyRuleList.php | 7 +- src/Appwrite/Models/Report.php | 43 +--- src/Appwrite/Models/ReportList.php | 7 +- src/Appwrite/Models/ResourceToken.php | 30 +-- src/Appwrite/Models/ResourceTokenList.php | 7 +- src/Appwrite/Models/Row.php | 27 +- src/Appwrite/Models/RowList.php | 7 +- src/Appwrite/Models/Runtime.php | 31 +-- src/Appwrite/Models/RuntimeList.php | 7 +- src/Appwrite/Models/Session.php | 118 +++------ src/Appwrite/Models/SessionList.php | 7 +- src/Appwrite/Models/Site.php | 131 +++------- src/Appwrite/Models/SiteList.php | 7 +- src/Appwrite/Models/Specification.php | 18 +- src/Appwrite/Models/SpecificationList.php | 7 +- src/Appwrite/Models/Subscriber.php | 35 +-- src/Appwrite/Models/SubscriberList.php | 7 +- src/Appwrite/Models/Table.php | 39 +-- src/Appwrite/Models/TableList.php | 7 +- src/Appwrite/Models/Target.php | 34 +-- src/Appwrite/Models/TargetList.php | 7 +- src/Appwrite/Models/Team.php | 23 +- src/Appwrite/Models/TeamList.php | 7 +- src/Appwrite/Models/Token.php | 26 +- src/Appwrite/Models/Topic.php | 34 +-- src/Appwrite/Models/TopicList.php | 7 +- src/Appwrite/Models/Transaction.php | 26 +- src/Appwrite/Models/TransactionList.php | 7 +- src/Appwrite/Models/User.php | 59 ++--- src/Appwrite/Models/UserList.php | 7 +- src/Appwrite/Models/Variable.php | 34 +-- src/Appwrite/Models/VariableList.php | 7 +- src/Appwrite/Models/VectorsdbCollection.php | 43 +--- .../Models/VectorsdbCollectionList.php | 7 +- src/Appwrite/Models/Webhook.php | 54 ++-- src/Appwrite/Models/WebhookList.php | 7 +- 292 files changed, 2289 insertions(+), 4649 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bde6f64e..9c18a87e 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 98d59f34..4719250f 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 f1af42c6..8bc1f62d 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 191d993d..8fd47418 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 532bf02f..daaabbf0 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 c5acb0ab..b446ae10 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' => "", + 'timeCost' => "", + 'threads' => "", + ]; return new static( type: $data['type'], diff --git a/src/Appwrite/Models/AlgoBcrypt.php b/src/Appwrite/Models/AlgoBcrypt.php index a2a916bb..34e048a0 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 3abcce42..4466b61c 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 9ce1b082..97d43b99 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 fd2e3e39..b87365ba 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 20e306e4..a4ba21bc 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 69661214..6bf6c9bd 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 78e5c79a..24d11d56 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 ccb07f61..8d19f61f 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 9c03edc3..cd5c3396 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 49a44339..9d73e0d7 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 47febab3..25f9edf9 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 2c34b679..c79879f7 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 09bf0e49..7ccaf66a 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 60d74c0b..c2259a7c 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 fe952101..eae43eb6 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 3e44cd97..1f6e6b56 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 08258206..4b028315 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 d82efa63..18fcf882 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 0f07edee..27721548 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 f5bdb09e..89a3da8d 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 40c7713d..659961e7 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 2e787048..d2d84316 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 70dd498b..84ca8200 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 096bb3ae..3c4a9f37 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 f4b8cd2f..0254fee3 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 c0b86b2a..7985b285 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 851af79a..0dd3e89e 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 ca6cdc7e..15e3fcd7 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 e0369578..d66da297 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 9675c7d1..f1e5e5a9 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 36d4bacf..94f85fd3 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 6416edd1..9005ded2 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 3ccb2c38..f23f7715 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 51b74698..85e1d4ad 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 5efc568b..0917a270 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 3396b69d..0e518b98 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 cb8e0858..d624f747 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 782068af..a0f547f3 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 f70d7a99..44422c20 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 635f8ccd..49691da9 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 1ccc459f..790139c0 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 0cc3171a..f27fe912 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 7e43ad0b..c6581f63 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 707421f7..6d7f13dc 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 f7a61a7d..3c4d2a1a 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 cc972f38..c30690a3 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 0ecbe7bb..d83da8f0 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 16f0841e..f40cb573 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 b3589932..68c69dcc 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 c94dc2e2..4ee13e87 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 de2e7910..0a2a3811 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' => "", + '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 3617db98..435e41ad 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 34e70cfc..6a00d25c 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 7bbc0305..c1eb7db5 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 7eb241b5..d7be453a 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 f24369ed..77fca40e 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 925a656b..f9c4c458 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 c446e11a..47ba3301 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 2ef80f49..db545277 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 a5107ea5..b5eaf075 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 e0bb2706..bab1fa8a 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 a9d00a06..87707036 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 93b337c8..980652fd 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 2c513f5d..108ff6a4 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 7017212e..19c51262 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 9bea0bbc..2f31acd9 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 92671a50..f8045d11 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 293e5df4..5bf44148 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 71ce5770..527001f4 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 11e3fc95..2e007589 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 d8c265bc..867b158c 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 a2c66da5..7ab8b112 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 bb9ac368..74ce172f 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 3b0084d5..c02a7152 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 fdcc1705..3af16511 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 e41c058f..b0157fef 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 ae208f01..0a9210a9 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 87ee856f..7d0afd3b 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 718ebae5..d2b33e37 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 62382d90..bd3a45e1 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 2f109442..86fb3468 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 3e2cce0e..0ef8132f 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 2fa2cfbb..ae2528dd 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 f2597558..6fdaf141 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 f0862f3c..cf2e8a92 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 b313589f..607036fb 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 a0f6aed7..c3666b3a 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 28ad1490..2b0f84e9 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 81e70d2e..20efb501 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 079ee9ba..fb6b0225 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 6b5e881d..a9cafba2 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 2e20e401..47704627 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 ad45dbb7..4212a97d 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 ac2add76..12e54077 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 5ad74e1c..74c1c36a 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 6647bf59..b1532138 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 8c3c2467..a9784de3 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 990c9093..c8be722d 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 228f5b56..035dfc5d 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 9802ab1f..7710285e 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 adb5bfc5..e16d3abb 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 0bcc77d2..f0998f5c 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 512864bb..563630fe 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 9866762f..02927028 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 daf34058..b4491a49 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 d73bc7e3..1768bfdb 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 a223990e..9ac12067 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 b4d00c66..c009925f 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 843c077e..84e99d1e 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 c02e196c..b0cf5b9c 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 23dfcea9..8a34e498 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 6af65e24..ddf5354b 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 0c2df1ee..934220ab 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 b68d820f..161d29ea 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 029d802b..dde35f28 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 a3823c45..0709c91c 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 b95fab15..8ac7d6fa 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 e2b8e14f..ee91c286 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 24304528..7a0e9896 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 178e2d69..f934a390 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 ea4376e5..7c3efaff 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 82727ba4..d4e8d01d 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 becb9ef9..8188732e 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 6127a13e..e5f38db1 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 c661b8b4..a6fbc219 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 548d7cff..a7573ae5 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 7ce5e10b..82b4c282 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 f5b571bb..f16cced6 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 4fb538ae..ce47bac1 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 37a7c03d..4f2fbb8e 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 0692f83f..b5b50f95 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 303aae57..4513abad 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 c535a6ed..dfa3e4a9 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 6c544ee2..461f1fc5 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 3f957a1a..216deb87 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 e17d4766..042450fb 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 8c3b18bf..51c8a8d0 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 fb46caeb..6a57c4b8 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 55c2ba92..247a85fc 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 44699043..2b44c41a 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 c2b2a62e..59223a66 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 0887a74f..f3d01d23 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 713ff2cf..48529162 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 0a2d84b3..267901bc 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 de505118..ea36b3e9 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 cf630a67..ea24047a 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 d2eabe86..18615db6 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 638840d4..5b16ccfc 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 ea9e5533..e9ce8037 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 f4097590..65ba2e29 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 1ef79997..21eab3d6 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 106ce4e3..60291620 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 35884ef5..87319813 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 778fed67..b885f0a6 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 4c9c3225..83d6c4b8 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 0c47d143..46fe409f 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 2cc6a7d3..92ad773a 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 5be4ac9f..507431ee 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 bef81cf4..be7dd75c 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 c315fbea..a2301f5d 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 92adcd4f..453b4e0e 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 1d5e9736..50487882 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 4fa40091..9845c93a 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 7b99a738..25a1794f 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 05560127..47fd8355 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 af477a69..695d6894 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 5b8242d3..85d3a744 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 f3912238..fc5f6433 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 d3ee4b85..56854bb9 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 98c639b8..4f5bb669 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 e9e939c0..f8d91efc 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 8dd63025..7108b5df 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 687f946c..a4f0a51a 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 44f6e011..9ae77113 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 4c149cab..62bad596 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 e9bcba0e..fa893a42 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 109d947d..694e4caf 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 4de9c591..5be06bc6 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 055b5382..a55d3e7c 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 f2021019..3f4a32f6 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 d2a252e3..c43c638b 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 db84e72a..226724bf 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 edecdfc1..0e3c3eac 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 fb40014e..bd2607be 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 5e741b93..3f695ffb 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 02244d4c..fd51b59e 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 b53be944..069ab8db 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 b03ad821..770dd7db 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 d9fb9a2c..08a80be0 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 d5becb06..16e5108c 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 d931eac6..e1f9b74c 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 ce0d76ff..70ad1ebc 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 f197b677..1e31a1ed 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 1250e72a..6cade4b2 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 76102249..a16d5e30 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 47dfabf1..354c0719 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 21ebd869..e0830331 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 38e866b5..5b043a20 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 e5d9957d..a81b1014 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 22b11a08..16ddf7cd 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 f53d6af6..5b83a171 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 cb708cb2..6b527220 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 a86ff2df..0a0a7bb4 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 f8dd64b4..ff08bd89 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 0d0991c4..c4a8c138 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 d251fa22..25ebc747 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 e7ca6867..6549f554 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 07b21311..2bf9d6c3 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 3919e543..6f3c8a1c 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 b4aa53b4..111dda83 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 0db98197..78f3d0dc 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 53f0add4..f6d66df0 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 92160ce5..569bc18f 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 1c99fe93..33db24d1 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 76d7227e..ac802484 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 48ace53b..1b809570 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 610f8153..773bb4e1 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 64f3b0de..22fc6187 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 50513f56..c8d64a41 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 4f9d78a6..7be14592 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 107f7715..a3a7bec6 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 977ceb60..b427b06a 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 e756f82c..98947600 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 6fdb54ee..c5cd5cbd 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 3db8231e..94264547 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 f05ed52f..a1599a40 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 db8ec85d..a625a123 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 e6eecd63..ce2938a0 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 4b1c34c4..32a1ff66 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 d59a9f9e..d08a1743 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 aad948c0..919a032f 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 4974fafd..d03d93a8 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 0b4126f1..8d59d218 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 d37938b3..2dba845a 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 27ab89aa..c139d5bb 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 94d8775a..49c5b449 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 abc120e7..a5b645e7 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 84c15d24..1f5dee2e 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 676f8fa8..95ae696c 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 7f35fe93..c363e108 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 a2e8f6ff..8a1f2bd7 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 d8f551ab..9898e6ad 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 28759de9..44aef67e 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 ec34ea00..f7261447 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 285292b1..0804bb78 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 e1fd286e..9f215abf 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 a0bd6113..382c5046 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 6a13de52..68bbeb5d 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 d40cde52..21b206ac 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 948ec1d7..cc9f7583 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 c86f84a6..413058a4 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 3b09e61a..8ecd43f9 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 839cea7a..ea32a528 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 76b380de..409cd33a 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 be6b50e6..2b9b1885 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 45aaf8a9..d37ab8ab 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 4eff1c5d..f5194b86 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 349f5ead..6b51ebed 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 071c8dfe..32baecf3 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 c4eba764..2374f0f1 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 c006f1a5..33e062cc 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 5adb2086..671bb5d4 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 371d171c..e3b32b48 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 0790b192..8ffeaccd 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 d699c842..e48faded 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 7efd6f0c..f4768059 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 03b3c32f..705cb0b5 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 dce6d3a5..5ad8103d 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' => "", + '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 994c11e1..c6352fb6 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 00a4decb..e25e4f5e 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 fe5c10ac..8596f116 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 463418cf..cea7901d 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 02e2b53b..8c75339d 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 2056faa6..d16f668d 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 caa2fcff..fbf02394 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 9cfdc2ec..4ba86969 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 ff65aa52..085038c1 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 539e4357..7e17740d 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 da0157ca..33fd99ee 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 fb77b479..8c4d99d0 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 8fe97fab..1f9cf830 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 9522d7c8..698af61c 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 512dc08c..2e9f1dc4 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' => "", + '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 a7f870f4..e5c2c05c 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 0c8c585c..9f1bef97 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 c402119f..dafb70d4 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 . '.'); } From c949065d600182d79e256838281e3d43583f40a3 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 12 Oct 2026 14:44:18 +0100 Subject: [PATCH 2/2] fix: use integer and boolean defaults where the spec's were empty strings AlgoArgon2's cost fields and the documentSecurity and rowSecurity flags took a '' default, which strict types turn into a TypeError when the field is missing. They now take 0 and false, as the spec emits after appwrite/appwrite#14370. --- src/Appwrite/Models/AlgoArgon2.php | 6 +++--- src/Appwrite/Models/Collection.php | 2 +- src/Appwrite/Models/Table.php | 2 +- src/Appwrite/Models/VectorsdbCollection.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Models/AlgoArgon2.php b/src/Appwrite/Models/AlgoArgon2.php index b446ae10..4b07065f 100644 --- a/src/Appwrite/Models/AlgoArgon2.php +++ b/src/Appwrite/Models/AlgoArgon2.php @@ -36,9 +36,9 @@ public static function from(array $data): static { $data += [ 'type' => "argon2", - 'memoryCost' => "", - 'timeCost' => "", - 'threads' => "", + 'memoryCost' => 0, + 'timeCost' => 0, + 'threads' => 0, ]; return new static( diff --git a/src/Appwrite/Models/Collection.php b/src/Appwrite/Models/Collection.php index 0a2a3811..34e1ff95 100644 --- a/src/Appwrite/Models/Collection.php +++ b/src/Appwrite/Models/Collection.php @@ -57,7 +57,7 @@ public static function from(array $data): static 'databaseId' => "", 'name' => "", 'enabled' => true, - 'documentSecurity' => "", + 'documentSecurity' => false, 'bytesMax' => 0, 'bytesUsed' => 0, ]; diff --git a/src/Appwrite/Models/Table.php b/src/Appwrite/Models/Table.php index 5ad8103d..49869583 100644 --- a/src/Appwrite/Models/Table.php +++ b/src/Appwrite/Models/Table.php @@ -57,7 +57,7 @@ public static function from(array $data): static 'databaseId' => "", 'name' => "", 'enabled' => true, - 'rowSecurity' => "", + 'rowSecurity' => false, 'bytesMax' => 0, 'bytesUsed' => 0, ]; diff --git a/src/Appwrite/Models/VectorsdbCollection.php b/src/Appwrite/Models/VectorsdbCollection.php index 2e9f1dc4..38e5ec63 100644 --- a/src/Appwrite/Models/VectorsdbCollection.php +++ b/src/Appwrite/Models/VectorsdbCollection.php @@ -59,7 +59,7 @@ public static function from(array $data): static 'databaseId' => "", 'name' => "", 'enabled' => true, - 'documentSecurity' => "", + 'documentSecurity' => false, 'bytesMax' => 0, 'bytesUsed' => 0, 'dimension' => 0,