Skip to content

Commit 0de359a

Browse files
committed
chore: update PHP SDK to 23.0.0
1 parent 476e034 commit 0de359a

7 files changed

Lines changed: 149 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44

55
* [BREAKING] Renamed Webhook model fields: `security``tls`, `httpUser``authUsername`, `httpPass``authPassword`, `signatureKey``secret`
66
* [BREAKING] Renamed Webhook service parameters to match: `security``tls`, `httpUser``authUsername`, `httpPass``authPassword`
7+
* [BREAKING] Renamed `Webhooks::updateSignature()` to `Webhooks::updateSecret()` with new optional `secret` parameter
8+
* Added `from(array)` static factory method and `toArray()` serializer to all response models with required-field validation
79
* Added `secret` parameter to Webhook create and update methods
810
* Added `x` OAuth provider to `OAuthProvider` enum
911
* Added `userType` field to `Log` model
1012
* Added `purge` parameter to `updateCollection` and `updateTable` for cache invalidation
1113
* Added Project service: platform CRUD, key CRUD, protocol/service status management
12-
* Added new models: `Key`, `KeyList`, `PlatformAndroid`, `PlatformApple`, `PlatformLinux`, `PlatformList`, and others
14+
* Added new models: `Key`, `KeyList`, `Project`, `DevKey`, `MockNumber`, `AuthProvider`, `PlatformAndroid`, `PlatformApple`, `PlatformLinux`, `PlatformList`, `PlatformWeb`, `PlatformWindows`, `BillingLimits`, `Block`
1315
* Added new enums: `PlatformType`, `ProtocolId`, `ServiceId`
14-
* Updated `BuildRuntime`, `Runtime`, `Scopes` enums with new values
16+
* Updated `BuildRuntime`, `Runtime` enums with `dart-3.11` and `flutter-3.41`
17+
* Updated `Scopes` enum with `keysRead`, `keysWrite`, `platformsRead`, `platformsWrite`
1518
* Updated `X-Appwrite-Response-Format` header to `1.9.1`
1619
* Updated TTL description for list caching in Databases and TablesDB
20+
* Replaced internal `FIELD_MAP`/`ARRAY_TYPES` constants and `parseResponse()` with explicit `Model::from()` hydration
1721

1822
## 22.0.0
1923

src/Appwrite/Services/Databases.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,47 @@ public function getAttribute(string $databaseId, string $collectionId, string $k
26092609
throw new \UnexpectedValueException('Expected array response when hydrating a response model.');
26102610
}
26112611

2612-
return \Appwrite\Models\AttributeBoolean::from($response);
2612+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'email') {
2613+
return \Appwrite\Models\AttributeEmail::from($response);
2614+
}
2615+
2616+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'enum') {
2617+
return \Appwrite\Models\AttributeEnum::from($response);
2618+
}
2619+
2620+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'url') {
2621+
return \Appwrite\Models\AttributeUrl::from($response);
2622+
}
2623+
2624+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'ip') {
2625+
return \Appwrite\Models\AttributeIp::from($response);
2626+
}
2627+
2628+
if (($response['type'] ?? null) === 'boolean') {
2629+
return \Appwrite\Models\AttributeBoolean::from($response);
2630+
}
2631+
2632+
if (($response['type'] ?? null) === 'integer') {
2633+
return \Appwrite\Models\AttributeInteger::from($response);
2634+
}
2635+
2636+
if (($response['type'] ?? null) === 'double') {
2637+
return \Appwrite\Models\AttributeFloat::from($response);
2638+
}
2639+
2640+
if (($response['type'] ?? null) === 'datetime') {
2641+
return \Appwrite\Models\AttributeDatetime::from($response);
2642+
}
2643+
2644+
if (($response['type'] ?? null) === 'relationship') {
2645+
return \Appwrite\Models\AttributeRelationship::from($response);
2646+
}
2647+
2648+
if (($response['type'] ?? null) === 'string') {
2649+
return \Appwrite\Models\AttributeString::from($response);
2650+
}
2651+
2652+
throw new \UnexpectedValueException('Unable to match response to any expected response model.');
26132653

26142654
}
26152655

src/Appwrite/Services/Project.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,27 @@ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\A
742742
throw new \UnexpectedValueException('Expected array response when hydrating a response model.');
743743
}
744744

745-
return \Appwrite\Models\PlatformWeb::from($response);
745+
if (($response['type'] ?? null) === 'web') {
746+
return \Appwrite\Models\PlatformWeb::from($response);
747+
}
748+
749+
if (($response['type'] ?? null) === 'apple') {
750+
return \Appwrite\Models\PlatformApple::from($response);
751+
}
752+
753+
if (($response['type'] ?? null) === 'android') {
754+
return \Appwrite\Models\PlatformAndroid::from($response);
755+
}
756+
757+
if (($response['type'] ?? null) === 'windows') {
758+
return \Appwrite\Models\PlatformWindows::from($response);
759+
}
760+
761+
if (($response['type'] ?? null) === 'linux') {
762+
return \Appwrite\Models\PlatformLinux::from($response);
763+
}
764+
765+
throw new \UnexpectedValueException('Unable to match response to any expected response model.');
746766

747767
}
748768

src/Appwrite/Services/TablesDB.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,47 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap
24512451
throw new \UnexpectedValueException('Expected array response when hydrating a response model.');
24522452
}
24532453

2454-
return \Appwrite\Models\ColumnBoolean::from($response);
2454+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'email') {
2455+
return \Appwrite\Models\ColumnEmail::from($response);
2456+
}
2457+
2458+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'enum') {
2459+
return \Appwrite\Models\ColumnEnum::from($response);
2460+
}
2461+
2462+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'url') {
2463+
return \Appwrite\Models\ColumnUrl::from($response);
2464+
}
2465+
2466+
if (($response['type'] ?? null) === 'string' && ($response['format'] ?? null) === 'ip') {
2467+
return \Appwrite\Models\ColumnIp::from($response);
2468+
}
2469+
2470+
if (($response['type'] ?? null) === 'boolean') {
2471+
return \Appwrite\Models\ColumnBoolean::from($response);
2472+
}
2473+
2474+
if (($response['type'] ?? null) === 'integer') {
2475+
return \Appwrite\Models\ColumnInteger::from($response);
2476+
}
2477+
2478+
if (($response['type'] ?? null) === 'double') {
2479+
return \Appwrite\Models\ColumnFloat::from($response);
2480+
}
2481+
2482+
if (($response['type'] ?? null) === 'datetime') {
2483+
return \Appwrite\Models\ColumnDatetime::from($response);
2484+
}
2485+
2486+
if (($response['type'] ?? null) === 'relationship') {
2487+
return \Appwrite\Models\ColumnRelationship::from($response);
2488+
}
2489+
2490+
if (($response['type'] ?? null) === 'string') {
2491+
return \Appwrite\Models\ColumnString::from($response);
2492+
}
2493+
2494+
throw new \UnexpectedValueException('Unable to match response to any expected response model.');
24552495

24562496
}
24572497

tests/Appwrite/Services/DatabasesTest.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,15 +1553,20 @@ public function testMethodUpdateVarcharAttribute(): void
15531553

15541554
public function testMethodGetAttribute(): void
15551555
{
1556-
$data = array(
1557-
"key" => "fullName",
1558-
"type" => "string",
1559-
"status" => "available",
1560-
"error" => "string",
1561-
"required" => true,
1562-
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
1563-
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
1564-
"size" => 128
1556+
$data = array_replace(
1557+
array(
1558+
"key" => "fullName",
1559+
"type" => "string",
1560+
"status" => "available",
1561+
"error" => "string",
1562+
"required" => true,
1563+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
1564+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
1565+
"size" => 128
1566+
),
1567+
array(
1568+
"type" => "string"
1569+
)
15651570
);
15661571

15671572
$this->client

tests/Appwrite/Services/ProjectTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,18 @@ public function testMethodUpdateWindowsPlatform(): void
562562

563563
public function testMethodGetPlatform(): void
564564
{
565-
$data = array(
566-
"\$id" => "5e5ea5c16897e",
567-
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
568-
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
569-
"name" => "My Web App",
570-
"type" => "windows",
571-
"packageName" => "com.company.appname"
565+
$data = array_replace(
566+
array(
567+
"\$id" => "5e5ea5c16897e",
568+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
569+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
570+
"name" => "My Web App",
571+
"type" => "windows",
572+
"packageName" => "com.company.appname"
573+
),
574+
array(
575+
"type" => "linux"
576+
)
572577
);
573578

574579
$this->client

tests/Appwrite/Services/TablesDBTest.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,15 +1522,20 @@ public function testMethodUpdateVarcharColumn(): void
15221522

15231523
public function testMethodGetColumn(): void
15241524
{
1525-
$data = array(
1526-
"key" => "fullName",
1527-
"type" => "string",
1528-
"status" => "available",
1529-
"error" => "string",
1530-
"required" => true,
1531-
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
1532-
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
1533-
"size" => 128
1525+
$data = array_replace(
1526+
array(
1527+
"key" => "fullName",
1528+
"type" => "string",
1529+
"status" => "available",
1530+
"error" => "string",
1531+
"required" => true,
1532+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
1533+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
1534+
"size" => 128
1535+
),
1536+
array(
1537+
"type" => "string"
1538+
)
15341539
);
15351540

15361541
$this->client

0 commit comments

Comments
 (0)