Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 24.1.0

* Added `sizeActual` property to `File` model for actual stored size after compression/encryption
* Updated `BillingLimits` properties to be nullable to match the server's sparse "limits crossed" response
* Updated `Project.billingLimits` to be nullable
* Updated advisor example docs to use API key authentication
* Removed orphaned `Prompt` enum (already unused; superseded by `ProjectOAuth2GooglePrompt` in 24.0.0)

## 24.0.0

* Breaking: Renamed `AuthMethod` enum to `ProjectAuthMethodId`
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/advisor/get-insight.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor;
$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setSession(''); // The user session to authenticate with
->setKey('<YOUR_API_KEY>'); // Your secret API key

$advisor = new Advisor($client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/advisor/get-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor;
$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setSession(''); // The user session to authenticate with
->setKey('<YOUR_API_KEY>'); // Your secret API key

$advisor = new Advisor($client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/advisor/list-insights.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor;
$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setSession(''); // The user session to authenticate with
->setKey('<YOUR_API_KEY>'); // Your secret API key

$advisor = new Advisor($client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/advisor/list-reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor;
$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setSession(''); // The user session to authenticate with
->setKey('<YOUR_API_KEY>'); // Your secret API key

$advisor = new Advisor($client);

Expand Down
16 changes: 0 additions & 16 deletions docs/examples/project/update-deny-canonical-email-policy.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client
*/
protected array $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/24.0.0 ()',
'user-agent' => 'AppwritePHPSDK/24.1.0 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '24.0.0',
'x-sdk-version'=> '24.1.0',
];

/**
Expand Down
61 changes: 0 additions & 61 deletions src/Appwrite/Enums/Prompt.php

This file was deleted.

72 changes: 24 additions & 48 deletions src/Appwrite/Models/BillingLimits.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
/**
* BillingLimits constructor.
*
* @param int $bandwidth bandwidth limit
* @param int $storage storage limit
* @param int $users users limit
* @param int $executions executions limit
* @param int $gBHours gbhours limit
* @param int $imageTransformations image transformations limit
* @param int $authPhone auth phone limit
* @param int $budgetLimit budget limit percentage
* @param int|null $bandwidth bandwidth limit
* @param int|null $storage storage limit
* @param int|null $users users limit
* @param int|null $executions executions limit
* @param int|null $gBHours gbhours limit
* @param int|null $imageTransformations image transformations limit
* @param int|null $authPhone auth phone limit
* @param int|null $budgetLimit budget limit percentage
*/
public function __construct(
public int $bandwidth,
public int $storage,
public int $users,
public int $executions,
public int $gBHours,
public int $imageTransformations,
public int $authPhone,
public int $budgetLimit
public ?int $bandwidth = null,
public ?int $storage = null,
public ?int $users = null,
public ?int $executions = null,
public ?int $gBHours = null,
public ?int $imageTransformations = null,
public ?int $authPhone = null,
public ?int $budgetLimit = null
) {
}

Expand All @@ -38,40 +38,16 @@ public function __construct(
*/
public static function from(array $data): static
{
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('users', $data)) {
throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.');
}
if (!array_key_exists('executions', $data)) {
throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.');
}
if (!array_key_exists('GBHours', $data)) {
throw new \InvalidArgumentException('Missing required field "GBHours" for ' . static::class . '.');
}
if (!array_key_exists('imageTransformations', $data)) {
throw new \InvalidArgumentException('Missing required field "imageTransformations" for ' . static::class . '.');
}
if (!array_key_exists('authPhone', $data)) {
throw new \InvalidArgumentException('Missing required field "authPhone" for ' . static::class . '.');
}
if (!array_key_exists('budgetLimit', $data)) {
throw new \InvalidArgumentException('Missing required field "budgetLimit" for ' . static::class . '.');
}

return new static(
Comment on lines 39 to 42
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 There is a stray blank line immediately after the opening brace of from(), left over from removing the required-field validation blocks. It has no functional impact but looks unintentional.

Suggested change
public static function from(array $data): static
{
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('users', $data)) {
throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.');
}
if (!array_key_exists('executions', $data)) {
throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.');
}
if (!array_key_exists('GBHours', $data)) {
throw new \InvalidArgumentException('Missing required field "GBHours" for ' . static::class . '.');
}
if (!array_key_exists('imageTransformations', $data)) {
throw new \InvalidArgumentException('Missing required field "imageTransformations" for ' . static::class . '.');
}
if (!array_key_exists('authPhone', $data)) {
throw new \InvalidArgumentException('Missing required field "authPhone" for ' . static::class . '.');
}
if (!array_key_exists('budgetLimit', $data)) {
throw new \InvalidArgumentException('Missing required field "budgetLimit" for ' . static::class . '.');
}
return new static(
public static function from(array $data): static
{
return new static(

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

bandwidth: $data['bandwidth'],
storage: $data['storage'],
users: $data['users'],
executions: $data['executions'],
gBHours: $data['GBHours'],
imageTransformations: $data['imageTransformations'],
authPhone: $data['authPhone'],
budgetLimit: $data['budgetLimit']
bandwidth: array_key_exists('bandwidth', $data) ? $data['bandwidth'] : null,
storage: array_key_exists('storage', $data) ? $data['storage'] : null,
users: array_key_exists('users', $data) ? $data['users'] : null,
executions: array_key_exists('executions', $data) ? $data['executions'] : null,
gBHours: array_key_exists('GBHours', $data) ? $data['GBHours'] : null,
imageTransformations: array_key_exists('imageTransformations', $data) ? $data['imageTransformations'] : null,
authPhone: array_key_exists('authPhone', $data) ? $data['authPhone'] : null,
budgetLimit: array_key_exists('budgetLimit', $data) ? $data['budgetLimit'] : null
);
}

Expand Down
7 changes: 7 additions & 0 deletions src/Appwrite/Models/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @param string $signature file md5 signature.
* @param string $mimeType file mime type.
* @param int $sizeOriginal file original size in bytes.
* @param int $sizeActual file actual stored size in bytes after compression and/or encryption.
* @param int $chunksTotal total number of chunks available
* @param int $chunksUploaded total number of chunks uploaded
* @param bool $encryption whether file contents are encrypted at rest.
Expand All @@ -36,6 +37,7 @@ public function __construct(
public string $signature,
public string $mimeType,
public int $sizeOriginal,
public int $sizeActual,
public int $chunksTotal,
public int $chunksUploaded,
public bool $encryption,
Expand Down Expand Up @@ -75,6 +77,9 @@ public static function from(array $data): static
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 . '.');
}
Expand All @@ -98,6 +103,7 @@ public static function from(array $data): static
signature: $data['signature'],
mimeType: $data['mimeType'],
sizeOriginal: $data['sizeOriginal'],
sizeActual: $data['sizeActual'],
chunksTotal: $data['chunksTotal'],
chunksUploaded: $data['chunksUploaded'],
encryption: $data['encryption'],
Expand All @@ -120,6 +126,7 @@ public function toArray(): array
'signature' => static::serializeValue($this->signature),
'mimeType' => static::serializeValue($this->mimeType),
'sizeOriginal' => static::serializeValue($this->sizeOriginal),
'sizeActual' => static::serializeValue($this->sizeActual),
'chunksTotal' => static::serializeValue($this->chunksTotal),
'chunksUploaded' => static::serializeValue($this->chunksUploaded),
'encryption' => static::serializeValue($this->encryption),
Expand Down
13 changes: 5 additions & 8 deletions src/Appwrite/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
* @param list<ProjectService> $services list of services.
* @param list<ProjectProtocol> $protocols list of protocols.
* @param string $region project region
* @param BillingLimits $billingLimits billing limits reached
* @param list<Block> $blocks project blocks information
* @param string $consoleAccessedAt last time the project was accessed via console. used with plan's projectinactivitydays to determine if project is paused.
* @param BillingLimits|null $billingLimits billing limits reached
*/
public function __construct(
public string $id,
Expand All @@ -65,9 +65,9 @@ public function __construct(
public array $services,
public array $protocols,
public string $region,
public BillingLimits $billingLimits,
public array $blocks,
public string $consoleAccessedAt
public string $consoleAccessedAt,
public ?BillingLimits $billingLimits = null
) {
}

Expand Down Expand Up @@ -148,9 +148,6 @@ public static function from(array $data): static
if (!array_key_exists('region', $data)) {
throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.');
}
if (!array_key_exists('billingLimits', $data)) {
throw new \InvalidArgumentException('Missing required field "billingLimits" for ' . static::class . '.');
}
if (!array_key_exists('blocks', $data)) {
throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.');
}
Expand Down Expand Up @@ -203,14 +200,14 @@ public static function from(array $data): static
)
: $data['protocols'],
region: $data['region'],
billingLimits: static::hydrateTypedValue(BillingLimits::class, $data['billingLimits']),
blocks: is_array($data['blocks'])
? array_map(
static fn (mixed $item): mixed => static::hydrateTypedValue(Block::class, $item),
$data['blocks']
)
: $data['blocks'],
consoleAccessedAt: $data['consoleAccessedAt']
consoleAccessedAt: $data['consoleAccessedAt'],
billingLimits: array_key_exists('billingLimits', $data) ? static::hydrateTypedValue(BillingLimits::class, $data['billingLimits'], true) : null
);
}

Expand Down
Loading