|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace ImageKit\Accounts\UsageAnalytics; |
| 6 | + |
| 7 | +use ImageKit\Core\Attributes\Required; |
| 8 | +use ImageKit\Core\Concerns\SdkModel; |
| 9 | +use ImageKit\Core\Concerns\SdkParams; |
| 10 | +use ImageKit\Core\Contracts\BaseModel; |
| 11 | + |
| 12 | +/** |
| 13 | + * **Note:** This API is currently in beta. |
| 14 | + * |
| 15 | + * Get the account analytics data between two dates. The response covers the period from the start date to the end date, both dates inclusive. Both dates are interpreted as UTC calendar days. |
| 16 | + * |
| 17 | + * The returned data is scoped to the requesting account only. Unlike `/v1/accounts/usage`, an agency account's analytics are not aggregated across its child accounts. |
| 18 | + * |
| 19 | + * The response is cached for 5 minutes per account and date range. Use `generatedAt` to check how fresh the returned data is. |
| 20 | + * |
| 21 | + * @see ImageKit\Services\Accounts\UsageAnalyticsService::get() |
| 22 | + * |
| 23 | + * @phpstan-type UsageAnalyticsGetParamsShape = array{ |
| 24 | + * endDate: string, startDate: string |
| 25 | + * } |
| 26 | + */ |
| 27 | +final class UsageAnalyticsGetParams implements BaseModel |
| 28 | +{ |
| 29 | + /** @use SdkModel<UsageAnalyticsGetParamsShape> */ |
| 30 | + use SdkModel; |
| 31 | + use SdkParams; |
| 32 | + |
| 33 | + /** |
| 34 | + * Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days. |
| 35 | + */ |
| 36 | + #[Required] |
| 37 | + public string $endDate; |
| 38 | + |
| 39 | + /** |
| 40 | + * Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days. |
| 41 | + */ |
| 42 | + #[Required] |
| 43 | + public string $startDate; |
| 44 | + |
| 45 | + /** |
| 46 | + * `new UsageAnalyticsGetParams()` is missing required properties by the API. |
| 47 | + * |
| 48 | + * To enforce required parameters use |
| 49 | + * ``` |
| 50 | + * UsageAnalyticsGetParams::with(endDate: ..., startDate: ...) |
| 51 | + * ``` |
| 52 | + * |
| 53 | + * Otherwise ensure the following setters are called |
| 54 | + * |
| 55 | + * ``` |
| 56 | + * (new UsageAnalyticsGetParams)->withEndDate(...)->withStartDate(...) |
| 57 | + * ``` |
| 58 | + */ |
| 59 | + public function __construct() |
| 60 | + { |
| 61 | + $this->initialize(); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Construct an instance from the required parameters. |
| 66 | + * |
| 67 | + * You must use named parameters to construct any parameters with a default value. |
| 68 | + */ |
| 69 | + public static function with(string $endDate, string $startDate): self |
| 70 | + { |
| 71 | + $self = new self; |
| 72 | + |
| 73 | + $self['endDate'] = $endDate; |
| 74 | + $self['startDate'] = $startDate; |
| 75 | + |
| 76 | + return $self; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days. |
| 81 | + */ |
| 82 | + public function withEndDate(string $endDate): self |
| 83 | + { |
| 84 | + $self = clone $this; |
| 85 | + $self['endDate'] = $endDate; |
| 86 | + |
| 87 | + return $self; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days. |
| 92 | + */ |
| 93 | + public function withStartDate(string $startDate): self |
| 94 | + { |
| 95 | + $self = clone $this; |
| 96 | + $self['startDate'] = $startDate; |
| 97 | + |
| 98 | + return $self; |
| 99 | + } |
| 100 | +} |
0 commit comments