Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 docs/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/google
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| clientId | string | 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com | |
| clientSecret | string | 'Client Secret' of Google OAuth2 app. For example: example-google-client-secret | |
| clientSecret | string | 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj | |
| prompt | array | Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. | |
| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | |

Expand Down Expand Up @@ -549,7 +549,7 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/linkedin
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| clientId | string | 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv | |
| primaryClientSecret | string | 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: example-linkedin-client-secret | |
| primaryClientSecret | string | 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== | |
| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | |


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
Loading