diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2aca35ae..4208b5cb 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.0" + ".": "0.6.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c8aab1..4a342386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 0.6.0 (2025-12-10) + +Full Changelog: [v0.5.0...v0.6.0](https://github.com/e-invoice-be/e-invoice-php/compare/v0.5.0...v0.6.0) + +### ⚠ BREAKING CHANGES + +* use camel casing for all class properties + +### Features + +* add `BaseResponse` class for accessing raw responses ([ebca89e](https://github.com/e-invoice-be/e-invoice-php/commit/ebca89eaa03eff90dd4ee4435910fb2c0658703e)) +* allow both model class instances and arrays in setters ([f22de1a](https://github.com/e-invoice-be/e-invoice-php/commit/f22de1aa99924f6721be1ab4a593f76e935661b9)) +* split out services into normal & raw types ([e290c64](https://github.com/e-invoice-be/e-invoice-php/commit/e290c6404f5c8db7ebea93902d3e69e54d9d9bf4)) +* use camel casing for all class properties ([9a81036](https://github.com/e-invoice-be/e-invoice-php/commit/9a81036ee96d23c0ab1cc22f68fde1555cb51f56)) + + +### Chores + +* ensure constant values are marked as optional in array types ([9cf1177](https://github.com/e-invoice-be/e-invoice-php/commit/9cf11779ff1e150b328100531e3e52d3f5f4d2ba)) +* **internal:** improve pagination tests ([e2a20ee](https://github.com/e-invoice-be/e-invoice-php/commit/e2a20ee5fa4bc6830ecfb9484082042ddfc61694)) +* switch from `#[Api(optional: true|false)]` to `#[Required]|#[Optional]` for annotations ([e2085d4](https://github.com/e-invoice-be/e-invoice-php/commit/e2085d469c3dac597e44ffc38f3cabef6401e8d3)) +* use `$self = clone $this;` instead of `$obj = clone $this;` ([3d841fa](https://github.com/e-invoice-be/e-invoice-php/commit/3d841fa738d64708d78b6b321b66bf13651c774f)) + ## 0.5.0 (2025-12-05) Full Changelog: [v0.4.1...v0.5.0](https://github.com/e-invoice-be/e-invoice-php/compare/v0.4.1...v0.5.0) diff --git a/README.md b/README.md index f9b65996..f44ba875 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ use EInvoiceAPI\Client; $client = new Client(apiKey: getenv('E_INVOICE_API_KEY') ?: 'My API Key'); -$documentResponse = $client->documents->create([]); +$documentResponse = $client->documents->create(); var_dump($documentResponse->id); ``` @@ -67,7 +67,7 @@ use EInvoiceAPI\Client; $client = new Client(apiKey: getenv('E_INVOICE_API_KEY') ?: 'My API Key'); -$page = $client->inbox->list([]); +$page = $client->inbox->list(); var_dump($page); @@ -91,11 +91,11 @@ When the library is unable to connect to the API, or if the API returns a non-su use EInvoiceAPI\Core\Exceptions\APIConnectionException; try { - $documentResponse = $client->documents->create([]); + $documentResponse = $client->documents->create(); } catch (APIConnectionException $e) { echo "The server could not be reached", PHP_EOL; var_dump($e->getPrevious()); -} catch (RateLimitError $_) { +} catch (RateLimitError $e) { echo "A 429 status code was received; we should back off a bit.", PHP_EOL; } catch (APIStatusError $e) { echo "Another non-200-range status code was received", PHP_EOL; @@ -137,7 +137,9 @@ use EInvoiceAPI\RequestOptions; $client = new Client(maxRetries: 0); // Or, configure per-request: -$result = $client->documents->create([], RequestOptions::with(maxRetries: 5)); +$result = $client->documents->create( + requestOptions: RequestOptions::with(maxRetries: 5) +); ``` ## Advanced concepts @@ -156,8 +158,7 @@ Note: the `extra*` parameters of the same name overrides the documented paramete use EInvoiceAPI\RequestOptions; $documentResponse = $client->documents->create( - [], - RequestOptions::with( + requestOptions: RequestOptions::with( extraQueryParams: ['my_query_parameter' => 'value'], extraBodyParams: ['my_body_parameter' => 'value'], extraHeaders: ['my-header' => 'value'], diff --git a/scripts/lint b/scripts/lint index 13f2f013..211ce906 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,4 @@ set -e cd -- "$(dirname -- "$0")/.." echo "==> Running PHPStan" -exec -- ./vendor/bin/phpstan analyse --memory-limit=2G +exec -- ./vendor/bin/phpstan analyse --memory-limit=12G diff --git a/src/Client.php b/src/Client.php index d3a8b80b..4037854f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -72,9 +72,9 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) headers: [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', - 'User-Agent' => sprintf('e-invoice/PHP %s', '0.5.0'), + 'User-Agent' => sprintf('e-invoice/PHP %s', '0.6.0'), 'X-Stainless-Lang' => 'php', - 'X-Stainless-Package-Version' => '0.5.0', + 'X-Stainless-Package-Version' => '0.6.0', 'X-Stainless-OS' => $this->getNormalizedOS(), 'X-Stainless-Arch' => $this->getNormalizedArchitecture(), 'X-Stainless-Runtime' => 'php', diff --git a/src/Core/Attributes/Optional.php b/src/Core/Attributes/Optional.php new file mode 100644 index 00000000..8c6d24e1 --- /dev/null +++ b/src/Core/Attributes/Optional.php @@ -0,0 +1,35 @@ +|Converter|string|null $type + * @param class-string<\BackedEnum>|Converter|null $enum + * @param class-string|Converter|null $union + * @param class-string|Converter|string|null $list + * @param class-string|Converter|string|null $map + */ + public function __construct( + ?string $apiName = null, + Converter|string|null $type = null, + Converter|string|null $enum = null, + Converter|string|null $union = null, + Converter|string|null $list = null, + Converter|string|null $map = null, + bool $nullable = false, + ) { + parent::__construct(apiName: $apiName, type: $type, enum: $enum, union: $union, list: $list, map: $map, nullable: $nullable); + $this->optional = true; + } +} diff --git a/src/Core/Attributes/Api.php b/src/Core/Attributes/Required.php similarity index 77% rename from src/Core/Attributes/Api.php rename to src/Core/Attributes/Required.php index 03f7c153..7863bc94 100644 --- a/src/Core/Attributes/Api.php +++ b/src/Core/Attributes/Required.php @@ -14,11 +14,17 @@ * @internal */ #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Api +class Required { /** @var class-string|Converter|string|null */ public readonly Converter|string|null $type; + public readonly ?string $apiName; + + public bool $optional; + + public readonly bool $nullable; + /** @var array */ private static array $enumConverters = []; @@ -30,14 +36,13 @@ final class Api * @param class-string|Converter|string|null $map */ public function __construct( - public readonly ?string $apiName = null, + ?string $apiName = null, Converter|string|null $type = null, Converter|string|null $enum = null, Converter|string|null $union = null, Converter|string|null $list = null, Converter|string|null $map = null, - public readonly bool $nullable = false, - public readonly bool $optional = false, + bool $nullable = false, ) { $type ??= $union; if (null !== $list) { @@ -47,17 +52,21 @@ public function __construct( $type ??= new MapOf($map); } if (null !== $enum) { - $type ??= $enum instanceof Converter ? $enum : $this->getEnumConverter($enum); + $type ??= $enum instanceof Converter ? $enum : self::enumConverter($enum); } + $this->apiName = $apiName; $this->type = $type; + $this->optional = false; + $this->nullable = $nullable; } /** @property class-string<\BackedEnum> $enum */ - private function getEnumConverter(string $enum): Converter + private static function enumConverter(string $enum): Converter { if (!isset(self::$enumConverters[$enum])) { - $converter = new EnumOf(array_column($enum::cases(), 'value')); // @phpstan-ignore-line + // @phpstan-ignore-next-line argument.type + $converter = new EnumOf(array_column($enum::cases(), column_key: 'value')); self::$enumConverters[$enum] = $converter; } diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index 646a9a5d..b802dfe9 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -5,11 +5,13 @@ namespace EInvoiceAPI\Core; use EInvoiceAPI\Core\Contracts\BasePage; +use EInvoiceAPI\Core\Contracts\BaseResponse; use EInvoiceAPI\Core\Contracts\BaseStream; use EInvoiceAPI\Core\Conversion\Contracts\Converter; use EInvoiceAPI\Core\Conversion\Contracts\ConverterSource; use EInvoiceAPI\Core\Exceptions\APIConnectionException; use EInvoiceAPI\Core\Exceptions\APIStatusException; +use EInvoiceAPI\Core\Implementation\RawResponse; use EInvoiceAPI\RequestOptions; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; @@ -51,9 +53,11 @@ public function __construct( * @param string|list $path * @param array $query * @param array $headers - * @param class-string> $page - * @param class-string> $stream + * @param class-string>|null $page + * @param class-string>|null $stream * @param RequestOptions|array|null $options + * + * @return BaseResponse */ public function request( string $method, @@ -65,7 +69,7 @@ public function request( ?string $page = null, ?string $stream = null, RequestOptions|array|null $options = [], - ): mixed { + ): BaseResponse { // @phpstan-ignore-next-line [$req, $opts] = $this->buildRequest(method: $method, path: $path, query: $query, headers: $headers, body: $body, opts: $options); ['method' => $method, 'path' => $uri, 'headers' => $headers] = $req; @@ -74,32 +78,11 @@ public function request( $request = $opts->requestFactory->createRequest($method, uri: $uri); $request = Util::withSetHeaders($request, headers: $headers); - // @phpstan-ignore-next-line + // @phpstan-ignore-next-line argument.type $rsp = $this->sendRequest($opts, req: $request, data: $body, redirectCount: 0, retryCount: 0); - if (!is_null($stream)) { - return new $stream( - convert: $convert, - request: $request, - response: $rsp - ); - } - - if (!is_null($page)) { - return new $page( - convert: $convert, - client: $this, - request: $req, - response: $rsp, - options: $opts, - ); - } - - if (!is_null($convert)) { - return Conversion::coerceResponse($convert, response: $rsp); - } - - return Util::decodeContent($rsp); + // @phpstan-ignore-next-line argument.type + return new RawResponse(client: $this, request: $request, response: $rsp, options: $opts, requestInfo: $req, stream: $stream, page: $page, convert: $convert ?? 'null'); } /** @return array */ diff --git a/src/Core/Concerns/ResponseProxy.php b/src/Core/Concerns/ResponseProxy.php new file mode 100644 index 00000000..2edc3b7c --- /dev/null +++ b/src/Core/Concerns/ResponseProxy.php @@ -0,0 +1,101 @@ +response->getProtocolVersion(); + } + + public function withProtocolVersion(string $version): static + { + $self = clone $this; + $self->response = $this->response->withProtocolVersion($version); + + return $self; + } + + public function getHeaders(): array + { + return $this->response->getHeaders(); + } + + public function hasHeader(string $name): bool + { + return $this->response->hasHeader($name); + } + + public function getHeader(string $name): array + { + return $this->response->getHeader($name); + } + + public function getHeaderLine(string $name): string + { + return $this->response->getHeaderLine($name); + } + + public function withHeader(string $name, $value): static + { + $self = clone $this; + $self->response = $this->response->withHeader($name, value: $value); + + return $self; + } + + public function withAddedHeader(string $name, $value): static + { + $self = clone $this; + $self->response = $this->response->withAddedHeader($name, value: $value); + + return $self; + } + + public function withoutHeader(string $name): static + { + $self = clone $this; + $self->response = $this->response->withoutHeader($name); + + return $self; + } + + public function getBody(): StreamInterface + { + return $this->response->getBody(); + } + + public function withBody(StreamInterface $body): static + { + $self = clone $this; + $self->response = $this->response->withBody($body); + + return $self; + } + + public function getStatusCode(): int + { + return $this->response->getStatusCode(); + } + + public function withStatus(int $code, string $reasonPhrase = ''): static + { + $self = clone $this; + $self->response = $this->response->withstatus($code, reasonPhrase: $reasonPhrase); + + return $self; + } + + public function getReasonPhrase(): string + { + return $this->response->getReasonPhrase(); + } +} diff --git a/src/Core/Concerns/SdkPage.php b/src/Core/Concerns/SdkPage.php index 666cb3f3..65aebcfc 100644 --- a/src/Core/Concerns/SdkPage.php +++ b/src/Core/Concerns/SdkPage.php @@ -5,6 +5,7 @@ namespace EInvoiceAPI\Core\Concerns; use EInvoiceAPI\Client; +use EInvoiceAPI\Core\Contracts\BaseResponse; use EInvoiceAPI\Core\Conversion\Contracts\Converter; use EInvoiceAPI\Core\Conversion\Contracts\ConverterSource; use EInvoiceAPI\Core\Exceptions\APIStatusException; @@ -14,8 +15,6 @@ * @internal * * @template Item - * - * @phpstan-import-type normalized_request from \EInvoiceAPI\Core\BaseClient */ trait SdkPage { @@ -23,13 +22,6 @@ trait SdkPage private Client $client; - /** - * normalized_request $request. - */ - private array $request; - - private RequestOptions $options; - /** * @return list */ @@ -61,7 +53,11 @@ public function getNextPage(): static [$req, $opts] = $next; // @phpstan-ignore-next-line argument.type - return $this->client->request(...$req, convert: $this->convert, page: $this::class, options: $opts); + /** @var BaseResponse */ + $response = $this->client->request(...$req, convert: $this->convert, page: $this::class, options: $opts); + + // @phpstan-ignore-next-line return.type + return $response->parse(); } /** diff --git a/src/Core/Concerns/SdkResponse.php b/src/Core/Concerns/SdkResponse.php deleted file mode 100644 index 18220918..00000000 --- a/src/Core/Concerns/SdkResponse.php +++ /dev/null @@ -1,29 +0,0 @@ -_rawResponse = $response; - $instance->__unserialize(Util::decodeContent($response)); // @phpstan-ignore-line - - return $instance; - } - - public function getRawResponse(): ?ResponseInterface - { - return $this->_rawResponse; - } -} diff --git a/src/Core/Contracts/BasePage.php b/src/Core/Contracts/BasePage.php index e81b3c65..ad858148 100644 --- a/src/Core/Contracts/BasePage.php +++ b/src/Core/Contracts/BasePage.php @@ -4,12 +4,6 @@ namespace EInvoiceAPI\Core\Contracts; -use EInvoiceAPI\Client; -use EInvoiceAPI\Core\Conversion\Contracts\Converter; -use EInvoiceAPI\Core\Conversion\Contracts\ConverterSource; -use EInvoiceAPI\RequestOptions; -use Psr\Http\Message\ResponseInterface; - /** * @internal * @@ -21,19 +15,6 @@ */ interface BasePage extends \IteratorAggregate { - /** - * @internal - * - * @param normalized_request $request - */ - public function __construct( - Converter|ConverterSource|string $convert, - Client $client, - array $request, - RequestOptions $options, - ResponseInterface $response, - ); - public function hasNextPage(): bool; /** diff --git a/src/Core/Contracts/BaseResponse.php b/src/Core/Contracts/BaseResponse.php new file mode 100644 index 00000000..a53dd993 --- /dev/null +++ b/src/Core/Contracts/BaseResponse.php @@ -0,0 +1,21 @@ +dump($value, state: $state); } + if (is_a($value, class: \BackedEnum::class)) { + return $value->value; + } + if (is_a($value, class: \DateTimeInterface::class)) { return $value->format(format: \DateTimeInterface::RFC3339); } @@ -43,15 +45,6 @@ public static function dump_unknown(mixed $value, DumpState $state): mixed return $value; } - public static function coerceResponse(Converter|ConverterSource|string $target, ResponseInterface $response): mixed - { - if (is_a($target, ResponseConverter::class, allow_string: true)) { - return $target::fromResponse($response); - } - - return self::coerce($target, Util::decodeContent($response)); - } - public static function coerce(Converter|ConverterSource|string $target, mixed $value, CoerceState $state = new CoerceState): mixed { if ($value instanceof $target) { @@ -68,6 +61,26 @@ public static function coerce(Converter|ConverterSource|string $target, mixed $v return $target->coerce($value, state: $state); } + return self::tryConvert($target, value: $value, state: $state); + } + + public static function dump(Converter|ConverterSource|string $target, mixed $value, DumpState $state = new DumpState): mixed + { + if ($target instanceof Converter) { + return $target->dump($value, state: $state); + } + + if (is_a($target, class: ConverterSource::class, allow_string: true)) { + return $target::converter()->dump($value, state: $state); + } + + self::tryConvert($target, value: $value, state: $state); + + return self::dump_unknown($value, state: $state); + } + + private static function tryConvert(Converter|ConverterSource|string $target, mixed $value, CoerceState|DumpState $state): mixed + { switch ($target) { case 'mixed': ++$state->yes; @@ -163,17 +176,4 @@ public static function coerce(Converter|ConverterSource|string $target, mixed $v return $value; } } - - public static function dump(Converter|ConverterSource|string $target, mixed $value, DumpState $state = new DumpState): mixed - { - if ($target instanceof Converter) { - return $target->dump($value, state: $state); - } - - if (is_a($target, class: ConverterSource::class, allow_string: true)) { - return $target::converter()->dump($value, state: $state); - } - - return self::dump_unknown($value, state: $state); - } } diff --git a/src/Core/Conversion/Concerns/ArrayOf.php b/src/Core/Conversion/Concerns/ArrayOf.php index 5b720146..fb041b72 100644 --- a/src/Core/Conversion/Concerns/ArrayOf.php +++ b/src/Core/Conversion/Concerns/ArrayOf.php @@ -32,10 +32,11 @@ public function coerce(mixed $value, CoerceState $state): mixed if (!is_array($value)) { return $value; } + ++$state->yes; $acc = []; foreach ($value as $k => $v) { - if ($this->nullable && null === $v) { + if ($this->nullable && is_null($v)) { ++$state->yes; $acc[$k] = null; } else { @@ -51,15 +52,27 @@ public function dump(mixed $value, DumpState $state): mixed if (!is_array($value)) { return Conversion::dump_unknown($value, state: $state); } + ++$state->yes; if (empty($value)) { return $this->empty(); } - return array_map(fn ($v) => Conversion::dump($this->type, value: $v, state: $state), array: $value); + $acc = []; + foreach ($value as $k => $v) { + if ($this->nullable && is_null($v)) { + ++$state->yes; + $acc[$k] = null; + } else { + $acc[$k] = Conversion::dump($this->type, value: $v, state: $state); + } + } + + return $acc; } - private function empty(): array|object // @phpstan-ignore-line + // @phpstan-ignore-next-line missingType.iterableValue + private function empty(): array|object { return (object) []; } diff --git a/src/Core/Conversion/Contracts/ResponseConverter.php b/src/Core/Conversion/Contracts/ResponseConverter.php deleted file mode 100644 index 8647ffb0..00000000 --- a/src/Core/Conversion/Contracts/ResponseConverter.php +++ /dev/null @@ -1,18 +0,0 @@ -members, strict: true)) { - ++$state->yes; - } elseif ($this->type === gettype($value)) { - ++$state->maybe; - } else { - ++$state->no; - } + $this->tally($value, state: $state); return $value; } public function dump(mixed $value, DumpState $state): mixed { + $this->tally($value, state: $state); + return Conversion::dump_unknown($value, state: $state); } + + private function tally(mixed $value, CoerceState|DumpState $state): void + { + if (in_array($value, haystack: $this->members, strict: true)) { + ++$state->yes; + } elseif ($this->type === gettype($value)) { + ++$state->maybe; + } else { + ++$state->no; + } + } } diff --git a/src/Core/Conversion/ModelOf.php b/src/Core/Conversion/ModelOf.php index 04190d95..c8c8cdd9 100644 --- a/src/Core/Conversion/ModelOf.php +++ b/src/Core/Conversion/ModelOf.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Core\Conversion; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Core\Conversion; use EInvoiceAPI\Core\Conversion\Contracts\Converter; @@ -27,7 +28,9 @@ public function __construct(public readonly \ReflectionClass $class) $properties = []; foreach ($this->class->getProperties() as $property) { - if (!empty($property->getAttributes(Api::class))) { + $attributes = [...$property->getAttributes(Required::class), ...$property->getAttributes(Optional::class)]; + + if (!empty($attributes)) { $name = $property->getName(); $properties[$name] = new PropertyInfo($property); } @@ -91,17 +94,6 @@ public function coerce(mixed $value, CoerceState $state): mixed return $this->from($acc); // @phpstan-ignore-line } - /** - * @param array $data - */ - public function from(array $data): BaseModel - { - $instance = $this->class->newInstanceWithoutConstructor(); - $instance->__unserialize($data); // @phpstan-ignore-line - - return $instance; - } - public function dump(mixed $value, DumpState $state): mixed { if ($value instanceof BaseModel) { @@ -109,10 +101,12 @@ public function dump(mixed $value, DumpState $state): mixed } if (is_array($value)) { + ++$state->yes; $acc = []; foreach ($value as $name => $item) { if (array_key_exists($name, array: $this->properties)) { + ++$state->yes; $info = $this->properties[$name]; $acc[$info->apiName] = Conversion::dump($info->type, value: $item, state: $state); } else { @@ -120,9 +114,23 @@ public function dump(mixed $value, DumpState $state): mixed } } - return empty($acc) ? ((object) []) : $acc; + return empty($acc) ? ((object) $acc) : $acc; } + ++$state->no; + return Conversion::dump_unknown($value, state: $state); } + + /** + * @param array $data + */ + public function from(array $data): BaseModel + { + $instance = $this->class->newInstanceWithoutConstructor(); + // @phpstan-ignore-next-line + $instance->__unserialize($data); + + return $instance; + } } diff --git a/src/Core/Conversion/PropertyInfo.php b/src/Core/Conversion/PropertyInfo.php index e7064c32..780c9719 100644 --- a/src/Core/Conversion/PropertyInfo.php +++ b/src/Core/Conversion/PropertyInfo.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Core\Conversion; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Conversion\Contracts\Converter; use EInvoiceAPI\Core\Conversion\Contracts\ConverterSource; @@ -28,9 +29,10 @@ public function __construct(public readonly \ReflectionProperty $property) $apiName = $property->getName(); $type = $property->getType(); $optional = false; + $attributes = [...$property->getAttributes(Required::class), ...$property->getAttributes(Optional::class)]; - foreach ($property->getAttributes(Api::class) as $attr) { - /** @var Api $attribute */ + foreach ($attributes as $attr) { + /** @var Required $attribute */ $attribute = $attr->newInstance(); $apiName = $attribute->apiName ?? $apiName; diff --git a/src/Core/Conversion/UnionOf.php b/src/Core/Conversion/UnionOf.php index efd24e01..f6671d5e 100644 --- a/src/Core/Conversion/UnionOf.php +++ b/src/Core/Conversion/UnionOf.php @@ -65,17 +65,46 @@ public function coerce(mixed $value, CoerceState $state): mixed public function dump(mixed $value, DumpState $state): mixed { - if (null !== ($target = $this->resolveVariant(value: $value))) { + if (!is_null($target = $this->resolveVariant(value: $value))) { return Conversion::dump($target, value: $value, state: $state); } - foreach ($this->variants as $variant) { + $alternatives = []; + foreach ($this->variants as $_ => $variant) { + ++$state->branched; if ($value instanceof $variant) { return Conversion::dump($variant, value: $value, state: $state); } + + $newState = new DumpState; + $dumped = Conversion::dump($variant, value: $value, state: $newState); + if (($newState->no + $newState->maybe) === 0) { + $state->yes += $newState->yes; + + return $dumped; + } + if ($newState->maybe > 0) { + $alternatives[] = [[-$newState->yes, -$newState->maybe, $newState->no], $newState, $dumped]; + } } - return Conversion::dump_unknown($value, state: $state); + usort( + $alternatives, + static fn (array $a, array $b): int => $a[0][0] <=> $b[0][0] ?: $a[0][1] <=> $b[0][1] ?: $a[0][2] <=> $b[0][2] + ); + + if (empty($alternatives)) { + ++$state->no; + + return Conversion::dump_unknown($value, state: $state); + } + + [[,$newState, $best]] = $alternatives; + $state->yes += $newState->yes; + $state->maybe += $newState->maybe; + $state->no += $newState->no; + + return $best; } private function resolveVariant( diff --git a/src/Core/Implementation/RawResponse.php b/src/Core/Implementation/RawResponse.php new file mode 100644 index 00000000..f80d9524 --- /dev/null +++ b/src/Core/Implementation/RawResponse.php @@ -0,0 +1,100 @@ + + * + * @phpstan-import-type normalized_request from \EInvoiceAPI\Core\BaseClient + */ +class RawResponse implements BaseResponse +{ + use ResponseProxy; + + private mixed $decodedBody; + + /** @var R */ + private mixed $coercedResponse; + + private bool $decoded = false; + private bool $coerced = false; + + /** + * @param normalized_request $requestInfo + */ + public function __construct( + private Client $client, + private RequestOptions $options, + private RequestInterface $request, + private ResponseInterface $response, + private array $requestInfo, + private Converter|ConverterSource|string $convert, + private ?string $page, + private ?string $stream, + ) {} + + public function getRequest(): RequestInterface + { + return $this->request; + } + + public function parse(): mixed + { + if (!$this->coerced) { + if (!is_null($this->stream)) { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = new $this->stream( + convert: $this->convert, + request: $this->request, + response: $this->response, + parsedBody: $this->getDecoded(), + ); + } elseif (!is_null($this->page)) { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = new $this->page( + convert: $this->convert, + client: $this->client, + requestInfo: $this->requestInfo, + options: $this->options, + response: $this->response, + parsedBody: $this->getDecoded(), + ); + } else { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = Conversion::coerce( + $this->convert, + value: $this->getDecoded(), + ); + } + + $this->coerced = true; + } + + return $this->coercedResponse; + } + + private function getDecoded(): mixed + { + if (!$this->decoded) { + $this->decodedBody = Util::decodeContent($this->response); + $this->decoded = true; + } + + return $this->decodedBody; + } +} diff --git a/src/Documents/Allowance.php b/src/Documents/Allowance.php index 55aa3ff0..f192c177 100644 --- a/src/Documents/Allowance.php +++ b/src/Documents/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: string|null, - * base_amount?: string|null, - * multiplier_factor?: string|null, + * baseAmount?: string|null, + * multiplierFactor?: string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: string|null, * } */ final class Allowance implements BaseModel @@ -31,48 +31,48 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $base_amount; + #[Optional('base_amount', nullable: true)] + public ?string $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public ?string $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $tax_rate; + #[Optional('tax_rate', nullable: true)] + public ?string $taxRate; public function __construct() { @@ -84,29 +84,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( ?string $amount = null, - ?string $base_amount = null, - ?string $multiplier_factor = null, + ?string $baseAmount = null, + ?string $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - ?string $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + ?string $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -114,10 +114,10 @@ public static function with( */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -125,10 +125,10 @@ public function withAmount(?string $amount): self */ public function withBaseAmount(?string $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -136,10 +136,10 @@ public function withBaseAmount(?string $baseAmount): self */ public function withMultiplierFactor(?string $multiplierFactor): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -147,10 +147,10 @@ public function withMultiplierFactor(?string $multiplierFactor): self */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -160,10 +160,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -173,10 +173,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -184,9 +184,9 @@ public function withTaxCode(TaxCode|string $taxCode): self */ public function withTaxRate(?string $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/Attachments/AttachmentAddParams.php b/src/Documents/Attachments/AttachmentAddParams.php index f9b683e8..e1b36224 100644 --- a/src/Documents/Attachments/AttachmentAddParams.php +++ b/src/Documents/Attachments/AttachmentAddParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\Attachments; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -22,7 +22,7 @@ final class AttachmentAddParams implements BaseModel use SdkModel; use SdkParams; - #[Api] + #[Required] public string $file; /** @@ -51,18 +51,18 @@ public function __construct() */ public static function with(string $file): self { - $obj = new self; + $self = new self; - $obj->file = $file; + $self['file'] = $file; - return $obj; + return $self; } public function withFile(string $file): self { - $obj = clone $this; - $obj->file = $file; + $self = clone $this; + $self['file'] = $file; - return $obj; + return $self; } } diff --git a/src/Documents/Attachments/AttachmentDeleteParams.php b/src/Documents/Attachments/AttachmentDeleteParams.php index 33e7aafb..6d0bc23b 100644 --- a/src/Documents/Attachments/AttachmentDeleteParams.php +++ b/src/Documents/Attachments/AttachmentDeleteParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\Attachments; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -14,7 +14,7 @@ * * @see EInvoiceAPI\Services\Documents\AttachmentsService::delete() * - * @phpstan-type AttachmentDeleteParamsShape = array{document_id: string} + * @phpstan-type AttachmentDeleteParamsShape = array{documentID: string} */ final class AttachmentDeleteParams implements BaseModel { @@ -22,15 +22,15 @@ final class AttachmentDeleteParams implements BaseModel use SdkModel; use SdkParams; - #[Api] - public string $document_id; + #[Required] + public string $documentID; /** * `new AttachmentDeleteParams()` is missing required properties by the API. * * To enforce required parameters use * ``` - * AttachmentDeleteParams::with(document_id: ...) + * AttachmentDeleteParams::with(documentID: ...) * ``` * * Otherwise ensure the following setters are called @@ -49,20 +49,20 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(string $document_id): self + public static function with(string $documentID): self { - $obj = new self; + $self = new self; - $obj->document_id = $document_id; + $self['documentID'] = $documentID; - return $obj; + return $self; } public function withDocumentID(string $documentID): self { - $obj = clone $this; - $obj->document_id = $documentID; + $self = clone $this; + $self['documentID'] = $documentID; - return $obj; + return $self; } } diff --git a/src/Documents/Attachments/AttachmentDeleteResponse.php b/src/Documents/Attachments/AttachmentDeleteResponse.php index 0e422a5f..b747ad44 100644 --- a/src/Documents/Attachments/AttachmentDeleteResponse.php +++ b/src/Documents/Attachments/AttachmentDeleteResponse.php @@ -4,31 +4,27 @@ namespace EInvoiceAPI\Documents\Attachments; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type AttachmentDeleteResponseShape = array{is_deleted: bool} + * @phpstan-type AttachmentDeleteResponseShape = array{isDeleted: bool} */ -final class AttachmentDeleteResponse implements BaseModel, ResponseConverter +final class AttachmentDeleteResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] - public bool $is_deleted; + #[Required('is_deleted')] + public bool $isDeleted; /** * `new AttachmentDeleteResponse()` is missing required properties by the API. * * To enforce required parameters use * ``` - * AttachmentDeleteResponse::with(is_deleted: ...) + * AttachmentDeleteResponse::with(isDeleted: ...) * ``` * * Otherwise ensure the following setters are called @@ -47,20 +43,20 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(bool $is_deleted): self + public static function with(bool $isDeleted): self { - $obj = new self; + $self = new self; - $obj->is_deleted = $is_deleted; + $self['isDeleted'] = $isDeleted; - return $obj; + return $self; } public function withIsDeleted(bool $isDeleted): self { - $obj = clone $this; - $obj->is_deleted = $isDeleted; + $self = clone $this; + $self['isDeleted'] = $isDeleted; - return $obj; + return $self; } } diff --git a/src/Documents/Attachments/AttachmentRetrieveParams.php b/src/Documents/Attachments/AttachmentRetrieveParams.php index 42c30abe..ffc06b86 100644 --- a/src/Documents/Attachments/AttachmentRetrieveParams.php +++ b/src/Documents/Attachments/AttachmentRetrieveParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\Attachments; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -14,7 +14,7 @@ * * @see EInvoiceAPI\Services\Documents\AttachmentsService::retrieve() * - * @phpstan-type AttachmentRetrieveParamsShape = array{document_id: string} + * @phpstan-type AttachmentRetrieveParamsShape = array{documentID: string} */ final class AttachmentRetrieveParams implements BaseModel { @@ -22,15 +22,15 @@ final class AttachmentRetrieveParams implements BaseModel use SdkModel; use SdkParams; - #[Api] - public string $document_id; + #[Required] + public string $documentID; /** * `new AttachmentRetrieveParams()` is missing required properties by the API. * * To enforce required parameters use * ``` - * AttachmentRetrieveParams::with(document_id: ...) + * AttachmentRetrieveParams::with(documentID: ...) * ``` * * Otherwise ensure the following setters are called @@ -49,20 +49,20 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(string $document_id): self + public static function with(string $documentID): self { - $obj = new self; + $self = new self; - $obj->document_id = $document_id; + $self['documentID'] = $documentID; - return $obj; + return $self; } public function withDocumentID(string $documentID): self { - $obj = clone $this; - $obj->document_id = $documentID; + $self = clone $this; + $self['documentID'] = $documentID; - return $obj; + return $self; } } diff --git a/src/Documents/Attachments/DocumentAttachment.php b/src/Documents/Attachments/DocumentAttachment.php index 88fbabe0..f84c8818 100644 --- a/src/Documents/Attachments/DocumentAttachment.php +++ b/src/Documents/Attachments/DocumentAttachment.php @@ -4,49 +4,46 @@ namespace EInvoiceAPI\Documents\Attachments; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type DocumentAttachmentShape = array{ * id: string, - * file_name: string, - * file_size?: int|null, - * file_type?: string|null, - * file_url?: string|null, + * fileName: string, + * fileSize?: int|null, + * fileType?: string|null, + * fileURL?: string|null, * } */ -final class DocumentAttachment implements BaseModel, ResponseConverter +final class DocumentAttachment implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] + #[Required] public string $id; - #[Api] - public string $file_name; + #[Required('file_name')] + public string $fileName; - #[Api(optional: true)] - public ?int $file_size; + #[Optional('file_size')] + public ?int $fileSize; - #[Api(optional: true)] - public ?string $file_type; + #[Optional('file_type')] + public ?string $fileType; - #[Api(nullable: true, optional: true)] - public ?string $file_url; + #[Optional('file_url', nullable: true)] + public ?string $fileURL; /** * `new DocumentAttachment()` is missing required properties by the API. * * To enforce required parameters use * ``` - * DocumentAttachment::with(id: ..., file_name: ...) + * DocumentAttachment::with(id: ..., fileName: ...) * ``` * * Otherwise ensure the following setters are called @@ -67,60 +64,60 @@ public function __construct() */ public static function with( string $id, - string $file_name, - ?int $file_size = null, - ?string $file_type = null, - ?string $file_url = null, + string $fileName, + ?int $fileSize = null, + ?string $fileType = null, + ?string $fileURL = null, ): self { - $obj = new self; + $self = new self; - $obj->id = $id; - $obj->file_name = $file_name; + $self['id'] = $id; + $self['fileName'] = $fileName; - null !== $file_size && $obj->file_size = $file_size; - null !== $file_type && $obj->file_type = $file_type; - null !== $file_url && $obj->file_url = $file_url; + null !== $fileSize && $self['fileSize'] = $fileSize; + null !== $fileType && $self['fileType'] = $fileType; + null !== $fileURL && $self['fileURL'] = $fileURL; - return $obj; + return $self; } public function withID(string $id): self { - $obj = clone $this; - $obj->id = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } public function withFileName(string $fileName): self { - $obj = clone $this; - $obj->file_name = $fileName; + $self = clone $this; + $self['fileName'] = $fileName; - return $obj; + return $self; } public function withFileSize(int $fileSize): self { - $obj = clone $this; - $obj->file_size = $fileSize; + $self = clone $this; + $self['fileSize'] = $fileSize; - return $obj; + return $self; } public function withFileType(string $fileType): self { - $obj = clone $this; - $obj->file_type = $fileType; + $self = clone $this; + $self['fileType'] = $fileType; - return $obj; + return $self; } public function withFileURL(?string $fileURL): self { - $obj = clone $this; - $obj->file_url = $fileURL; + $self = clone $this; + $self['fileURL'] = $fileURL; - return $obj; + return $self; } } diff --git a/src/Documents/Charge.php b/src/Documents/Charge.php index 3b17e8d5..f189ee13 100644 --- a/src/Documents/Charge.php +++ b/src/Documents/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: string|null, - * base_amount?: string|null, - * multiplier_factor?: string|null, + * baseAmount?: string|null, + * multiplierFactor?: string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $base_amount; + #[Optional('base_amount', nullable: true)] + public ?string $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public ?string $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public ?string $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,16 +67,16 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, nullable: true, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class, nullable: true)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public ?string $tax_rate; + #[Optional('tax_rate', nullable: true)] + public ?string $taxRate; public function __construct() { @@ -88,29 +88,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( ?string $amount = null, - ?string $base_amount = null, - ?string $multiplier_factor = null, + ?string $baseAmount = null, + ?string $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - ?string $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + ?string $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -118,10 +118,10 @@ public static function with( */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -129,10 +129,10 @@ public function withAmount(?string $amount): self */ public function withBaseAmount(?string $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -140,10 +140,10 @@ public function withBaseAmount(?string $baseAmount): self */ public function withMultiplierFactor(?string $multiplierFactor): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -151,10 +151,10 @@ public function withMultiplierFactor(?string $multiplierFactor): self */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -164,10 +164,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -181,10 +181,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string|null $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -192,9 +192,9 @@ public function withTaxCode(TaxCode|string|null $taxCode): self */ public function withTaxRate(?string $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentAttachmentCreate.php b/src/Documents/DocumentAttachmentCreate.php index a25aa604..5127212d 100644 --- a/src/Documents/DocumentAttachmentCreate.php +++ b/src/Documents/DocumentAttachmentCreate.php @@ -4,16 +4,17 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; /** * @phpstan-type DocumentAttachmentCreateShape = array{ - * file_name: string, - * file_data?: string|null, - * file_size?: int|null, - * file_type?: string|null, + * fileName: string, + * fileData?: string|null, + * fileSize?: int|null, + * fileType?: string|null, * } */ final class DocumentAttachmentCreate implements BaseModel @@ -21,27 +22,27 @@ final class DocumentAttachmentCreate implements BaseModel /** @use SdkModel */ use SdkModel; - #[Api] - public string $file_name; + #[Required('file_name')] + public string $fileName; /** * Base64 encoded file data. */ - #[Api(nullable: true, optional: true)] - public ?string $file_data; + #[Optional('file_data', nullable: true)] + public ?string $fileData; - #[Api(optional: true)] - public ?int $file_size; + #[Optional('file_size')] + public ?int $fileSize; - #[Api(optional: true)] - public ?string $file_type; + #[Optional('file_type')] + public ?string $fileType; /** * `new DocumentAttachmentCreate()` is missing required properties by the API. * * To enforce required parameters use * ``` - * DocumentAttachmentCreate::with(file_name: ...) + * DocumentAttachmentCreate::with(fileName: ...) * ``` * * Otherwise ensure the following setters are called @@ -61,28 +62,28 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - string $file_name, - ?string $file_data = null, - ?int $file_size = null, - ?string $file_type = null, + string $fileName, + ?string $fileData = null, + ?int $fileSize = null, + ?string $fileType = null, ): self { - $obj = new self; + $self = new self; - $obj->file_name = $file_name; + $self['fileName'] = $fileName; - null !== $file_data && $obj->file_data = $file_data; - null !== $file_size && $obj->file_size = $file_size; - null !== $file_type && $obj->file_type = $file_type; + null !== $fileData && $self['fileData'] = $fileData; + null !== $fileSize && $self['fileSize'] = $fileSize; + null !== $fileType && $self['fileType'] = $fileType; - return $obj; + return $self; } public function withFileName(string $fileName): self { - $obj = clone $this; - $obj->file_name = $fileName; + $self = clone $this; + $self['fileName'] = $fileName; - return $obj; + return $self; } /** @@ -90,25 +91,25 @@ public function withFileName(string $fileName): self */ public function withFileData(?string $fileData): self { - $obj = clone $this; - $obj->file_data = $fileData; + $self = clone $this; + $self['fileData'] = $fileData; - return $obj; + return $self; } public function withFileSize(int $fileSize): self { - $obj = clone $this; - $obj->file_size = $fileSize; + $self = clone $this; + $self['fileSize'] = $fileSize; - return $obj; + return $self; } public function withFileType(string $fileType): self { - $obj = clone $this; - $obj->file_type = $fileType; + $self = clone $this; + $self['fileType'] = $fileType; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate.php b/src/Documents/DocumentCreate.php index 37531e02..b053e149 100644 --- a/src/Documents/DocumentCreate.php +++ b/src/Documents/DocumentCreate.php @@ -4,10 +4,11 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreate\Allowance; +use EInvoiceAPI\Documents\DocumentCreate\Allowance\ReasonCode; use EInvoiceAPI\Documents\DocumentCreate\Charge; use EInvoiceAPI\Documents\DocumentCreate\Item; use EInvoiceAPI\Documents\DocumentCreate\TaxCode; @@ -18,53 +19,53 @@ /** * @phpstan-type DocumentCreateShape = array{ * allowances?: list<\EInvoiceAPI\Documents\DocumentCreate\Allowance>|null, - * amount_due?: float|string|null, + * amountDue?: float|string|null, * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, * charges?: list<\EInvoiceAPI\Documents\DocumentCreate\Charge>|null, * currency?: value-of|null, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, * direction?: value-of|null, - * document_type?: value-of|null, - * due_date?: \DateTimeInterface|null, - * invoice_date?: \DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: float|string|null, + * documentType?: value-of|null, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: float|string|null, * items?: list|null, * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * previous_unpaid_balance?: float|string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: \DateTimeInterface|null, - * service_start_date?: \DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * previousUnpaidBalance?: float|string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, * state?: value-of|null, * subtotal?: float|string|null, - * tax_code?: value-of|null, - * tax_details?: list|null, - * total_discount?: float|string|null, - * total_tax?: float|string|null, + * taxCode?: value-of|null, + * taxDetails?: list|null, + * totalDiscount?: float|string|null, + * totalTax?: float|string|null, * vatex?: value-of|null, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, * } */ final class DocumentCreate implements BaseModel @@ -73,40 +74,38 @@ final class DocumentCreate implements BaseModel use SdkModel; /** @var list|null $allowances */ - #[Api( + #[Optional( list: Allowance::class, - nullable: true, - optional: true, + nullable: true )] public ?array $allowances; /** * The amount due for payment. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $amount_due; + #[Optional('amount_due', nullable: true)] + public float|string|null $amountDue; /** @var list|null $attachments */ - #[Api(list: DocumentAttachmentCreate::class, nullable: true, optional: true)] + #[Optional(list: DocumentAttachmentCreate::class, nullable: true)] public ?array $attachments; /** * The billing address (if different from customer address). */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address; + #[Optional('billing_address', nullable: true)] + public ?string $billingAddress; /** * The recipient name at the billing address. */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address_recipient; + #[Optional('billing_address_recipient', nullable: true)] + public ?string $billingAddressRecipient; /** @var list|null $charges */ - #[Api( + #[Optional( list: Charge::class, - nullable: true, - optional: true, + nullable: true )] public ?array $charges; @@ -115,212 +114,216 @@ final class DocumentCreate implements BaseModel * * @var value-of|null $currency */ - #[Api(enum: CurrencyCode::class, optional: true)] + #[Optional(enum: CurrencyCode::class)] public ?string $currency; /** * The address of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address; + #[Optional('customer_address', nullable: true)] + public ?string $customerAddress; /** * The recipient name at the customer address. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address_recipient; + #[Optional('customer_address_recipient', nullable: true)] + public ?string $customerAddressRecipient; /** * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_company_id; + #[Optional('customer_company_id', nullable: true)] + public ?string $customerCompanyID; /** * The email address of the customer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_email; + #[Optional('customer_email', nullable: true)] + public ?string $customerEmail; /** * The unique identifier for the customer in your system. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_id; + #[Optional('customer_id', nullable: true)] + public ?string $customerID; /** * The company name of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_name; + #[Optional('customer_name', nullable: true)] + public ?string $customerName; /** * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_tax_id; + #[Optional('customer_tax_id', nullable: true)] + public ?string $customerTaxID; /** * The direction of the document: INBOUND (purchases) or OUTBOUND (sales). * * @var value-of|null $direction */ - #[Api(enum: DocumentDirection::class, optional: true)] + #[Optional(enum: DocumentDirection::class)] public ?string $direction; /** * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE. * - * @var value-of|null $document_type + * @var value-of|null $documentType */ - #[Api(enum: DocumentType::class, optional: true)] - public ?string $document_type; + #[Optional('document_type', enum: DocumentType::class)] + public ?string $documentType; /** * The date when payment is due. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $due_date; + #[Optional('due_date', nullable: true)] + public ?\DateTimeInterface $dueDate; /** * The date when the invoice was issued. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $invoice_date; + #[Optional('invoice_date', nullable: true)] + public ?\DateTimeInterface $invoiceDate; /** * The unique invoice identifier/number. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_id; + #[Optional('invoice_id', nullable: true)] + public ?string $invoiceID; /** * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $invoice_total; + #[Optional('invoice_total', nullable: true)] + public float|string|null $invoiceTotal; /** * At least one line item is required. * * @var list|null $items */ - #[Api(list: Item::class, optional: true)] + #[Optional(list: Item::class)] public ?array $items; /** * Additional notes or comments for the invoice. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $note; - /** @var list|null $payment_details */ - #[Api(list: PaymentDetailCreate::class, nullable: true, optional: true)] - public ?array $payment_details; + /** @var list|null $paymentDetails */ + #[Optional( + 'payment_details', + list: PaymentDetailCreate::class, + nullable: true + )] + public ?array $paymentDetails; /** * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30'). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_term; + #[Optional('payment_term', nullable: true)] + public ?string $paymentTerm; /** * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $previous_unpaid_balance; + #[Optional('previous_unpaid_balance', nullable: true)] + public float|string|null $previousUnpaidBalance; /** * The purchase order reference number. */ - #[Api(nullable: true, optional: true)] - public ?string $purchase_order; + #[Optional('purchase_order', nullable: true)] + public ?string $purchaseOrder; /** * The address where payment should be sent or remitted to. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address; + #[Optional('remittance_address', nullable: true)] + public ?string $remittanceAddress; /** * The recipient name at the remittance address. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address_recipient; + #[Optional('remittance_address_recipient', nullable: true)] + public ?string $remittanceAddressRecipient; /** * The address where services were performed or goods were delivered. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address; + #[Optional('service_address', nullable: true)] + public ?string $serviceAddress; /** * The recipient name at the service address. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address_recipient; + #[Optional('service_address_recipient', nullable: true)] + public ?string $serviceAddressRecipient; /** * The end date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_end_date; + #[Optional('service_end_date', nullable: true)] + public ?\DateTimeInterface $serviceEndDate; /** * The start date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_start_date; + #[Optional('service_start_date', nullable: true)] + public ?\DateTimeInterface $serviceStartDate; /** * The shipping/delivery address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address; + #[Optional('shipping_address', nullable: true)] + public ?string $shippingAddress; /** * The recipient name at the shipping address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address_recipient; + #[Optional('shipping_address_recipient', nullable: true)] + public ?string $shippingAddressRecipient; /** * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED. * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, optional: true)] + #[Optional(enum: DocumentState::class)] public ?string $state; /** * The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $subtotal; /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; - /** @var list|null $tax_details */ - #[Api(list: TaxDetail::class, nullable: true, optional: true)] - public ?array $tax_details; + /** @var list|null $taxDetails */ + #[Optional('tax_details', list: TaxDetail::class, nullable: true)] + public ?array $taxDetails; /** * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $total_discount; + #[Optional('total_discount', nullable: true)] + public float|string|null $totalDiscount; /** * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $total_tax; + #[Optional('total_tax', nullable: true)] + public float|string|null $totalTax; /** * VATEX code list for VAT exemption reasons. @@ -330,50 +333,50 @@ final class DocumentCreate implements BaseModel * * @var value-of|null $vatex */ - #[Api(enum: Vatex::class, nullable: true, optional: true)] + #[Optional(enum: Vatex::class, nullable: true)] public ?string $vatex; /** * Textual explanation for VAT exemption. */ - #[Api(nullable: true, optional: true)] - public ?string $vatex_note; + #[Optional('vatex_note', nullable: true)] + public ?string $vatexNote; /** * The address of the vendor/seller. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address; + #[Optional('vendor_address', nullable: true)] + public ?string $vendorAddress; /** * The recipient name at the vendor address. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address_recipient; + #[Optional('vendor_address_recipient', nullable: true)] + public ?string $vendorAddressRecipient; /** * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_company_id; + #[Optional('vendor_company_id', nullable: true)] + public ?string $vendorCompanyID; /** * The email address of the vendor. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_email; + #[Optional('vendor_email', nullable: true)] + public ?string $vendorEmail; /** * The name of the vendor/seller/supplier. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_name; + #[Optional('vendor_name', nullable: true)] + public ?string $vendorName; /** * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_tax_id; + #[Optional('vendor_tax_id', nullable: true)] + public ?string $vendorTaxID; public function __construct() { @@ -385,132 +388,180 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $attachments - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances + * @param list|null $attachments + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges * @param CurrencyCode|value-of $currency * @param DocumentDirection|value-of $direction - * @param DocumentType|value-of $document_type - * @param list $items - * @param list|null $payment_details + * @param DocumentType|value-of $documentType + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }> $items + * @param list|null $paymentDetails * @param DocumentState|value-of $state - * @param TaxCode|value-of $tax_code - * @param list|null $tax_details + * @param TaxCode|value-of $taxCode + * @param list|null $taxDetails * @param Vatex|value-of|null $vatex */ public static function with( ?array $allowances = null, - float|string|null $amount_due = null, + float|string|null $amountDue = null, ?array $attachments = null, - ?string $billing_address = null, - ?string $billing_address_recipient = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, ?array $charges = null, CurrencyCode|string|null $currency = null, - ?string $customer_address = null, - ?string $customer_address_recipient = null, - ?string $customer_company_id = null, - ?string $customer_email = null, - ?string $customer_id = null, - ?string $customer_name = null, - ?string $customer_tax_id = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, DocumentDirection|string|null $direction = null, - DocumentType|string|null $document_type = null, - ?\DateTimeInterface $due_date = null, - ?\DateTimeInterface $invoice_date = null, - ?string $invoice_id = null, - float|string|null $invoice_total = null, + DocumentType|string|null $documentType = null, + ?\DateTimeInterface $dueDate = null, + ?\DateTimeInterface $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, ?array $items = null, ?string $note = null, - ?array $payment_details = null, - ?string $payment_term = null, - float|string|null $previous_unpaid_balance = null, - ?string $purchase_order = null, - ?string $remittance_address = null, - ?string $remittance_address_recipient = null, - ?string $service_address = null, - ?string $service_address_recipient = null, - ?\DateTimeInterface $service_end_date = null, - ?\DateTimeInterface $service_start_date = null, - ?string $shipping_address = null, - ?string $shipping_address_recipient = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + ?\DateTimeInterface $serviceEndDate = null, + ?\DateTimeInterface $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, DocumentState|string|null $state = null, float|string|null $subtotal = null, - TaxCode|string|null $tax_code = null, - ?array $tax_details = null, - float|string|null $total_discount = null, - float|string|null $total_tax = null, + TaxCode|string|null $taxCode = null, + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, Vatex|string|null $vatex = null, - ?string $vatex_note = null, - ?string $vendor_address = null, - ?string $vendor_address_recipient = null, - ?string $vendor_company_id = null, - ?string $vendor_email = null, - ?string $vendor_name = null, - ?string $vendor_tax_id = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ): self { - $obj = new self; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount_due && $obj->amount_due = $amount_due; - null !== $attachments && $obj->attachments = $attachments; - null !== $billing_address && $obj->billing_address = $billing_address; - null !== $billing_address_recipient && $obj->billing_address_recipient = $billing_address_recipient; - null !== $charges && $obj->charges = $charges; - null !== $currency && $obj['currency'] = $currency; - null !== $customer_address && $obj->customer_address = $customer_address; - null !== $customer_address_recipient && $obj->customer_address_recipient = $customer_address_recipient; - null !== $customer_company_id && $obj->customer_company_id = $customer_company_id; - null !== $customer_email && $obj->customer_email = $customer_email; - null !== $customer_id && $obj->customer_id = $customer_id; - null !== $customer_name && $obj->customer_name = $customer_name; - null !== $customer_tax_id && $obj->customer_tax_id = $customer_tax_id; - null !== $direction && $obj['direction'] = $direction; - null !== $document_type && $obj['document_type'] = $document_type; - null !== $due_date && $obj->due_date = $due_date; - null !== $invoice_date && $obj->invoice_date = $invoice_date; - null !== $invoice_id && $obj->invoice_id = $invoice_id; - null !== $invoice_total && $obj->invoice_total = $invoice_total; - null !== $items && $obj->items = $items; - null !== $note && $obj->note = $note; - null !== $payment_details && $obj->payment_details = $payment_details; - null !== $payment_term && $obj->payment_term = $payment_term; - null !== $previous_unpaid_balance && $obj->previous_unpaid_balance = $previous_unpaid_balance; - null !== $purchase_order && $obj->purchase_order = $purchase_order; - null !== $remittance_address && $obj->remittance_address = $remittance_address; - null !== $remittance_address_recipient && $obj->remittance_address_recipient = $remittance_address_recipient; - null !== $service_address && $obj->service_address = $service_address; - null !== $service_address_recipient && $obj->service_address_recipient = $service_address_recipient; - null !== $service_end_date && $obj->service_end_date = $service_end_date; - null !== $service_start_date && $obj->service_start_date = $service_start_date; - null !== $shipping_address && $obj->shipping_address = $shipping_address; - null !== $shipping_address_recipient && $obj->shipping_address_recipient = $shipping_address_recipient; - null !== $state && $obj['state'] = $state; - null !== $subtotal && $obj->subtotal = $subtotal; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_details && $obj->tax_details = $tax_details; - null !== $total_discount && $obj->total_discount = $total_discount; - null !== $total_tax && $obj->total_tax = $total_tax; - null !== $vatex && $obj['vatex'] = $vatex; - null !== $vatex_note && $obj->vatex_note = $vatex_note; - null !== $vendor_address && $obj->vendor_address = $vendor_address; - null !== $vendor_address_recipient && $obj->vendor_address_recipient = $vendor_address_recipient; - null !== $vendor_company_id && $obj->vendor_company_id = $vendor_company_id; - null !== $vendor_email && $obj->vendor_email = $vendor_email; - null !== $vendor_name && $obj->vendor_name = $vendor_name; - null !== $vendor_tax_id && $obj->vendor_tax_id = $vendor_tax_id; - - return $obj; + $self = new self; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amountDue && $self['amountDue'] = $amountDue; + null !== $attachments && $self['attachments'] = $attachments; + null !== $billingAddress && $self['billingAddress'] = $billingAddress; + null !== $billingAddressRecipient && $self['billingAddressRecipient'] = $billingAddressRecipient; + null !== $charges && $self['charges'] = $charges; + null !== $currency && $self['currency'] = $currency; + null !== $customerAddress && $self['customerAddress'] = $customerAddress; + null !== $customerAddressRecipient && $self['customerAddressRecipient'] = $customerAddressRecipient; + null !== $customerCompanyID && $self['customerCompanyID'] = $customerCompanyID; + null !== $customerEmail && $self['customerEmail'] = $customerEmail; + null !== $customerID && $self['customerID'] = $customerID; + null !== $customerName && $self['customerName'] = $customerName; + null !== $customerTaxID && $self['customerTaxID'] = $customerTaxID; + null !== $direction && $self['direction'] = $direction; + null !== $documentType && $self['documentType'] = $documentType; + null !== $dueDate && $self['dueDate'] = $dueDate; + null !== $invoiceDate && $self['invoiceDate'] = $invoiceDate; + null !== $invoiceID && $self['invoiceID'] = $invoiceID; + null !== $invoiceTotal && $self['invoiceTotal'] = $invoiceTotal; + null !== $items && $self['items'] = $items; + null !== $note && $self['note'] = $note; + null !== $paymentDetails && $self['paymentDetails'] = $paymentDetails; + null !== $paymentTerm && $self['paymentTerm'] = $paymentTerm; + null !== $previousUnpaidBalance && $self['previousUnpaidBalance'] = $previousUnpaidBalance; + null !== $purchaseOrder && $self['purchaseOrder'] = $purchaseOrder; + null !== $remittanceAddress && $self['remittanceAddress'] = $remittanceAddress; + null !== $remittanceAddressRecipient && $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; + null !== $serviceAddress && $self['serviceAddress'] = $serviceAddress; + null !== $serviceAddressRecipient && $self['serviceAddressRecipient'] = $serviceAddressRecipient; + null !== $serviceEndDate && $self['serviceEndDate'] = $serviceEndDate; + null !== $serviceStartDate && $self['serviceStartDate'] = $serviceStartDate; + null !== $shippingAddress && $self['shippingAddress'] = $shippingAddress; + null !== $shippingAddressRecipient && $self['shippingAddressRecipient'] = $shippingAddressRecipient; + null !== $state && $self['state'] = $state; + null !== $subtotal && $self['subtotal'] = $subtotal; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxDetails && $self['taxDetails'] = $taxDetails; + null !== $totalDiscount && $self['totalDiscount'] = $totalDiscount; + null !== $totalTax && $self['totalTax'] = $totalTax; + null !== $vatex && $self['vatex'] = $vatex; + null !== $vatexNote && $self['vatexNote'] = $vatexNote; + null !== $vendorAddress && $self['vendorAddress'] = $vendorAddress; + null !== $vendorAddressRecipient && $self['vendorAddressRecipient'] = $vendorAddressRecipient; + null !== $vendorCompanyID && $self['vendorCompanyID'] = $vendorCompanyID; + null !== $vendorEmail && $self['vendorEmail'] = $vendorEmail; + null !== $vendorName && $self['vendorName'] = $vendorName; + null !== $vendorTaxID && $self['vendorTaxID'] = $vendorTaxID; + + return $self; } /** - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -518,21 +569,26 @@ public function withAllowances(?array $allowances): self */ public function withAmountDue(float|string|null $amountDue): self { - $obj = clone $this; - $obj->amount_due = $amountDue; + $self = clone $this; + $self['amountDue'] = $amountDue; - return $obj; + return $self; } /** - * @param list|null $attachments + * @param list|null $attachments */ public function withAttachments(?array $attachments): self { - $obj = clone $this; - $obj->attachments = $attachments; + $self = clone $this; + $self['attachments'] = $attachments; - return $obj; + return $self; } /** @@ -540,10 +596,10 @@ public function withAttachments(?array $attachments): self */ public function withBillingAddress(?string $billingAddress): self { - $obj = clone $this; - $obj->billing_address = $billingAddress; + $self = clone $this; + $self['billingAddress'] = $billingAddress; - return $obj; + return $self; } /** @@ -552,21 +608,29 @@ public function withBillingAddress(?string $billingAddress): self public function withBillingAddressRecipient( ?string $billingAddressRecipient ): self { - $obj = clone $this; - $obj->billing_address_recipient = $billingAddressRecipient; + $self = clone $this; + $self['billingAddressRecipient'] = $billingAddressRecipient; - return $obj; + return $self; } /** - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -576,10 +640,10 @@ public function withCharges(?array $charges): self */ public function withCurrency(CurrencyCode|string $currency): self { - $obj = clone $this; - $obj['currency'] = $currency; + $self = clone $this; + $self['currency'] = $currency; - return $obj; + return $self; } /** @@ -587,10 +651,10 @@ public function withCurrency(CurrencyCode|string $currency): self */ public function withCustomerAddress(?string $customerAddress): self { - $obj = clone $this; - $obj->customer_address = $customerAddress; + $self = clone $this; + $self['customerAddress'] = $customerAddress; - return $obj; + return $self; } /** @@ -599,10 +663,10 @@ public function withCustomerAddress(?string $customerAddress): self public function withCustomerAddressRecipient( ?string $customerAddressRecipient ): self { - $obj = clone $this; - $obj->customer_address_recipient = $customerAddressRecipient; + $self = clone $this; + $self['customerAddressRecipient'] = $customerAddressRecipient; - return $obj; + return $self; } /** @@ -610,10 +674,10 @@ public function withCustomerAddressRecipient( */ public function withCustomerCompanyID(?string $customerCompanyID): self { - $obj = clone $this; - $obj->customer_company_id = $customerCompanyID; + $self = clone $this; + $self['customerCompanyID'] = $customerCompanyID; - return $obj; + return $self; } /** @@ -621,10 +685,10 @@ public function withCustomerCompanyID(?string $customerCompanyID): self */ public function withCustomerEmail(?string $customerEmail): self { - $obj = clone $this; - $obj->customer_email = $customerEmail; + $self = clone $this; + $self['customerEmail'] = $customerEmail; - return $obj; + return $self; } /** @@ -632,10 +696,10 @@ public function withCustomerEmail(?string $customerEmail): self */ public function withCustomerID(?string $customerID): self { - $obj = clone $this; - $obj->customer_id = $customerID; + $self = clone $this; + $self['customerID'] = $customerID; - return $obj; + return $self; } /** @@ -643,10 +707,10 @@ public function withCustomerID(?string $customerID): self */ public function withCustomerName(?string $customerName): self { - $obj = clone $this; - $obj->customer_name = $customerName; + $self = clone $this; + $self['customerName'] = $customerName; - return $obj; + return $self; } /** @@ -654,10 +718,10 @@ public function withCustomerName(?string $customerName): self */ public function withCustomerTaxID(?string $customerTaxID): self { - $obj = clone $this; - $obj->customer_tax_id = $customerTaxID; + $self = clone $this; + $self['customerTaxID'] = $customerTaxID; - return $obj; + return $self; } /** @@ -667,10 +731,10 @@ public function withCustomerTaxID(?string $customerTaxID): self */ public function withDirection(DocumentDirection|string $direction): self { - $obj = clone $this; - $obj['direction'] = $direction; + $self = clone $this; + $self['direction'] = $direction; - return $obj; + return $self; } /** @@ -680,10 +744,10 @@ public function withDirection(DocumentDirection|string $direction): self */ public function withDocumentType(DocumentType|string $documentType): self { - $obj = clone $this; - $obj['document_type'] = $documentType; + $self = clone $this; + $self['documentType'] = $documentType; - return $obj; + return $self; } /** @@ -691,10 +755,10 @@ public function withDocumentType(DocumentType|string $documentType): self */ public function withDueDate(?\DateTimeInterface $dueDate): self { - $obj = clone $this; - $obj->due_date = $dueDate; + $self = clone $this; + $self['dueDate'] = $dueDate; - return $obj; + return $self; } /** @@ -702,10 +766,10 @@ public function withDueDate(?\DateTimeInterface $dueDate): self */ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self { - $obj = clone $this; - $obj->invoice_date = $invoiceDate; + $self = clone $this; + $self['invoiceDate'] = $invoiceDate; - return $obj; + return $self; } /** @@ -713,10 +777,10 @@ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self */ public function withInvoiceID(?string $invoiceID): self { - $obj = clone $this; - $obj->invoice_id = $invoiceID; + $self = clone $this; + $self['invoiceID'] = $invoiceID; - return $obj; + return $self; } /** @@ -724,23 +788,35 @@ public function withInvoiceID(?string $invoiceID): self */ public function withInvoiceTotal(float|string|null $invoiceTotal): self { - $obj = clone $this; - $obj->invoice_total = $invoiceTotal; + $self = clone $this; + $self['invoiceTotal'] = $invoiceTotal; - return $obj; + return $self; } /** * At least one line item is required. * - * @param list $items + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }> $items */ public function withItems(array $items): self { - $obj = clone $this; - $obj->items = $items; + $self = clone $this; + $self['items'] = $items; - return $obj; + return $self; } /** @@ -748,21 +824,26 @@ public function withItems(array $items): self */ public function withNote(?string $note): self { - $obj = clone $this; - $obj->note = $note; + $self = clone $this; + $self['note'] = $note; - return $obj; + return $self; } /** - * @param list|null $paymentDetails + * @param list|null $paymentDetails */ public function withPaymentDetails(?array $paymentDetails): self { - $obj = clone $this; - $obj->payment_details = $paymentDetails; + $self = clone $this; + $self['paymentDetails'] = $paymentDetails; - return $obj; + return $self; } /** @@ -770,10 +851,10 @@ public function withPaymentDetails(?array $paymentDetails): self */ public function withPaymentTerm(?string $paymentTerm): self { - $obj = clone $this; - $obj->payment_term = $paymentTerm; + $self = clone $this; + $self['paymentTerm'] = $paymentTerm; - return $obj; + return $self; } /** @@ -782,10 +863,10 @@ public function withPaymentTerm(?string $paymentTerm): self public function withPreviousUnpaidBalance( float|string|null $previousUnpaidBalance ): self { - $obj = clone $this; - $obj->previous_unpaid_balance = $previousUnpaidBalance; + $self = clone $this; + $self['previousUnpaidBalance'] = $previousUnpaidBalance; - return $obj; + return $self; } /** @@ -793,10 +874,10 @@ public function withPreviousUnpaidBalance( */ public function withPurchaseOrder(?string $purchaseOrder): self { - $obj = clone $this; - $obj->purchase_order = $purchaseOrder; + $self = clone $this; + $self['purchaseOrder'] = $purchaseOrder; - return $obj; + return $self; } /** @@ -804,10 +885,10 @@ public function withPurchaseOrder(?string $purchaseOrder): self */ public function withRemittanceAddress(?string $remittanceAddress): self { - $obj = clone $this; - $obj->remittance_address = $remittanceAddress; + $self = clone $this; + $self['remittanceAddress'] = $remittanceAddress; - return $obj; + return $self; } /** @@ -816,10 +897,10 @@ public function withRemittanceAddress(?string $remittanceAddress): self public function withRemittanceAddressRecipient( ?string $remittanceAddressRecipient ): self { - $obj = clone $this; - $obj->remittance_address_recipient = $remittanceAddressRecipient; + $self = clone $this; + $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; - return $obj; + return $self; } /** @@ -827,10 +908,10 @@ public function withRemittanceAddressRecipient( */ public function withServiceAddress(?string $serviceAddress): self { - $obj = clone $this; - $obj->service_address = $serviceAddress; + $self = clone $this; + $self['serviceAddress'] = $serviceAddress; - return $obj; + return $self; } /** @@ -839,10 +920,10 @@ public function withServiceAddress(?string $serviceAddress): self public function withServiceAddressRecipient( ?string $serviceAddressRecipient ): self { - $obj = clone $this; - $obj->service_address_recipient = $serviceAddressRecipient; + $self = clone $this; + $self['serviceAddressRecipient'] = $serviceAddressRecipient; - return $obj; + return $self; } /** @@ -851,10 +932,10 @@ public function withServiceAddressRecipient( public function withServiceEndDate( ?\DateTimeInterface $serviceEndDate ): self { - $obj = clone $this; - $obj->service_end_date = $serviceEndDate; + $self = clone $this; + $self['serviceEndDate'] = $serviceEndDate; - return $obj; + return $self; } /** @@ -863,10 +944,10 @@ public function withServiceEndDate( public function withServiceStartDate( ?\DateTimeInterface $serviceStartDate ): self { - $obj = clone $this; - $obj->service_start_date = $serviceStartDate; + $self = clone $this; + $self['serviceStartDate'] = $serviceStartDate; - return $obj; + return $self; } /** @@ -874,10 +955,10 @@ public function withServiceStartDate( */ public function withShippingAddress(?string $shippingAddress): self { - $obj = clone $this; - $obj->shipping_address = $shippingAddress; + $self = clone $this; + $self['shippingAddress'] = $shippingAddress; - return $obj; + return $self; } /** @@ -886,10 +967,10 @@ public function withShippingAddress(?string $shippingAddress): self public function withShippingAddressRecipient( ?string $shippingAddressRecipient ): self { - $obj = clone $this; - $obj->shipping_address_recipient = $shippingAddressRecipient; + $self = clone $this; + $self['shippingAddressRecipient'] = $shippingAddressRecipient; - return $obj; + return $self; } /** @@ -899,10 +980,10 @@ public function withShippingAddressRecipient( */ public function withState(DocumentState|string $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -910,10 +991,10 @@ public function withState(DocumentState|string $state): self */ public function withSubtotal(float|string|null $subtotal): self { - $obj = clone $this; - $obj->subtotal = $subtotal; + $self = clone $this; + $self['subtotal'] = $subtotal; - return $obj; + return $self; } /** @@ -923,21 +1004,23 @@ public function withSubtotal(float|string|null $subtotal): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** - * @param list|null $taxDetails + * @param list|null $taxDetails */ public function withTaxDetails(?array $taxDetails): self { - $obj = clone $this; - $obj->tax_details = $taxDetails; + $self = clone $this; + $self['taxDetails'] = $taxDetails; - return $obj; + return $self; } /** @@ -945,10 +1028,10 @@ public function withTaxDetails(?array $taxDetails): self */ public function withTotalDiscount(float|string|null $totalDiscount): self { - $obj = clone $this; - $obj->total_discount = $totalDiscount; + $self = clone $this; + $self['totalDiscount'] = $totalDiscount; - return $obj; + return $self; } /** @@ -956,10 +1039,10 @@ public function withTotalDiscount(float|string|null $totalDiscount): self */ public function withTotalTax(float|string|null $totalTax): self { - $obj = clone $this; - $obj->total_tax = $totalTax; + $self = clone $this; + $self['totalTax'] = $totalTax; - return $obj; + return $self; } /** @@ -972,10 +1055,10 @@ public function withTotalTax(float|string|null $totalTax): self */ public function withVatex(Vatex|string|null $vatex): self { - $obj = clone $this; - $obj['vatex'] = $vatex; + $self = clone $this; + $self['vatex'] = $vatex; - return $obj; + return $self; } /** @@ -983,10 +1066,10 @@ public function withVatex(Vatex|string|null $vatex): self */ public function withVatexNote(?string $vatexNote): self { - $obj = clone $this; - $obj->vatex_note = $vatexNote; + $self = clone $this; + $self['vatexNote'] = $vatexNote; - return $obj; + return $self; } /** @@ -994,10 +1077,10 @@ public function withVatexNote(?string $vatexNote): self */ public function withVendorAddress(?string $vendorAddress): self { - $obj = clone $this; - $obj->vendor_address = $vendorAddress; + $self = clone $this; + $self['vendorAddress'] = $vendorAddress; - return $obj; + return $self; } /** @@ -1006,10 +1089,10 @@ public function withVendorAddress(?string $vendorAddress): self public function withVendorAddressRecipient( ?string $vendorAddressRecipient ): self { - $obj = clone $this; - $obj->vendor_address_recipient = $vendorAddressRecipient; + $self = clone $this; + $self['vendorAddressRecipient'] = $vendorAddressRecipient; - return $obj; + return $self; } /** @@ -1017,10 +1100,10 @@ public function withVendorAddressRecipient( */ public function withVendorCompanyID(?string $vendorCompanyID): self { - $obj = clone $this; - $obj->vendor_company_id = $vendorCompanyID; + $self = clone $this; + $self['vendorCompanyID'] = $vendorCompanyID; - return $obj; + return $self; } /** @@ -1028,10 +1111,10 @@ public function withVendorCompanyID(?string $vendorCompanyID): self */ public function withVendorEmail(?string $vendorEmail): self { - $obj = clone $this; - $obj->vendor_email = $vendorEmail; + $self = clone $this; + $self['vendorEmail'] = $vendorEmail; - return $obj; + return $self; } /** @@ -1039,10 +1122,10 @@ public function withVendorEmail(?string $vendorEmail): self */ public function withVendorName(?string $vendorName): self { - $obj = clone $this; - $obj->vendor_name = $vendorName; + $self = clone $this; + $self['vendorName'] = $vendorName; - return $obj; + return $self; } /** @@ -1050,9 +1133,9 @@ public function withVendorName(?string $vendorName): self */ public function withVendorTaxID(?string $vendorTaxID): self { - $obj = clone $this; - $obj->vendor_tax_id = $vendorTaxID; + $self = clone $this; + $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate/Allowance.php b/src/Documents/DocumentCreate/Allowance.php index eca26acb..baa0db57 100644 --- a/src/Documents/DocumentCreate/Allowance.php +++ b/src/Documents/DocumentCreate/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreate\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Documents\DocumentCreate\Allowance\TaxCode>|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentCreate\Allowance\TaxCode>|null, + * taxRate?: float|string|null, * } */ final class Allowance implements BaseModel @@ -31,51 +31,51 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -87,29 +87,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -117,10 +117,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -128,10 +128,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -140,10 +140,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -151,10 +151,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -164,10 +164,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -178,10 +178,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string $taxCode ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -189,9 +189,9 @@ public function withTaxCode( */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate/Charge.php b/src/Documents/DocumentCreate/Charge.php index 15efa6af..43b41379 100644 --- a/src/Documents/DocumentCreate/Charge.php +++ b/src/Documents/DocumentCreate/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreate\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Documents\DocumentCreate\Charge\TaxCode>|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentCreate\Charge\TaxCode>|null, + * taxRate?: float|string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,20 +67,20 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, nullable: true, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -92,29 +92,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -122,10 +122,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -133,10 +133,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -145,10 +145,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -156,10 +156,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -169,10 +169,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -187,10 +187,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string|null $taxCode ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -198,9 +198,9 @@ public function withTaxCode( */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate/Item.php b/src/Documents/DocumentCreate/Item.php index 3524cc41..64e7e2e9 100644 --- a/src/Documents/DocumentCreate/Item.php +++ b/src/Documents/DocumentCreate/Item.php @@ -4,10 +4,12 @@ namespace EInvoiceAPI\Documents\DocumentCreate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreate\Item\Allowance; +use EInvoiceAPI\Documents\DocumentCreate\Item\Allowance\ReasonCode; +use EInvoiceAPI\Documents\DocumentCreate\Item\Allowance\TaxCode; use EInvoiceAPI\Documents\DocumentCreate\Item\Charge; use EInvoiceAPI\Documents\UnitOfMeasureCode; @@ -18,12 +20,12 @@ * charges?: list<\EInvoiceAPI\Documents\DocumentCreate\Item\Charge>|null, * date?: null|null, * description?: string|null, - * product_code?: string|null, + * productCode?: string|null, * quantity?: float|string|null, * tax?: float|string|null, - * tax_rate?: float|string|null, + * taxRate?: float|string|null, * unit?: value-of|null, - * unit_price?: float|string|null, + * unitPrice?: float|string|null, * } */ final class Item implements BaseModel @@ -36,17 +38,16 @@ final class Item implements BaseModel * * @var list|null $allowances */ - #[Api( + #[Optional( list: Allowance::class, nullable: true, - optional: true, )] public ?array $allowances; /** * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** @@ -54,60 +55,59 @@ final class Item implements BaseModel * * @var list|null $charges */ - #[Api( + #[Optional( list: Charge::class, nullable: true, - optional: true, )] public ?array $charges; /** @var null|null $date */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public null $date; /** * The description of the line item. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The product code of the line item. */ - #[Api(nullable: true, optional: true)] - public ?string $product_code; + #[Optional('product_code', nullable: true)] + public ?string $productCode; /** * The quantity of items (goods or services) that is the subject of the line item. Must be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $quantity; /** * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $tax; /** * The VAT rate of the line item expressed as percentage with 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. * * @var value-of|null $unit */ - #[Api(enum: UnitOfMeasureCode::class, nullable: true, optional: true)] + #[Optional(enum: UnitOfMeasureCode::class, nullable: true)] public ?string $unit; /** * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting item price discount. Must be rounded to maximum 4 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $unit_price; + #[Optional('unit_price', nullable: true)] + public float|string|null $unitPrice; public function __construct() { @@ -119,8 +119,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges * @param UnitOfMeasureCode|value-of|null $unit */ public static function with( @@ -129,42 +145,50 @@ public static function with( ?array $charges = null, null $date = null, ?string $description = null, - ?string $product_code = null, + ?string $productCode = null, float|string|null $quantity = null, float|string|null $tax = null, - float|string|null $tax_rate = null, + float|string|null $taxRate = null, UnitOfMeasureCode|string|null $unit = null, - float|string|null $unit_price = null, + float|string|null $unitPrice = null, ): self { - $obj = new self; - - $obj->date = $date; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount && $obj->amount = $amount; - null !== $charges && $obj->charges = $charges; - null !== $description && $obj->description = $description; - null !== $product_code && $obj->product_code = $product_code; - null !== $quantity && $obj->quantity = $quantity; - null !== $tax && $obj->tax = $tax; - null !== $tax_rate && $obj->tax_rate = $tax_rate; - null !== $unit && $obj['unit'] = $unit; - null !== $unit_price && $obj->unit_price = $unit_price; - - return $obj; + $self = new self; + + $self['date'] = $date; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amount && $self['amount'] = $amount; + null !== $charges && $self['charges'] = $charges; + null !== $description && $self['description'] = $description; + null !== $productCode && $self['productCode'] = $productCode; + null !== $quantity && $self['quantity'] = $quantity; + null !== $tax && $self['tax'] = $tax; + null !== $taxRate && $self['taxRate'] = $taxRate; + null !== $unit && $self['unit'] = $unit; + null !== $unitPrice && $self['unitPrice'] = $unitPrice; + + return $self; } /** * The allowances of the line item. * - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -172,23 +196,31 @@ public function withAllowances(?array $allowances): self */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** * The charges of the line item. * - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -196,10 +228,10 @@ public function withCharges(?array $charges): self */ public function withDate(null $date): self { - $obj = clone $this; - $obj->date = $date; + $self = clone $this; + $self['date'] = $date; - return $obj; + return $self; } /** @@ -207,10 +239,10 @@ public function withDate(null $date): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -218,10 +250,10 @@ public function withDescription(?string $description): self */ public function withProductCode(?string $productCode): self { - $obj = clone $this; - $obj->product_code = $productCode; + $self = clone $this; + $self['productCode'] = $productCode; - return $obj; + return $self; } /** @@ -229,10 +261,10 @@ public function withProductCode(?string $productCode): self */ public function withQuantity(float|string|null $quantity): self { - $obj = clone $this; - $obj->quantity = $quantity; + $self = clone $this; + $self['quantity'] = $quantity; - return $obj; + return $self; } /** @@ -240,10 +272,10 @@ public function withQuantity(float|string|null $quantity): self */ public function withTax(float|string|null $tax): self { - $obj = clone $this; - $obj->tax = $tax; + $self = clone $this; + $self['tax'] = $tax; - return $obj; + return $self; } /** @@ -251,10 +283,10 @@ public function withTax(float|string|null $tax): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -264,10 +296,10 @@ public function withTaxRate(float|string|null $taxRate): self */ public function withUnit(UnitOfMeasureCode|string|null $unit): self { - $obj = clone $this; - $obj['unit'] = $unit; + $self = clone $this; + $self['unit'] = $unit; - return $obj; + return $self; } /** @@ -275,9 +307,9 @@ public function withUnit(UnitOfMeasureCode|string|null $unit): self */ public function withUnitPrice(float|string|null $unitPrice): self { - $obj = clone $this; - $obj->unit_price = $unitPrice; + $self = clone $this; + $self['unitPrice'] = $unitPrice; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate/Item/Allowance.php b/src/Documents/DocumentCreate/Item/Allowance.php index 5ce570cd..a690579d 100644 --- a/src/Documents/DocumentCreate/Item/Allowance.php +++ b/src/Documents/DocumentCreate/Item/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreate\Item; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreate\Item\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, * } */ final class Allowance implements BaseModel @@ -31,48 +31,48 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -84,29 +84,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -114,10 +114,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -125,10 +125,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -137,10 +137,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -148,10 +148,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -161,10 +161,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -174,10 +174,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -185,9 +185,9 @@ public function withTaxCode(TaxCode|string $taxCode): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate/Item/Charge.php b/src/Documents/DocumentCreate/Item/Charge.php index 78aa4a8f..18c79867 100644 --- a/src/Documents/DocumentCreate/Item/Charge.php +++ b/src/Documents/DocumentCreate/Item/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreate\Item; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreate\Item\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,16 +67,16 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, nullable: true, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class, nullable: true)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -88,29 +88,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -118,10 +118,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -129,10 +129,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -141,10 +141,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -152,10 +152,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -165,10 +165,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -182,10 +182,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string|null $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -193,9 +193,9 @@ public function withTaxCode(TaxCode|string|null $taxCode): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreate/TaxDetail.php b/src/Documents/DocumentCreate/TaxDetail.php index c19099d6..f0db831d 100644 --- a/src/Documents/DocumentCreate/TaxDetail.php +++ b/src/Documents/DocumentCreate/TaxDetail.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class TaxDetail implements BaseModel /** * The tax amount for this tax category. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00'). */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $rate; public function __construct() @@ -44,12 +44,12 @@ public static function with( float|string|null $amount = null, ?string $rate = null ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $rate && $obj->rate = $rate; + null !== $amount && $self['amount'] = $amount; + null !== $rate && $self['rate'] = $rate; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withAmount(float|string|null $amount): self */ public function withRate(?string $rate): self { - $obj = clone $this; - $obj->rate = $rate; + $self = clone $this; + $self['rate'] = $rate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateFromPdfParams.php b/src/Documents/DocumentCreateFromPdfParams.php index b2b642cc..f3e275b7 100644 --- a/src/Documents/DocumentCreateFromPdfParams.php +++ b/src/Documents/DocumentCreateFromPdfParams.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -15,7 +16,7 @@ * @see EInvoiceAPI\Services\DocumentsService::createFromPdf() * * @phpstan-type DocumentCreateFromPdfParamsShape = array{ - * file: string, customer_tax_id?: string|null, vendor_tax_id?: string|null + * file: string, customerTaxID?: string|null, vendorTaxID?: string|null * } */ final class DocumentCreateFromPdfParams implements BaseModel @@ -24,14 +25,14 @@ final class DocumentCreateFromPdfParams implements BaseModel use SdkModel; use SdkParams; - #[Api] + #[Required] public string $file; - #[Api(nullable: true, optional: true)] - public ?string $customer_tax_id; + #[Optional(nullable: true)] + public ?string $customerTaxID; - #[Api(nullable: true, optional: true)] - public ?string $vendor_tax_id; + #[Optional(nullable: true)] + public ?string $vendorTaxID; /** * `new DocumentCreateFromPdfParams()` is missing required properties by the API. @@ -59,40 +60,40 @@ public function __construct() */ public static function with( string $file, - ?string $customer_tax_id = null, - ?string $vendor_tax_id = null + ?string $customerTaxID = null, + ?string $vendorTaxID = null ): self { - $obj = new self; + $self = new self; - $obj->file = $file; + $self['file'] = $file; - null !== $customer_tax_id && $obj->customer_tax_id = $customer_tax_id; - null !== $vendor_tax_id && $obj->vendor_tax_id = $vendor_tax_id; + null !== $customerTaxID && $self['customerTaxID'] = $customerTaxID; + null !== $vendorTaxID && $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } public function withFile(string $file): self { - $obj = clone $this; - $obj->file = $file; + $self = clone $this; + $self['file'] = $file; - return $obj; + return $self; } public function withCustomerTaxID(?string $customerTaxID): self { - $obj = clone $this; - $obj->customer_tax_id = $customerTaxID; + $self = clone $this; + $self['customerTaxID'] = $customerTaxID; - return $obj; + return $self; } public function withVendorTaxID(?string $vendorTaxID): self { - $obj = clone $this; - $obj->vendor_tax_id = $vendorTaxID; + $self = clone $this; + $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams.php b/src/Documents/DocumentCreateParams.php index 53fd7e91..722cb35d 100644 --- a/src/Documents/DocumentCreateParams.php +++ b/src/Documents/DocumentCreateParams.php @@ -4,14 +4,15 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreateParams\Allowance; +use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\ReasonCode; +use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\TaxCode; use EInvoiceAPI\Documents\DocumentCreateParams\Charge; use EInvoiceAPI\Documents\DocumentCreateParams\Item; -use EInvoiceAPI\Documents\DocumentCreateParams\TaxCode; use EInvoiceAPI\Documents\DocumentCreateParams\TaxDetail; use EInvoiceAPI\Documents\DocumentCreateParams\Vatex; use EInvoiceAPI\Inbox\DocumentState; @@ -22,54 +23,94 @@ * @see EInvoiceAPI\Services\DocumentsService::create() * * @phpstan-type DocumentCreateParamsShape = array{ - * allowances?: list<\EInvoiceAPI\Documents\DocumentCreateParams\Allowance>|null, - * amount_due?: float|string|null, - * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, - * charges?: list<\EInvoiceAPI\Documents\DocumentCreateParams\Charge>|null, + * allowances?: list<\EInvoiceAPI\Documents\DocumentCreateParams\Allowance|array{ + * amount?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, + * reason?: string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null, + * amountDue?: float|string|null, + * attachments?: list|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, + * charges?: list<\EInvoiceAPI\Documents\DocumentCreateParams\Charge|array{ + * amount?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, + * reason?: string|null, + * reasonCode?: value-of<\EInvoiceAPI\Documents\DocumentCreateParams\Charge\ReasonCode>|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentCreateParams\Charge\TaxCode>|null, + * taxRate?: float|string|null, + * }>|null, * currency?: CurrencyCode|value-of, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, * direction?: DocumentDirection|value-of, - * document_type?: DocumentType|value-of, - * due_date?: \DateTimeInterface|null, - * invoice_date?: \DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: float|string|null, - * items?: list, + * documentType?: DocumentType|value-of, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: float|string|null, + * items?: list|null, + * amount?: float|string|null, + * charges?: list<\EInvoiceAPI\Documents\DocumentCreateParams\Item\Charge>|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }>, * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * previous_unpaid_balance?: float|string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: \DateTimeInterface|null, - * service_start_date?: \DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * previousUnpaidBalance?: float|string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, * state?: DocumentState|value-of, * subtotal?: float|string|null, - * tax_code?: TaxCode|value-of, - * tax_details?: list|null, - * total_discount?: float|string|null, - * total_tax?: float|string|null, + * taxCode?: \EInvoiceAPI\Documents\DocumentCreateParams\TaxCode|value-of<\EInvoiceAPI\Documents\DocumentCreateParams\TaxCode>, + * taxDetails?: list|null, + * totalDiscount?: float|string|null, + * totalTax?: float|string|null, * vatex?: null|Vatex|value-of, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, * } */ final class DocumentCreateParams implements BaseModel @@ -81,40 +122,38 @@ final class DocumentCreateParams implements BaseModel /** * @var list|null $allowances */ - #[Api( + #[Optional( list: Allowance::class, nullable: true, - optional: true, )] public ?array $allowances; /** * The amount due for payment. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $amount_due; + #[Optional('amount_due', nullable: true)] + public float|string|null $amountDue; /** @var list|null $attachments */ - #[Api(list: DocumentAttachmentCreate::class, nullable: true, optional: true)] + #[Optional(list: DocumentAttachmentCreate::class, nullable: true)] public ?array $attachments; /** * The billing address (if different from customer address). */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address; + #[Optional('billing_address', nullable: true)] + public ?string $billingAddress; /** * The recipient name at the billing address. */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address_recipient; + #[Optional('billing_address_recipient', nullable: true)] + public ?string $billingAddressRecipient; /** @var list|null $charges */ - #[Api( + #[Optional( list: Charge::class, nullable: true, - optional: true, )] public ?array $charges; @@ -123,212 +162,219 @@ final class DocumentCreateParams implements BaseModel * * @var value-of|null $currency */ - #[Api(enum: CurrencyCode::class, optional: true)] + #[Optional(enum: CurrencyCode::class)] public ?string $currency; /** * The address of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address; + #[Optional('customer_address', nullable: true)] + public ?string $customerAddress; /** * The recipient name at the customer address. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address_recipient; + #[Optional('customer_address_recipient', nullable: true)] + public ?string $customerAddressRecipient; /** * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_company_id; + #[Optional('customer_company_id', nullable: true)] + public ?string $customerCompanyID; /** * The email address of the customer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_email; + #[Optional('customer_email', nullable: true)] + public ?string $customerEmail; /** * The unique identifier for the customer in your system. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_id; + #[Optional('customer_id', nullable: true)] + public ?string $customerID; /** * The company name of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_name; + #[Optional('customer_name', nullable: true)] + public ?string $customerName; /** * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_tax_id; + #[Optional('customer_tax_id', nullable: true)] + public ?string $customerTaxID; /** * The direction of the document: INBOUND (purchases) or OUTBOUND (sales). * * @var value-of|null $direction */ - #[Api(enum: DocumentDirection::class, optional: true)] + #[Optional(enum: DocumentDirection::class)] public ?string $direction; /** * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE. * - * @var value-of|null $document_type + * @var value-of|null $documentType */ - #[Api(enum: DocumentType::class, optional: true)] - public ?string $document_type; + #[Optional('document_type', enum: DocumentType::class)] + public ?string $documentType; /** * The date when payment is due. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $due_date; + #[Optional('due_date', nullable: true)] + public ?\DateTimeInterface $dueDate; /** * The date when the invoice was issued. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $invoice_date; + #[Optional('invoice_date', nullable: true)] + public ?\DateTimeInterface $invoiceDate; /** * The unique invoice identifier/number. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_id; + #[Optional('invoice_id', nullable: true)] + public ?string $invoiceID; /** * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $invoice_total; + #[Optional('invoice_total', nullable: true)] + public float|string|null $invoiceTotal; /** * At least one line item is required. * * @var list|null $items */ - #[Api(list: Item::class, optional: true)] + #[Optional(list: Item::class)] public ?array $items; /** * Additional notes or comments for the invoice. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $note; - /** @var list|null $payment_details */ - #[Api(list: PaymentDetailCreate::class, nullable: true, optional: true)] - public ?array $payment_details; + /** @var list|null $paymentDetails */ + #[Optional( + 'payment_details', + list: PaymentDetailCreate::class, + nullable: true + )] + public ?array $paymentDetails; /** * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30'). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_term; + #[Optional('payment_term', nullable: true)] + public ?string $paymentTerm; /** * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $previous_unpaid_balance; + #[Optional('previous_unpaid_balance', nullable: true)] + public float|string|null $previousUnpaidBalance; /** * The purchase order reference number. */ - #[Api(nullable: true, optional: true)] - public ?string $purchase_order; + #[Optional('purchase_order', nullable: true)] + public ?string $purchaseOrder; /** * The address where payment should be sent or remitted to. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address; + #[Optional('remittance_address', nullable: true)] + public ?string $remittanceAddress; /** * The recipient name at the remittance address. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address_recipient; + #[Optional('remittance_address_recipient', nullable: true)] + public ?string $remittanceAddressRecipient; /** * The address where services were performed or goods were delivered. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address; + #[Optional('service_address', nullable: true)] + public ?string $serviceAddress; /** * The recipient name at the service address. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address_recipient; + #[Optional('service_address_recipient', nullable: true)] + public ?string $serviceAddressRecipient; /** * The end date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_end_date; + #[Optional('service_end_date', nullable: true)] + public ?\DateTimeInterface $serviceEndDate; /** * The start date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_start_date; + #[Optional('service_start_date', nullable: true)] + public ?\DateTimeInterface $serviceStartDate; /** * The shipping/delivery address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address; + #[Optional('shipping_address', nullable: true)] + public ?string $shippingAddress; /** * The recipient name at the shipping address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address_recipient; + #[Optional('shipping_address_recipient', nullable: true)] + public ?string $shippingAddressRecipient; /** * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED. * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, optional: true)] + #[Optional(enum: DocumentState::class)] public ?string $state; /** * The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $subtotal; /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional( + 'tax_code', + enum: DocumentCreateParams\TaxCode::class + )] + public ?string $taxCode; - /** @var list|null $tax_details */ - #[Api(list: TaxDetail::class, nullable: true, optional: true)] - public ?array $tax_details; + /** @var list|null $taxDetails */ + #[Optional('tax_details', list: TaxDetail::class, nullable: true)] + public ?array $taxDetails; /** * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $total_discount; + #[Optional('total_discount', nullable: true)] + public float|string|null $totalDiscount; /** * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $total_tax; + #[Optional('total_tax', nullable: true)] + public float|string|null $totalTax; /** * VATEX code list for VAT exemption reasons. @@ -338,50 +384,50 @@ final class DocumentCreateParams implements BaseModel * * @var value-of|null $vatex */ - #[Api(enum: Vatex::class, nullable: true, optional: true)] + #[Optional(enum: Vatex::class, nullable: true)] public ?string $vatex; /** * Textual explanation for VAT exemption. */ - #[Api(nullable: true, optional: true)] - public ?string $vatex_note; + #[Optional('vatex_note', nullable: true)] + public ?string $vatexNote; /** * The address of the vendor/seller. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address; + #[Optional('vendor_address', nullable: true)] + public ?string $vendorAddress; /** * The recipient name at the vendor address. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address_recipient; + #[Optional('vendor_address_recipient', nullable: true)] + public ?string $vendorAddressRecipient; /** * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_company_id; + #[Optional('vendor_company_id', nullable: true)] + public ?string $vendorCompanyID; /** * The email address of the vendor. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_email; + #[Optional('vendor_email', nullable: true)] + public ?string $vendorEmail; /** * The name of the vendor/seller/supplier. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_name; + #[Optional('vendor_name', nullable: true)] + public ?string $vendorName; /** * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_tax_id; + #[Optional('vendor_tax_id', nullable: true)] + public ?string $vendorTaxID; public function __construct() { @@ -393,132 +439,180 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $attachments - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances + * @param list|null $attachments + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges * @param CurrencyCode|value-of $currency * @param DocumentDirection|value-of $direction - * @param DocumentType|value-of $document_type - * @param list $items - * @param list|null $payment_details + * @param DocumentType|value-of $documentType + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }> $items + * @param list|null $paymentDetails * @param DocumentState|value-of $state - * @param TaxCode|value-of $tax_code - * @param list|null $tax_details + * @param DocumentCreateParams\TaxCode|value-of $taxCode + * @param list|null $taxDetails * @param Vatex|value-of|null $vatex */ public static function with( ?array $allowances = null, - float|string|null $amount_due = null, + float|string|null $amountDue = null, ?array $attachments = null, - ?string $billing_address = null, - ?string $billing_address_recipient = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, ?array $charges = null, CurrencyCode|string|null $currency = null, - ?string $customer_address = null, - ?string $customer_address_recipient = null, - ?string $customer_company_id = null, - ?string $customer_email = null, - ?string $customer_id = null, - ?string $customer_name = null, - ?string $customer_tax_id = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, DocumentDirection|string|null $direction = null, - DocumentType|string|null $document_type = null, - ?\DateTimeInterface $due_date = null, - ?\DateTimeInterface $invoice_date = null, - ?string $invoice_id = null, - float|string|null $invoice_total = null, + DocumentType|string|null $documentType = null, + ?\DateTimeInterface $dueDate = null, + ?\DateTimeInterface $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, ?array $items = null, ?string $note = null, - ?array $payment_details = null, - ?string $payment_term = null, - float|string|null $previous_unpaid_balance = null, - ?string $purchase_order = null, - ?string $remittance_address = null, - ?string $remittance_address_recipient = null, - ?string $service_address = null, - ?string $service_address_recipient = null, - ?\DateTimeInterface $service_end_date = null, - ?\DateTimeInterface $service_start_date = null, - ?string $shipping_address = null, - ?string $shipping_address_recipient = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + ?\DateTimeInterface $serviceEndDate = null, + ?\DateTimeInterface $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, DocumentState|string|null $state = null, float|string|null $subtotal = null, - TaxCode|string|null $tax_code = null, - ?array $tax_details = null, - float|string|null $total_discount = null, - float|string|null $total_tax = null, + DocumentCreateParams\TaxCode|string|null $taxCode = null, + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, Vatex|string|null $vatex = null, - ?string $vatex_note = null, - ?string $vendor_address = null, - ?string $vendor_address_recipient = null, - ?string $vendor_company_id = null, - ?string $vendor_email = null, - ?string $vendor_name = null, - ?string $vendor_tax_id = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ): self { - $obj = new self; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount_due && $obj->amount_due = $amount_due; - null !== $attachments && $obj->attachments = $attachments; - null !== $billing_address && $obj->billing_address = $billing_address; - null !== $billing_address_recipient && $obj->billing_address_recipient = $billing_address_recipient; - null !== $charges && $obj->charges = $charges; - null !== $currency && $obj['currency'] = $currency; - null !== $customer_address && $obj->customer_address = $customer_address; - null !== $customer_address_recipient && $obj->customer_address_recipient = $customer_address_recipient; - null !== $customer_company_id && $obj->customer_company_id = $customer_company_id; - null !== $customer_email && $obj->customer_email = $customer_email; - null !== $customer_id && $obj->customer_id = $customer_id; - null !== $customer_name && $obj->customer_name = $customer_name; - null !== $customer_tax_id && $obj->customer_tax_id = $customer_tax_id; - null !== $direction && $obj['direction'] = $direction; - null !== $document_type && $obj['document_type'] = $document_type; - null !== $due_date && $obj->due_date = $due_date; - null !== $invoice_date && $obj->invoice_date = $invoice_date; - null !== $invoice_id && $obj->invoice_id = $invoice_id; - null !== $invoice_total && $obj->invoice_total = $invoice_total; - null !== $items && $obj->items = $items; - null !== $note && $obj->note = $note; - null !== $payment_details && $obj->payment_details = $payment_details; - null !== $payment_term && $obj->payment_term = $payment_term; - null !== $previous_unpaid_balance && $obj->previous_unpaid_balance = $previous_unpaid_balance; - null !== $purchase_order && $obj->purchase_order = $purchase_order; - null !== $remittance_address && $obj->remittance_address = $remittance_address; - null !== $remittance_address_recipient && $obj->remittance_address_recipient = $remittance_address_recipient; - null !== $service_address && $obj->service_address = $service_address; - null !== $service_address_recipient && $obj->service_address_recipient = $service_address_recipient; - null !== $service_end_date && $obj->service_end_date = $service_end_date; - null !== $service_start_date && $obj->service_start_date = $service_start_date; - null !== $shipping_address && $obj->shipping_address = $shipping_address; - null !== $shipping_address_recipient && $obj->shipping_address_recipient = $shipping_address_recipient; - null !== $state && $obj['state'] = $state; - null !== $subtotal && $obj->subtotal = $subtotal; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_details && $obj->tax_details = $tax_details; - null !== $total_discount && $obj->total_discount = $total_discount; - null !== $total_tax && $obj->total_tax = $total_tax; - null !== $vatex && $obj['vatex'] = $vatex; - null !== $vatex_note && $obj->vatex_note = $vatex_note; - null !== $vendor_address && $obj->vendor_address = $vendor_address; - null !== $vendor_address_recipient && $obj->vendor_address_recipient = $vendor_address_recipient; - null !== $vendor_company_id && $obj->vendor_company_id = $vendor_company_id; - null !== $vendor_email && $obj->vendor_email = $vendor_email; - null !== $vendor_name && $obj->vendor_name = $vendor_name; - null !== $vendor_tax_id && $obj->vendor_tax_id = $vendor_tax_id; - - return $obj; + $self = new self; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amountDue && $self['amountDue'] = $amountDue; + null !== $attachments && $self['attachments'] = $attachments; + null !== $billingAddress && $self['billingAddress'] = $billingAddress; + null !== $billingAddressRecipient && $self['billingAddressRecipient'] = $billingAddressRecipient; + null !== $charges && $self['charges'] = $charges; + null !== $currency && $self['currency'] = $currency; + null !== $customerAddress && $self['customerAddress'] = $customerAddress; + null !== $customerAddressRecipient && $self['customerAddressRecipient'] = $customerAddressRecipient; + null !== $customerCompanyID && $self['customerCompanyID'] = $customerCompanyID; + null !== $customerEmail && $self['customerEmail'] = $customerEmail; + null !== $customerID && $self['customerID'] = $customerID; + null !== $customerName && $self['customerName'] = $customerName; + null !== $customerTaxID && $self['customerTaxID'] = $customerTaxID; + null !== $direction && $self['direction'] = $direction; + null !== $documentType && $self['documentType'] = $documentType; + null !== $dueDate && $self['dueDate'] = $dueDate; + null !== $invoiceDate && $self['invoiceDate'] = $invoiceDate; + null !== $invoiceID && $self['invoiceID'] = $invoiceID; + null !== $invoiceTotal && $self['invoiceTotal'] = $invoiceTotal; + null !== $items && $self['items'] = $items; + null !== $note && $self['note'] = $note; + null !== $paymentDetails && $self['paymentDetails'] = $paymentDetails; + null !== $paymentTerm && $self['paymentTerm'] = $paymentTerm; + null !== $previousUnpaidBalance && $self['previousUnpaidBalance'] = $previousUnpaidBalance; + null !== $purchaseOrder && $self['purchaseOrder'] = $purchaseOrder; + null !== $remittanceAddress && $self['remittanceAddress'] = $remittanceAddress; + null !== $remittanceAddressRecipient && $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; + null !== $serviceAddress && $self['serviceAddress'] = $serviceAddress; + null !== $serviceAddressRecipient && $self['serviceAddressRecipient'] = $serviceAddressRecipient; + null !== $serviceEndDate && $self['serviceEndDate'] = $serviceEndDate; + null !== $serviceStartDate && $self['serviceStartDate'] = $serviceStartDate; + null !== $shippingAddress && $self['shippingAddress'] = $shippingAddress; + null !== $shippingAddressRecipient && $self['shippingAddressRecipient'] = $shippingAddressRecipient; + null !== $state && $self['state'] = $state; + null !== $subtotal && $self['subtotal'] = $subtotal; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxDetails && $self['taxDetails'] = $taxDetails; + null !== $totalDiscount && $self['totalDiscount'] = $totalDiscount; + null !== $totalTax && $self['totalTax'] = $totalTax; + null !== $vatex && $self['vatex'] = $vatex; + null !== $vatexNote && $self['vatexNote'] = $vatexNote; + null !== $vendorAddress && $self['vendorAddress'] = $vendorAddress; + null !== $vendorAddressRecipient && $self['vendorAddressRecipient'] = $vendorAddressRecipient; + null !== $vendorCompanyID && $self['vendorCompanyID'] = $vendorCompanyID; + null !== $vendorEmail && $self['vendorEmail'] = $vendorEmail; + null !== $vendorName && $self['vendorName'] = $vendorName; + null !== $vendorTaxID && $self['vendorTaxID'] = $vendorTaxID; + + return $self; } /** - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -526,21 +620,26 @@ public function withAllowances(?array $allowances): self */ public function withAmountDue(float|string|null $amountDue): self { - $obj = clone $this; - $obj->amount_due = $amountDue; + $self = clone $this; + $self['amountDue'] = $amountDue; - return $obj; + return $self; } /** - * @param list|null $attachments + * @param list|null $attachments */ public function withAttachments(?array $attachments): self { - $obj = clone $this; - $obj->attachments = $attachments; + $self = clone $this; + $self['attachments'] = $attachments; - return $obj; + return $self; } /** @@ -548,10 +647,10 @@ public function withAttachments(?array $attachments): self */ public function withBillingAddress(?string $billingAddress): self { - $obj = clone $this; - $obj->billing_address = $billingAddress; + $self = clone $this; + $self['billingAddress'] = $billingAddress; - return $obj; + return $self; } /** @@ -560,21 +659,29 @@ public function withBillingAddress(?string $billingAddress): self public function withBillingAddressRecipient( ?string $billingAddressRecipient ): self { - $obj = clone $this; - $obj->billing_address_recipient = $billingAddressRecipient; + $self = clone $this; + $self['billingAddressRecipient'] = $billingAddressRecipient; - return $obj; + return $self; } /** - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -584,10 +691,10 @@ public function withCharges(?array $charges): self */ public function withCurrency(CurrencyCode|string $currency): self { - $obj = clone $this; - $obj['currency'] = $currency; + $self = clone $this; + $self['currency'] = $currency; - return $obj; + return $self; } /** @@ -595,10 +702,10 @@ public function withCurrency(CurrencyCode|string $currency): self */ public function withCustomerAddress(?string $customerAddress): self { - $obj = clone $this; - $obj->customer_address = $customerAddress; + $self = clone $this; + $self['customerAddress'] = $customerAddress; - return $obj; + return $self; } /** @@ -607,10 +714,10 @@ public function withCustomerAddress(?string $customerAddress): self public function withCustomerAddressRecipient( ?string $customerAddressRecipient ): self { - $obj = clone $this; - $obj->customer_address_recipient = $customerAddressRecipient; + $self = clone $this; + $self['customerAddressRecipient'] = $customerAddressRecipient; - return $obj; + return $self; } /** @@ -618,10 +725,10 @@ public function withCustomerAddressRecipient( */ public function withCustomerCompanyID(?string $customerCompanyID): self { - $obj = clone $this; - $obj->customer_company_id = $customerCompanyID; + $self = clone $this; + $self['customerCompanyID'] = $customerCompanyID; - return $obj; + return $self; } /** @@ -629,10 +736,10 @@ public function withCustomerCompanyID(?string $customerCompanyID): self */ public function withCustomerEmail(?string $customerEmail): self { - $obj = clone $this; - $obj->customer_email = $customerEmail; + $self = clone $this; + $self['customerEmail'] = $customerEmail; - return $obj; + return $self; } /** @@ -640,10 +747,10 @@ public function withCustomerEmail(?string $customerEmail): self */ public function withCustomerID(?string $customerID): self { - $obj = clone $this; - $obj->customer_id = $customerID; + $self = clone $this; + $self['customerID'] = $customerID; - return $obj; + return $self; } /** @@ -651,10 +758,10 @@ public function withCustomerID(?string $customerID): self */ public function withCustomerName(?string $customerName): self { - $obj = clone $this; - $obj->customer_name = $customerName; + $self = clone $this; + $self['customerName'] = $customerName; - return $obj; + return $self; } /** @@ -662,10 +769,10 @@ public function withCustomerName(?string $customerName): self */ public function withCustomerTaxID(?string $customerTaxID): self { - $obj = clone $this; - $obj->customer_tax_id = $customerTaxID; + $self = clone $this; + $self['customerTaxID'] = $customerTaxID; - return $obj; + return $self; } /** @@ -675,10 +782,10 @@ public function withCustomerTaxID(?string $customerTaxID): self */ public function withDirection(DocumentDirection|string $direction): self { - $obj = clone $this; - $obj['direction'] = $direction; + $self = clone $this; + $self['direction'] = $direction; - return $obj; + return $self; } /** @@ -688,10 +795,10 @@ public function withDirection(DocumentDirection|string $direction): self */ public function withDocumentType(DocumentType|string $documentType): self { - $obj = clone $this; - $obj['document_type'] = $documentType; + $self = clone $this; + $self['documentType'] = $documentType; - return $obj; + return $self; } /** @@ -699,10 +806,10 @@ public function withDocumentType(DocumentType|string $documentType): self */ public function withDueDate(?\DateTimeInterface $dueDate): self { - $obj = clone $this; - $obj->due_date = $dueDate; + $self = clone $this; + $self['dueDate'] = $dueDate; - return $obj; + return $self; } /** @@ -710,10 +817,10 @@ public function withDueDate(?\DateTimeInterface $dueDate): self */ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self { - $obj = clone $this; - $obj->invoice_date = $invoiceDate; + $self = clone $this; + $self['invoiceDate'] = $invoiceDate; - return $obj; + return $self; } /** @@ -721,10 +828,10 @@ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self */ public function withInvoiceID(?string $invoiceID): self { - $obj = clone $this; - $obj->invoice_id = $invoiceID; + $self = clone $this; + $self['invoiceID'] = $invoiceID; - return $obj; + return $self; } /** @@ -732,23 +839,35 @@ public function withInvoiceID(?string $invoiceID): self */ public function withInvoiceTotal(float|string|null $invoiceTotal): self { - $obj = clone $this; - $obj->invoice_total = $invoiceTotal; + $self = clone $this; + $self['invoiceTotal'] = $invoiceTotal; - return $obj; + return $self; } /** * At least one line item is required. * - * @param list $items + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }> $items */ public function withItems(array $items): self { - $obj = clone $this; - $obj->items = $items; + $self = clone $this; + $self['items'] = $items; - return $obj; + return $self; } /** @@ -756,21 +875,26 @@ public function withItems(array $items): self */ public function withNote(?string $note): self { - $obj = clone $this; - $obj->note = $note; + $self = clone $this; + $self['note'] = $note; - return $obj; + return $self; } /** - * @param list|null $paymentDetails + * @param list|null $paymentDetails */ public function withPaymentDetails(?array $paymentDetails): self { - $obj = clone $this; - $obj->payment_details = $paymentDetails; + $self = clone $this; + $self['paymentDetails'] = $paymentDetails; - return $obj; + return $self; } /** @@ -778,10 +902,10 @@ public function withPaymentDetails(?array $paymentDetails): self */ public function withPaymentTerm(?string $paymentTerm): self { - $obj = clone $this; - $obj->payment_term = $paymentTerm; + $self = clone $this; + $self['paymentTerm'] = $paymentTerm; - return $obj; + return $self; } /** @@ -790,10 +914,10 @@ public function withPaymentTerm(?string $paymentTerm): self public function withPreviousUnpaidBalance( float|string|null $previousUnpaidBalance ): self { - $obj = clone $this; - $obj->previous_unpaid_balance = $previousUnpaidBalance; + $self = clone $this; + $self['previousUnpaidBalance'] = $previousUnpaidBalance; - return $obj; + return $self; } /** @@ -801,10 +925,10 @@ public function withPreviousUnpaidBalance( */ public function withPurchaseOrder(?string $purchaseOrder): self { - $obj = clone $this; - $obj->purchase_order = $purchaseOrder; + $self = clone $this; + $self['purchaseOrder'] = $purchaseOrder; - return $obj; + return $self; } /** @@ -812,10 +936,10 @@ public function withPurchaseOrder(?string $purchaseOrder): self */ public function withRemittanceAddress(?string $remittanceAddress): self { - $obj = clone $this; - $obj->remittance_address = $remittanceAddress; + $self = clone $this; + $self['remittanceAddress'] = $remittanceAddress; - return $obj; + return $self; } /** @@ -824,10 +948,10 @@ public function withRemittanceAddress(?string $remittanceAddress): self public function withRemittanceAddressRecipient( ?string $remittanceAddressRecipient ): self { - $obj = clone $this; - $obj->remittance_address_recipient = $remittanceAddressRecipient; + $self = clone $this; + $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; - return $obj; + return $self; } /** @@ -835,10 +959,10 @@ public function withRemittanceAddressRecipient( */ public function withServiceAddress(?string $serviceAddress): self { - $obj = clone $this; - $obj->service_address = $serviceAddress; + $self = clone $this; + $self['serviceAddress'] = $serviceAddress; - return $obj; + return $self; } /** @@ -847,10 +971,10 @@ public function withServiceAddress(?string $serviceAddress): self public function withServiceAddressRecipient( ?string $serviceAddressRecipient ): self { - $obj = clone $this; - $obj->service_address_recipient = $serviceAddressRecipient; + $self = clone $this; + $self['serviceAddressRecipient'] = $serviceAddressRecipient; - return $obj; + return $self; } /** @@ -859,10 +983,10 @@ public function withServiceAddressRecipient( public function withServiceEndDate( ?\DateTimeInterface $serviceEndDate ): self { - $obj = clone $this; - $obj->service_end_date = $serviceEndDate; + $self = clone $this; + $self['serviceEndDate'] = $serviceEndDate; - return $obj; + return $self; } /** @@ -871,10 +995,10 @@ public function withServiceEndDate( public function withServiceStartDate( ?\DateTimeInterface $serviceStartDate ): self { - $obj = clone $this; - $obj->service_start_date = $serviceStartDate; + $self = clone $this; + $self['serviceStartDate'] = $serviceStartDate; - return $obj; + return $self; } /** @@ -882,10 +1006,10 @@ public function withServiceStartDate( */ public function withShippingAddress(?string $shippingAddress): self { - $obj = clone $this; - $obj->shipping_address = $shippingAddress; + $self = clone $this; + $self['shippingAddress'] = $shippingAddress; - return $obj; + return $self; } /** @@ -894,10 +1018,10 @@ public function withShippingAddress(?string $shippingAddress): self public function withShippingAddressRecipient( ?string $shippingAddressRecipient ): self { - $obj = clone $this; - $obj->shipping_address_recipient = $shippingAddressRecipient; + $self = clone $this; + $self['shippingAddressRecipient'] = $shippingAddressRecipient; - return $obj; + return $self; } /** @@ -907,10 +1031,10 @@ public function withShippingAddressRecipient( */ public function withState(DocumentState|string $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -918,34 +1042,37 @@ public function withState(DocumentState|string $state): self */ public function withSubtotal(float|string|null $subtotal): self { - $obj = clone $this; - $obj->subtotal = $subtotal; + $self = clone $this; + $self['subtotal'] = $subtotal; - return $obj; + return $self; } /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @param TaxCode|value-of $taxCode + * @param DocumentCreateParams\TaxCode|value-of $taxCode */ - public function withTaxCode(TaxCode|string $taxCode): self - { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + public function withTaxCode( + DocumentCreateParams\TaxCode|string $taxCode + ): self { + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** - * @param list|null $taxDetails + * @param list|null $taxDetails */ public function withTaxDetails(?array $taxDetails): self { - $obj = clone $this; - $obj->tax_details = $taxDetails; + $self = clone $this; + $self['taxDetails'] = $taxDetails; - return $obj; + return $self; } /** @@ -953,10 +1080,10 @@ public function withTaxDetails(?array $taxDetails): self */ public function withTotalDiscount(float|string|null $totalDiscount): self { - $obj = clone $this; - $obj->total_discount = $totalDiscount; + $self = clone $this; + $self['totalDiscount'] = $totalDiscount; - return $obj; + return $self; } /** @@ -964,10 +1091,10 @@ public function withTotalDiscount(float|string|null $totalDiscount): self */ public function withTotalTax(float|string|null $totalTax): self { - $obj = clone $this; - $obj->total_tax = $totalTax; + $self = clone $this; + $self['totalTax'] = $totalTax; - return $obj; + return $self; } /** @@ -980,10 +1107,10 @@ public function withTotalTax(float|string|null $totalTax): self */ public function withVatex(Vatex|string|null $vatex): self { - $obj = clone $this; - $obj['vatex'] = $vatex; + $self = clone $this; + $self['vatex'] = $vatex; - return $obj; + return $self; } /** @@ -991,10 +1118,10 @@ public function withVatex(Vatex|string|null $vatex): self */ public function withVatexNote(?string $vatexNote): self { - $obj = clone $this; - $obj->vatex_note = $vatexNote; + $self = clone $this; + $self['vatexNote'] = $vatexNote; - return $obj; + return $self; } /** @@ -1002,10 +1129,10 @@ public function withVatexNote(?string $vatexNote): self */ public function withVendorAddress(?string $vendorAddress): self { - $obj = clone $this; - $obj->vendor_address = $vendorAddress; + $self = clone $this; + $self['vendorAddress'] = $vendorAddress; - return $obj; + return $self; } /** @@ -1014,10 +1141,10 @@ public function withVendorAddress(?string $vendorAddress): self public function withVendorAddressRecipient( ?string $vendorAddressRecipient ): self { - $obj = clone $this; - $obj->vendor_address_recipient = $vendorAddressRecipient; + $self = clone $this; + $self['vendorAddressRecipient'] = $vendorAddressRecipient; - return $obj; + return $self; } /** @@ -1025,10 +1152,10 @@ public function withVendorAddressRecipient( */ public function withVendorCompanyID(?string $vendorCompanyID): self { - $obj = clone $this; - $obj->vendor_company_id = $vendorCompanyID; + $self = clone $this; + $self['vendorCompanyID'] = $vendorCompanyID; - return $obj; + return $self; } /** @@ -1036,10 +1163,10 @@ public function withVendorCompanyID(?string $vendorCompanyID): self */ public function withVendorEmail(?string $vendorEmail): self { - $obj = clone $this; - $obj->vendor_email = $vendorEmail; + $self = clone $this; + $self['vendorEmail'] = $vendorEmail; - return $obj; + return $self; } /** @@ -1047,10 +1174,10 @@ public function withVendorEmail(?string $vendorEmail): self */ public function withVendorName(?string $vendorName): self { - $obj = clone $this; - $obj->vendor_name = $vendorName; + $self = clone $this; + $self['vendorName'] = $vendorName; - return $obj; + return $self; } /** @@ -1058,9 +1185,9 @@ public function withVendorName(?string $vendorName): self */ public function withVendorTaxID(?string $vendorTaxID): self { - $obj = clone $this; - $obj->vendor_tax_id = $vendorTaxID; + $self = clone $this; + $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams/Allowance.php b/src/Documents/DocumentCreateParams/Allowance.php index 0ad57a94..44d9c779 100644 --- a/src/Documents/DocumentCreateParams/Allowance.php +++ b/src/Documents/DocumentCreateParams/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreateParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Documents\DocumentCreateParams\Allowance\TaxCode>|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentCreateParams\Allowance\TaxCode>|null, + * taxRate?: float|string|null, * } */ final class Allowance implements BaseModel @@ -31,51 +31,51 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -87,29 +87,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -117,10 +117,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -128,10 +128,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -140,10 +140,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -151,10 +151,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -164,10 +164,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -178,10 +178,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string $taxCode, ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -189,9 +189,9 @@ public function withTaxCode( */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams/Charge.php b/src/Documents/DocumentCreateParams/Charge.php index a187cead..6701c0eb 100644 --- a/src/Documents/DocumentCreateParams/Charge.php +++ b/src/Documents/DocumentCreateParams/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreateParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreateParams\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Documents\DocumentCreateParams\Charge\TaxCode>|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentCreateParams\Charge\TaxCode>|null, + * taxRate?: float|string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,20 +67,20 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, nullable: true, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -92,29 +92,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -122,10 +122,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -133,10 +133,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -145,10 +145,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -156,10 +156,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -169,10 +169,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -187,10 +187,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string|null $taxCode, ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -198,9 +198,9 @@ public function withTaxCode( */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams/Item.php b/src/Documents/DocumentCreateParams/Item.php index d1169244..e5394a63 100644 --- a/src/Documents/DocumentCreateParams/Item.php +++ b/src/Documents/DocumentCreateParams/Item.php @@ -4,10 +4,12 @@ namespace EInvoiceAPI\Documents\DocumentCreateParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreateParams\Item\Allowance; +use EInvoiceAPI\Documents\DocumentCreateParams\Item\Allowance\ReasonCode; +use EInvoiceAPI\Documents\DocumentCreateParams\Item\Allowance\TaxCode; use EInvoiceAPI\Documents\DocumentCreateParams\Item\Charge; use EInvoiceAPI\Documents\UnitOfMeasureCode; @@ -18,12 +20,12 @@ * charges?: list<\EInvoiceAPI\Documents\DocumentCreateParams\Item\Charge>|null, * date?: null|null, * description?: string|null, - * product_code?: string|null, + * productCode?: string|null, * quantity?: float|string|null, * tax?: float|string|null, - * tax_rate?: float|string|null, + * taxRate?: float|string|null, * unit?: value-of|null, - * unit_price?: float|string|null, + * unitPrice?: float|string|null, * } */ final class Item implements BaseModel @@ -36,17 +38,16 @@ final class Item implements BaseModel * * @var list|null $allowances */ - #[Api( + #[Optional( list: Allowance::class, nullable: true, - optional: true, )] public ?array $allowances; /** * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** @@ -54,60 +55,59 @@ final class Item implements BaseModel * * @var list|null $charges */ - #[Api( + #[Optional( list: Charge::class, nullable: true, - optional: true, )] public ?array $charges; /** @var null|null $date */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public null $date; /** * The description of the line item. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The product code of the line item. */ - #[Api(nullable: true, optional: true)] - public ?string $product_code; + #[Optional('product_code', nullable: true)] + public ?string $productCode; /** * The quantity of items (goods or services) that is the subject of the line item. Must be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $quantity; /** * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $tax; /** * The VAT rate of the line item expressed as percentage with 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. * * @var value-of|null $unit */ - #[Api(enum: UnitOfMeasureCode::class, nullable: true, optional: true)] + #[Optional(enum: UnitOfMeasureCode::class, nullable: true)] public ?string $unit; /** * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting item price discount. Must be rounded to maximum 4 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $unit_price; + #[Optional('unit_price', nullable: true)] + public float|string|null $unitPrice; public function __construct() { @@ -119,8 +119,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges * @param UnitOfMeasureCode|value-of|null $unit */ public static function with( @@ -129,42 +145,50 @@ public static function with( ?array $charges = null, null $date = null, ?string $description = null, - ?string $product_code = null, + ?string $productCode = null, float|string|null $quantity = null, float|string|null $tax = null, - float|string|null $tax_rate = null, + float|string|null $taxRate = null, UnitOfMeasureCode|string|null $unit = null, - float|string|null $unit_price = null, + float|string|null $unitPrice = null, ): self { - $obj = new self; - - $obj->date = $date; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount && $obj->amount = $amount; - null !== $charges && $obj->charges = $charges; - null !== $description && $obj->description = $description; - null !== $product_code && $obj->product_code = $product_code; - null !== $quantity && $obj->quantity = $quantity; - null !== $tax && $obj->tax = $tax; - null !== $tax_rate && $obj->tax_rate = $tax_rate; - null !== $unit && $obj['unit'] = $unit; - null !== $unit_price && $obj->unit_price = $unit_price; - - return $obj; + $self = new self; + + $self['date'] = $date; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amount && $self['amount'] = $amount; + null !== $charges && $self['charges'] = $charges; + null !== $description && $self['description'] = $description; + null !== $productCode && $self['productCode'] = $productCode; + null !== $quantity && $self['quantity'] = $quantity; + null !== $tax && $self['tax'] = $tax; + null !== $taxRate && $self['taxRate'] = $taxRate; + null !== $unit && $self['unit'] = $unit; + null !== $unitPrice && $self['unitPrice'] = $unitPrice; + + return $self; } /** * The allowances of the line item. * - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -172,23 +196,31 @@ public function withAllowances(?array $allowances): self */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** * The charges of the line item. * - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -196,10 +228,10 @@ public function withCharges(?array $charges): self */ public function withDate(null $date): self { - $obj = clone $this; - $obj->date = $date; + $self = clone $this; + $self['date'] = $date; - return $obj; + return $self; } /** @@ -207,10 +239,10 @@ public function withDate(null $date): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -218,10 +250,10 @@ public function withDescription(?string $description): self */ public function withProductCode(?string $productCode): self { - $obj = clone $this; - $obj->product_code = $productCode; + $self = clone $this; + $self['productCode'] = $productCode; - return $obj; + return $self; } /** @@ -229,10 +261,10 @@ public function withProductCode(?string $productCode): self */ public function withQuantity(float|string|null $quantity): self { - $obj = clone $this; - $obj->quantity = $quantity; + $self = clone $this; + $self['quantity'] = $quantity; - return $obj; + return $self; } /** @@ -240,10 +272,10 @@ public function withQuantity(float|string|null $quantity): self */ public function withTax(float|string|null $tax): self { - $obj = clone $this; - $obj->tax = $tax; + $self = clone $this; + $self['tax'] = $tax; - return $obj; + return $self; } /** @@ -251,10 +283,10 @@ public function withTax(float|string|null $tax): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -264,10 +296,10 @@ public function withTaxRate(float|string|null $taxRate): self */ public function withUnit(UnitOfMeasureCode|string|null $unit): self { - $obj = clone $this; - $obj['unit'] = $unit; + $self = clone $this; + $self['unit'] = $unit; - return $obj; + return $self; } /** @@ -275,9 +307,9 @@ public function withUnit(UnitOfMeasureCode|string|null $unit): self */ public function withUnitPrice(float|string|null $unitPrice): self { - $obj = clone $this; - $obj->unit_price = $unitPrice; + $self = clone $this; + $self['unitPrice'] = $unitPrice; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams/Item/Allowance.php b/src/Documents/DocumentCreateParams/Item/Allowance.php index d1c8d8c8..a966e652 100644 --- a/src/Documents/DocumentCreateParams/Item/Allowance.php +++ b/src/Documents/DocumentCreateParams/Item/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreateParams\Item; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreateParams\Item\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, * } */ final class Allowance implements BaseModel @@ -31,48 +31,48 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -84,29 +84,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -114,10 +114,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -125,10 +125,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -137,10 +137,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -148,10 +148,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -161,10 +161,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -174,10 +174,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -185,9 +185,9 @@ public function withTaxCode(TaxCode|string $taxCode): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams/Item/Charge.php b/src/Documents/DocumentCreateParams/Item/Charge.php index dd3c210f..27c1f305 100644 --- a/src/Documents/DocumentCreateParams/Item/Charge.php +++ b/src/Documents/DocumentCreateParams/Item/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreateParams\Item; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentCreateParams\Item\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,16 +67,16 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, nullable: true, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class, nullable: true)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -88,29 +88,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -118,10 +118,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -129,10 +129,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -141,10 +141,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -152,10 +152,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -165,10 +165,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -182,10 +182,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string|null $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -193,9 +193,9 @@ public function withTaxCode(TaxCode|string|null $taxCode): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentCreateParams/TaxDetail.php b/src/Documents/DocumentCreateParams/TaxDetail.php index eb3c41d4..c63ebb8e 100644 --- a/src/Documents/DocumentCreateParams/TaxDetail.php +++ b/src/Documents/DocumentCreateParams/TaxDetail.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentCreateParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class TaxDetail implements BaseModel /** * The tax amount for this tax category. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00'). */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $rate; public function __construct() @@ -44,12 +44,12 @@ public static function with( float|string|null $amount = null, ?string $rate = null ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $rate && $obj->rate = $rate; + null !== $amount && $self['amount'] = $amount; + null !== $rate && $self['rate'] = $rate; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withAmount(float|string|null $amount): self */ public function withRate(?string $rate): self { - $obj = clone $this; - $obj->rate = $rate; + $self = clone $this; + $self['rate'] = $rate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentDeleteResponse.php b/src/Documents/DocumentDeleteResponse.php index 61a64a4f..a1aef7e3 100644 --- a/src/Documents/DocumentDeleteResponse.php +++ b/src/Documents/DocumentDeleteResponse.php @@ -4,31 +4,27 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type DocumentDeleteResponseShape = array{is_deleted: bool} + * @phpstan-type DocumentDeleteResponseShape = array{isDeleted: bool} */ -final class DocumentDeleteResponse implements BaseModel, ResponseConverter +final class DocumentDeleteResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] - public bool $is_deleted; + #[Required('is_deleted')] + public bool $isDeleted; /** * `new DocumentDeleteResponse()` is missing required properties by the API. * * To enforce required parameters use * ``` - * DocumentDeleteResponse::with(is_deleted: ...) + * DocumentDeleteResponse::with(isDeleted: ...) * ``` * * Otherwise ensure the following setters are called @@ -47,20 +43,20 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(bool $is_deleted): self + public static function with(bool $isDeleted): self { - $obj = new self; + $self = new self; - $obj->is_deleted = $is_deleted; + $self['isDeleted'] = $isDeleted; - return $obj; + return $self; } public function withIsDeleted(bool $isDeleted): self { - $obj = clone $this; - $obj->is_deleted = $isDeleted; + $self = clone $this; + $self['isDeleted'] = $isDeleted; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentNewFromPdfResponse.php b/src/Documents/DocumentNewFromPdfResponse.php index 1f0668e6..1372a2c5 100644 --- a/src/Documents/DocumentNewFromPdfResponse.php +++ b/src/Documents/DocumentNewFromPdfResponse.php @@ -4,11 +4,10 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; +use EInvoiceAPI\Documents\Allowance\ReasonCode; use EInvoiceAPI\Documents\DocumentNewFromPdfResponse\Item; use EInvoiceAPI\Documents\DocumentNewFromPdfResponse\TaxCode; use EInvoiceAPI\Documents\DocumentNewFromPdfResponse\TaxDetail; @@ -18,91 +17,89 @@ /** * @phpstan-type DocumentNewFromPdfResponseShape = array{ * allowances?: list|null, - * amount_due?: string|null, + * amountDue?: string|null, * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, * charges?: list|null, * currency?: value-of|null, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, * direction?: value-of|null, - * document_type?: value-of|null, - * due_date?: \DateTimeInterface|null, - * invoice_date?: \DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: string|null, + * documentType?: value-of|null, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: string|null, * items?: list|null, * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: \DateTimeInterface|null, - * service_start_date?: \DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, * state?: value-of|null, * subtotal?: string|null, * success?: bool|null, - * tax_code?: value-of|null, - * tax_details?: list|null, - * total_discount?: string|null, - * total_tax?: string|null, - * ubl_document?: string|null, + * taxCode?: value-of|null, + * taxDetails?: list|null, + * totalDiscount?: string|null, + * totalTax?: string|null, + * ublDocument?: string|null, * vatex?: value-of|null, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, * } */ -final class DocumentNewFromPdfResponse implements BaseModel, ResponseConverter +final class DocumentNewFromPdfResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** @var list|null $allowances */ - #[Api(list: Allowance::class, nullable: true, optional: true)] + #[Optional(list: Allowance::class, nullable: true)] public ?array $allowances; /** * The amount due for payment. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $amount_due; + #[Optional('amount_due', nullable: true)] + public ?string $amountDue; /** @var list|null $attachments */ - #[Api(list: DocumentAttachmentCreate::class, nullable: true, optional: true)] + #[Optional(list: DocumentAttachmentCreate::class, nullable: true)] public ?array $attachments; /** * The billing address (if different from customer address). */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address; + #[Optional('billing_address', nullable: true)] + public ?string $billingAddress; /** * The recipient name at the billing address. */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address_recipient; + #[Optional('billing_address_recipient', nullable: true)] + public ?string $billingAddressRecipient; /** @var list|null $charges */ - #[Api(list: Charge::class, nullable: true, optional: true)] + #[Optional(list: Charge::class, nullable: true)] public ?array $charges; /** @@ -110,218 +107,222 @@ final class DocumentNewFromPdfResponse implements BaseModel, ResponseConverter * * @var value-of|null $currency */ - #[Api(enum: CurrencyCode::class, optional: true)] + #[Optional(enum: CurrencyCode::class)] public ?string $currency; /** * The address of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address; + #[Optional('customer_address', nullable: true)] + public ?string $customerAddress; /** * The recipient name at the customer address. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address_recipient; + #[Optional('customer_address_recipient', nullable: true)] + public ?string $customerAddressRecipient; /** * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_company_id; + #[Optional('customer_company_id', nullable: true)] + public ?string $customerCompanyID; /** * The email address of the customer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_email; + #[Optional('customer_email', nullable: true)] + public ?string $customerEmail; /** * The unique identifier for the customer in your system. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_id; + #[Optional('customer_id', nullable: true)] + public ?string $customerID; /** * The company name of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_name; + #[Optional('customer_name', nullable: true)] + public ?string $customerName; /** * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_tax_id; + #[Optional('customer_tax_id', nullable: true)] + public ?string $customerTaxID; /** * The direction of the document: INBOUND (purchases) or OUTBOUND (sales). * * @var value-of|null $direction */ - #[Api(enum: DocumentDirection::class, optional: true)] + #[Optional(enum: DocumentDirection::class)] public ?string $direction; /** * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE. * - * @var value-of|null $document_type + * @var value-of|null $documentType */ - #[Api(enum: DocumentType::class, optional: true)] - public ?string $document_type; + #[Optional('document_type', enum: DocumentType::class)] + public ?string $documentType; /** * The date when payment is due. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $due_date; + #[Optional('due_date', nullable: true)] + public ?\DateTimeInterface $dueDate; /** * The date when the invoice was issued. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $invoice_date; + #[Optional('invoice_date', nullable: true)] + public ?\DateTimeInterface $invoiceDate; /** * The unique invoice identifier/number. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_id; + #[Optional('invoice_id', nullable: true)] + public ?string $invoiceID; /** * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_total; + #[Optional('invoice_total', nullable: true)] + public ?string $invoiceTotal; /** * At least one line item is required. * * @var list|null $items */ - #[Api(list: Item::class, optional: true)] + #[Optional(list: Item::class)] public ?array $items; /** * Additional notes or comments for the invoice. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $note; - /** @var list|null $payment_details */ - #[Api(list: PaymentDetailCreate::class, nullable: true, optional: true)] - public ?array $payment_details; + /** @var list|null $paymentDetails */ + #[Optional( + 'payment_details', + list: PaymentDetailCreate::class, + nullable: true + )] + public ?array $paymentDetails; /** * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30'). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_term; + #[Optional('payment_term', nullable: true)] + public ?string $paymentTerm; /** * The purchase order reference number. */ - #[Api(nullable: true, optional: true)] - public ?string $purchase_order; + #[Optional('purchase_order', nullable: true)] + public ?string $purchaseOrder; /** * The address where payment should be sent or remitted to. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address; + #[Optional('remittance_address', nullable: true)] + public ?string $remittanceAddress; /** * The recipient name at the remittance address. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address_recipient; + #[Optional('remittance_address_recipient', nullable: true)] + public ?string $remittanceAddressRecipient; /** * The address where services were performed or goods were delivered. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address; + #[Optional('service_address', nullable: true)] + public ?string $serviceAddress; /** * The recipient name at the service address. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address_recipient; + #[Optional('service_address_recipient', nullable: true)] + public ?string $serviceAddressRecipient; /** * The end date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_end_date; + #[Optional('service_end_date', nullable: true)] + public ?\DateTimeInterface $serviceEndDate; /** * The start date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_start_date; + #[Optional('service_start_date', nullable: true)] + public ?\DateTimeInterface $serviceStartDate; /** * The shipping/delivery address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address; + #[Optional('shipping_address', nullable: true)] + public ?string $shippingAddress; /** * The recipient name at the shipping address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address_recipient; + #[Optional('shipping_address_recipient', nullable: true)] + public ?string $shippingAddressRecipient; /** * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED. * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, optional: true)] + #[Optional(enum: DocumentState::class)] public ?string $state; /** * The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $subtotal; /** * Whether the PDF was successfully converted into a compliant e-invoice. */ - #[Api(optional: true)] + #[Optional] public ?bool $success; /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; - /** @var list|null $tax_details */ - #[Api(list: TaxDetail::class, nullable: true, optional: true)] - public ?array $tax_details; + /** @var list|null $taxDetails */ + #[Optional('tax_details', list: TaxDetail::class, nullable: true)] + public ?array $taxDetails; /** * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $total_discount; + #[Optional('total_discount', nullable: true)] + public ?string $totalDiscount; /** * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $total_tax; + #[Optional('total_tax', nullable: true)] + public ?string $totalTax; /** * The UBL document as an XML string. */ - #[Api(nullable: true, optional: true)] - public ?string $ubl_document; + #[Optional('ubl_document', nullable: true)] + public ?string $ublDocument; /** * VATEX code list for VAT exemption reasons. @@ -331,50 +332,50 @@ final class DocumentNewFromPdfResponse implements BaseModel, ResponseConverter * * @var value-of|null $vatex */ - #[Api(enum: Vatex::class, nullable: true, optional: true)] + #[Optional(enum: Vatex::class, nullable: true)] public ?string $vatex; /** * Textual explanation for VAT exemption. */ - #[Api(nullable: true, optional: true)] - public ?string $vatex_note; + #[Optional('vatex_note', nullable: true)] + public ?string $vatexNote; /** * The address of the vendor/seller. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address; + #[Optional('vendor_address', nullable: true)] + public ?string $vendorAddress; /** * The recipient name at the vendor address. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address_recipient; + #[Optional('vendor_address_recipient', nullable: true)] + public ?string $vendorAddressRecipient; /** * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_company_id; + #[Optional('vendor_company_id', nullable: true)] + public ?string $vendorCompanyID; /** * The email address of the vendor. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_email; + #[Optional('vendor_email', nullable: true)] + public ?string $vendorEmail; /** * The name of the vendor/seller/supplier. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_name; + #[Optional('vendor_name', nullable: true)] + public ?string $vendorName; /** * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_tax_id; + #[Optional('vendor_tax_id', nullable: true)] + public ?string $vendorTaxID; public function __construct() { @@ -386,134 +387,182 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $attachments - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances + * @param list|null $attachments + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges * @param CurrencyCode|value-of $currency * @param DocumentDirection|value-of $direction - * @param DocumentType|value-of $document_type - * @param list $items - * @param list|null $payment_details + * @param DocumentType|value-of $documentType + * @param list|null, + * amount?: string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: string|null, + * tax?: string|null, + * taxRate?: string|null, + * unit?: value-of|null, + * unitPrice?: string|null, + * }> $items + * @param list|null $paymentDetails * @param DocumentState|value-of $state - * @param TaxCode|value-of $tax_code - * @param list|null $tax_details + * @param TaxCode|value-of $taxCode + * @param list|null $taxDetails * @param Vatex|value-of|null $vatex */ public static function with( ?array $allowances = null, - ?string $amount_due = null, + ?string $amountDue = null, ?array $attachments = null, - ?string $billing_address = null, - ?string $billing_address_recipient = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, ?array $charges = null, CurrencyCode|string|null $currency = null, - ?string $customer_address = null, - ?string $customer_address_recipient = null, - ?string $customer_company_id = null, - ?string $customer_email = null, - ?string $customer_id = null, - ?string $customer_name = null, - ?string $customer_tax_id = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, DocumentDirection|string|null $direction = null, - DocumentType|string|null $document_type = null, - ?\DateTimeInterface $due_date = null, - ?\DateTimeInterface $invoice_date = null, - ?string $invoice_id = null, - ?string $invoice_total = null, + DocumentType|string|null $documentType = null, + ?\DateTimeInterface $dueDate = null, + ?\DateTimeInterface $invoiceDate = null, + ?string $invoiceID = null, + ?string $invoiceTotal = null, ?array $items = null, ?string $note = null, - ?array $payment_details = null, - ?string $payment_term = null, - ?string $purchase_order = null, - ?string $remittance_address = null, - ?string $remittance_address_recipient = null, - ?string $service_address = null, - ?string $service_address_recipient = null, - ?\DateTimeInterface $service_end_date = null, - ?\DateTimeInterface $service_start_date = null, - ?string $shipping_address = null, - ?string $shipping_address_recipient = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + ?\DateTimeInterface $serviceEndDate = null, + ?\DateTimeInterface $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, DocumentState|string|null $state = null, ?string $subtotal = null, ?bool $success = null, - TaxCode|string|null $tax_code = null, - ?array $tax_details = null, - ?string $total_discount = null, - ?string $total_tax = null, - ?string $ubl_document = null, + TaxCode|string|null $taxCode = null, + ?array $taxDetails = null, + ?string $totalDiscount = null, + ?string $totalTax = null, + ?string $ublDocument = null, Vatex|string|null $vatex = null, - ?string $vatex_note = null, - ?string $vendor_address = null, - ?string $vendor_address_recipient = null, - ?string $vendor_company_id = null, - ?string $vendor_email = null, - ?string $vendor_name = null, - ?string $vendor_tax_id = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ): self { - $obj = new self; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount_due && $obj->amount_due = $amount_due; - null !== $attachments && $obj->attachments = $attachments; - null !== $billing_address && $obj->billing_address = $billing_address; - null !== $billing_address_recipient && $obj->billing_address_recipient = $billing_address_recipient; - null !== $charges && $obj->charges = $charges; - null !== $currency && $obj['currency'] = $currency; - null !== $customer_address && $obj->customer_address = $customer_address; - null !== $customer_address_recipient && $obj->customer_address_recipient = $customer_address_recipient; - null !== $customer_company_id && $obj->customer_company_id = $customer_company_id; - null !== $customer_email && $obj->customer_email = $customer_email; - null !== $customer_id && $obj->customer_id = $customer_id; - null !== $customer_name && $obj->customer_name = $customer_name; - null !== $customer_tax_id && $obj->customer_tax_id = $customer_tax_id; - null !== $direction && $obj['direction'] = $direction; - null !== $document_type && $obj['document_type'] = $document_type; - null !== $due_date && $obj->due_date = $due_date; - null !== $invoice_date && $obj->invoice_date = $invoice_date; - null !== $invoice_id && $obj->invoice_id = $invoice_id; - null !== $invoice_total && $obj->invoice_total = $invoice_total; - null !== $items && $obj->items = $items; - null !== $note && $obj->note = $note; - null !== $payment_details && $obj->payment_details = $payment_details; - null !== $payment_term && $obj->payment_term = $payment_term; - null !== $purchase_order && $obj->purchase_order = $purchase_order; - null !== $remittance_address && $obj->remittance_address = $remittance_address; - null !== $remittance_address_recipient && $obj->remittance_address_recipient = $remittance_address_recipient; - null !== $service_address && $obj->service_address = $service_address; - null !== $service_address_recipient && $obj->service_address_recipient = $service_address_recipient; - null !== $service_end_date && $obj->service_end_date = $service_end_date; - null !== $service_start_date && $obj->service_start_date = $service_start_date; - null !== $shipping_address && $obj->shipping_address = $shipping_address; - null !== $shipping_address_recipient && $obj->shipping_address_recipient = $shipping_address_recipient; - null !== $state && $obj['state'] = $state; - null !== $subtotal && $obj->subtotal = $subtotal; - null !== $success && $obj->success = $success; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_details && $obj->tax_details = $tax_details; - null !== $total_discount && $obj->total_discount = $total_discount; - null !== $total_tax && $obj->total_tax = $total_tax; - null !== $ubl_document && $obj->ubl_document = $ubl_document; - null !== $vatex && $obj['vatex'] = $vatex; - null !== $vatex_note && $obj->vatex_note = $vatex_note; - null !== $vendor_address && $obj->vendor_address = $vendor_address; - null !== $vendor_address_recipient && $obj->vendor_address_recipient = $vendor_address_recipient; - null !== $vendor_company_id && $obj->vendor_company_id = $vendor_company_id; - null !== $vendor_email && $obj->vendor_email = $vendor_email; - null !== $vendor_name && $obj->vendor_name = $vendor_name; - null !== $vendor_tax_id && $obj->vendor_tax_id = $vendor_tax_id; - - return $obj; + $self = new self; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amountDue && $self['amountDue'] = $amountDue; + null !== $attachments && $self['attachments'] = $attachments; + null !== $billingAddress && $self['billingAddress'] = $billingAddress; + null !== $billingAddressRecipient && $self['billingAddressRecipient'] = $billingAddressRecipient; + null !== $charges && $self['charges'] = $charges; + null !== $currency && $self['currency'] = $currency; + null !== $customerAddress && $self['customerAddress'] = $customerAddress; + null !== $customerAddressRecipient && $self['customerAddressRecipient'] = $customerAddressRecipient; + null !== $customerCompanyID && $self['customerCompanyID'] = $customerCompanyID; + null !== $customerEmail && $self['customerEmail'] = $customerEmail; + null !== $customerID && $self['customerID'] = $customerID; + null !== $customerName && $self['customerName'] = $customerName; + null !== $customerTaxID && $self['customerTaxID'] = $customerTaxID; + null !== $direction && $self['direction'] = $direction; + null !== $documentType && $self['documentType'] = $documentType; + null !== $dueDate && $self['dueDate'] = $dueDate; + null !== $invoiceDate && $self['invoiceDate'] = $invoiceDate; + null !== $invoiceID && $self['invoiceID'] = $invoiceID; + null !== $invoiceTotal && $self['invoiceTotal'] = $invoiceTotal; + null !== $items && $self['items'] = $items; + null !== $note && $self['note'] = $note; + null !== $paymentDetails && $self['paymentDetails'] = $paymentDetails; + null !== $paymentTerm && $self['paymentTerm'] = $paymentTerm; + null !== $purchaseOrder && $self['purchaseOrder'] = $purchaseOrder; + null !== $remittanceAddress && $self['remittanceAddress'] = $remittanceAddress; + null !== $remittanceAddressRecipient && $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; + null !== $serviceAddress && $self['serviceAddress'] = $serviceAddress; + null !== $serviceAddressRecipient && $self['serviceAddressRecipient'] = $serviceAddressRecipient; + null !== $serviceEndDate && $self['serviceEndDate'] = $serviceEndDate; + null !== $serviceStartDate && $self['serviceStartDate'] = $serviceStartDate; + null !== $shippingAddress && $self['shippingAddress'] = $shippingAddress; + null !== $shippingAddressRecipient && $self['shippingAddressRecipient'] = $shippingAddressRecipient; + null !== $state && $self['state'] = $state; + null !== $subtotal && $self['subtotal'] = $subtotal; + null !== $success && $self['success'] = $success; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxDetails && $self['taxDetails'] = $taxDetails; + null !== $totalDiscount && $self['totalDiscount'] = $totalDiscount; + null !== $totalTax && $self['totalTax'] = $totalTax; + null !== $ublDocument && $self['ublDocument'] = $ublDocument; + null !== $vatex && $self['vatex'] = $vatex; + null !== $vatexNote && $self['vatexNote'] = $vatexNote; + null !== $vendorAddress && $self['vendorAddress'] = $vendorAddress; + null !== $vendorAddressRecipient && $self['vendorAddressRecipient'] = $vendorAddressRecipient; + null !== $vendorCompanyID && $self['vendorCompanyID'] = $vendorCompanyID; + null !== $vendorEmail && $self['vendorEmail'] = $vendorEmail; + null !== $vendorName && $self['vendorName'] = $vendorName; + null !== $vendorTaxID && $self['vendorTaxID'] = $vendorTaxID; + + return $self; } /** - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -521,21 +570,26 @@ public function withAllowances(?array $allowances): self */ public function withAmountDue(?string $amountDue): self { - $obj = clone $this; - $obj->amount_due = $amountDue; + $self = clone $this; + $self['amountDue'] = $amountDue; - return $obj; + return $self; } /** - * @param list|null $attachments + * @param list|null $attachments */ public function withAttachments(?array $attachments): self { - $obj = clone $this; - $obj->attachments = $attachments; + $self = clone $this; + $self['attachments'] = $attachments; - return $obj; + return $self; } /** @@ -543,10 +597,10 @@ public function withAttachments(?array $attachments): self */ public function withBillingAddress(?string $billingAddress): self { - $obj = clone $this; - $obj->billing_address = $billingAddress; + $self = clone $this; + $self['billingAddress'] = $billingAddress; - return $obj; + return $self; } /** @@ -555,21 +609,29 @@ public function withBillingAddress(?string $billingAddress): self public function withBillingAddressRecipient( ?string $billingAddressRecipient ): self { - $obj = clone $this; - $obj->billing_address_recipient = $billingAddressRecipient; + $self = clone $this; + $self['billingAddressRecipient'] = $billingAddressRecipient; - return $obj; + return $self; } /** - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -579,10 +641,10 @@ public function withCharges(?array $charges): self */ public function withCurrency(CurrencyCode|string $currency): self { - $obj = clone $this; - $obj['currency'] = $currency; + $self = clone $this; + $self['currency'] = $currency; - return $obj; + return $self; } /** @@ -590,10 +652,10 @@ public function withCurrency(CurrencyCode|string $currency): self */ public function withCustomerAddress(?string $customerAddress): self { - $obj = clone $this; - $obj->customer_address = $customerAddress; + $self = clone $this; + $self['customerAddress'] = $customerAddress; - return $obj; + return $self; } /** @@ -602,10 +664,10 @@ public function withCustomerAddress(?string $customerAddress): self public function withCustomerAddressRecipient( ?string $customerAddressRecipient ): self { - $obj = clone $this; - $obj->customer_address_recipient = $customerAddressRecipient; + $self = clone $this; + $self['customerAddressRecipient'] = $customerAddressRecipient; - return $obj; + return $self; } /** @@ -613,10 +675,10 @@ public function withCustomerAddressRecipient( */ public function withCustomerCompanyID(?string $customerCompanyID): self { - $obj = clone $this; - $obj->customer_company_id = $customerCompanyID; + $self = clone $this; + $self['customerCompanyID'] = $customerCompanyID; - return $obj; + return $self; } /** @@ -624,10 +686,10 @@ public function withCustomerCompanyID(?string $customerCompanyID): self */ public function withCustomerEmail(?string $customerEmail): self { - $obj = clone $this; - $obj->customer_email = $customerEmail; + $self = clone $this; + $self['customerEmail'] = $customerEmail; - return $obj; + return $self; } /** @@ -635,10 +697,10 @@ public function withCustomerEmail(?string $customerEmail): self */ public function withCustomerID(?string $customerID): self { - $obj = clone $this; - $obj->customer_id = $customerID; + $self = clone $this; + $self['customerID'] = $customerID; - return $obj; + return $self; } /** @@ -646,10 +708,10 @@ public function withCustomerID(?string $customerID): self */ public function withCustomerName(?string $customerName): self { - $obj = clone $this; - $obj->customer_name = $customerName; + $self = clone $this; + $self['customerName'] = $customerName; - return $obj; + return $self; } /** @@ -657,10 +719,10 @@ public function withCustomerName(?string $customerName): self */ public function withCustomerTaxID(?string $customerTaxID): self { - $obj = clone $this; - $obj->customer_tax_id = $customerTaxID; + $self = clone $this; + $self['customerTaxID'] = $customerTaxID; - return $obj; + return $self; } /** @@ -670,10 +732,10 @@ public function withCustomerTaxID(?string $customerTaxID): self */ public function withDirection(DocumentDirection|string $direction): self { - $obj = clone $this; - $obj['direction'] = $direction; + $self = clone $this; + $self['direction'] = $direction; - return $obj; + return $self; } /** @@ -683,10 +745,10 @@ public function withDirection(DocumentDirection|string $direction): self */ public function withDocumentType(DocumentType|string $documentType): self { - $obj = clone $this; - $obj['document_type'] = $documentType; + $self = clone $this; + $self['documentType'] = $documentType; - return $obj; + return $self; } /** @@ -694,10 +756,10 @@ public function withDocumentType(DocumentType|string $documentType): self */ public function withDueDate(?\DateTimeInterface $dueDate): self { - $obj = clone $this; - $obj->due_date = $dueDate; + $self = clone $this; + $self['dueDate'] = $dueDate; - return $obj; + return $self; } /** @@ -705,10 +767,10 @@ public function withDueDate(?\DateTimeInterface $dueDate): self */ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self { - $obj = clone $this; - $obj->invoice_date = $invoiceDate; + $self = clone $this; + $self['invoiceDate'] = $invoiceDate; - return $obj; + return $self; } /** @@ -716,10 +778,10 @@ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self */ public function withInvoiceID(?string $invoiceID): self { - $obj = clone $this; - $obj->invoice_id = $invoiceID; + $self = clone $this; + $self['invoiceID'] = $invoiceID; - return $obj; + return $self; } /** @@ -727,23 +789,35 @@ public function withInvoiceID(?string $invoiceID): self */ public function withInvoiceTotal(?string $invoiceTotal): self { - $obj = clone $this; - $obj->invoice_total = $invoiceTotal; + $self = clone $this; + $self['invoiceTotal'] = $invoiceTotal; - return $obj; + return $self; } /** * At least one line item is required. * - * @param list $items + * @param list|null, + * amount?: string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: string|null, + * tax?: string|null, + * taxRate?: string|null, + * unit?: value-of|null, + * unitPrice?: string|null, + * }> $items */ public function withItems(array $items): self { - $obj = clone $this; - $obj->items = $items; + $self = clone $this; + $self['items'] = $items; - return $obj; + return $self; } /** @@ -751,21 +825,26 @@ public function withItems(array $items): self */ public function withNote(?string $note): self { - $obj = clone $this; - $obj->note = $note; + $self = clone $this; + $self['note'] = $note; - return $obj; + return $self; } /** - * @param list|null $paymentDetails + * @param list|null $paymentDetails */ public function withPaymentDetails(?array $paymentDetails): self { - $obj = clone $this; - $obj->payment_details = $paymentDetails; + $self = clone $this; + $self['paymentDetails'] = $paymentDetails; - return $obj; + return $self; } /** @@ -773,10 +852,10 @@ public function withPaymentDetails(?array $paymentDetails): self */ public function withPaymentTerm(?string $paymentTerm): self { - $obj = clone $this; - $obj->payment_term = $paymentTerm; + $self = clone $this; + $self['paymentTerm'] = $paymentTerm; - return $obj; + return $self; } /** @@ -784,10 +863,10 @@ public function withPaymentTerm(?string $paymentTerm): self */ public function withPurchaseOrder(?string $purchaseOrder): self { - $obj = clone $this; - $obj->purchase_order = $purchaseOrder; + $self = clone $this; + $self['purchaseOrder'] = $purchaseOrder; - return $obj; + return $self; } /** @@ -795,10 +874,10 @@ public function withPurchaseOrder(?string $purchaseOrder): self */ public function withRemittanceAddress(?string $remittanceAddress): self { - $obj = clone $this; - $obj->remittance_address = $remittanceAddress; + $self = clone $this; + $self['remittanceAddress'] = $remittanceAddress; - return $obj; + return $self; } /** @@ -807,10 +886,10 @@ public function withRemittanceAddress(?string $remittanceAddress): self public function withRemittanceAddressRecipient( ?string $remittanceAddressRecipient ): self { - $obj = clone $this; - $obj->remittance_address_recipient = $remittanceAddressRecipient; + $self = clone $this; + $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; - return $obj; + return $self; } /** @@ -818,10 +897,10 @@ public function withRemittanceAddressRecipient( */ public function withServiceAddress(?string $serviceAddress): self { - $obj = clone $this; - $obj->service_address = $serviceAddress; + $self = clone $this; + $self['serviceAddress'] = $serviceAddress; - return $obj; + return $self; } /** @@ -830,10 +909,10 @@ public function withServiceAddress(?string $serviceAddress): self public function withServiceAddressRecipient( ?string $serviceAddressRecipient ): self { - $obj = clone $this; - $obj->service_address_recipient = $serviceAddressRecipient; + $self = clone $this; + $self['serviceAddressRecipient'] = $serviceAddressRecipient; - return $obj; + return $self; } /** @@ -842,10 +921,10 @@ public function withServiceAddressRecipient( public function withServiceEndDate( ?\DateTimeInterface $serviceEndDate ): self { - $obj = clone $this; - $obj->service_end_date = $serviceEndDate; + $self = clone $this; + $self['serviceEndDate'] = $serviceEndDate; - return $obj; + return $self; } /** @@ -854,10 +933,10 @@ public function withServiceEndDate( public function withServiceStartDate( ?\DateTimeInterface $serviceStartDate ): self { - $obj = clone $this; - $obj->service_start_date = $serviceStartDate; + $self = clone $this; + $self['serviceStartDate'] = $serviceStartDate; - return $obj; + return $self; } /** @@ -865,10 +944,10 @@ public function withServiceStartDate( */ public function withShippingAddress(?string $shippingAddress): self { - $obj = clone $this; - $obj->shipping_address = $shippingAddress; + $self = clone $this; + $self['shippingAddress'] = $shippingAddress; - return $obj; + return $self; } /** @@ -877,10 +956,10 @@ public function withShippingAddress(?string $shippingAddress): self public function withShippingAddressRecipient( ?string $shippingAddressRecipient ): self { - $obj = clone $this; - $obj->shipping_address_recipient = $shippingAddressRecipient; + $self = clone $this; + $self['shippingAddressRecipient'] = $shippingAddressRecipient; - return $obj; + return $self; } /** @@ -890,10 +969,10 @@ public function withShippingAddressRecipient( */ public function withState(DocumentState|string $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -901,10 +980,10 @@ public function withState(DocumentState|string $state): self */ public function withSubtotal(?string $subtotal): self { - $obj = clone $this; - $obj->subtotal = $subtotal; + $self = clone $this; + $self['subtotal'] = $subtotal; - return $obj; + return $self; } /** @@ -912,10 +991,10 @@ public function withSubtotal(?string $subtotal): self */ public function withSuccess(bool $success): self { - $obj = clone $this; - $obj->success = $success; + $self = clone $this; + $self['success'] = $success; - return $obj; + return $self; } /** @@ -925,21 +1004,23 @@ public function withSuccess(bool $success): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** - * @param list|null $taxDetails + * @param list|null $taxDetails */ public function withTaxDetails(?array $taxDetails): self { - $obj = clone $this; - $obj->tax_details = $taxDetails; + $self = clone $this; + $self['taxDetails'] = $taxDetails; - return $obj; + return $self; } /** @@ -947,10 +1028,10 @@ public function withTaxDetails(?array $taxDetails): self */ public function withTotalDiscount(?string $totalDiscount): self { - $obj = clone $this; - $obj->total_discount = $totalDiscount; + $self = clone $this; + $self['totalDiscount'] = $totalDiscount; - return $obj; + return $self; } /** @@ -958,10 +1039,10 @@ public function withTotalDiscount(?string $totalDiscount): self */ public function withTotalTax(?string $totalTax): self { - $obj = clone $this; - $obj->total_tax = $totalTax; + $self = clone $this; + $self['totalTax'] = $totalTax; - return $obj; + return $self; } /** @@ -969,10 +1050,10 @@ public function withTotalTax(?string $totalTax): self */ public function withUblDocument(?string $ublDocument): self { - $obj = clone $this; - $obj->ubl_document = $ublDocument; + $self = clone $this; + $self['ublDocument'] = $ublDocument; - return $obj; + return $self; } /** @@ -985,10 +1066,10 @@ public function withUblDocument(?string $ublDocument): self */ public function withVatex(Vatex|string|null $vatex): self { - $obj = clone $this; - $obj['vatex'] = $vatex; + $self = clone $this; + $self['vatex'] = $vatex; - return $obj; + return $self; } /** @@ -996,10 +1077,10 @@ public function withVatex(Vatex|string|null $vatex): self */ public function withVatexNote(?string $vatexNote): self { - $obj = clone $this; - $obj->vatex_note = $vatexNote; + $self = clone $this; + $self['vatexNote'] = $vatexNote; - return $obj; + return $self; } /** @@ -1007,10 +1088,10 @@ public function withVatexNote(?string $vatexNote): self */ public function withVendorAddress(?string $vendorAddress): self { - $obj = clone $this; - $obj->vendor_address = $vendorAddress; + $self = clone $this; + $self['vendorAddress'] = $vendorAddress; - return $obj; + return $self; } /** @@ -1019,10 +1100,10 @@ public function withVendorAddress(?string $vendorAddress): self public function withVendorAddressRecipient( ?string $vendorAddressRecipient ): self { - $obj = clone $this; - $obj->vendor_address_recipient = $vendorAddressRecipient; + $self = clone $this; + $self['vendorAddressRecipient'] = $vendorAddressRecipient; - return $obj; + return $self; } /** @@ -1030,10 +1111,10 @@ public function withVendorAddressRecipient( */ public function withVendorCompanyID(?string $vendorCompanyID): self { - $obj = clone $this; - $obj->vendor_company_id = $vendorCompanyID; + $self = clone $this; + $self['vendorCompanyID'] = $vendorCompanyID; - return $obj; + return $self; } /** @@ -1041,10 +1122,10 @@ public function withVendorCompanyID(?string $vendorCompanyID): self */ public function withVendorEmail(?string $vendorEmail): self { - $obj = clone $this; - $obj->vendor_email = $vendorEmail; + $self = clone $this; + $self['vendorEmail'] = $vendorEmail; - return $obj; + return $self; } /** @@ -1052,10 +1133,10 @@ public function withVendorEmail(?string $vendorEmail): self */ public function withVendorName(?string $vendorName): self { - $obj = clone $this; - $obj->vendor_name = $vendorName; + $self = clone $this; + $self['vendorName'] = $vendorName; - return $obj; + return $self; } /** @@ -1063,9 +1144,9 @@ public function withVendorName(?string $vendorName): self */ public function withVendorTaxID(?string $vendorTaxID): self { - $obj = clone $this; - $obj->vendor_tax_id = $vendorTaxID; + $self = clone $this; + $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentNewFromPdfResponse/Item.php b/src/Documents/DocumentNewFromPdfResponse/Item.php index 2af8b135..092d3024 100644 --- a/src/Documents/DocumentNewFromPdfResponse/Item.php +++ b/src/Documents/DocumentNewFromPdfResponse/Item.php @@ -4,10 +4,12 @@ namespace EInvoiceAPI\Documents\DocumentNewFromPdfResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\Allowance; +use EInvoiceAPI\Documents\Allowance\ReasonCode; +use EInvoiceAPI\Documents\Allowance\TaxCode; use EInvoiceAPI\Documents\Charge; use EInvoiceAPI\Documents\UnitOfMeasureCode; @@ -18,12 +20,12 @@ * charges?: list|null, * date?: null|null, * description?: string|null, - * product_code?: string|null, + * productCode?: string|null, * quantity?: string|null, * tax?: string|null, - * tax_rate?: string|null, + * taxRate?: string|null, * unit?: value-of|null, - * unit_price?: string|null, + * unitPrice?: string|null, * } */ final class Item implements BaseModel @@ -36,13 +38,13 @@ final class Item implements BaseModel * * @var list|null $allowances */ - #[Api(list: Allowance::class, nullable: true, optional: true)] + #[Optional(list: Allowance::class, nullable: true)] public ?array $allowances; /** * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** @@ -50,56 +52,56 @@ final class Item implements BaseModel * * @var list|null $charges */ - #[Api(list: Charge::class, nullable: true, optional: true)] + #[Optional(list: Charge::class, nullable: true)] public ?array $charges; /** @var null|null $date */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public null $date; /** * The description of the line item. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The product code of the line item. */ - #[Api(nullable: true, optional: true)] - public ?string $product_code; + #[Optional('product_code', nullable: true)] + public ?string $productCode; /** * The quantity of items (goods or services) that is the subject of the line item. Must be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $quantity; /** * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $tax; /** * The VAT rate of the line item expressed as percentage with 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $tax_rate; + #[Optional('tax_rate', nullable: true)] + public ?string $taxRate; /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. * * @var value-of|null $unit */ - #[Api(enum: UnitOfMeasureCode::class, nullable: true, optional: true)] + #[Optional(enum: UnitOfMeasureCode::class, nullable: true)] public ?string $unit; /** * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting item price discount. Must be rounded to maximum 4 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $unit_price; + #[Optional('unit_price', nullable: true)] + public ?string $unitPrice; public function __construct() { @@ -111,8 +113,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges * @param UnitOfMeasureCode|value-of|null $unit */ public static function with( @@ -121,42 +139,50 @@ public static function with( ?array $charges = null, null $date = null, ?string $description = null, - ?string $product_code = null, + ?string $productCode = null, ?string $quantity = null, ?string $tax = null, - ?string $tax_rate = null, + ?string $taxRate = null, UnitOfMeasureCode|string|null $unit = null, - ?string $unit_price = null, + ?string $unitPrice = null, ): self { - $obj = new self; - - $obj->date = $date; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount && $obj->amount = $amount; - null !== $charges && $obj->charges = $charges; - null !== $description && $obj->description = $description; - null !== $product_code && $obj->product_code = $product_code; - null !== $quantity && $obj->quantity = $quantity; - null !== $tax && $obj->tax = $tax; - null !== $tax_rate && $obj->tax_rate = $tax_rate; - null !== $unit && $obj['unit'] = $unit; - null !== $unit_price && $obj->unit_price = $unit_price; - - return $obj; + $self = new self; + + $self['date'] = $date; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amount && $self['amount'] = $amount; + null !== $charges && $self['charges'] = $charges; + null !== $description && $self['description'] = $description; + null !== $productCode && $self['productCode'] = $productCode; + null !== $quantity && $self['quantity'] = $quantity; + null !== $tax && $self['tax'] = $tax; + null !== $taxRate && $self['taxRate'] = $taxRate; + null !== $unit && $self['unit'] = $unit; + null !== $unitPrice && $self['unitPrice'] = $unitPrice; + + return $self; } /** * The allowances of the line item. * - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -164,23 +190,31 @@ public function withAllowances(?array $allowances): self */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** * The charges of the line item. * - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -188,10 +222,10 @@ public function withCharges(?array $charges): self */ public function withDate(null $date): self { - $obj = clone $this; - $obj->date = $date; + $self = clone $this; + $self['date'] = $date; - return $obj; + return $self; } /** @@ -199,10 +233,10 @@ public function withDate(null $date): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -210,10 +244,10 @@ public function withDescription(?string $description): self */ public function withProductCode(?string $productCode): self { - $obj = clone $this; - $obj->product_code = $productCode; + $self = clone $this; + $self['productCode'] = $productCode; - return $obj; + return $self; } /** @@ -221,10 +255,10 @@ public function withProductCode(?string $productCode): self */ public function withQuantity(?string $quantity): self { - $obj = clone $this; - $obj->quantity = $quantity; + $self = clone $this; + $self['quantity'] = $quantity; - return $obj; + return $self; } /** @@ -232,10 +266,10 @@ public function withQuantity(?string $quantity): self */ public function withTax(?string $tax): self { - $obj = clone $this; - $obj->tax = $tax; + $self = clone $this; + $self['tax'] = $tax; - return $obj; + return $self; } /** @@ -243,10 +277,10 @@ public function withTax(?string $tax): self */ public function withTaxRate(?string $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -256,10 +290,10 @@ public function withTaxRate(?string $taxRate): self */ public function withUnit(UnitOfMeasureCode|string|null $unit): self { - $obj = clone $this; - $obj['unit'] = $unit; + $self = clone $this; + $self['unit'] = $unit; - return $obj; + return $self; } /** @@ -267,9 +301,9 @@ public function withUnit(UnitOfMeasureCode|string|null $unit): self */ public function withUnitPrice(?string $unitPrice): self { - $obj = clone $this; - $obj->unit_price = $unitPrice; + $self = clone $this; + $self['unitPrice'] = $unitPrice; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentNewFromPdfResponse/TaxDetail.php b/src/Documents/DocumentNewFromPdfResponse/TaxDetail.php index d5015b76..b4064dce 100644 --- a/src/Documents/DocumentNewFromPdfResponse/TaxDetail.php +++ b/src/Documents/DocumentNewFromPdfResponse/TaxDetail.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentNewFromPdfResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class TaxDetail implements BaseModel /** * The tax amount for this tax category. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00'). */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $rate; public function __construct() @@ -42,12 +42,12 @@ public static function with( ?string $amount = null, ?string $rate = null ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $rate && $obj->rate = $rate; + null !== $amount && $self['amount'] = $amount; + null !== $rate && $self['rate'] = $rate; - return $obj; + return $self; } /** @@ -55,10 +55,10 @@ public static function with( */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public function withAmount(?string $amount): self */ public function withRate(?string $rate): self { - $obj = clone $this; - $obj->rate = $rate; + $self = clone $this; + $self['rate'] = $rate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentResponse.php b/src/Documents/DocumentResponse.php index cb8c4d9f..efd1c9fe 100644 --- a/src/Documents/DocumentResponse.php +++ b/src/Documents/DocumentResponse.php @@ -4,14 +4,12 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; use EInvoiceAPI\Documents\Attachments\DocumentAttachment; -use EInvoiceAPI\Documents\DocumentResponse\Allowance; -use EInvoiceAPI\Documents\DocumentResponse\Charge; +use EInvoiceAPI\Documents\DocumentResponse\Allowance\ReasonCode; use EInvoiceAPI\Documents\DocumentResponse\Item; use EInvoiceAPI\Documents\DocumentResponse\PaymentDetail; use EInvoiceAPI\Documents\DocumentResponse\TaxCode; @@ -23,99 +21,95 @@ * @phpstan-type DocumentResponseShape = array{ * id: string, * allowances?: list<\EInvoiceAPI\Documents\DocumentResponse\Allowance>|null, - * amount_due?: string|null, + * amountDue?: string|null, * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, * charges?: list<\EInvoiceAPI\Documents\DocumentResponse\Charge>|null, * currency?: value-of|null, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, * direction?: value-of|null, - * document_type?: value-of|null, - * due_date?: \DateTimeInterface|null, - * invoice_date?: \DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: string|null, + * documentType?: value-of|null, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: string|null, * items?: list|null, * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: \DateTimeInterface|null, - * service_start_date?: \DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, * state?: value-of|null, * subtotal?: string|null, - * tax_code?: value-of|null, - * tax_details?: list|null, - * total_discount?: string|null, - * total_tax?: string|null, + * taxCode?: value-of|null, + * taxDetails?: list|null, + * totalDiscount?: string|null, + * totalTax?: string|null, * vatex?: value-of|null, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, * } */ -final class DocumentResponse implements BaseModel, ResponseConverter +final class DocumentResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] + #[Required] public string $id; - /** @var list|null $allowances */ - #[Api( - list: Allowance::class, + /** @var list|null $allowances */ + #[Optional( + list: DocumentResponse\Allowance::class, nullable: true, - optional: true, )] public ?array $allowances; /** * The amount due for payment. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $amount_due; + #[Optional('amount_due', nullable: true)] + public ?string $amountDue; /** @var list|null $attachments */ - #[Api(list: DocumentAttachment::class, nullable: true, optional: true)] + #[Optional(list: DocumentAttachment::class, nullable: true)] public ?array $attachments; /** * The billing address (if different from customer address). */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address; + #[Optional('billing_address', nullable: true)] + public ?string $billingAddress; /** * The recipient name at the billing address. */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address_recipient; + #[Optional('billing_address_recipient', nullable: true)] + public ?string $billingAddressRecipient; - /** @var list|null $charges */ - #[Api( - list: Charge::class, - nullable: true, - optional: true, + /** @var list|null $charges */ + #[Optional( + list: DocumentResponse\Charge::class, + nullable: true )] public ?array $charges; @@ -124,202 +118,202 @@ final class DocumentResponse implements BaseModel, ResponseConverter * * @var value-of|null $currency */ - #[Api(enum: CurrencyCode::class, optional: true)] + #[Optional(enum: CurrencyCode::class)] public ?string $currency; /** * The address of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address; + #[Optional('customer_address', nullable: true)] + public ?string $customerAddress; /** * The recipient name at the customer address. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address_recipient; + #[Optional('customer_address_recipient', nullable: true)] + public ?string $customerAddressRecipient; /** * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_company_id; + #[Optional('customer_company_id', nullable: true)] + public ?string $customerCompanyID; /** * The email address of the customer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_email; + #[Optional('customer_email', nullable: true)] + public ?string $customerEmail; /** * The unique identifier for the customer in your system. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_id; + #[Optional('customer_id', nullable: true)] + public ?string $customerID; /** * The company name of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_name; + #[Optional('customer_name', nullable: true)] + public ?string $customerName; /** * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_tax_id; + #[Optional('customer_tax_id', nullable: true)] + public ?string $customerTaxID; /** * The direction of the document: INBOUND (purchases) or OUTBOUND (sales). * * @var value-of|null $direction */ - #[Api(enum: DocumentDirection::class, optional: true)] + #[Optional(enum: DocumentDirection::class)] public ?string $direction; /** * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE. * - * @var value-of|null $document_type + * @var value-of|null $documentType */ - #[Api(enum: DocumentType::class, optional: true)] - public ?string $document_type; + #[Optional('document_type', enum: DocumentType::class)] + public ?string $documentType; /** * The date when payment is due. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $due_date; + #[Optional('due_date', nullable: true)] + public ?\DateTimeInterface $dueDate; /** * The date when the invoice was issued. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $invoice_date; + #[Optional('invoice_date', nullable: true)] + public ?\DateTimeInterface $invoiceDate; /** * The unique invoice identifier/number. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_id; + #[Optional('invoice_id', nullable: true)] + public ?string $invoiceID; /** * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_total; + #[Optional('invoice_total', nullable: true)] + public ?string $invoiceTotal; /** @var list|null $items */ - #[Api(list: Item::class, nullable: true, optional: true)] + #[Optional(list: Item::class, nullable: true)] public ?array $items; /** * Additional notes or comments for the invoice. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $note; - /** @var list|null $payment_details */ - #[Api(list: PaymentDetail::class, nullable: true, optional: true)] - public ?array $payment_details; + /** @var list|null $paymentDetails */ + #[Optional('payment_details', list: PaymentDetail::class, nullable: true)] + public ?array $paymentDetails; /** * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30'). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_term; + #[Optional('payment_term', nullable: true)] + public ?string $paymentTerm; /** * The purchase order reference number. */ - #[Api(nullable: true, optional: true)] - public ?string $purchase_order; + #[Optional('purchase_order', nullable: true)] + public ?string $purchaseOrder; /** * The address where payment should be sent or remitted to. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address; + #[Optional('remittance_address', nullable: true)] + public ?string $remittanceAddress; /** * The recipient name at the remittance address. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address_recipient; + #[Optional('remittance_address_recipient', nullable: true)] + public ?string $remittanceAddressRecipient; /** * The address where services were performed or goods were delivered. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address; + #[Optional('service_address', nullable: true)] + public ?string $serviceAddress; /** * The recipient name at the service address. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address_recipient; + #[Optional('service_address_recipient', nullable: true)] + public ?string $serviceAddressRecipient; /** * The end date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_end_date; + #[Optional('service_end_date', nullable: true)] + public ?\DateTimeInterface $serviceEndDate; /** * The start date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_start_date; + #[Optional('service_start_date', nullable: true)] + public ?\DateTimeInterface $serviceStartDate; /** * The shipping/delivery address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address; + #[Optional('shipping_address', nullable: true)] + public ?string $shippingAddress; /** * The recipient name at the shipping address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address_recipient; + #[Optional('shipping_address_recipient', nullable: true)] + public ?string $shippingAddressRecipient; /** * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED. * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, optional: true)] + #[Optional(enum: DocumentState::class)] public ?string $state; /** * The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $subtotal; /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; - /** @var list|null $tax_details */ - #[Api(list: TaxDetail::class, nullable: true, optional: true)] - public ?array $tax_details; + /** @var list|null $taxDetails */ + #[Optional('tax_details', list: TaxDetail::class, nullable: true)] + public ?array $taxDetails; /** * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $total_discount; + #[Optional('total_discount', nullable: true)] + public ?string $totalDiscount; /** * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $total_tax; + #[Optional('total_tax', nullable: true)] + public ?string $totalTax; /** * VATEX code list for VAT exemption reasons. @@ -329,50 +323,50 @@ final class DocumentResponse implements BaseModel, ResponseConverter * * @var value-of|null $vatex */ - #[Api(enum: Vatex::class, nullable: true, optional: true)] + #[Optional(enum: Vatex::class, nullable: true)] public ?string $vatex; /** * Textual explanation for VAT exemption. */ - #[Api(nullable: true, optional: true)] - public ?string $vatex_note; + #[Optional('vatex_note', nullable: true)] + public ?string $vatexNote; /** * The address of the vendor/seller. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address; + #[Optional('vendor_address', nullable: true)] + public ?string $vendorAddress; /** * The recipient name at the vendor address. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address_recipient; + #[Optional('vendor_address_recipient', nullable: true)] + public ?string $vendorAddressRecipient; /** * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_company_id; + #[Optional('vendor_company_id', nullable: true)] + public ?string $vendorCompanyID; /** * The email address of the vendor. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_email; + #[Optional('vendor_email', nullable: true)] + public ?string $vendorEmail; /** * The name of the vendor/seller/supplier. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_name; + #[Optional('vendor_name', nullable: true)] + public ?string $vendorName; /** * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_tax_id; + #[Optional('vendor_tax_id', nullable: true)] + public ?string $vendorTaxID; /** * `new DocumentResponse()` is missing required properties by the API. @@ -398,141 +392,190 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $attachments - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances + * @param list|null $attachments + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges * @param CurrencyCode|value-of $currency * @param DocumentDirection|value-of $direction - * @param DocumentType|value-of $document_type - * @param list|null $items - * @param list|null $payment_details + * @param DocumentType|value-of $documentType + * @param list|null, + * amount?: string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: string|null, + * tax?: string|null, + * taxRate?: string|null, + * unit?: value-of|null, + * unitPrice?: string|null, + * }>|null $items + * @param list|null $paymentDetails * @param DocumentState|value-of $state - * @param TaxCode|value-of $tax_code - * @param list|null $tax_details + * @param TaxCode|value-of $taxCode + * @param list|null $taxDetails * @param Vatex|value-of|null $vatex */ public static function with( string $id, ?array $allowances = null, - ?string $amount_due = null, + ?string $amountDue = null, ?array $attachments = null, - ?string $billing_address = null, - ?string $billing_address_recipient = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, ?array $charges = null, CurrencyCode|string|null $currency = null, - ?string $customer_address = null, - ?string $customer_address_recipient = null, - ?string $customer_company_id = null, - ?string $customer_email = null, - ?string $customer_id = null, - ?string $customer_name = null, - ?string $customer_tax_id = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, DocumentDirection|string|null $direction = null, - DocumentType|string|null $document_type = null, - ?\DateTimeInterface $due_date = null, - ?\DateTimeInterface $invoice_date = null, - ?string $invoice_id = null, - ?string $invoice_total = null, + DocumentType|string|null $documentType = null, + ?\DateTimeInterface $dueDate = null, + ?\DateTimeInterface $invoiceDate = null, + ?string $invoiceID = null, + ?string $invoiceTotal = null, ?array $items = null, ?string $note = null, - ?array $payment_details = null, - ?string $payment_term = null, - ?string $purchase_order = null, - ?string $remittance_address = null, - ?string $remittance_address_recipient = null, - ?string $service_address = null, - ?string $service_address_recipient = null, - ?\DateTimeInterface $service_end_date = null, - ?\DateTimeInterface $service_start_date = null, - ?string $shipping_address = null, - ?string $shipping_address_recipient = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + ?\DateTimeInterface $serviceEndDate = null, + ?\DateTimeInterface $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, DocumentState|string|null $state = null, ?string $subtotal = null, - TaxCode|string|null $tax_code = null, - ?array $tax_details = null, - ?string $total_discount = null, - ?string $total_tax = null, + TaxCode|string|null $taxCode = null, + ?array $taxDetails = null, + ?string $totalDiscount = null, + ?string $totalTax = null, Vatex|string|null $vatex = null, - ?string $vatex_note = null, - ?string $vendor_address = null, - ?string $vendor_address_recipient = null, - ?string $vendor_company_id = null, - ?string $vendor_email = null, - ?string $vendor_name = null, - ?string $vendor_tax_id = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ): self { - $obj = new self; - - $obj->id = $id; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount_due && $obj->amount_due = $amount_due; - null !== $attachments && $obj->attachments = $attachments; - null !== $billing_address && $obj->billing_address = $billing_address; - null !== $billing_address_recipient && $obj->billing_address_recipient = $billing_address_recipient; - null !== $charges && $obj->charges = $charges; - null !== $currency && $obj['currency'] = $currency; - null !== $customer_address && $obj->customer_address = $customer_address; - null !== $customer_address_recipient && $obj->customer_address_recipient = $customer_address_recipient; - null !== $customer_company_id && $obj->customer_company_id = $customer_company_id; - null !== $customer_email && $obj->customer_email = $customer_email; - null !== $customer_id && $obj->customer_id = $customer_id; - null !== $customer_name && $obj->customer_name = $customer_name; - null !== $customer_tax_id && $obj->customer_tax_id = $customer_tax_id; - null !== $direction && $obj['direction'] = $direction; - null !== $document_type && $obj['document_type'] = $document_type; - null !== $due_date && $obj->due_date = $due_date; - null !== $invoice_date && $obj->invoice_date = $invoice_date; - null !== $invoice_id && $obj->invoice_id = $invoice_id; - null !== $invoice_total && $obj->invoice_total = $invoice_total; - null !== $items && $obj->items = $items; - null !== $note && $obj->note = $note; - null !== $payment_details && $obj->payment_details = $payment_details; - null !== $payment_term && $obj->payment_term = $payment_term; - null !== $purchase_order && $obj->purchase_order = $purchase_order; - null !== $remittance_address && $obj->remittance_address = $remittance_address; - null !== $remittance_address_recipient && $obj->remittance_address_recipient = $remittance_address_recipient; - null !== $service_address && $obj->service_address = $service_address; - null !== $service_address_recipient && $obj->service_address_recipient = $service_address_recipient; - null !== $service_end_date && $obj->service_end_date = $service_end_date; - null !== $service_start_date && $obj->service_start_date = $service_start_date; - null !== $shipping_address && $obj->shipping_address = $shipping_address; - null !== $shipping_address_recipient && $obj->shipping_address_recipient = $shipping_address_recipient; - null !== $state && $obj['state'] = $state; - null !== $subtotal && $obj->subtotal = $subtotal; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_details && $obj->tax_details = $tax_details; - null !== $total_discount && $obj->total_discount = $total_discount; - null !== $total_tax && $obj->total_tax = $total_tax; - null !== $vatex && $obj['vatex'] = $vatex; - null !== $vatex_note && $obj->vatex_note = $vatex_note; - null !== $vendor_address && $obj->vendor_address = $vendor_address; - null !== $vendor_address_recipient && $obj->vendor_address_recipient = $vendor_address_recipient; - null !== $vendor_company_id && $obj->vendor_company_id = $vendor_company_id; - null !== $vendor_email && $obj->vendor_email = $vendor_email; - null !== $vendor_name && $obj->vendor_name = $vendor_name; - null !== $vendor_tax_id && $obj->vendor_tax_id = $vendor_tax_id; - - return $obj; + $self = new self; + + $self['id'] = $id; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amountDue && $self['amountDue'] = $amountDue; + null !== $attachments && $self['attachments'] = $attachments; + null !== $billingAddress && $self['billingAddress'] = $billingAddress; + null !== $billingAddressRecipient && $self['billingAddressRecipient'] = $billingAddressRecipient; + null !== $charges && $self['charges'] = $charges; + null !== $currency && $self['currency'] = $currency; + null !== $customerAddress && $self['customerAddress'] = $customerAddress; + null !== $customerAddressRecipient && $self['customerAddressRecipient'] = $customerAddressRecipient; + null !== $customerCompanyID && $self['customerCompanyID'] = $customerCompanyID; + null !== $customerEmail && $self['customerEmail'] = $customerEmail; + null !== $customerID && $self['customerID'] = $customerID; + null !== $customerName && $self['customerName'] = $customerName; + null !== $customerTaxID && $self['customerTaxID'] = $customerTaxID; + null !== $direction && $self['direction'] = $direction; + null !== $documentType && $self['documentType'] = $documentType; + null !== $dueDate && $self['dueDate'] = $dueDate; + null !== $invoiceDate && $self['invoiceDate'] = $invoiceDate; + null !== $invoiceID && $self['invoiceID'] = $invoiceID; + null !== $invoiceTotal && $self['invoiceTotal'] = $invoiceTotal; + null !== $items && $self['items'] = $items; + null !== $note && $self['note'] = $note; + null !== $paymentDetails && $self['paymentDetails'] = $paymentDetails; + null !== $paymentTerm && $self['paymentTerm'] = $paymentTerm; + null !== $purchaseOrder && $self['purchaseOrder'] = $purchaseOrder; + null !== $remittanceAddress && $self['remittanceAddress'] = $remittanceAddress; + null !== $remittanceAddressRecipient && $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; + null !== $serviceAddress && $self['serviceAddress'] = $serviceAddress; + null !== $serviceAddressRecipient && $self['serviceAddressRecipient'] = $serviceAddressRecipient; + null !== $serviceEndDate && $self['serviceEndDate'] = $serviceEndDate; + null !== $serviceStartDate && $self['serviceStartDate'] = $serviceStartDate; + null !== $shippingAddress && $self['shippingAddress'] = $shippingAddress; + null !== $shippingAddressRecipient && $self['shippingAddressRecipient'] = $shippingAddressRecipient; + null !== $state && $self['state'] = $state; + null !== $subtotal && $self['subtotal'] = $subtotal; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxDetails && $self['taxDetails'] = $taxDetails; + null !== $totalDiscount && $self['totalDiscount'] = $totalDiscount; + null !== $totalTax && $self['totalTax'] = $totalTax; + null !== $vatex && $self['vatex'] = $vatex; + null !== $vatexNote && $self['vatexNote'] = $vatexNote; + null !== $vendorAddress && $self['vendorAddress'] = $vendorAddress; + null !== $vendorAddressRecipient && $self['vendorAddressRecipient'] = $vendorAddressRecipient; + null !== $vendorCompanyID && $self['vendorCompanyID'] = $vendorCompanyID; + null !== $vendorEmail && $self['vendorEmail'] = $vendorEmail; + null !== $vendorName && $self['vendorName'] = $vendorName; + null !== $vendorTaxID && $self['vendorTaxID'] = $vendorTaxID; + + return $self; } public function withID(string $id): self { - $obj = clone $this; - $obj->id = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -540,21 +583,27 @@ public function withAllowances(?array $allowances): self */ public function withAmountDue(?string $amountDue): self { - $obj = clone $this; - $obj->amount_due = $amountDue; + $self = clone $this; + $self['amountDue'] = $amountDue; - return $obj; + return $self; } /** - * @param list|null $attachments + * @param list|null $attachments */ public function withAttachments(?array $attachments): self { - $obj = clone $this; - $obj->attachments = $attachments; + $self = clone $this; + $self['attachments'] = $attachments; - return $obj; + return $self; } /** @@ -562,10 +611,10 @@ public function withAttachments(?array $attachments): self */ public function withBillingAddress(?string $billingAddress): self { - $obj = clone $this; - $obj->billing_address = $billingAddress; + $self = clone $this; + $self['billingAddress'] = $billingAddress; - return $obj; + return $self; } /** @@ -574,21 +623,29 @@ public function withBillingAddress(?string $billingAddress): self public function withBillingAddressRecipient( ?string $billingAddressRecipient ): self { - $obj = clone $this; - $obj->billing_address_recipient = $billingAddressRecipient; + $self = clone $this; + $self['billingAddressRecipient'] = $billingAddressRecipient; - return $obj; + return $self; } /** - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -598,10 +655,10 @@ public function withCharges(?array $charges): self */ public function withCurrency(CurrencyCode|string $currency): self { - $obj = clone $this; - $obj['currency'] = $currency; + $self = clone $this; + $self['currency'] = $currency; - return $obj; + return $self; } /** @@ -609,10 +666,10 @@ public function withCurrency(CurrencyCode|string $currency): self */ public function withCustomerAddress(?string $customerAddress): self { - $obj = clone $this; - $obj->customer_address = $customerAddress; + $self = clone $this; + $self['customerAddress'] = $customerAddress; - return $obj; + return $self; } /** @@ -621,10 +678,10 @@ public function withCustomerAddress(?string $customerAddress): self public function withCustomerAddressRecipient( ?string $customerAddressRecipient ): self { - $obj = clone $this; - $obj->customer_address_recipient = $customerAddressRecipient; + $self = clone $this; + $self['customerAddressRecipient'] = $customerAddressRecipient; - return $obj; + return $self; } /** @@ -632,10 +689,10 @@ public function withCustomerAddressRecipient( */ public function withCustomerCompanyID(?string $customerCompanyID): self { - $obj = clone $this; - $obj->customer_company_id = $customerCompanyID; + $self = clone $this; + $self['customerCompanyID'] = $customerCompanyID; - return $obj; + return $self; } /** @@ -643,10 +700,10 @@ public function withCustomerCompanyID(?string $customerCompanyID): self */ public function withCustomerEmail(?string $customerEmail): self { - $obj = clone $this; - $obj->customer_email = $customerEmail; + $self = clone $this; + $self['customerEmail'] = $customerEmail; - return $obj; + return $self; } /** @@ -654,10 +711,10 @@ public function withCustomerEmail(?string $customerEmail): self */ public function withCustomerID(?string $customerID): self { - $obj = clone $this; - $obj->customer_id = $customerID; + $self = clone $this; + $self['customerID'] = $customerID; - return $obj; + return $self; } /** @@ -665,10 +722,10 @@ public function withCustomerID(?string $customerID): self */ public function withCustomerName(?string $customerName): self { - $obj = clone $this; - $obj->customer_name = $customerName; + $self = clone $this; + $self['customerName'] = $customerName; - return $obj; + return $self; } /** @@ -676,10 +733,10 @@ public function withCustomerName(?string $customerName): self */ public function withCustomerTaxID(?string $customerTaxID): self { - $obj = clone $this; - $obj->customer_tax_id = $customerTaxID; + $self = clone $this; + $self['customerTaxID'] = $customerTaxID; - return $obj; + return $self; } /** @@ -689,10 +746,10 @@ public function withCustomerTaxID(?string $customerTaxID): self */ public function withDirection(DocumentDirection|string $direction): self { - $obj = clone $this; - $obj['direction'] = $direction; + $self = clone $this; + $self['direction'] = $direction; - return $obj; + return $self; } /** @@ -702,10 +759,10 @@ public function withDirection(DocumentDirection|string $direction): self */ public function withDocumentType(DocumentType|string $documentType): self { - $obj = clone $this; - $obj['document_type'] = $documentType; + $self = clone $this; + $self['documentType'] = $documentType; - return $obj; + return $self; } /** @@ -713,10 +770,10 @@ public function withDocumentType(DocumentType|string $documentType): self */ public function withDueDate(?\DateTimeInterface $dueDate): self { - $obj = clone $this; - $obj->due_date = $dueDate; + $self = clone $this; + $self['dueDate'] = $dueDate; - return $obj; + return $self; } /** @@ -724,10 +781,10 @@ public function withDueDate(?\DateTimeInterface $dueDate): self */ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self { - $obj = clone $this; - $obj->invoice_date = $invoiceDate; + $self = clone $this; + $self['invoiceDate'] = $invoiceDate; - return $obj; + return $self; } /** @@ -735,10 +792,10 @@ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self */ public function withInvoiceID(?string $invoiceID): self { - $obj = clone $this; - $obj->invoice_id = $invoiceID; + $self = clone $this; + $self['invoiceID'] = $invoiceID; - return $obj; + return $self; } /** @@ -746,21 +803,33 @@ public function withInvoiceID(?string $invoiceID): self */ public function withInvoiceTotal(?string $invoiceTotal): self { - $obj = clone $this; - $obj->invoice_total = $invoiceTotal; + $self = clone $this; + $self['invoiceTotal'] = $invoiceTotal; - return $obj; + return $self; } /** - * @param list|null $items + * @param list|null, + * amount?: string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: string|null, + * tax?: string|null, + * taxRate?: string|null, + * unit?: value-of|null, + * unitPrice?: string|null, + * }>|null $items */ public function withItems(?array $items): self { - $obj = clone $this; - $obj->items = $items; + $self = clone $this; + $self['items'] = $items; - return $obj; + return $self; } /** @@ -768,21 +837,26 @@ public function withItems(?array $items): self */ public function withNote(?string $note): self { - $obj = clone $this; - $obj->note = $note; + $self = clone $this; + $self['note'] = $note; - return $obj; + return $self; } /** - * @param list|null $paymentDetails + * @param list|null $paymentDetails */ public function withPaymentDetails(?array $paymentDetails): self { - $obj = clone $this; - $obj->payment_details = $paymentDetails; + $self = clone $this; + $self['paymentDetails'] = $paymentDetails; - return $obj; + return $self; } /** @@ -790,10 +864,10 @@ public function withPaymentDetails(?array $paymentDetails): self */ public function withPaymentTerm(?string $paymentTerm): self { - $obj = clone $this; - $obj->payment_term = $paymentTerm; + $self = clone $this; + $self['paymentTerm'] = $paymentTerm; - return $obj; + return $self; } /** @@ -801,10 +875,10 @@ public function withPaymentTerm(?string $paymentTerm): self */ public function withPurchaseOrder(?string $purchaseOrder): self { - $obj = clone $this; - $obj->purchase_order = $purchaseOrder; + $self = clone $this; + $self['purchaseOrder'] = $purchaseOrder; - return $obj; + return $self; } /** @@ -812,10 +886,10 @@ public function withPurchaseOrder(?string $purchaseOrder): self */ public function withRemittanceAddress(?string $remittanceAddress): self { - $obj = clone $this; - $obj->remittance_address = $remittanceAddress; + $self = clone $this; + $self['remittanceAddress'] = $remittanceAddress; - return $obj; + return $self; } /** @@ -824,10 +898,10 @@ public function withRemittanceAddress(?string $remittanceAddress): self public function withRemittanceAddressRecipient( ?string $remittanceAddressRecipient ): self { - $obj = clone $this; - $obj->remittance_address_recipient = $remittanceAddressRecipient; + $self = clone $this; + $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; - return $obj; + return $self; } /** @@ -835,10 +909,10 @@ public function withRemittanceAddressRecipient( */ public function withServiceAddress(?string $serviceAddress): self { - $obj = clone $this; - $obj->service_address = $serviceAddress; + $self = clone $this; + $self['serviceAddress'] = $serviceAddress; - return $obj; + return $self; } /** @@ -847,10 +921,10 @@ public function withServiceAddress(?string $serviceAddress): self public function withServiceAddressRecipient( ?string $serviceAddressRecipient ): self { - $obj = clone $this; - $obj->service_address_recipient = $serviceAddressRecipient; + $self = clone $this; + $self['serviceAddressRecipient'] = $serviceAddressRecipient; - return $obj; + return $self; } /** @@ -859,10 +933,10 @@ public function withServiceAddressRecipient( public function withServiceEndDate( ?\DateTimeInterface $serviceEndDate ): self { - $obj = clone $this; - $obj->service_end_date = $serviceEndDate; + $self = clone $this; + $self['serviceEndDate'] = $serviceEndDate; - return $obj; + return $self; } /** @@ -871,10 +945,10 @@ public function withServiceEndDate( public function withServiceStartDate( ?\DateTimeInterface $serviceStartDate ): self { - $obj = clone $this; - $obj->service_start_date = $serviceStartDate; + $self = clone $this; + $self['serviceStartDate'] = $serviceStartDate; - return $obj; + return $self; } /** @@ -882,10 +956,10 @@ public function withServiceStartDate( */ public function withShippingAddress(?string $shippingAddress): self { - $obj = clone $this; - $obj->shipping_address = $shippingAddress; + $self = clone $this; + $self['shippingAddress'] = $shippingAddress; - return $obj; + return $self; } /** @@ -894,10 +968,10 @@ public function withShippingAddress(?string $shippingAddress): self public function withShippingAddressRecipient( ?string $shippingAddressRecipient ): self { - $obj = clone $this; - $obj->shipping_address_recipient = $shippingAddressRecipient; + $self = clone $this; + $self['shippingAddressRecipient'] = $shippingAddressRecipient; - return $obj; + return $self; } /** @@ -907,10 +981,10 @@ public function withShippingAddressRecipient( */ public function withState(DocumentState|string $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -918,10 +992,10 @@ public function withState(DocumentState|string $state): self */ public function withSubtotal(?string $subtotal): self { - $obj = clone $this; - $obj->subtotal = $subtotal; + $self = clone $this; + $self['subtotal'] = $subtotal; - return $obj; + return $self; } /** @@ -931,21 +1005,23 @@ public function withSubtotal(?string $subtotal): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** - * @param list|null $taxDetails + * @param list|null $taxDetails */ public function withTaxDetails(?array $taxDetails): self { - $obj = clone $this; - $obj->tax_details = $taxDetails; + $self = clone $this; + $self['taxDetails'] = $taxDetails; - return $obj; + return $self; } /** @@ -953,10 +1029,10 @@ public function withTaxDetails(?array $taxDetails): self */ public function withTotalDiscount(?string $totalDiscount): self { - $obj = clone $this; - $obj->total_discount = $totalDiscount; + $self = clone $this; + $self['totalDiscount'] = $totalDiscount; - return $obj; + return $self; } /** @@ -964,10 +1040,10 @@ public function withTotalDiscount(?string $totalDiscount): self */ public function withTotalTax(?string $totalTax): self { - $obj = clone $this; - $obj->total_tax = $totalTax; + $self = clone $this; + $self['totalTax'] = $totalTax; - return $obj; + return $self; } /** @@ -980,10 +1056,10 @@ public function withTotalTax(?string $totalTax): self */ public function withVatex(Vatex|string|null $vatex): self { - $obj = clone $this; - $obj['vatex'] = $vatex; + $self = clone $this; + $self['vatex'] = $vatex; - return $obj; + return $self; } /** @@ -991,10 +1067,10 @@ public function withVatex(Vatex|string|null $vatex): self */ public function withVatexNote(?string $vatexNote): self { - $obj = clone $this; - $obj->vatex_note = $vatexNote; + $self = clone $this; + $self['vatexNote'] = $vatexNote; - return $obj; + return $self; } /** @@ -1002,10 +1078,10 @@ public function withVatexNote(?string $vatexNote): self */ public function withVendorAddress(?string $vendorAddress): self { - $obj = clone $this; - $obj->vendor_address = $vendorAddress; + $self = clone $this; + $self['vendorAddress'] = $vendorAddress; - return $obj; + return $self; } /** @@ -1014,10 +1090,10 @@ public function withVendorAddress(?string $vendorAddress): self public function withVendorAddressRecipient( ?string $vendorAddressRecipient ): self { - $obj = clone $this; - $obj->vendor_address_recipient = $vendorAddressRecipient; + $self = clone $this; + $self['vendorAddressRecipient'] = $vendorAddressRecipient; - return $obj; + return $self; } /** @@ -1025,10 +1101,10 @@ public function withVendorAddressRecipient( */ public function withVendorCompanyID(?string $vendorCompanyID): self { - $obj = clone $this; - $obj->vendor_company_id = $vendorCompanyID; + $self = clone $this; + $self['vendorCompanyID'] = $vendorCompanyID; - return $obj; + return $self; } /** @@ -1036,10 +1112,10 @@ public function withVendorCompanyID(?string $vendorCompanyID): self */ public function withVendorEmail(?string $vendorEmail): self { - $obj = clone $this; - $obj->vendor_email = $vendorEmail; + $self = clone $this; + $self['vendorEmail'] = $vendorEmail; - return $obj; + return $self; } /** @@ -1047,10 +1123,10 @@ public function withVendorEmail(?string $vendorEmail): self */ public function withVendorName(?string $vendorName): self { - $obj = clone $this; - $obj->vendor_name = $vendorName; + $self = clone $this; + $self['vendorName'] = $vendorName; - return $obj; + return $self; } /** @@ -1058,9 +1134,9 @@ public function withVendorName(?string $vendorName): self */ public function withVendorTaxID(?string $vendorTaxID): self { - $obj = clone $this; - $obj->vendor_tax_id = $vendorTaxID; + $self = clone $this; + $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentResponse/Allowance.php b/src/Documents/DocumentResponse/Allowance.php index eba78d63..4eb7bb1b 100644 --- a/src/Documents/DocumentResponse/Allowance.php +++ b/src/Documents/DocumentResponse/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentResponse\Allowance\ReasonCode; @@ -13,12 +13,12 @@ /** * @phpstan-type AllowanceShape = array{ * amount?: string|null, - * base_amount?: string|null, - * multiplier_factor?: string|null, + * baseAmount?: string|null, + * multiplierFactor?: string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Documents\DocumentResponse\Allowance\TaxCode>|null, - * tax_rate?: string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentResponse\Allowance\TaxCode>|null, + * taxRate?: string|null, * } */ final class Allowance implements BaseModel @@ -29,51 +29,51 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $base_amount; + #[Optional('base_amount', nullable: true)] + public ?string $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public ?string $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $tax_rate; + #[Optional('tax_rate', nullable: true)] + public ?string $taxRate; public function __construct() { @@ -85,29 +85,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( ?string $amount = null, - ?string $base_amount = null, - ?string $multiplier_factor = null, + ?string $baseAmount = null, + ?string $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - ?string $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + ?string $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -115,10 +115,10 @@ public static function with( */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -126,10 +126,10 @@ public function withAmount(?string $amount): self */ public function withBaseAmount(?string $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -137,10 +137,10 @@ public function withBaseAmount(?string $baseAmount): self */ public function withMultiplierFactor(?string $multiplierFactor): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -148,10 +148,10 @@ public function withMultiplierFactor(?string $multiplierFactor): self */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -161,10 +161,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -175,10 +175,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string $taxCode ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -186,9 +186,9 @@ public function withTaxCode( */ public function withTaxRate(?string $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentResponse/Charge.php b/src/Documents/DocumentResponse/Charge.php index b563f0bd..4a7b8f66 100644 --- a/src/Documents/DocumentResponse/Charge.php +++ b/src/Documents/DocumentResponse/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\DocumentResponse\Charge\ReasonCode; @@ -13,12 +13,12 @@ /** * @phpstan-type ChargeShape = array{ * amount?: string|null, - * base_amount?: string|null, - * multiplier_factor?: string|null, + * baseAmount?: string|null, + * multiplierFactor?: string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Documents\DocumentResponse\Charge\TaxCode>|null, - * tax_rate?: string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Documents\DocumentResponse\Charge\TaxCode>|null, + * taxRate?: string|null, * } */ final class Charge implements BaseModel @@ -29,34 +29,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $base_amount; + #[Optional('base_amount', nullable: true)] + public ?string $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public ?string $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public ?string $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -65,20 +65,20 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, nullable: true, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public ?string $tax_rate; + #[Optional('tax_rate', nullable: true)] + public ?string $taxRate; public function __construct() { @@ -90,29 +90,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( ?string $amount = null, - ?string $base_amount = null, - ?string $multiplier_factor = null, + ?string $baseAmount = null, + ?string $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - ?string $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + ?string $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -120,10 +120,10 @@ public static function with( */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -131,10 +131,10 @@ public function withAmount(?string $amount): self */ public function withBaseAmount(?string $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -142,10 +142,10 @@ public function withBaseAmount(?string $baseAmount): self */ public function withMultiplierFactor(?string $multiplierFactor): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -153,10 +153,10 @@ public function withMultiplierFactor(?string $multiplierFactor): self */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -166,10 +166,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -184,10 +184,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string|null $taxCode ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -195,9 +195,9 @@ public function withTaxCode( */ public function withTaxRate(?string $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentResponse/Item.php b/src/Documents/DocumentResponse/Item.php index 1293b3c3..4dd3f017 100644 --- a/src/Documents/DocumentResponse/Item.php +++ b/src/Documents/DocumentResponse/Item.php @@ -4,10 +4,12 @@ namespace EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\Allowance; +use EInvoiceAPI\Documents\Allowance\ReasonCode; +use EInvoiceAPI\Documents\Allowance\TaxCode; use EInvoiceAPI\Documents\Charge; use EInvoiceAPI\Documents\UnitOfMeasureCode; @@ -18,12 +20,12 @@ * charges?: list<\EInvoiceAPI\Documents\Charge>|null, * date?: null|null, * description?: string|null, - * product_code?: string|null, + * productCode?: string|null, * quantity?: string|null, * tax?: string|null, - * tax_rate?: string|null, + * taxRate?: string|null, * unit?: value-of|null, - * unit_price?: string|null, + * unitPrice?: string|null, * } */ final class Item implements BaseModel @@ -36,17 +38,13 @@ final class Item implements BaseModel * * @var list|null $allowances */ - #[Api( - list: Allowance::class, - nullable: true, - optional: true, - )] + #[Optional(list: Allowance::class, nullable: true)] public ?array $allowances; /** * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** @@ -54,60 +52,56 @@ final class Item implements BaseModel * * @var list|null $charges */ - #[Api( - list: Charge::class, - nullable: true, - optional: true - )] + #[Optional(list: Charge::class, nullable: true)] public ?array $charges; /** @var null|null $date */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public null $date; /** * The description of the line item. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The product code of the line item. */ - #[Api(nullable: true, optional: true)] - public ?string $product_code; + #[Optional('product_code', nullable: true)] + public ?string $productCode; /** * The quantity of items (goods or services) that is the subject of the line item. Must be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $quantity; /** * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $tax; /** * The VAT rate of the line item expressed as percentage with 2 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $tax_rate; + #[Optional('tax_rate', nullable: true)] + public ?string $taxRate; /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. * * @var value-of|null $unit */ - #[Api(enum: UnitOfMeasureCode::class, nullable: true, optional: true)] + #[Optional(enum: UnitOfMeasureCode::class, nullable: true)] public ?string $unit; /** * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting item price discount. Must be rounded to maximum 4 decimals. */ - #[Api(nullable: true, optional: true)] - public ?string $unit_price; + #[Optional('unit_price', nullable: true)] + public ?string $unitPrice; public function __construct() { @@ -119,8 +113,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges * @param UnitOfMeasureCode|value-of|null $unit */ public static function with( @@ -129,42 +139,50 @@ public static function with( ?array $charges = null, null $date = null, ?string $description = null, - ?string $product_code = null, + ?string $productCode = null, ?string $quantity = null, ?string $tax = null, - ?string $tax_rate = null, + ?string $taxRate = null, UnitOfMeasureCode|string|null $unit = null, - ?string $unit_price = null, + ?string $unitPrice = null, ): self { - $obj = new self; - - $obj->date = $date; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount && $obj->amount = $amount; - null !== $charges && $obj->charges = $charges; - null !== $description && $obj->description = $description; - null !== $product_code && $obj->product_code = $product_code; - null !== $quantity && $obj->quantity = $quantity; - null !== $tax && $obj->tax = $tax; - null !== $tax_rate && $obj->tax_rate = $tax_rate; - null !== $unit && $obj['unit'] = $unit; - null !== $unit_price && $obj->unit_price = $unit_price; - - return $obj; + $self = new self; + + $self['date'] = $date; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amount && $self['amount'] = $amount; + null !== $charges && $self['charges'] = $charges; + null !== $description && $self['description'] = $description; + null !== $productCode && $self['productCode'] = $productCode; + null !== $quantity && $self['quantity'] = $quantity; + null !== $tax && $self['tax'] = $tax; + null !== $taxRate && $self['taxRate'] = $taxRate; + null !== $unit && $self['unit'] = $unit; + null !== $unitPrice && $self['unitPrice'] = $unitPrice; + + return $self; } /** * The allowances of the line item. * - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -172,23 +190,31 @@ public function withAllowances(?array $allowances): self */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** * The charges of the line item. * - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -196,10 +222,10 @@ public function withCharges(?array $charges): self */ public function withDate(null $date): self { - $obj = clone $this; - $obj->date = $date; + $self = clone $this; + $self['date'] = $date; - return $obj; + return $self; } /** @@ -207,10 +233,10 @@ public function withDate(null $date): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -218,10 +244,10 @@ public function withDescription(?string $description): self */ public function withProductCode(?string $productCode): self { - $obj = clone $this; - $obj->product_code = $productCode; + $self = clone $this; + $self['productCode'] = $productCode; - return $obj; + return $self; } /** @@ -229,10 +255,10 @@ public function withProductCode(?string $productCode): self */ public function withQuantity(?string $quantity): self { - $obj = clone $this; - $obj->quantity = $quantity; + $self = clone $this; + $self['quantity'] = $quantity; - return $obj; + return $self; } /** @@ -240,10 +266,10 @@ public function withQuantity(?string $quantity): self */ public function withTax(?string $tax): self { - $obj = clone $this; - $obj->tax = $tax; + $self = clone $this; + $self['tax'] = $tax; - return $obj; + return $self; } /** @@ -251,10 +277,10 @@ public function withTax(?string $tax): self */ public function withTaxRate(?string $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -264,10 +290,10 @@ public function withTaxRate(?string $taxRate): self */ public function withUnit(UnitOfMeasureCode|string|null $unit): self { - $obj = clone $this; - $obj['unit'] = $unit; + $self = clone $this; + $self['unit'] = $unit; - return $obj; + return $self; } /** @@ -275,9 +301,9 @@ public function withUnit(UnitOfMeasureCode|string|null $unit): self */ public function withUnitPrice(?string $unitPrice): self { - $obj = clone $this; - $obj->unit_price = $unitPrice; + $self = clone $this; + $self['unitPrice'] = $unitPrice; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentResponse/PaymentDetail.php b/src/Documents/DocumentResponse/PaymentDetail.php index bcc859d5..e4592f03 100644 --- a/src/Documents/DocumentResponse/PaymentDetail.php +++ b/src/Documents/DocumentResponse/PaymentDetail.php @@ -4,15 +4,15 @@ namespace EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; /** * @phpstan-type PaymentDetailShape = array{ - * bank_account_number?: string|null, + * bankAccountNumber?: string|null, * iban?: string|null, - * payment_reference?: string|null, + * paymentReference?: string|null, * swift?: string|null, * } */ @@ -24,25 +24,25 @@ final class PaymentDetail implements BaseModel /** * Bank account number (for non-IBAN accounts). */ - #[Api(nullable: true, optional: true)] - public ?string $bank_account_number; + #[Optional('bank_account_number', nullable: true)] + public ?string $bankAccountNumber; /** * International Bank Account Number for payment transfers. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $iban; /** * Structured payment reference or communication (e.g., structured communication for Belgian bank transfers). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_reference; + #[Optional('payment_reference', nullable: true)] + public ?string $paymentReference; /** * SWIFT/BIC code of the bank. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $swift; public function __construct() @@ -56,19 +56,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?string $bank_account_number = null, + ?string $bankAccountNumber = null, ?string $iban = null, - ?string $payment_reference = null, + ?string $paymentReference = null, ?string $swift = null, ): self { - $obj = new self; + $self = new self; - null !== $bank_account_number && $obj->bank_account_number = $bank_account_number; - null !== $iban && $obj->iban = $iban; - null !== $payment_reference && $obj->payment_reference = $payment_reference; - null !== $swift && $obj->swift = $swift; + null !== $bankAccountNumber && $self['bankAccountNumber'] = $bankAccountNumber; + null !== $iban && $self['iban'] = $iban; + null !== $paymentReference && $self['paymentReference'] = $paymentReference; + null !== $swift && $self['swift'] = $swift; - return $obj; + return $self; } /** @@ -76,10 +76,10 @@ public static function with( */ public function withBankAccountNumber(?string $bankAccountNumber): self { - $obj = clone $this; - $obj->bank_account_number = $bankAccountNumber; + $self = clone $this; + $self['bankAccountNumber'] = $bankAccountNumber; - return $obj; + return $self; } /** @@ -87,10 +87,10 @@ public function withBankAccountNumber(?string $bankAccountNumber): self */ public function withIban(?string $iban): self { - $obj = clone $this; - $obj->iban = $iban; + $self = clone $this; + $self['iban'] = $iban; - return $obj; + return $self; } /** @@ -98,10 +98,10 @@ public function withIban(?string $iban): self */ public function withPaymentReference(?string $paymentReference): self { - $obj = clone $this; - $obj->payment_reference = $paymentReference; + $self = clone $this; + $self['paymentReference'] = $paymentReference; - return $obj; + return $self; } /** @@ -109,9 +109,9 @@ public function withPaymentReference(?string $paymentReference): self */ public function withSwift(?string $swift): self { - $obj = clone $this; - $obj->swift = $swift; + $self = clone $this; + $self['swift'] = $swift; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentResponse/TaxDetail.php b/src/Documents/DocumentResponse/TaxDetail.php index bf8c42fe..1a42d3ef 100644 --- a/src/Documents/DocumentResponse/TaxDetail.php +++ b/src/Documents/DocumentResponse/TaxDetail.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class TaxDetail implements BaseModel /** * The tax amount for this tax category. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $amount; /** * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00'). */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $rate; public function __construct() @@ -42,12 +42,12 @@ public static function with( ?string $amount = null, ?string $rate = null ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $rate && $obj->rate = $rate; + null !== $amount && $self['amount'] = $amount; + null !== $rate && $self['rate'] = $rate; - return $obj; + return $self; } /** @@ -55,10 +55,10 @@ public static function with( */ public function withAmount(?string $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public function withAmount(?string $amount): self */ public function withRate(?string $rate): self { - $obj = clone $this; - $obj->rate = $rate; + $self = clone $this; + $self['rate'] = $rate; - return $obj; + return $self; } } diff --git a/src/Documents/DocumentSendParams.php b/src/Documents/DocumentSendParams.php index 25594e10..c6b90f15 100644 --- a/src/Documents/DocumentSendParams.php +++ b/src/Documents/DocumentSendParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -16,10 +16,10 @@ * * @phpstan-type DocumentSendParamsShape = array{ * email?: string|null, - * receiver_peppol_id?: string|null, - * receiver_peppol_scheme?: string|null, - * sender_peppol_id?: string|null, - * sender_peppol_scheme?: string|null, + * receiverPeppolID?: string|null, + * receiverPeppolScheme?: string|null, + * senderPeppolID?: string|null, + * senderPeppolScheme?: string|null, * } */ final class DocumentSendParams implements BaseModel @@ -28,20 +28,20 @@ final class DocumentSendParams implements BaseModel use SdkModel; use SdkParams; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; - #[Api(nullable: true, optional: true)] - public ?string $receiver_peppol_id; + #[Optional(nullable: true)] + public ?string $receiverPeppolID; - #[Api(nullable: true, optional: true)] - public ?string $receiver_peppol_scheme; + #[Optional(nullable: true)] + public ?string $receiverPeppolScheme; - #[Api(nullable: true, optional: true)] - public ?string $sender_peppol_id; + #[Optional(nullable: true)] + public ?string $senderPeppolID; - #[Api(nullable: true, optional: true)] - public ?string $sender_peppol_scheme; + #[Optional(nullable: true)] + public ?string $senderPeppolScheme; public function __construct() { @@ -55,60 +55,60 @@ public function __construct() */ public static function with( ?string $email = null, - ?string $receiver_peppol_id = null, - ?string $receiver_peppol_scheme = null, - ?string $sender_peppol_id = null, - ?string $sender_peppol_scheme = null, + ?string $receiverPeppolID = null, + ?string $receiverPeppolScheme = null, + ?string $senderPeppolID = null, + ?string $senderPeppolScheme = null, ): self { - $obj = new self; + $self = new self; - null !== $email && $obj->email = $email; - null !== $receiver_peppol_id && $obj->receiver_peppol_id = $receiver_peppol_id; - null !== $receiver_peppol_scheme && $obj->receiver_peppol_scheme = $receiver_peppol_scheme; - null !== $sender_peppol_id && $obj->sender_peppol_id = $sender_peppol_id; - null !== $sender_peppol_scheme && $obj->sender_peppol_scheme = $sender_peppol_scheme; + null !== $email && $self['email'] = $email; + null !== $receiverPeppolID && $self['receiverPeppolID'] = $receiverPeppolID; + null !== $receiverPeppolScheme && $self['receiverPeppolScheme'] = $receiverPeppolScheme; + null !== $senderPeppolID && $self['senderPeppolID'] = $senderPeppolID; + null !== $senderPeppolScheme && $self['senderPeppolScheme'] = $senderPeppolScheme; - return $obj; + return $self; } public function withEmail(?string $email): self { - $obj = clone $this; - $obj->email = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } public function withReceiverPeppolID(?string $receiverPeppolID): self { - $obj = clone $this; - $obj->receiver_peppol_id = $receiverPeppolID; + $self = clone $this; + $self['receiverPeppolID'] = $receiverPeppolID; - return $obj; + return $self; } public function withReceiverPeppolScheme( ?string $receiverPeppolScheme ): self { - $obj = clone $this; - $obj->receiver_peppol_scheme = $receiverPeppolScheme; + $self = clone $this; + $self['receiverPeppolScheme'] = $receiverPeppolScheme; - return $obj; + return $self; } public function withSenderPeppolID(?string $senderPeppolID): self { - $obj = clone $this; - $obj->sender_peppol_id = $senderPeppolID; + $self = clone $this; + $self['senderPeppolID'] = $senderPeppolID; - return $obj; + return $self; } public function withSenderPeppolScheme(?string $senderPeppolScheme): self { - $obj = clone $this; - $obj->sender_peppol_scheme = $senderPeppolScheme; + $self = clone $this; + $self['senderPeppolScheme'] = $senderPeppolScheme; - return $obj; + return $self; } } diff --git a/src/Documents/PaymentDetailCreate.php b/src/Documents/PaymentDetailCreate.php index ab910473..cfe4883a 100644 --- a/src/Documents/PaymentDetailCreate.php +++ b/src/Documents/PaymentDetailCreate.php @@ -4,15 +4,15 @@ namespace EInvoiceAPI\Documents; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; /** * @phpstan-type PaymentDetailCreateShape = array{ - * bank_account_number?: string|null, + * bankAccountNumber?: string|null, * iban?: string|null, - * payment_reference?: string|null, + * paymentReference?: string|null, * swift?: string|null, * } */ @@ -24,25 +24,25 @@ final class PaymentDetailCreate implements BaseModel /** * Bank account number (for non-IBAN accounts). */ - #[Api(nullable: true, optional: true)] - public ?string $bank_account_number; + #[Optional('bank_account_number', nullable: true)] + public ?string $bankAccountNumber; /** * International Bank Account Number for payment transfers. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $iban; /** * Structured payment reference or communication (e.g., structured communication for Belgian bank transfers). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_reference; + #[Optional('payment_reference', nullable: true)] + public ?string $paymentReference; /** * SWIFT/BIC code of the bank. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $swift; public function __construct() @@ -56,19 +56,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?string $bank_account_number = null, + ?string $bankAccountNumber = null, ?string $iban = null, - ?string $payment_reference = null, + ?string $paymentReference = null, ?string $swift = null, ): self { - $obj = new self; + $self = new self; - null !== $bank_account_number && $obj->bank_account_number = $bank_account_number; - null !== $iban && $obj->iban = $iban; - null !== $payment_reference && $obj->payment_reference = $payment_reference; - null !== $swift && $obj->swift = $swift; + null !== $bankAccountNumber && $self['bankAccountNumber'] = $bankAccountNumber; + null !== $iban && $self['iban'] = $iban; + null !== $paymentReference && $self['paymentReference'] = $paymentReference; + null !== $swift && $self['swift'] = $swift; - return $obj; + return $self; } /** @@ -76,10 +76,10 @@ public static function with( */ public function withBankAccountNumber(?string $bankAccountNumber): self { - $obj = clone $this; - $obj->bank_account_number = $bankAccountNumber; + $self = clone $this; + $self['bankAccountNumber'] = $bankAccountNumber; - return $obj; + return $self; } /** @@ -87,10 +87,10 @@ public function withBankAccountNumber(?string $bankAccountNumber): self */ public function withIban(?string $iban): self { - $obj = clone $this; - $obj->iban = $iban; + $self = clone $this; + $self['iban'] = $iban; - return $obj; + return $self; } /** @@ -98,10 +98,10 @@ public function withIban(?string $iban): self */ public function withPaymentReference(?string $paymentReference): self { - $obj = clone $this; - $obj->payment_reference = $paymentReference; + $self = clone $this; + $self['paymentReference'] = $paymentReference; - return $obj; + return $self; } /** @@ -109,9 +109,9 @@ public function withPaymentReference(?string $paymentReference): self */ public function withSwift(?string $swift): self { - $obj = clone $this; - $obj->swift = $swift; + $self = clone $this; + $self['swift'] = $swift; - return $obj; + return $self; } } diff --git a/src/Documents/Ubl/UblCreateFromUblParams.php b/src/Documents/Ubl/UblCreateFromUblParams.php index d3eb5e08..590c9fa6 100644 --- a/src/Documents/Ubl/UblCreateFromUblParams.php +++ b/src/Documents/Ubl/UblCreateFromUblParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Documents\Ubl; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -22,7 +22,7 @@ final class UblCreateFromUblParams implements BaseModel use SdkModel; use SdkParams; - #[Api] + #[Required] public string $file; /** @@ -51,18 +51,18 @@ public function __construct() */ public static function with(string $file): self { - $obj = new self; + $self = new self; - $obj->file = $file; + $self['file'] = $file; - return $obj; + return $self; } public function withFile(string $file): self { - $obj = clone $this; - $obj->file = $file; + $self = clone $this; + $self['file'] = $file; - return $obj; + return $self; } } diff --git a/src/Documents/Ubl/UblGetResponse.php b/src/Documents/Ubl/UblGetResponse.php index 5d2ef4e5..9c8cd80c 100644 --- a/src/Documents/Ubl/UblGetResponse.php +++ b/src/Documents/Ubl/UblGetResponse.php @@ -4,69 +4,66 @@ namespace EInvoiceAPI\Documents\Ubl; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type UblGetResponseShape = array{ * id: string, - * file_name: string, - * file_hash?: string|null, - * file_size?: int|null, - * receiver_peppol_id?: string|null, - * receiver_peppol_scheme?: string|null, - * sender_peppol_id?: string|null, - * sender_peppol_scheme?: string|null, - * signed_url?: string|null, - * validated_at?: \DateTimeInterface|null, + * fileName: string, + * fileHash?: string|null, + * fileSize?: int|null, + * receiverPeppolID?: string|null, + * receiverPeppolScheme?: string|null, + * senderPeppolID?: string|null, + * senderPeppolScheme?: string|null, + * signedURL?: string|null, + * validatedAt?: \DateTimeInterface|null, * } */ -final class UblGetResponse implements BaseModel, ResponseConverter +final class UblGetResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] + #[Required] public string $id; - #[Api] - public string $file_name; + #[Required('file_name')] + public string $fileName; - #[Api(nullable: true, optional: true)] - public ?string $file_hash; + #[Optional('file_hash', nullable: true)] + public ?string $fileHash; - #[Api(optional: true)] - public ?int $file_size; + #[Optional('file_size')] + public ?int $fileSize; - #[Api(nullable: true, optional: true)] - public ?string $receiver_peppol_id; + #[Optional('receiver_peppol_id', nullable: true)] + public ?string $receiverPeppolID; - #[Api(nullable: true, optional: true)] - public ?string $receiver_peppol_scheme; + #[Optional('receiver_peppol_scheme', nullable: true)] + public ?string $receiverPeppolScheme; - #[Api(nullable: true, optional: true)] - public ?string $sender_peppol_id; + #[Optional('sender_peppol_id', nullable: true)] + public ?string $senderPeppolID; - #[Api(nullable: true, optional: true)] - public ?string $sender_peppol_scheme; + #[Optional('sender_peppol_scheme', nullable: true)] + public ?string $senderPeppolScheme; - #[Api(nullable: true, optional: true)] - public ?string $signed_url; + #[Optional('signed_url', nullable: true)] + public ?string $signedURL; - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $validated_at; + #[Optional('validated_at', nullable: true)] + public ?\DateTimeInterface $validatedAt; /** * `new UblGetResponse()` is missing required properties by the API. * * To enforce required parameters use * ``` - * UblGetResponse::with(id: ..., file_name: ...) + * UblGetResponse::with(id: ..., fileName: ...) * ``` * * Otherwise ensure the following setters are called @@ -87,111 +84,111 @@ public function __construct() */ public static function with( string $id, - string $file_name, - ?string $file_hash = null, - ?int $file_size = null, - ?string $receiver_peppol_id = null, - ?string $receiver_peppol_scheme = null, - ?string $sender_peppol_id = null, - ?string $sender_peppol_scheme = null, - ?string $signed_url = null, - ?\DateTimeInterface $validated_at = null, + string $fileName, + ?string $fileHash = null, + ?int $fileSize = null, + ?string $receiverPeppolID = null, + ?string $receiverPeppolScheme = null, + ?string $senderPeppolID = null, + ?string $senderPeppolScheme = null, + ?string $signedURL = null, + ?\DateTimeInterface $validatedAt = null, ): self { - $obj = new self; + $self = new self; - $obj->id = $id; - $obj->file_name = $file_name; + $self['id'] = $id; + $self['fileName'] = $fileName; - null !== $file_hash && $obj->file_hash = $file_hash; - null !== $file_size && $obj->file_size = $file_size; - null !== $receiver_peppol_id && $obj->receiver_peppol_id = $receiver_peppol_id; - null !== $receiver_peppol_scheme && $obj->receiver_peppol_scheme = $receiver_peppol_scheme; - null !== $sender_peppol_id && $obj->sender_peppol_id = $sender_peppol_id; - null !== $sender_peppol_scheme && $obj->sender_peppol_scheme = $sender_peppol_scheme; - null !== $signed_url && $obj->signed_url = $signed_url; - null !== $validated_at && $obj->validated_at = $validated_at; + null !== $fileHash && $self['fileHash'] = $fileHash; + null !== $fileSize && $self['fileSize'] = $fileSize; + null !== $receiverPeppolID && $self['receiverPeppolID'] = $receiverPeppolID; + null !== $receiverPeppolScheme && $self['receiverPeppolScheme'] = $receiverPeppolScheme; + null !== $senderPeppolID && $self['senderPeppolID'] = $senderPeppolID; + null !== $senderPeppolScheme && $self['senderPeppolScheme'] = $senderPeppolScheme; + null !== $signedURL && $self['signedURL'] = $signedURL; + null !== $validatedAt && $self['validatedAt'] = $validatedAt; - return $obj; + return $self; } public function withID(string $id): self { - $obj = clone $this; - $obj->id = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } public function withFileName(string $fileName): self { - $obj = clone $this; - $obj->file_name = $fileName; + $self = clone $this; + $self['fileName'] = $fileName; - return $obj; + return $self; } public function withFileHash(?string $fileHash): self { - $obj = clone $this; - $obj->file_hash = $fileHash; + $self = clone $this; + $self['fileHash'] = $fileHash; - return $obj; + return $self; } public function withFileSize(int $fileSize): self { - $obj = clone $this; - $obj->file_size = $fileSize; + $self = clone $this; + $self['fileSize'] = $fileSize; - return $obj; + return $self; } public function withReceiverPeppolID(?string $receiverPeppolID): self { - $obj = clone $this; - $obj->receiver_peppol_id = $receiverPeppolID; + $self = clone $this; + $self['receiverPeppolID'] = $receiverPeppolID; - return $obj; + return $self; } public function withReceiverPeppolScheme( ?string $receiverPeppolScheme ): self { - $obj = clone $this; - $obj->receiver_peppol_scheme = $receiverPeppolScheme; + $self = clone $this; + $self['receiverPeppolScheme'] = $receiverPeppolScheme; - return $obj; + return $self; } public function withSenderPeppolID(?string $senderPeppolID): self { - $obj = clone $this; - $obj->sender_peppol_id = $senderPeppolID; + $self = clone $this; + $self['senderPeppolID'] = $senderPeppolID; - return $obj; + return $self; } public function withSenderPeppolScheme(?string $senderPeppolScheme): self { - $obj = clone $this; - $obj->sender_peppol_scheme = $senderPeppolScheme; + $self = clone $this; + $self['senderPeppolScheme'] = $senderPeppolScheme; - return $obj; + return $self; } public function withSignedURL(?string $signedURL): self { - $obj = clone $this; - $obj->signed_url = $signedURL; + $self = clone $this; + $self['signedURL'] = $signedURL; - return $obj; + return $self; } public function withValidatedAt(?\DateTimeInterface $validatedAt): self { - $obj = clone $this; - $obj->validated_at = $validatedAt; + $self = clone $this; + $self['validatedAt'] = $validatedAt; - return $obj; + return $self; } } diff --git a/src/DocumentsNumberPage.php b/src/DocumentsNumberPage.php index 6a43ed25..696efb39 100644 --- a/src/DocumentsNumberPage.php +++ b/src/DocumentsNumberPage.php @@ -2,7 +2,7 @@ namespace EInvoiceAPI; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkPage; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -11,7 +11,6 @@ use EInvoiceAPI\Core\Conversion\Contracts\Converter; use EInvoiceAPI\Core\Conversion\Contracts\ConverterSource; use EInvoiceAPI\Core\Conversion\ListOf; -use EInvoiceAPI\Core\Util; use EInvoiceAPI\DocumentsNumberPage\Item; use Psr\Http\Message\ResponseInterface; @@ -19,7 +18,7 @@ * @phpstan-type DocumentsNumberPageShape = array{ * items?: list|null, * page?: int|null, - * page_size?: int|null, + * pageSize?: int|null, * total?: int|null, * } * @@ -36,16 +35,16 @@ final class DocumentsNumberPage implements BaseModel, BasePage use SdkPage; /** @var list|null $items */ - #[Api(list: Item::class, optional: true)] + #[Optional(list: Item::class)] public ?array $items; - #[Api(optional: true)] + #[Optional] public ?int $page; - #[Api(optional: true)] - public ?int $page_size; + #[Optional('page_size')] + public ?int $pageSize; - #[Api(optional: true)] + #[Optional] public ?int $total; /** @@ -57,25 +56,24 @@ final class DocumentsNumberPage implements BaseModel, BasePage * query: array, * headers: array|null>, * body: mixed, - * } $request + * } $requestInfo */ public function __construct( private string|Converter|ConverterSource $convert, private Client $client, - private array $request, + private array $requestInfo, private RequestOptions $options, - ResponseInterface $response, + private ResponseInterface $response, + private mixed $parsedBody, ) { $this->initialize(); - $data = Util::decodeContent($response); - - if (!is_array($data)) { + if (!is_array($this->parsedBody)) { return; } // @phpstan-ignore-next-line argument.type - self::__unserialize($data); + self::__unserialize($this->parsedBody); if ($this->offsetGet('items')) { $acc = Conversion::coerce( @@ -117,7 +115,7 @@ public function nextRequest(): ?array } $nextRequest = array_merge_recursive( - $this->request, + $this->requestInfo, ['query' => $curr + 1] ); diff --git a/src/Inbox/InboxListCreditNotesParams.php b/src/Inbox/InboxListCreditNotesParams.php index 28c50c51..0dc1720c 100644 --- a/src/Inbox/InboxListCreditNotesParams.php +++ b/src/Inbox/InboxListCreditNotesParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Inbox; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -15,7 +15,7 @@ * @see EInvoiceAPI\Services\InboxService::listCreditNotes() * * @phpstan-type InboxListCreditNotesParamsShape = array{ - * page?: int, page_size?: int + * page?: int, pageSize?: int * } */ final class InboxListCreditNotesParams implements BaseModel @@ -27,14 +27,14 @@ final class InboxListCreditNotesParams implements BaseModel /** * Page number. */ - #[Api(optional: true)] + #[Optional] public ?int $page; /** * Number of items per page. */ - #[Api(optional: true)] - public ?int $page_size; + #[Optional] + public ?int $pageSize; public function __construct() { @@ -46,14 +46,14 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?int $page = null, ?int $page_size = null): self + public static function with(?int $page = null, ?int $pageSize = null): self { - $obj = new self; + $self = new self; - null !== $page && $obj->page = $page; - null !== $page_size && $obj->page_size = $page_size; + null !== $page && $self['page'] = $page; + null !== $pageSize && $self['pageSize'] = $pageSize; - return $obj; + return $self; } /** @@ -61,10 +61,10 @@ public static function with(?int $page = null, ?int $page_size = null): self */ public function withPage(int $page): self { - $obj = clone $this; - $obj->page = $page; + $self = clone $this; + $self['page'] = $page; - return $obj; + return $self; } /** @@ -72,9 +72,9 @@ public function withPage(int $page): self */ public function withPageSize(int $pageSize): self { - $obj = clone $this; - $obj->page_size = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } } diff --git a/src/Inbox/InboxListInvoicesParams.php b/src/Inbox/InboxListInvoicesParams.php index 748de543..66852507 100644 --- a/src/Inbox/InboxListInvoicesParams.php +++ b/src/Inbox/InboxListInvoicesParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Inbox; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -14,7 +14,7 @@ * * @see EInvoiceAPI\Services\InboxService::listInvoices() * - * @phpstan-type InboxListInvoicesParamsShape = array{page?: int, page_size?: int} + * @phpstan-type InboxListInvoicesParamsShape = array{page?: int, pageSize?: int} */ final class InboxListInvoicesParams implements BaseModel { @@ -25,14 +25,14 @@ final class InboxListInvoicesParams implements BaseModel /** * Page number. */ - #[Api(optional: true)] + #[Optional] public ?int $page; /** * Number of items per page. */ - #[Api(optional: true)] - public ?int $page_size; + #[Optional] + public ?int $pageSize; public function __construct() { @@ -44,14 +44,14 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?int $page = null, ?int $page_size = null): self + public static function with(?int $page = null, ?int $pageSize = null): self { - $obj = new self; + $self = new self; - null !== $page && $obj->page = $page; - null !== $page_size && $obj->page_size = $page_size; + null !== $page && $self['page'] = $page; + null !== $pageSize && $self['pageSize'] = $pageSize; - return $obj; + return $self; } /** @@ -59,10 +59,10 @@ public static function with(?int $page = null, ?int $page_size = null): self */ public function withPage(int $page): self { - $obj = clone $this; - $obj->page = $page; + $self = clone $this; + $self['page'] = $page; - return $obj; + return $self; } /** @@ -70,9 +70,9 @@ public function withPage(int $page): self */ public function withPageSize(int $pageSize): self { - $obj = clone $this; - $obj->page_size = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } } diff --git a/src/Inbox/InboxListParams.php b/src/Inbox/InboxListParams.php index 4e435e50..bda86874 100644 --- a/src/Inbox/InboxListParams.php +++ b/src/Inbox/InboxListParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Inbox; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -16,10 +16,10 @@ * @see EInvoiceAPI\Services\InboxService::list() * * @phpstan-type InboxListParamsShape = array{ - * date_from?: \DateTimeInterface|null, - * date_to?: \DateTimeInterface|null, + * dateFrom?: \DateTimeInterface|null, + * dateTo?: \DateTimeInterface|null, * page?: int, - * page_size?: int, + * pageSize?: int, * search?: string|null, * sender?: string|null, * state?: null|DocumentState|value-of, @@ -35,37 +35,37 @@ final class InboxListParams implements BaseModel /** * Filter by issue date (from). */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $date_from; + #[Optional(nullable: true)] + public ?\DateTimeInterface $dateFrom; /** * Filter by issue date (to). */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $date_to; + #[Optional(nullable: true)] + public ?\DateTimeInterface $dateTo; /** * Page number. */ - #[Api(optional: true)] + #[Optional] public ?int $page; /** * Number of items per page. */ - #[Api(optional: true)] - public ?int $page_size; + #[Optional] + public ?int $pageSize; /** * Search in invoice number, seller/buyer names. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $search; /** * Filter by sender ID. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $sender; /** @@ -73,7 +73,7 @@ final class InboxListParams implements BaseModel * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, nullable: true, optional: true)] + #[Optional(enum: DocumentState::class, nullable: true)] public ?string $state; /** @@ -81,7 +81,7 @@ final class InboxListParams implements BaseModel * * @var value-of|null $type */ - #[Api(enum: DocumentType::class, nullable: true, optional: true)] + #[Optional(enum: DocumentType::class, nullable: true)] public ?string $type; public function __construct() @@ -98,27 +98,27 @@ public function __construct() * @param DocumentType|value-of|null $type */ public static function with( - ?\DateTimeInterface $date_from = null, - ?\DateTimeInterface $date_to = null, + ?\DateTimeInterface $dateFrom = null, + ?\DateTimeInterface $dateTo = null, ?int $page = null, - ?int $page_size = null, + ?int $pageSize = null, ?string $search = null, ?string $sender = null, DocumentState|string|null $state = null, DocumentType|string|null $type = null, ): self { - $obj = new self; - - null !== $date_from && $obj->date_from = $date_from; - null !== $date_to && $obj->date_to = $date_to; - null !== $page && $obj->page = $page; - null !== $page_size && $obj->page_size = $page_size; - null !== $search && $obj->search = $search; - null !== $sender && $obj->sender = $sender; - null !== $state && $obj['state'] = $state; - null !== $type && $obj['type'] = $type; - - return $obj; + $self = new self; + + null !== $dateFrom && $self['dateFrom'] = $dateFrom; + null !== $dateTo && $self['dateTo'] = $dateTo; + null !== $page && $self['page'] = $page; + null !== $pageSize && $self['pageSize'] = $pageSize; + null !== $search && $self['search'] = $search; + null !== $sender && $self['sender'] = $sender; + null !== $state && $self['state'] = $state; + null !== $type && $self['type'] = $type; + + return $self; } /** @@ -126,10 +126,10 @@ public static function with( */ public function withDateFrom(?\DateTimeInterface $dateFrom): self { - $obj = clone $this; - $obj->date_from = $dateFrom; + $self = clone $this; + $self['dateFrom'] = $dateFrom; - return $obj; + return $self; } /** @@ -137,10 +137,10 @@ public function withDateFrom(?\DateTimeInterface $dateFrom): self */ public function withDateTo(?\DateTimeInterface $dateTo): self { - $obj = clone $this; - $obj->date_to = $dateTo; + $self = clone $this; + $self['dateTo'] = $dateTo; - return $obj; + return $self; } /** @@ -148,10 +148,10 @@ public function withDateTo(?\DateTimeInterface $dateTo): self */ public function withPage(int $page): self { - $obj = clone $this; - $obj->page = $page; + $self = clone $this; + $self['page'] = $page; - return $obj; + return $self; } /** @@ -159,10 +159,10 @@ public function withPage(int $page): self */ public function withPageSize(int $pageSize): self { - $obj = clone $this; - $obj->page_size = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } /** @@ -170,10 +170,10 @@ public function withPageSize(int $pageSize): self */ public function withSearch(?string $search): self { - $obj = clone $this; - $obj->search = $search; + $self = clone $this; + $self['search'] = $search; - return $obj; + return $self; } /** @@ -181,10 +181,10 @@ public function withSearch(?string $search): self */ public function withSender(?string $sender): self { - $obj = clone $this; - $obj->sender = $sender; + $self = clone $this; + $self['sender'] = $sender; - return $obj; + return $self; } /** @@ -194,10 +194,10 @@ public function withSender(?string $sender): self */ public function withState(DocumentState|string|null $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -207,9 +207,9 @@ public function withState(DocumentState|string|null $state): self */ public function withType(DocumentType|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } } diff --git a/src/Inbox/PaginatedDocumentResponse.php b/src/Inbox/PaginatedDocumentResponse.php index 9a72850e..8bc55295 100644 --- a/src/Inbox/PaginatedDocumentResponse.php +++ b/src/Inbox/PaginatedDocumentResponse.php @@ -4,16 +4,27 @@ namespace EInvoiceAPI\Inbox; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; +use EInvoiceAPI\Documents\Attachments\DocumentAttachment; +use EInvoiceAPI\Documents\CurrencyCode; +use EInvoiceAPI\Documents\DocumentDirection; use EInvoiceAPI\Documents\DocumentResponse; +use EInvoiceAPI\Documents\DocumentResponse\Allowance; +use EInvoiceAPI\Documents\DocumentResponse\Charge; +use EInvoiceAPI\Documents\DocumentResponse\Item; +use EInvoiceAPI\Documents\DocumentResponse\PaymentDetail; +use EInvoiceAPI\Documents\DocumentResponse\TaxCode; +use EInvoiceAPI\Documents\DocumentResponse\TaxDetail; +use EInvoiceAPI\Documents\DocumentResponse\Vatex; +use EInvoiceAPI\Documents\DocumentType; /** * @phpstan-type PaginatedDocumentResponseShape = array{ * items: list, * page: int, - * page_size: int, + * pageSize: int, * pages: int, * total: int, * } @@ -24,19 +35,19 @@ final class PaginatedDocumentResponse implements BaseModel use SdkModel; /** @var list $items */ - #[Api(list: DocumentResponse::class)] + #[Required(list: DocumentResponse::class)] public array $items; - #[Api] + #[Required] public int $page; - #[Api] - public int $page_size; + #[Required('page_size')] + public int $pageSize; - #[Api] + #[Required] public int $pages; - #[Api] + #[Required] public int $total; /** @@ -45,7 +56,7 @@ final class PaginatedDocumentResponse implements BaseModel * To enforce required parameters use * ``` * PaginatedDocumentResponse::with( - * items: ..., page: ..., page_size: ..., pages: ..., total: ... + * items: ..., page: ..., pageSize: ..., pages: ..., total: ... * ) * ``` * @@ -70,66 +81,164 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $items + * @param list|null, + * amountDue?: string|null, + * attachments?: list|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, + * charges?: list|null, + * currency?: value-of|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, + * direction?: value-of|null, + * documentType?: value-of|null, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: string|null, + * items?: list|null, + * note?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, + * state?: value-of|null, + * subtotal?: string|null, + * taxCode?: value-of|null, + * taxDetails?: list|null, + * totalDiscount?: string|null, + * totalTax?: string|null, + * vatex?: value-of|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, + * }> $items */ public static function with( array $items, int $page, - int $page_size, + int $pageSize, int $pages, int $total ): self { - $obj = new self; + $self = new self; - $obj->items = $items; - $obj->page = $page; - $obj->page_size = $page_size; - $obj->pages = $pages; - $obj->total = $total; + $self['items'] = $items; + $self['page'] = $page; + $self['pageSize'] = $pageSize; + $self['pages'] = $pages; + $self['total'] = $total; - return $obj; + return $self; } /** - * @param list $items + * @param list|null, + * amountDue?: string|null, + * attachments?: list|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, + * charges?: list|null, + * currency?: value-of|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, + * direction?: value-of|null, + * documentType?: value-of|null, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: string|null, + * items?: list|null, + * note?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, + * state?: value-of|null, + * subtotal?: string|null, + * taxCode?: value-of|null, + * taxDetails?: list|null, + * totalDiscount?: string|null, + * totalTax?: string|null, + * vatex?: value-of|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, + * }> $items */ public function withItems(array $items): self { - $obj = clone $this; - $obj->items = $items; + $self = clone $this; + $self['items'] = $items; - return $obj; + return $self; } public function withPage(int $page): self { - $obj = clone $this; - $obj->page = $page; + $self = clone $this; + $self['page'] = $page; - return $obj; + return $self; } public function withPageSize(int $pageSize): self { - $obj = clone $this; - $obj->page_size = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } public function withPages(int $pages): self { - $obj = clone $this; - $obj->pages = $pages; + $self = clone $this; + $self['pages'] = $pages; - return $obj; + return $self; } public function withTotal(int $total): self { - $obj = clone $this; - $obj->total = $total; + $self = clone $this; + $self['total'] = $total; - return $obj; + return $self; } } diff --git a/src/Lookup/Certificate.php b/src/Lookup/Certificate.php index 6dbadc4d..aa42f621 100644 --- a/src/Lookup/Certificate.php +++ b/src/Lookup/Certificate.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Lookup; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -23,7 +24,7 @@ final class Certificate implements BaseModel /** * Status of the certificate validation: 'success', 'error', or 'pending'. */ - #[Api] + #[Required] public string $status; /** @@ -31,13 +32,13 @@ final class Certificate implements BaseModel * * @var array|null $details */ - #[Api(map: 'mixed', nullable: true, optional: true)] + #[Optional(map: 'mixed', nullable: true)] public ?array $details; /** * Error message if certificate validation failed. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $error; /** @@ -71,14 +72,14 @@ public static function with( ?array $details = null, ?string $error = null ): self { - $obj = new self; + $self = new self; - $obj->status = $status; + $self['status'] = $status; - null !== $details && $obj->details = $details; - null !== $error && $obj->error = $error; + null !== $details && $self['details'] = $details; + null !== $error && $self['error'] = $error; - return $obj; + return $self; } /** @@ -86,10 +87,10 @@ public static function with( */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -99,10 +100,10 @@ public function withStatus(string $status): self */ public function withDetails(?array $details): self { - $obj = clone $this; - $obj->details = $details; + $self = clone $this; + $self['details'] = $details; - return $obj; + return $self; } /** @@ -110,9 +111,9 @@ public function withDetails(?array $details): self */ public function withError(?string $error): self { - $obj = clone $this; - $obj->error = $error; + $self = clone $this; + $self['error'] = $error; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetParticipantsResponse.php b/src/Lookup/LookupGetParticipantsResponse.php index 163ef3bc..67c8659a 100644 --- a/src/Lookup/LookupGetParticipantsResponse.php +++ b/src/Lookup/LookupGetParticipantsResponse.php @@ -4,61 +4,60 @@ namespace EInvoiceAPI\Lookup; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant; +use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\DocumentType; +use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\Entity; /** * Represents the result of a Peppol directory search. * * @phpstan-type LookupGetParticipantsResponseShape = array{ - * query_terms: string, - * search_date: string, - * total_count: int, - * used_count: int, + * queryTerms: string, + * searchDate: string, + * totalCount: int, + * usedCount: int, * participants?: list|null, * } */ -final class LookupGetParticipantsResponse implements BaseModel, ResponseConverter +final class LookupGetParticipantsResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Query terms used for search. */ - #[Api] - public string $query_terms; + #[Required('query_terms')] + public string $queryTerms; /** * Search date of the result. */ - #[Api] - public string $search_date; + #[Required('search_date')] + public string $searchDate; /** * Total number of results. */ - #[Api] - public int $total_count; + #[Required('total_count')] + public int $totalCount; /** * Number of results returned by the API. */ - #[Api] - public int $used_count; + #[Required('used_count')] + public int $usedCount; /** * List of participants. * * @var list|null $participants */ - #[Api(list: Participant::class, optional: true)] + #[Optional(list: Participant::class)] public ?array $participants; /** @@ -67,7 +66,7 @@ final class LookupGetParticipantsResponse implements BaseModel, ResponseConverte * To enforce required parameters use * ``` * LookupGetParticipantsResponse::with( - * query_terms: ..., search_date: ..., total_count: ..., used_count: ... + * queryTerms: ..., searchDate: ..., totalCount: ..., usedCount: ... * ) * ``` * @@ -91,25 +90,30 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $participants + * @param list|null, + * entities?: list|null, + * }> $participants */ public static function with( - string $query_terms, - string $search_date, - int $total_count, - int $used_count, + string $queryTerms, + string $searchDate, + int $totalCount, + int $usedCount, ?array $participants = null, ): self { - $obj = new self; + $self = new self; - $obj->query_terms = $query_terms; - $obj->search_date = $search_date; - $obj->total_count = $total_count; - $obj->used_count = $used_count; + $self['queryTerms'] = $queryTerms; + $self['searchDate'] = $searchDate; + $self['totalCount'] = $totalCount; + $self['usedCount'] = $usedCount; - null !== $participants && $obj->participants = $participants; + null !== $participants && $self['participants'] = $participants; - return $obj; + return $self; } /** @@ -117,10 +121,10 @@ public static function with( */ public function withQueryTerms(string $queryTerms): self { - $obj = clone $this; - $obj->query_terms = $queryTerms; + $self = clone $this; + $self['queryTerms'] = $queryTerms; - return $obj; + return $self; } /** @@ -128,10 +132,10 @@ public function withQueryTerms(string $queryTerms): self */ public function withSearchDate(string $searchDate): self { - $obj = clone $this; - $obj->search_date = $searchDate; + $self = clone $this; + $self['searchDate'] = $searchDate; - return $obj; + return $self; } /** @@ -139,10 +143,10 @@ public function withSearchDate(string $searchDate): self */ public function withTotalCount(int $totalCount): self { - $obj = clone $this; - $obj->total_count = $totalCount; + $self = clone $this; + $self['totalCount'] = $totalCount; - return $obj; + return $self; } /** @@ -150,22 +154,27 @@ public function withTotalCount(int $totalCount): self */ public function withUsedCount(int $usedCount): self { - $obj = clone $this; - $obj->used_count = $usedCount; + $self = clone $this; + $self['usedCount'] = $usedCount; - return $obj; + return $self; } /** * List of participants. * - * @param list $participants + * @param list|null, + * entities?: list|null, + * }> $participants */ public function withParticipants(array $participants): self { - $obj = clone $this; - $obj->participants = $participants; + $self = clone $this; + $self['participants'] = $participants; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetParticipantsResponse/Participant.php b/src/Lookup/LookupGetParticipantsResponse/Participant.php index e87da552..307c71a9 100644 --- a/src/Lookup/LookupGetParticipantsResponse/Participant.php +++ b/src/Lookup/LookupGetParticipantsResponse/Participant.php @@ -4,19 +4,21 @@ namespace EInvoiceAPI\Lookup\LookupGetParticipantsResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\DocumentType; use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\Entity; +use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\Entity\Identifier; /** * Represents a Peppol participant with their details. * * @phpstan-type ParticipantShape = array{ - * peppol_id: string, - * peppol_scheme: string, - * document_types?: list|null, + * peppolID: string, + * peppolScheme: string, + * documentTypes?: list|null, * entities?: list|null, * } */ @@ -28,29 +30,29 @@ final class Participant implements BaseModel /** * Peppol ID of the participant. */ - #[Api] - public string $peppol_id; + #[Required('peppol_id')] + public string $peppolID; /** * Peppol scheme of the participant. */ - #[Api] - public string $peppol_scheme; + #[Required('peppol_scheme')] + public string $peppolScheme; /** * List of supported document types. * - * @var list|null $document_types + * @var list|null $documentTypes */ - #[Api(list: DocumentType::class, optional: true)] - public ?array $document_types; + #[Optional('document_types', list: DocumentType::class)] + public ?array $documentTypes; /** * List of business entities. * * @var list|null $entities */ - #[Api(list: Entity::class, optional: true)] + #[Optional(list: Entity::class)] public ?array $entities; /** @@ -58,7 +60,7 @@ final class Participant implements BaseModel * * To enforce required parameters use * ``` - * Participant::with(peppol_id: ..., peppol_scheme: ...) + * Participant::with(peppolID: ..., peppolScheme: ...) * ``` * * Otherwise ensure the following setters are called @@ -77,24 +79,32 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $document_types - * @param list $entities + * @param list $documentTypes + * @param list|null, + * name?: string|null, + * registrationDate?: string|null, + * website?: string|null, + * }> $entities */ public static function with( - string $peppol_id, - string $peppol_scheme, - ?array $document_types = null, + string $peppolID, + string $peppolScheme, + ?array $documentTypes = null, ?array $entities = null, ): self { - $obj = new self; + $self = new self; - $obj->peppol_id = $peppol_id; - $obj->peppol_scheme = $peppol_scheme; + $self['peppolID'] = $peppolID; + $self['peppolScheme'] = $peppolScheme; - null !== $document_types && $obj->document_types = $document_types; - null !== $entities && $obj->entities = $entities; + null !== $documentTypes && $self['documentTypes'] = $documentTypes; + null !== $entities && $self['entities'] = $entities; - return $obj; + return $self; } /** @@ -102,10 +112,10 @@ public static function with( */ public function withPeppolID(string $peppolID): self { - $obj = clone $this; - $obj->peppol_id = $peppolID; + $self = clone $this; + $self['peppolID'] = $peppolID; - return $obj; + return $self; } /** @@ -113,35 +123,43 @@ public function withPeppolID(string $peppolID): self */ public function withPeppolScheme(string $peppolScheme): self { - $obj = clone $this; - $obj->peppol_scheme = $peppolScheme; + $self = clone $this; + $self['peppolScheme'] = $peppolScheme; - return $obj; + return $self; } /** * List of supported document types. * - * @param list $documentTypes + * @param list $documentTypes */ public function withDocumentTypes(array $documentTypes): self { - $obj = clone $this; - $obj->document_types = $documentTypes; + $self = clone $this; + $self['documentTypes'] = $documentTypes; - return $obj; + return $self; } /** * List of business entities. * - * @param list $entities + * @param list|null, + * name?: string|null, + * registrationDate?: string|null, + * website?: string|null, + * }> $entities */ public function withEntities(array $entities): self { - $obj = clone $this; - $obj->entities = $entities; + $self = clone $this; + $self['entities'] = $entities; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetParticipantsResponse/Participant/DocumentType.php b/src/Lookup/LookupGetParticipantsResponse/Participant/DocumentType.php index c7b74428..95de15e7 100644 --- a/src/Lookup/LookupGetParticipantsResponse/Participant/DocumentType.php +++ b/src/Lookup/LookupGetParticipantsResponse/Participant/DocumentType.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class DocumentType implements BaseModel /** * Document type scheme. */ - #[Api] + #[Required] public string $scheme; /** * Document type value. */ - #[Api] + #[Required] public string $value; /** @@ -56,12 +56,12 @@ public function __construct() */ public static function with(string $scheme, string $value): self { - $obj = new self; + $self = new self; - $obj->scheme = $scheme; - $obj->value = $value; + $self['scheme'] = $scheme; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -69,10 +69,10 @@ public static function with(string $scheme, string $value): self */ public function withScheme(string $scheme): self { - $obj = clone $this; - $obj->scheme = $scheme; + $self = clone $this; + $self['scheme'] = $scheme; - return $obj; + return $self; } /** @@ -80,9 +80,9 @@ public function withScheme(string $scheme): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetParticipantsResponse/Participant/Entity.php b/src/Lookup/LookupGetParticipantsResponse/Participant/Entity.php index c4f98d67..a227470a 100644 --- a/src/Lookup/LookupGetParticipantsResponse/Participant/Entity.php +++ b/src/Lookup/LookupGetParticipantsResponse/Participant/Entity.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\Entity\Identifier; @@ -13,12 +13,12 @@ * Represents a business entity. * * @phpstan-type EntityShape = array{ - * additional_info?: string|null, - * country_code?: string|null, - * geo_info?: string|null, + * additionalInfo?: string|null, + * countryCode?: string|null, + * geoInfo?: string|null, * identifiers?: list|null, * name?: string|null, - * registration_date?: string|null, + * registrationDate?: string|null, * website?: string|null, * } */ @@ -30,45 +30,45 @@ final class Entity implements BaseModel /** * Additional information. */ - #[Api(nullable: true, optional: true)] - public ?string $additional_info; + #[Optional('additional_info', nullable: true)] + public ?string $additionalInfo; /** * Country code. */ - #[Api(nullable: true, optional: true)] - public ?string $country_code; + #[Optional('country_code', nullable: true)] + public ?string $countryCode; /** * Geographic information. */ - #[Api(nullable: true, optional: true)] - public ?string $geo_info; + #[Optional('geo_info', nullable: true)] + public ?string $geoInfo; /** * List of business identifiers. * * @var list|null $identifiers */ - #[Api(list: Identifier::class, optional: true)] + #[Optional(list: Identifier::class)] public ?array $identifiers; /** * Business entity name. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * Registration date. */ - #[Api(nullable: true, optional: true)] - public ?string $registration_date; + #[Optional('registration_date', nullable: true)] + public ?string $registrationDate; /** * Website URL. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $website; public function __construct() @@ -81,28 +81,28 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $identifiers + * @param list $identifiers */ public static function with( - ?string $additional_info = null, - ?string $country_code = null, - ?string $geo_info = null, + ?string $additionalInfo = null, + ?string $countryCode = null, + ?string $geoInfo = null, ?array $identifiers = null, ?string $name = null, - ?string $registration_date = null, + ?string $registrationDate = null, ?string $website = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $country_code && $obj->country_code = $country_code; - null !== $geo_info && $obj->geo_info = $geo_info; - null !== $identifiers && $obj->identifiers = $identifiers; - null !== $name && $obj->name = $name; - null !== $registration_date && $obj->registration_date = $registration_date; - null !== $website && $obj->website = $website; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $countryCode && $self['countryCode'] = $countryCode; + null !== $geoInfo && $self['geoInfo'] = $geoInfo; + null !== $identifiers && $self['identifiers'] = $identifiers; + null !== $name && $self['name'] = $name; + null !== $registrationDate && $self['registrationDate'] = $registrationDate; + null !== $website && $self['website'] = $website; - return $obj; + return $self; } /** @@ -110,10 +110,10 @@ public static function with( */ public function withAdditionalInfo(?string $additionalInfo): self { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -121,10 +121,10 @@ public function withAdditionalInfo(?string $additionalInfo): self */ public function withCountryCode(?string $countryCode): self { - $obj = clone $this; - $obj->country_code = $countryCode; + $self = clone $this; + $self['countryCode'] = $countryCode; - return $obj; + return $self; } /** @@ -132,23 +132,23 @@ public function withCountryCode(?string $countryCode): self */ public function withGeoInfo(?string $geoInfo): self { - $obj = clone $this; - $obj->geo_info = $geoInfo; + $self = clone $this; + $self['geoInfo'] = $geoInfo; - return $obj; + return $self; } /** * List of business identifiers. * - * @param list $identifiers + * @param list $identifiers */ public function withIdentifiers(array $identifiers): self { - $obj = clone $this; - $obj->identifiers = $identifiers; + $self = clone $this; + $self['identifiers'] = $identifiers; - return $obj; + return $self; } /** @@ -156,10 +156,10 @@ public function withIdentifiers(array $identifiers): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -167,10 +167,10 @@ public function withName(?string $name): self */ public function withRegistrationDate(?string $registrationDate): self { - $obj = clone $this; - $obj->registration_date = $registrationDate; + $self = clone $this; + $self['registrationDate'] = $registrationDate; - return $obj; + return $self; } /** @@ -178,9 +178,9 @@ public function withRegistrationDate(?string $registrationDate): self */ public function withWebsite(?string $website): self { - $obj = clone $this; - $obj->website = $website; + $self = clone $this; + $self['website'] = $website; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetParticipantsResponse/Participant/Entity/Identifier.php b/src/Lookup/LookupGetParticipantsResponse/Participant/Entity/Identifier.php index b4797c25..533d3bdd 100644 --- a/src/Lookup/LookupGetParticipantsResponse/Participant/Entity/Identifier.php +++ b/src/Lookup/LookupGetParticipantsResponse/Participant/Entity/Identifier.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetParticipantsResponse\Participant\Entity; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class Identifier implements BaseModel /** * Identifier scheme. */ - #[Api] + #[Required] public string $scheme; /** * Identifier value. */ - #[Api] + #[Required] public string $value; /** @@ -56,12 +56,12 @@ public function __construct() */ public static function with(string $scheme, string $value): self { - $obj = new self; + $self = new self; - $obj->scheme = $scheme; - $obj->value = $value; + $self['scheme'] = $scheme; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -69,10 +69,10 @@ public static function with(string $scheme, string $value): self */ public function withScheme(string $scheme): self { - $obj = clone $this; - $obj->scheme = $scheme; + $self = clone $this; + $self['scheme'] = $scheme; - return $obj; + return $self; } /** @@ -80,9 +80,9 @@ public function withScheme(string $scheme): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse.php b/src/Lookup/LookupGetResponse.php index 55d7ab71..aec82ec8 100644 --- a/src/Lookup/LookupGetResponse.php +++ b/src/Lookup/LookupGetResponse.php @@ -4,15 +4,16 @@ namespace EInvoiceAPI\Lookup; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; use EInvoiceAPI\Lookup\LookupGetResponse\BusinessCard; +use EInvoiceAPI\Lookup\LookupGetResponse\BusinessCard\Entity; use EInvoiceAPI\Lookup\LookupGetResponse\DNSInfo; +use EInvoiceAPI\Lookup\LookupGetResponse\DNSInfo\DNSRecord; use EInvoiceAPI\Lookup\LookupGetResponse\QueryMetadata; use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata; +use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint; /** * Response from a Peppol ID lookup operation. @@ -37,17 +38,15 @@ * status: string, * } */ -final class LookupGetResponse implements BaseModel, ResponseConverter +final class LookupGetResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Business card information for the Peppol participant. */ - #[Api] + #[Required] public BusinessCard $businessCard; /** @@ -55,13 +54,13 @@ final class LookupGetResponse implements BaseModel, ResponseConverter * * @var list $certificates */ - #[Api(list: Certificate::class)] + #[Required(list: Certificate::class)] public array $certificates; /** * Information about the DNS lookup performed. */ - #[Api] + #[Required] public DNSInfo $dnsInfo; /** @@ -69,31 +68,31 @@ final class LookupGetResponse implements BaseModel, ResponseConverter * * @var list $errors */ - #[Api(list: 'string')] + #[Required(list: 'string')] public array $errors; /** * Total execution time of the lookup operation in milliseconds. */ - #[Api] + #[Required] public float $executionTimeMs; /** * Metadata about the query that was performed. */ - #[Api] + #[Required] public QueryMetadata $queryMetadata; /** * Service metadata information for the Peppol participant. */ - #[Api] + #[Required] public ServiceMetadata $serviceMetadata; /** * Overall status of the lookup: 'success' or 'error'. */ - #[Api] + #[Required] public string $status; /** @@ -137,66 +136,109 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $certificates + * @param BusinessCard|array{ + * entities: list, + * queryTimeMs: float, + * status: string, + * error?: string|null, + * } $businessCard + * @param list|null, error?: string|null + * }> $certificates + * @param DNSInfo|array{ + * dnsRecords: list, + * smlHostname: string, + * status: string, + * error?: string|null, + * } $dnsInfo * @param list $errors + * @param QueryMetadata|array{ + * identifierScheme: string, + * identifierValue: string, + * smlDomain: string, + * timestamp: string, + * version: string, + * } $queryMetadata + * @param ServiceMetadata|array{ + * endpoints: list, + * queryTimeMs: float, + * status: string, + * error?: string|null, + * } $serviceMetadata */ public static function with( - BusinessCard $businessCard, + BusinessCard|array $businessCard, array $certificates, - DNSInfo $dnsInfo, + DNSInfo|array $dnsInfo, array $errors, float $executionTimeMs, - QueryMetadata $queryMetadata, - ServiceMetadata $serviceMetadata, + QueryMetadata|array $queryMetadata, + ServiceMetadata|array $serviceMetadata, string $status, ): self { - $obj = new self; - - $obj->businessCard = $businessCard; - $obj->certificates = $certificates; - $obj->dnsInfo = $dnsInfo; - $obj->errors = $errors; - $obj->executionTimeMs = $executionTimeMs; - $obj->queryMetadata = $queryMetadata; - $obj->serviceMetadata = $serviceMetadata; - $obj->status = $status; - - return $obj; + $self = new self; + + $self['businessCard'] = $businessCard; + $self['certificates'] = $certificates; + $self['dnsInfo'] = $dnsInfo; + $self['errors'] = $errors; + $self['executionTimeMs'] = $executionTimeMs; + $self['queryMetadata'] = $queryMetadata; + $self['serviceMetadata'] = $serviceMetadata; + $self['status'] = $status; + + return $self; } /** * Business card information for the Peppol participant. + * + * @param BusinessCard|array{ + * entities: list, + * queryTimeMs: float, + * status: string, + * error?: string|null, + * } $businessCard */ - public function withBusinessCard(BusinessCard $businessCard): self + public function withBusinessCard(BusinessCard|array $businessCard): self { - $obj = clone $this; - $obj->businessCard = $businessCard; + $self = clone $this; + $self['businessCard'] = $businessCard; - return $obj; + return $self; } /** * List of certificates found for the Peppol participant. * - * @param list $certificates + * @param list|null, error?: string|null + * }> $certificates */ public function withCertificates(array $certificates): self { - $obj = clone $this; - $obj->certificates = $certificates; + $self = clone $this; + $self['certificates'] = $certificates; - return $obj; + return $self; } /** * Information about the DNS lookup performed. + * + * @param DNSInfo|array{ + * dnsRecords: list, + * smlHostname: string, + * status: string, + * error?: string|null, + * } $dnsInfo */ - public function withDNSInfo(DNSInfo $dnsInfo): self + public function withDNSInfo(DNSInfo|array $dnsInfo): self { - $obj = clone $this; - $obj->dnsInfo = $dnsInfo; + $self = clone $this; + $self['dnsInfo'] = $dnsInfo; - return $obj; + return $self; } /** @@ -206,10 +248,10 @@ public function withDNSInfo(DNSInfo $dnsInfo): self */ public function withErrors(array $errors): self { - $obj = clone $this; - $obj->errors = $errors; + $self = clone $this; + $self['errors'] = $errors; - return $obj; + return $self; } /** @@ -217,32 +259,48 @@ public function withErrors(array $errors): self */ public function withExecutionTimeMs(float $executionTimeMs): self { - $obj = clone $this; - $obj->executionTimeMs = $executionTimeMs; + $self = clone $this; + $self['executionTimeMs'] = $executionTimeMs; - return $obj; + return $self; } /** * Metadata about the query that was performed. + * + * @param QueryMetadata|array{ + * identifierScheme: string, + * identifierValue: string, + * smlDomain: string, + * timestamp: string, + * version: string, + * } $queryMetadata */ - public function withQueryMetadata(QueryMetadata $queryMetadata): self + public function withQueryMetadata(QueryMetadata|array $queryMetadata): self { - $obj = clone $this; - $obj->queryMetadata = $queryMetadata; + $self = clone $this; + $self['queryMetadata'] = $queryMetadata; - return $obj; + return $self; } /** * Service metadata information for the Peppol participant. + * + * @param ServiceMetadata|array{ + * endpoints: list, + * queryTimeMs: float, + * status: string, + * error?: string|null, + * } $serviceMetadata */ - public function withServiceMetadata(ServiceMetadata $serviceMetadata): self - { - $obj = clone $this; - $obj->serviceMetadata = $serviceMetadata; + public function withServiceMetadata( + ServiceMetadata|array $serviceMetadata + ): self { + $self = clone $this; + $self['serviceMetadata'] = $serviceMetadata; - return $obj; + return $self; } /** @@ -250,9 +308,9 @@ public function withServiceMetadata(ServiceMetadata $serviceMetadata): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/BusinessCard.php b/src/Lookup/LookupGetResponse/BusinessCard.php index c2c55f86..bdd6dd6e 100644 --- a/src/Lookup/LookupGetResponse/BusinessCard.php +++ b/src/Lookup/LookupGetResponse/BusinessCard.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\LookupGetResponse\BusinessCard\Entity; @@ -29,25 +30,25 @@ final class BusinessCard implements BaseModel * * @var list $entities */ - #[Api(list: Entity::class)] + #[Required(list: Entity::class)] public array $entities; /** * Time taken to query the business card in milliseconds. */ - #[Api] + #[Required] public float $queryTimeMs; /** * Status of the business card lookup: 'success', 'error', or 'pending'. */ - #[Api] + #[Required] public string $status; /** * Error message if business card lookup failed. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $error; /** @@ -74,7 +75,12 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $entities + * @param list|null, + * countryCode?: string|null, + * name?: string|null, + * registrationDate?: string|null, + * }> $entities */ public static function with( array $entities, @@ -82,28 +88,33 @@ public static function with( string $status, ?string $error = null ): self { - $obj = new self; + $self = new self; - $obj->entities = $entities; - $obj->queryTimeMs = $queryTimeMs; - $obj->status = $status; + $self['entities'] = $entities; + $self['queryTimeMs'] = $queryTimeMs; + $self['status'] = $status; - null !== $error && $obj->error = $error; + null !== $error && $self['error'] = $error; - return $obj; + return $self; } /** * List of business entities associated with the Peppol ID. * - * @param list $entities + * @param list|null, + * countryCode?: string|null, + * name?: string|null, + * registrationDate?: string|null, + * }> $entities */ public function withEntities(array $entities): self { - $obj = clone $this; - $obj->entities = $entities; + $self = clone $this; + $self['entities'] = $entities; - return $obj; + return $self; } /** @@ -111,10 +122,10 @@ public function withEntities(array $entities): self */ public function withQueryTimeMs(float $queryTimeMs): self { - $obj = clone $this; - $obj->queryTimeMs = $queryTimeMs; + $self = clone $this; + $self['queryTimeMs'] = $queryTimeMs; - return $obj; + return $self; } /** @@ -122,10 +133,10 @@ public function withQueryTimeMs(float $queryTimeMs): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -133,9 +144,9 @@ public function withStatus(string $status): self */ public function withError(?string $error): self { - $obj = clone $this; - $obj->error = $error; + $self = clone $this; + $self['error'] = $error; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/BusinessCard/Entity.php b/src/Lookup/LookupGetResponse/BusinessCard/Entity.php index d6d72e0b..8974e3b3 100644 --- a/src/Lookup/LookupGetResponse/BusinessCard/Entity.php +++ b/src/Lookup/LookupGetResponse/BusinessCard/Entity.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\BusinessCard; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -28,25 +28,25 @@ final class Entity implements BaseModel * * @var list|null $additionalInformation */ - #[Api(list: 'string', nullable: true, optional: true)] + #[Optional(list: 'string', nullable: true)] public ?array $additionalInformation; /** * ISO 3166-1 alpha-2 country code of the business entity. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $countryCode; /** * Name of the business entity. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * ISO 8601 date of when the entity was registered in Peppol. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $registrationDate; public function __construct() @@ -67,14 +67,14 @@ public static function with( ?string $name = null, ?string $registrationDate = null, ): self { - $obj = new self; + $self = new self; - null !== $additionalInformation && $obj->additionalInformation = $additionalInformation; - null !== $countryCode && $obj->countryCode = $countryCode; - null !== $name && $obj->name = $name; - null !== $registrationDate && $obj->registrationDate = $registrationDate; + null !== $additionalInformation && $self['additionalInformation'] = $additionalInformation; + null !== $countryCode && $self['countryCode'] = $countryCode; + null !== $name && $self['name'] = $name; + null !== $registrationDate && $self['registrationDate'] = $registrationDate; - return $obj; + return $self; } /** @@ -85,10 +85,10 @@ public static function with( public function withAdditionalInformation( ?array $additionalInformation ): self { - $obj = clone $this; - $obj->additionalInformation = $additionalInformation; + $self = clone $this; + $self['additionalInformation'] = $additionalInformation; - return $obj; + return $self; } /** @@ -96,10 +96,10 @@ public function withAdditionalInformation( */ public function withCountryCode(?string $countryCode): self { - $obj = clone $this; - $obj->countryCode = $countryCode; + $self = clone $this; + $self['countryCode'] = $countryCode; - return $obj; + return $self; } /** @@ -107,10 +107,10 @@ public function withCountryCode(?string $countryCode): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -118,9 +118,9 @@ public function withName(?string $name): self */ public function withRegistrationDate(?string $registrationDate): self { - $obj = clone $this; - $obj->registrationDate = $registrationDate; + $self = clone $this; + $self['registrationDate'] = $registrationDate; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/DNSInfo.php b/src/Lookup/LookupGetResponse/DNSInfo.php index 4b55d8a1..7c3801d7 100644 --- a/src/Lookup/LookupGetResponse/DNSInfo.php +++ b/src/Lookup/LookupGetResponse/DNSInfo.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\LookupGetResponse\DNSInfo\DNSRecord; @@ -29,25 +30,25 @@ final class DNSInfo implements BaseModel * * @var list $dnsRecords */ - #[Api(list: DNSRecord::class)] + #[Required(list: DNSRecord::class)] public array $dnsRecords; /** * Hostname of the SML used for the query. */ - #[Api] + #[Required] public string $smlHostname; /** * Status of the DNS lookup: 'success', 'error', or 'pending'. */ - #[Api] + #[Required] public string $status; /** * Error message if the DNS lookup failed. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $error; /** @@ -74,7 +75,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $dnsRecords + * @param list $dnsRecords */ public static function with( array $dnsRecords, @@ -82,28 +83,28 @@ public static function with( string $status, ?string $error = null, ): self { - $obj = new self; + $self = new self; - $obj->dnsRecords = $dnsRecords; - $obj->smlHostname = $smlHostname; - $obj->status = $status; + $self['dnsRecords'] = $dnsRecords; + $self['smlHostname'] = $smlHostname; + $self['status'] = $status; - null !== $error && $obj->error = $error; + null !== $error && $self['error'] = $error; - return $obj; + return $self; } /** * List of DNS records found for the Peppol participant. * - * @param list $dnsRecords + * @param list $dnsRecords */ public function withDNSRecords(array $dnsRecords): self { - $obj = clone $this; - $obj->dnsRecords = $dnsRecords; + $self = clone $this; + $self['dnsRecords'] = $dnsRecords; - return $obj; + return $self; } /** @@ -111,10 +112,10 @@ public function withDNSRecords(array $dnsRecords): self */ public function withSmlHostname(string $smlHostname): self { - $obj = clone $this; - $obj->smlHostname = $smlHostname; + $self = clone $this; + $self['smlHostname'] = $smlHostname; - return $obj; + return $self; } /** @@ -122,10 +123,10 @@ public function withSmlHostname(string $smlHostname): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -133,9 +134,9 @@ public function withStatus(string $status): self */ public function withError(?string $error): self { - $obj = clone $this; - $obj->error = $error; + $self = clone $this; + $self['error'] = $error; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/DNSInfo/DNSRecord.php b/src/Lookup/LookupGetResponse/DNSInfo/DNSRecord.php index 7e41bd66..7b793573 100644 --- a/src/Lookup/LookupGetResponse/DNSInfo/DNSRecord.php +++ b/src/Lookup/LookupGetResponse/DNSInfo/DNSRecord.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\DNSInfo; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,7 +21,7 @@ final class DNSRecord implements BaseModel /** * IP address found in the DNS record. */ - #[Api] + #[Required] public string $ip; /** @@ -50,11 +50,11 @@ public function __construct() */ public static function with(string $ip): self { - $obj = new self; + $self = new self; - $obj->ip = $ip; + $self['ip'] = $ip; - return $obj; + return $self; } /** @@ -62,9 +62,9 @@ public static function with(string $ip): self */ public function withIP(string $ip): self { - $obj = clone $this; - $obj->ip = $ip; + $self = clone $this; + $self['ip'] = $ip; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/QueryMetadata.php b/src/Lookup/LookupGetResponse/QueryMetadata.php index c035a59e..bd968e2c 100644 --- a/src/Lookup/LookupGetResponse/QueryMetadata.php +++ b/src/Lookup/LookupGetResponse/QueryMetadata.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -27,31 +27,31 @@ final class QueryMetadata implements BaseModel /** * Scheme of the identifier, typically 'iso6523-actorid-upis'. */ - #[Api] + #[Required] public string $identifierScheme; /** * The actual Peppol ID value being queried. */ - #[Api] + #[Required] public string $identifierValue; /** * Domain of the SML (Service Metadata Locator) used for the lookup. */ - #[Api] + #[Required] public string $smlDomain; /** * ISO 8601 timestamp of when the query was executed. */ - #[Api] + #[Required] public string $timestamp; /** * Version of the API used for the lookup. */ - #[Api] + #[Required] public string $version; /** @@ -96,15 +96,15 @@ public static function with( string $timestamp, string $version, ): self { - $obj = new self; + $self = new self; - $obj->identifierScheme = $identifierScheme; - $obj->identifierValue = $identifierValue; - $obj->smlDomain = $smlDomain; - $obj->timestamp = $timestamp; - $obj->version = $version; + $self['identifierScheme'] = $identifierScheme; + $self['identifierValue'] = $identifierValue; + $self['smlDomain'] = $smlDomain; + $self['timestamp'] = $timestamp; + $self['version'] = $version; - return $obj; + return $self; } /** @@ -112,10 +112,10 @@ public static function with( */ public function withIdentifierScheme(string $identifierScheme): self { - $obj = clone $this; - $obj->identifierScheme = $identifierScheme; + $self = clone $this; + $self['identifierScheme'] = $identifierScheme; - return $obj; + return $self; } /** @@ -123,10 +123,10 @@ public function withIdentifierScheme(string $identifierScheme): self */ public function withIdentifierValue(string $identifierValue): self { - $obj = clone $this; - $obj->identifierValue = $identifierValue; + $self = clone $this; + $self['identifierValue'] = $identifierValue; - return $obj; + return $self; } /** @@ -134,10 +134,10 @@ public function withIdentifierValue(string $identifierValue): self */ public function withSmlDomain(string $smlDomain): self { - $obj = clone $this; - $obj->smlDomain = $smlDomain; + $self = clone $this; + $self['smlDomain'] = $smlDomain; - return $obj; + return $self; } /** @@ -145,10 +145,10 @@ public function withSmlDomain(string $smlDomain): self */ public function withTimestamp(string $timestamp): self { - $obj = clone $this; - $obj->timestamp = $timestamp; + $self = clone $this; + $self['timestamp'] = $timestamp; - return $obj; + return $self; } /** @@ -156,9 +156,9 @@ public function withTimestamp(string $timestamp): self */ public function withVersion(string $version): self { - $obj = clone $this; - $obj->version = $version; + $self = clone $this; + $self['version'] = $version; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/ServiceMetadata.php b/src/Lookup/LookupGetResponse/ServiceMetadata.php index ff5a2a0d..afcbb0aa 100644 --- a/src/Lookup/LookupGetResponse/ServiceMetadata.php +++ b/src/Lookup/LookupGetResponse/ServiceMetadata.php @@ -4,10 +4,13 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint; +use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\DocumentType; +use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process; /** * Service metadata information for the Peppol participant. @@ -29,25 +32,25 @@ final class ServiceMetadata implements BaseModel * * @var list $endpoints */ - #[Api(list: Endpoint::class)] + #[Required(list: Endpoint::class)] public array $endpoints; /** * Time taken to query the service metadata in milliseconds. */ - #[Api] + #[Required] public float $queryTimeMs; /** * Status of the service metadata lookup: 'success', 'error', or 'pending'. */ - #[Api] + #[Required] public string $status; /** * Error message if service metadata lookup failed. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $error; /** @@ -74,7 +77,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $endpoints + * @param list, + * status: string, + * url: string, + * error?: string|null, + * processes?: list|null, + * }> $endpoints */ public static function with( array $endpoints, @@ -82,28 +91,34 @@ public static function with( string $status, ?string $error = null ): self { - $obj = new self; + $self = new self; - $obj->endpoints = $endpoints; - $obj->queryTimeMs = $queryTimeMs; - $obj->status = $status; + $self['endpoints'] = $endpoints; + $self['queryTimeMs'] = $queryTimeMs; + $self['status'] = $status; - null !== $error && $obj->error = $error; + null !== $error && $self['error'] = $error; - return $obj; + return $self; } /** * List of endpoints found for the Peppol participant. * - * @param list $endpoints + * @param list, + * status: string, + * url: string, + * error?: string|null, + * processes?: list|null, + * }> $endpoints */ public function withEndpoints(array $endpoints): self { - $obj = clone $this; - $obj->endpoints = $endpoints; + $self = clone $this; + $self['endpoints'] = $endpoints; - return $obj; + return $self; } /** @@ -111,10 +126,10 @@ public function withEndpoints(array $endpoints): self */ public function withQueryTimeMs(float $queryTimeMs): self { - $obj = clone $this; - $obj->queryTimeMs = $queryTimeMs; + $self = clone $this; + $self['queryTimeMs'] = $queryTimeMs; - return $obj; + return $self; } /** @@ -122,10 +137,10 @@ public function withQueryTimeMs(float $queryTimeMs): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -133,9 +148,9 @@ public function withStatus(string $status): self */ public function withError(?string $error): self { - $obj = clone $this; - $obj->error = $error; + $self = clone $this; + $self['error'] = $error; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint.php b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint.php index 9b984a75..499f6a01 100644 --- a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint.php +++ b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint.php @@ -4,11 +4,13 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\DocumentType; use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process; +use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process\ProcessID; /** * Information about a Peppol participant's endpoint. @@ -31,25 +33,25 @@ final class Endpoint implements BaseModel * * @var list $documentTypes */ - #[Api(list: DocumentType::class)] + #[Required(list: DocumentType::class)] public array $documentTypes; /** * Status of the endpoint lookup: 'success', 'error', or 'pending'. */ - #[Api] + #[Required] public string $status; /** * URL of the endpoint. */ - #[Api] + #[Required] public string $url; /** * Error message if endpoint lookup failed. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $error; /** @@ -57,7 +59,7 @@ final class Endpoint implements BaseModel * * @var list|null $processes */ - #[Api(list: Process::class, nullable: true, optional: true)] + #[Optional(list: Process::class, nullable: true)] public ?array $processes; /** @@ -84,8 +86,11 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $documentTypes - * @param list|null $processes + * @param list $documentTypes + * @param list, + * processID: ProcessID, + * }>|null $processes */ public static function with( array $documentTypes, @@ -94,29 +99,29 @@ public static function with( ?string $error = null, ?array $processes = null, ): self { - $obj = new self; + $self = new self; - $obj->documentTypes = $documentTypes; - $obj->status = $status; - $obj->url = $url; + $self['documentTypes'] = $documentTypes; + $self['status'] = $status; + $self['url'] = $url; - null !== $error && $obj->error = $error; - null !== $processes && $obj->processes = $processes; + null !== $error && $self['error'] = $error; + null !== $processes && $self['processes'] = $processes; - return $obj; + return $self; } /** * List of document types supported by this endpoint. * - * @param list $documentTypes + * @param list $documentTypes */ public function withDocumentTypes(array $documentTypes): self { - $obj = clone $this; - $obj->documentTypes = $documentTypes; + $self = clone $this; + $self['documentTypes'] = $documentTypes; - return $obj; + return $self; } /** @@ -124,10 +129,10 @@ public function withDocumentTypes(array $documentTypes): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -135,10 +140,10 @@ public function withStatus(string $status): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj->url = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -146,22 +151,25 @@ public function withURL(string $url): self */ public function withError(?string $error): self { - $obj = clone $this; - $obj->error = $error; + $self = clone $this; + $self['error'] = $error; - return $obj; + return $self; } /** * List of processes supported by this endpoint. * - * @param list|null $processes + * @param list, + * processID: ProcessID, + * }>|null $processes */ public function withProcesses(?array $processes): self { - $obj = clone $this; - $obj->processes = $processes; + $self = clone $this; + $self['processes'] = $processes; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/DocumentType.php b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/DocumentType.php index c23e4b4f..690b703f 100644 --- a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/DocumentType.php +++ b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/DocumentType.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class DocumentType implements BaseModel /** * Scheme of the document type identifier. */ - #[Api] + #[Required] public string $scheme; /** * Value of the document type identifier. */ - #[Api] + #[Required] public string $value; /** @@ -56,12 +56,12 @@ public function __construct() */ public static function with(string $scheme, string $value): self { - $obj = new self; + $self = new self; - $obj->scheme = $scheme; - $obj->value = $value; + $self['scheme'] = $scheme; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -69,10 +69,10 @@ public static function with(string $scheme, string $value): self */ public function withScheme(string $scheme): self { - $obj = clone $this; - $obj->scheme = $scheme; + $self = clone $this; + $self['scheme'] = $scheme; - return $obj; + return $self; } /** @@ -80,9 +80,9 @@ public function withScheme(string $scheme): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process.php b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process.php index fb916a63..dca18dd9 100644 --- a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process.php +++ b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process.php @@ -4,9 +4,10 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; +use EInvoiceAPI\Lookup\Certificate; use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process\Endpoint; use EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process\ProcessID; @@ -14,7 +15,7 @@ * Process information in the Peppol network. * * @phpstan-type ProcessShape = array{ - * endpoints: list, processId: ProcessID + * endpoints: list, processID: ProcessID * } */ final class Process implements BaseModel @@ -27,21 +28,21 @@ final class Process implements BaseModel * * @var list $endpoints */ - #[Api(list: Endpoint::class)] + #[Required(list: Endpoint::class)] public array $endpoints; /** * Identifier of the process. */ - #[Api] - public ProcessID $processId; + #[Required('processId')] + public ProcessID $processID; /** * `new Process()` is missing required properties by the API. * * To enforce required parameters use * ``` - * Process::with(endpoints: ..., processId: ...) + * Process::with(endpoints: ..., processID: ...) * ``` * * Otherwise ensure the following setters are called @@ -60,39 +61,62 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $endpoints + * @param list $endpoints + * @param ProcessID|array{scheme: string, value: string} $processID */ - public static function with(array $endpoints, ProcessID $processId): self - { - $obj = new self; + public static function with( + array $endpoints, + ProcessID|array $processID + ): self { + $self = new self; - $obj->endpoints = $endpoints; - $obj->processId = $processId; + $self['endpoints'] = $endpoints; + $self['processID'] = $processID; - return $obj; + return $self; } /** * List of endpoints supporting this process. * - * @param list $endpoints + * @param list $endpoints */ public function withEndpoints(array $endpoints): self { - $obj = clone $this; - $obj->endpoints = $endpoints; + $self = clone $this; + $self['endpoints'] = $endpoints; - return $obj; + return $self; } /** * Identifier of the process. + * + * @param ProcessID|array{scheme: string, value: string} $processID */ - public function withProcessID(ProcessID $processID): self + public function withProcessID(ProcessID|array $processID): self { - $obj = clone $this; - $obj->processId = $processID; + $self = clone $this; + $self['processID'] = $processID; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/Endpoint.php b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/Endpoint.php index 06fce25f..846138db 100644 --- a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/Endpoint.php +++ b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/Endpoint.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Lookup\Certificate; @@ -19,8 +20,8 @@ * serviceActivationDate?: string|null, * serviceDescription?: string|null, * serviceExpirationDate?: string|null, - * technicalContactUrl?: string|null, - * technicalInformationUrl?: string|null, + * technicalContactURL?: string|null, + * technicalInformationURL?: string|null, * } */ final class Endpoint implements BaseModel @@ -31,50 +32,50 @@ final class Endpoint implements BaseModel /** * URL or address of the endpoint. */ - #[Api] + #[Required] public string $address; /** * Transport profile used by this endpoint. */ - #[Api] + #[Required] public string $transportProfile; /** * Certificate information for a Peppol endpoint. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?Certificate $certificate; /** * ISO 8601 date when the service was activated. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $serviceActivationDate; /** * Human-readable description of the service. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $serviceDescription; /** * ISO 8601 date when the service will expire. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $serviceExpirationDate; /** * URL for technical contact information. */ - #[Api(nullable: true, optional: true)] - public ?string $technicalContactUrl; + #[Optional('technicalContactUrl', nullable: true)] + public ?string $technicalContactURL; /** * URL for technical documentation. */ - #[Api(nullable: true, optional: true)] - public ?string $technicalInformationUrl; + #[Optional('technicalInformationUrl', nullable: true)] + public ?string $technicalInformationURL; /** * `new Endpoint()` is missing required properties by the API. @@ -99,30 +100,34 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param Certificate|array{ + * status: string, details?: array|null, error?: string|null + * }|null $certificate */ public static function with( string $address, string $transportProfile, - ?Certificate $certificate = null, + Certificate|array|null $certificate = null, ?string $serviceActivationDate = null, ?string $serviceDescription = null, ?string $serviceExpirationDate = null, - ?string $technicalContactUrl = null, - ?string $technicalInformationUrl = null, + ?string $technicalContactURL = null, + ?string $technicalInformationURL = null, ): self { - $obj = new self; + $self = new self; - $obj->address = $address; - $obj->transportProfile = $transportProfile; + $self['address'] = $address; + $self['transportProfile'] = $transportProfile; - null !== $certificate && $obj->certificate = $certificate; - null !== $serviceActivationDate && $obj->serviceActivationDate = $serviceActivationDate; - null !== $serviceDescription && $obj->serviceDescription = $serviceDescription; - null !== $serviceExpirationDate && $obj->serviceExpirationDate = $serviceExpirationDate; - null !== $technicalContactUrl && $obj->technicalContactUrl = $technicalContactUrl; - null !== $technicalInformationUrl && $obj->technicalInformationUrl = $technicalInformationUrl; + null !== $certificate && $self['certificate'] = $certificate; + null !== $serviceActivationDate && $self['serviceActivationDate'] = $serviceActivationDate; + null !== $serviceDescription && $self['serviceDescription'] = $serviceDescription; + null !== $serviceExpirationDate && $self['serviceExpirationDate'] = $serviceExpirationDate; + null !== $technicalContactURL && $self['technicalContactURL'] = $technicalContactURL; + null !== $technicalInformationURL && $self['technicalInformationURL'] = $technicalInformationURL; - return $obj; + return $self; } /** @@ -130,10 +135,10 @@ public static function with( */ public function withAddress(string $address): self { - $obj = clone $this; - $obj->address = $address; + $self = clone $this; + $self['address'] = $address; - return $obj; + return $self; } /** @@ -141,21 +146,25 @@ public function withAddress(string $address): self */ public function withTransportProfile(string $transportProfile): self { - $obj = clone $this; - $obj->transportProfile = $transportProfile; + $self = clone $this; + $self['transportProfile'] = $transportProfile; - return $obj; + return $self; } /** * Certificate information for a Peppol endpoint. + * + * @param Certificate|array{ + * status: string, details?: array|null, error?: string|null + * }|null $certificate */ - public function withCertificate(?Certificate $certificate): self + public function withCertificate(Certificate|array|null $certificate): self { - $obj = clone $this; - $obj->certificate = $certificate; + $self = clone $this; + $self['certificate'] = $certificate; - return $obj; + return $self; } /** @@ -164,10 +173,10 @@ public function withCertificate(?Certificate $certificate): self public function withServiceActivationDate( ?string $serviceActivationDate ): self { - $obj = clone $this; - $obj->serviceActivationDate = $serviceActivationDate; + $self = clone $this; + $self['serviceActivationDate'] = $serviceActivationDate; - return $obj; + return $self; } /** @@ -175,10 +184,10 @@ public function withServiceActivationDate( */ public function withServiceDescription(?string $serviceDescription): self { - $obj = clone $this; - $obj->serviceDescription = $serviceDescription; + $self = clone $this; + $self['serviceDescription'] = $serviceDescription; - return $obj; + return $self; } /** @@ -187,10 +196,10 @@ public function withServiceDescription(?string $serviceDescription): self public function withServiceExpirationDate( ?string $serviceExpirationDate ): self { - $obj = clone $this; - $obj->serviceExpirationDate = $serviceExpirationDate; + $self = clone $this; + $self['serviceExpirationDate'] = $serviceExpirationDate; - return $obj; + return $self; } /** @@ -198,10 +207,10 @@ public function withServiceExpirationDate( */ public function withTechnicalContactURL(?string $technicalContactURL): self { - $obj = clone $this; - $obj->technicalContactUrl = $technicalContactURL; + $self = clone $this; + $self['technicalContactURL'] = $technicalContactURL; - return $obj; + return $self; } /** @@ -210,9 +219,9 @@ public function withTechnicalContactURL(?string $technicalContactURL): self public function withTechnicalInformationURL( ?string $technicalInformationURL ): self { - $obj = clone $this; - $obj->technicalInformationUrl = $technicalInformationURL; + $self = clone $this; + $self['technicalInformationURL'] = $technicalInformationURL; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/ProcessID.php b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/ProcessID.php index 8b9cb773..b7b263eb 100644 --- a/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/ProcessID.php +++ b/src/Lookup/LookupGetResponse/ServiceMetadata/Endpoint/Process/ProcessID.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup\LookupGetResponse\ServiceMetadata\Endpoint\Process; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class ProcessID implements BaseModel /** * Scheme of the process identifier. */ - #[Api] + #[Required] public string $scheme; /** * Value of the process identifier. */ - #[Api] + #[Required] public string $value; /** @@ -56,12 +56,12 @@ public function __construct() */ public static function with(string $scheme, string $value): self { - $obj = new self; + $self = new self; - $obj->scheme = $scheme; - $obj->value = $value; + $self['scheme'] = $scheme; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -69,10 +69,10 @@ public static function with(string $scheme, string $value): self */ public function withScheme(string $scheme): self { - $obj = clone $this; - $obj->scheme = $scheme; + $self = clone $this; + $self['scheme'] = $scheme; - return $obj; + return $self; } /** @@ -80,9 +80,9 @@ public function withScheme(string $scheme): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupRetrieveParams.php b/src/Lookup/LookupRetrieveParams.php index bd6ee433..2bb0c60d 100644 --- a/src/Lookup/LookupRetrieveParams.php +++ b/src/Lookup/LookupRetrieveParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Lookup; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -14,7 +14,7 @@ * * @see EInvoiceAPI\Services\LookupService::retrieve() * - * @phpstan-type LookupRetrieveParamsShape = array{peppol_id: string} + * @phpstan-type LookupRetrieveParamsShape = array{peppolID: string} */ final class LookupRetrieveParams implements BaseModel { @@ -25,15 +25,15 @@ final class LookupRetrieveParams implements BaseModel /** * Peppol ID in the format `:`. Example: `0208:1018265814` for a Belgian company. */ - #[Api] - public string $peppol_id; + #[Required] + public string $peppolID; /** * `new LookupRetrieveParams()` is missing required properties by the API. * * To enforce required parameters use * ``` - * LookupRetrieveParams::with(peppol_id: ...) + * LookupRetrieveParams::with(peppolID: ...) * ``` * * Otherwise ensure the following setters are called @@ -52,13 +52,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(string $peppol_id): self + public static function with(string $peppolID): self { - $obj = new self; + $self = new self; - $obj->peppol_id = $peppol_id; + $self['peppolID'] = $peppolID; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $peppol_id): self */ public function withPeppolID(string $peppolID): self { - $obj = clone $this; - $obj->peppol_id = $peppolID; + $self = clone $this; + $self['peppolID'] = $peppolID; - return $obj; + return $self; } } diff --git a/src/Lookup/LookupRetrieveParticipantsParams.php b/src/Lookup/LookupRetrieveParticipantsParams.php index 152c8195..32ce1229 100644 --- a/src/Lookup/LookupRetrieveParticipantsParams.php +++ b/src/Lookup/LookupRetrieveParticipantsParams.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Lookup; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -15,7 +16,7 @@ * @see EInvoiceAPI\Services\LookupService::retrieveParticipants() * * @phpstan-type LookupRetrieveParticipantsParamsShape = array{ - * query: string, country_code?: string|null + * query: string, countryCode?: string|null * } */ final class LookupRetrieveParticipantsParams implements BaseModel @@ -27,14 +28,14 @@ final class LookupRetrieveParticipantsParams implements BaseModel /** * Query to lookup. */ - #[Api] + #[Required] public string $query; /** * Country code of the company to lookup. If not provided, the search will be global. */ - #[Api(nullable: true, optional: true)] - public ?string $country_code; + #[Optional(nullable: true)] + public ?string $countryCode; /** * `new LookupRetrieveParticipantsParams()` is missing required properties by the API. @@ -62,15 +63,15 @@ public function __construct() */ public static function with( string $query, - ?string $country_code = null + ?string $countryCode = null ): self { - $obj = new self; + $self = new self; - $obj->query = $query; + $self['query'] = $query; - null !== $country_code && $obj->country_code = $country_code; + null !== $countryCode && $self['countryCode'] = $countryCode; - return $obj; + return $self; } /** @@ -78,10 +79,10 @@ public static function with( */ public function withQuery(string $query): self { - $obj = clone $this; - $obj->query = $query; + $self = clone $this; + $self['query'] = $query; - return $obj; + return $self; } /** @@ -89,9 +90,9 @@ public function withQuery(string $query): self */ public function withCountryCode(?string $countryCode): self { - $obj = clone $this; - $obj->country_code = $countryCode; + $self = clone $this; + $self['countryCode'] = $countryCode; - return $obj; + return $self; } } diff --git a/src/Me/MeGetResponse.php b/src/Me/MeGetResponse.php index 332c9441..513e2cd5 100644 --- a/src/Me/MeGetResponse.php +++ b/src/Me/MeGetResponse.php @@ -4,48 +4,45 @@ namespace EInvoiceAPI\Me; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; use EInvoiceAPI\Me\MeGetResponse\Plan; /** * @phpstan-type MeGetResponseShape = array{ - * credit_balance: int, + * creditBalance: int, * name: string, * plan: value-of, - * bcc_recipient_email?: string|null, - * company_address?: string|null, - * company_city?: string|null, - * company_country?: string|null, - * company_email?: string|null, - * company_name?: string|null, - * company_number?: string|null, - * company_tax_id?: string|null, - * company_zip?: string|null, + * bccRecipientEmail?: string|null, + * companyAddress?: string|null, + * companyCity?: string|null, + * companyCountry?: string|null, + * companyEmail?: string|null, + * companyName?: string|null, + * companyNumber?: string|null, + * companyTaxID?: string|null, + * companyZip?: string|null, * description?: string|null, * ibans?: list|null, - * peppol_ids?: list|null, - * smp_registration?: bool|null, - * smp_registration_date?: \DateTimeInterface|null, + * peppolIDs?: list|null, + * smpRegistration?: bool|null, + * smpRegistrationDate?: \DateTimeInterface|null, * } */ -final class MeGetResponse implements BaseModel, ResponseConverter +final class MeGetResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Credit balance of the tenant. */ - #[Api] - public int $credit_balance; + #[Required('credit_balance')] + public int $creditBalance; - #[Api] + #[Required] public string $name; /** @@ -53,64 +50,64 @@ final class MeGetResponse implements BaseModel, ResponseConverter * * @var value-of $plan */ - #[Api(enum: Plan::class)] + #[Required(enum: Plan::class)] public string $plan; /** * BCC recipient email to deliver documents. */ - #[Api(nullable: true, optional: true)] - public ?string $bcc_recipient_email; + #[Optional('bcc_recipient_email', nullable: true)] + public ?string $bccRecipientEmail; /** * Address of the company. Must be in the form of `Street Name Street Number`. */ - #[Api(nullable: true, optional: true)] - public ?string $company_address; + #[Optional('company_address', nullable: true)] + public ?string $companyAddress; /** * City of the company. */ - #[Api(nullable: true, optional: true)] - public ?string $company_city; + #[Optional('company_city', nullable: true)] + public ?string $companyCity; /** * Country of the company. */ - #[Api(nullable: true, optional: true)] - public ?string $company_country; + #[Optional('company_country', nullable: true)] + public ?string $companyCountry; /** * Email of the company. */ - #[Api(nullable: true, optional: true)] - public ?string $company_email; + #[Optional('company_email', nullable: true)] + public ?string $companyEmail; /** * Name of the company. Must include the company type. For example: `BV`, `NV`, `CVBA`, `VOF`. */ - #[Api(nullable: true, optional: true)] - public ?string $company_name; + #[Optional('company_name', nullable: true)] + public ?string $companyName; /** * Company number. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. */ - #[Api(nullable: true, optional: true)] - public ?string $company_number; + #[Optional('company_number', nullable: true)] + public ?string $companyNumber; /** * Company tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $company_tax_id; + #[Optional('company_tax_id', nullable: true)] + public ?string $companyTaxID; /** * Zip code of the company. */ - #[Api(nullable: true, optional: true)] - public ?string $company_zip; + #[Optional('company_zip', nullable: true)] + public ?string $companyZip; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** @@ -118,35 +115,35 @@ final class MeGetResponse implements BaseModel, ResponseConverter * * @var list|null $ibans */ - #[Api(list: 'string', nullable: true, optional: true)] + #[Optional(list: 'string', nullable: true)] public ?array $ibans; /** * Peppol IDs of the tenant. * - * @var list|null $peppol_ids + * @var list|null $peppolIDs */ - #[Api(list: 'string', nullable: true, optional: true)] - public ?array $peppol_ids; + #[Optional('peppol_ids', list: 'string', nullable: true)] + public ?array $peppolIDs; /** * Whether the tenant is registered on our SMP. */ - #[Api(nullable: true, optional: true)] - public ?bool $smp_registration; + #[Optional('smp_registration', nullable: true)] + public ?bool $smpRegistration; /** * Date when the tenant was registered on SMP. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $smp_registration_date; + #[Optional('smp_registration_date', nullable: true)] + public ?\DateTimeInterface $smpRegistrationDate; /** * `new MeGetResponse()` is missing required properties by the API. * * To enforce required parameters use * ``` - * MeGetResponse::with(credit_balance: ..., name: ..., plan: ...) + * MeGetResponse::with(creditBalance: ..., name: ..., plan: ...) * ``` * * Otherwise ensure the following setters are called @@ -167,49 +164,49 @@ public function __construct() * * @param Plan|value-of $plan * @param list|null $ibans - * @param list|null $peppol_ids + * @param list|null $peppolIDs */ public static function with( - int $credit_balance, + int $creditBalance, string $name, Plan|string $plan, - ?string $bcc_recipient_email = null, - ?string $company_address = null, - ?string $company_city = null, - ?string $company_country = null, - ?string $company_email = null, - ?string $company_name = null, - ?string $company_number = null, - ?string $company_tax_id = null, - ?string $company_zip = null, + ?string $bccRecipientEmail = null, + ?string $companyAddress = null, + ?string $companyCity = null, + ?string $companyCountry = null, + ?string $companyEmail = null, + ?string $companyName = null, + ?string $companyNumber = null, + ?string $companyTaxID = null, + ?string $companyZip = null, ?string $description = null, ?array $ibans = null, - ?array $peppol_ids = null, - ?bool $smp_registration = null, - ?\DateTimeInterface $smp_registration_date = null, + ?array $peppolIDs = null, + ?bool $smpRegistration = null, + ?\DateTimeInterface $smpRegistrationDate = null, ): self { - $obj = new self; - - $obj->credit_balance = $credit_balance; - $obj->name = $name; - $obj['plan'] = $plan; - - null !== $bcc_recipient_email && $obj->bcc_recipient_email = $bcc_recipient_email; - null !== $company_address && $obj->company_address = $company_address; - null !== $company_city && $obj->company_city = $company_city; - null !== $company_country && $obj->company_country = $company_country; - null !== $company_email && $obj->company_email = $company_email; - null !== $company_name && $obj->company_name = $company_name; - null !== $company_number && $obj->company_number = $company_number; - null !== $company_tax_id && $obj->company_tax_id = $company_tax_id; - null !== $company_zip && $obj->company_zip = $company_zip; - null !== $description && $obj->description = $description; - null !== $ibans && $obj->ibans = $ibans; - null !== $peppol_ids && $obj->peppol_ids = $peppol_ids; - null !== $smp_registration && $obj->smp_registration = $smp_registration; - null !== $smp_registration_date && $obj->smp_registration_date = $smp_registration_date; - - return $obj; + $self = new self; + + $self['creditBalance'] = $creditBalance; + $self['name'] = $name; + $self['plan'] = $plan; + + null !== $bccRecipientEmail && $self['bccRecipientEmail'] = $bccRecipientEmail; + null !== $companyAddress && $self['companyAddress'] = $companyAddress; + null !== $companyCity && $self['companyCity'] = $companyCity; + null !== $companyCountry && $self['companyCountry'] = $companyCountry; + null !== $companyEmail && $self['companyEmail'] = $companyEmail; + null !== $companyName && $self['companyName'] = $companyName; + null !== $companyNumber && $self['companyNumber'] = $companyNumber; + null !== $companyTaxID && $self['companyTaxID'] = $companyTaxID; + null !== $companyZip && $self['companyZip'] = $companyZip; + null !== $description && $self['description'] = $description; + null !== $ibans && $self['ibans'] = $ibans; + null !== $peppolIDs && $self['peppolIDs'] = $peppolIDs; + null !== $smpRegistration && $self['smpRegistration'] = $smpRegistration; + null !== $smpRegistrationDate && $self['smpRegistrationDate'] = $smpRegistrationDate; + + return $self; } /** @@ -217,18 +214,18 @@ public static function with( */ public function withCreditBalance(int $creditBalance): self { - $obj = clone $this; - $obj->credit_balance = $creditBalance; + $self = clone $this; + $self['creditBalance'] = $creditBalance; - return $obj; + return $self; } public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -238,10 +235,10 @@ public function withName(string $name): self */ public function withPlan(Plan|string $plan): self { - $obj = clone $this; - $obj['plan'] = $plan; + $self = clone $this; + $self['plan'] = $plan; - return $obj; + return $self; } /** @@ -249,10 +246,10 @@ public function withPlan(Plan|string $plan): self */ public function withBccRecipientEmail(?string $bccRecipientEmail): self { - $obj = clone $this; - $obj->bcc_recipient_email = $bccRecipientEmail; + $self = clone $this; + $self['bccRecipientEmail'] = $bccRecipientEmail; - return $obj; + return $self; } /** @@ -260,10 +257,10 @@ public function withBccRecipientEmail(?string $bccRecipientEmail): self */ public function withCompanyAddress(?string $companyAddress): self { - $obj = clone $this; - $obj->company_address = $companyAddress; + $self = clone $this; + $self['companyAddress'] = $companyAddress; - return $obj; + return $self; } /** @@ -271,10 +268,10 @@ public function withCompanyAddress(?string $companyAddress): self */ public function withCompanyCity(?string $companyCity): self { - $obj = clone $this; - $obj->company_city = $companyCity; + $self = clone $this; + $self['companyCity'] = $companyCity; - return $obj; + return $self; } /** @@ -282,10 +279,10 @@ public function withCompanyCity(?string $companyCity): self */ public function withCompanyCountry(?string $companyCountry): self { - $obj = clone $this; - $obj->company_country = $companyCountry; + $self = clone $this; + $self['companyCountry'] = $companyCountry; - return $obj; + return $self; } /** @@ -293,10 +290,10 @@ public function withCompanyCountry(?string $companyCountry): self */ public function withCompanyEmail(?string $companyEmail): self { - $obj = clone $this; - $obj->company_email = $companyEmail; + $self = clone $this; + $self['companyEmail'] = $companyEmail; - return $obj; + return $self; } /** @@ -304,10 +301,10 @@ public function withCompanyEmail(?string $companyEmail): self */ public function withCompanyName(?string $companyName): self { - $obj = clone $this; - $obj->company_name = $companyName; + $self = clone $this; + $self['companyName'] = $companyName; - return $obj; + return $self; } /** @@ -315,10 +312,10 @@ public function withCompanyName(?string $companyName): self */ public function withCompanyNumber(?string $companyNumber): self { - $obj = clone $this; - $obj->company_number = $companyNumber; + $self = clone $this; + $self['companyNumber'] = $companyNumber; - return $obj; + return $self; } /** @@ -326,10 +323,10 @@ public function withCompanyNumber(?string $companyNumber): self */ public function withCompanyTaxID(?string $companyTaxID): self { - $obj = clone $this; - $obj->company_tax_id = $companyTaxID; + $self = clone $this; + $self['companyTaxID'] = $companyTaxID; - return $obj; + return $self; } /** @@ -337,18 +334,18 @@ public function withCompanyTaxID(?string $companyTaxID): self */ public function withCompanyZip(?string $companyZip): self { - $obj = clone $this; - $obj->company_zip = $companyZip; + $self = clone $this; + $self['companyZip'] = $companyZip; - return $obj; + return $self; } public function withDescription(?string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -358,10 +355,10 @@ public function withDescription(?string $description): self */ public function withIbans(?array $ibans): self { - $obj = clone $this; - $obj->ibans = $ibans; + $self = clone $this; + $self['ibans'] = $ibans; - return $obj; + return $self; } /** @@ -371,10 +368,10 @@ public function withIbans(?array $ibans): self */ public function withPeppolIDs(?array $peppolIDs): self { - $obj = clone $this; - $obj->peppol_ids = $peppolIDs; + $self = clone $this; + $self['peppolIDs'] = $peppolIDs; - return $obj; + return $self; } /** @@ -382,10 +379,10 @@ public function withPeppolIDs(?array $peppolIDs): self */ public function withSmpRegistration(?bool $smpRegistration): self { - $obj = clone $this; - $obj->smp_registration = $smpRegistration; + $self = clone $this; + $self['smpRegistration'] = $smpRegistration; - return $obj; + return $self; } /** @@ -394,9 +391,9 @@ public function withSmpRegistration(?bool $smpRegistration): self public function withSmpRegistrationDate( ?\DateTimeInterface $smpRegistrationDate ): self { - $obj = clone $this; - $obj->smp_registration_date = $smpRegistrationDate; + $self = clone $this; + $self['smpRegistrationDate'] = $smpRegistrationDate; - return $obj; + return $self; } } diff --git a/src/Outbox/OutboxListDraftDocumentsParams.php b/src/Outbox/OutboxListDraftDocumentsParams.php index 7bdd37dc..f5bec6bc 100644 --- a/src/Outbox/OutboxListDraftDocumentsParams.php +++ b/src/Outbox/OutboxListDraftDocumentsParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Outbox; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -15,7 +15,7 @@ * @see EInvoiceAPI\Services\OutboxService::listDraftDocuments() * * @phpstan-type OutboxListDraftDocumentsParamsShape = array{ - * page?: int, page_size?: int + * page?: int, pageSize?: int * } */ final class OutboxListDraftDocumentsParams implements BaseModel @@ -27,14 +27,14 @@ final class OutboxListDraftDocumentsParams implements BaseModel /** * Page number. */ - #[Api(optional: true)] + #[Optional] public ?int $page; /** * Number of items per page. */ - #[Api(optional: true)] - public ?int $page_size; + #[Optional] + public ?int $pageSize; public function __construct() { @@ -46,14 +46,14 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?int $page = null, ?int $page_size = null): self + public static function with(?int $page = null, ?int $pageSize = null): self { - $obj = new self; + $self = new self; - null !== $page && $obj->page = $page; - null !== $page_size && $obj->page_size = $page_size; + null !== $page && $self['page'] = $page; + null !== $pageSize && $self['pageSize'] = $pageSize; - return $obj; + return $self; } /** @@ -61,10 +61,10 @@ public static function with(?int $page = null, ?int $page_size = null): self */ public function withPage(int $page): self { - $obj = clone $this; - $obj->page = $page; + $self = clone $this; + $self['page'] = $page; - return $obj; + return $self; } /** @@ -72,9 +72,9 @@ public function withPage(int $page): self */ public function withPageSize(int $pageSize): self { - $obj = clone $this; - $obj->page_size = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } } diff --git a/src/Outbox/OutboxListReceivedDocumentsParams.php b/src/Outbox/OutboxListReceivedDocumentsParams.php index 24dbfac1..7957ee5b 100644 --- a/src/Outbox/OutboxListReceivedDocumentsParams.php +++ b/src/Outbox/OutboxListReceivedDocumentsParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Outbox; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -17,10 +17,10 @@ * @see EInvoiceAPI\Services\OutboxService::listReceivedDocuments() * * @phpstan-type OutboxListReceivedDocumentsParamsShape = array{ - * date_from?: \DateTimeInterface|null, - * date_to?: \DateTimeInterface|null, + * dateFrom?: \DateTimeInterface|null, + * dateTo?: \DateTimeInterface|null, * page?: int, - * page_size?: int, + * pageSize?: int, * search?: string|null, * sender?: string|null, * state?: null|DocumentState|value-of, @@ -36,37 +36,37 @@ final class OutboxListReceivedDocumentsParams implements BaseModel /** * Filter by issue date (from). */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $date_from; + #[Optional(nullable: true)] + public ?\DateTimeInterface $dateFrom; /** * Filter by issue date (to). */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $date_to; + #[Optional(nullable: true)] + public ?\DateTimeInterface $dateTo; /** * Page number. */ - #[Api(optional: true)] + #[Optional] public ?int $page; /** * Number of items per page. */ - #[Api(optional: true)] - public ?int $page_size; + #[Optional] + public ?int $pageSize; /** * Search in invoice number, seller/buyer names. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $search; /** * Filter by sender ID. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $sender; /** @@ -74,7 +74,7 @@ final class OutboxListReceivedDocumentsParams implements BaseModel * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, nullable: true, optional: true)] + #[Optional(enum: DocumentState::class, nullable: true)] public ?string $state; /** @@ -82,7 +82,7 @@ final class OutboxListReceivedDocumentsParams implements BaseModel * * @var value-of|null $type */ - #[Api(enum: DocumentType::class, nullable: true, optional: true)] + #[Optional(enum: DocumentType::class, nullable: true)] public ?string $type; public function __construct() @@ -99,27 +99,27 @@ public function __construct() * @param DocumentType|value-of|null $type */ public static function with( - ?\DateTimeInterface $date_from = null, - ?\DateTimeInterface $date_to = null, + ?\DateTimeInterface $dateFrom = null, + ?\DateTimeInterface $dateTo = null, ?int $page = null, - ?int $page_size = null, + ?int $pageSize = null, ?string $search = null, ?string $sender = null, DocumentState|string|null $state = null, DocumentType|string|null $type = null, ): self { - $obj = new self; - - null !== $date_from && $obj->date_from = $date_from; - null !== $date_to && $obj->date_to = $date_to; - null !== $page && $obj->page = $page; - null !== $page_size && $obj->page_size = $page_size; - null !== $search && $obj->search = $search; - null !== $sender && $obj->sender = $sender; - null !== $state && $obj['state'] = $state; - null !== $type && $obj['type'] = $type; - - return $obj; + $self = new self; + + null !== $dateFrom && $self['dateFrom'] = $dateFrom; + null !== $dateTo && $self['dateTo'] = $dateTo; + null !== $page && $self['page'] = $page; + null !== $pageSize && $self['pageSize'] = $pageSize; + null !== $search && $self['search'] = $search; + null !== $sender && $self['sender'] = $sender; + null !== $state && $self['state'] = $state; + null !== $type && $self['type'] = $type; + + return $self; } /** @@ -127,10 +127,10 @@ public static function with( */ public function withDateFrom(?\DateTimeInterface $dateFrom): self { - $obj = clone $this; - $obj->date_from = $dateFrom; + $self = clone $this; + $self['dateFrom'] = $dateFrom; - return $obj; + return $self; } /** @@ -138,10 +138,10 @@ public function withDateFrom(?\DateTimeInterface $dateFrom): self */ public function withDateTo(?\DateTimeInterface $dateTo): self { - $obj = clone $this; - $obj->date_to = $dateTo; + $self = clone $this; + $self['dateTo'] = $dateTo; - return $obj; + return $self; } /** @@ -149,10 +149,10 @@ public function withDateTo(?\DateTimeInterface $dateTo): self */ public function withPage(int $page): self { - $obj = clone $this; - $obj->page = $page; + $self = clone $this; + $self['page'] = $page; - return $obj; + return $self; } /** @@ -160,10 +160,10 @@ public function withPage(int $page): self */ public function withPageSize(int $pageSize): self { - $obj = clone $this; - $obj->page_size = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } /** @@ -171,10 +171,10 @@ public function withPageSize(int $pageSize): self */ public function withSearch(?string $search): self { - $obj = clone $this; - $obj->search = $search; + $self = clone $this; + $self['search'] = $search; - return $obj; + return $self; } /** @@ -182,10 +182,10 @@ public function withSearch(?string $search): self */ public function withSender(?string $sender): self { - $obj = clone $this; - $obj->sender = $sender; + $self = clone $this; + $self['sender'] = $sender; - return $obj; + return $self; } /** @@ -195,10 +195,10 @@ public function withSender(?string $sender): self */ public function withState(DocumentState|string|null $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -208,9 +208,9 @@ public function withState(DocumentState|string|null $state): self */ public function withType(DocumentType|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } } diff --git a/src/RequestOptions.php b/src/RequestOptions.php index c3f67e34..463f4f07 100644 --- a/src/RequestOptions.php +++ b/src/RequestOptions.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI; -use EInvoiceAPI\Core\Attributes\Api as Property; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required as Property; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Core\Implementation\Omit; @@ -49,26 +50,26 @@ final class RequestOptions implements BaseModel public float $maxRetryDelay = 8.0; /** @var array|null>|null $extraHeaders */ - #[Property(optional: true)] + #[Optional] public ?array $extraHeaders; /** @var array|null $extraQueryParams */ - #[Property(optional: true)] + #[Optional] public ?array $extraQueryParams; - #[Property(optional: true)] + #[Optional] public mixed $extraBodyParams; - #[Property(optional: true)] + #[Optional] public ?ClientInterface $transporter; - #[Property(optional: true)] + #[Optional] public ?UriFactoryInterface $uriFactory; - #[Property(optional: true)] + #[Optional] public ?StreamFactoryInterface $streamFactory; - #[Property(optional: true)] + #[Optional] public ?RequestFactoryInterface $requestFactory; public function __construct() @@ -105,53 +106,55 @@ public static function with( ?StreamFactoryInterface $streamFactory = null, ?RequestFactoryInterface $requestFactory = null, ): self { - $obj = new self; - - null !== $timeout && $obj->timeout = $timeout; - null !== $maxRetries && $obj->maxRetries = $maxRetries; - null !== $initialRetryDelay && $obj->initialRetryDelay = $initialRetryDelay; - null !== $maxRetryDelay && $obj->maxRetryDelay = $maxRetryDelay; - null !== $extraHeaders && $obj->extraHeaders = $extraHeaders; - null !== $extraQueryParams && $obj->extraQueryParams = $extraQueryParams; - omit !== $extraBodyParams && $obj->extraBodyParams = $extraBodyParams; - null !== $transporter && $obj->transporter = $transporter; - null !== $uriFactory && $obj->uriFactory = $uriFactory; - null !== $streamFactory && $obj->streamFactory = $streamFactory; - null !== $requestFactory && $obj->requestFactory = $requestFactory; - - return $obj; + $self = new self; + + null !== $timeout && $self->timeout = $timeout; + null !== $maxRetries && $self->maxRetries = $maxRetries; + null !== $initialRetryDelay && $self + ->initialRetryDelay = $initialRetryDelay + ; + null !== $maxRetryDelay && $self->maxRetryDelay = $maxRetryDelay; + null !== $extraHeaders && $self->extraHeaders = $extraHeaders; + null !== $extraQueryParams && $self->extraQueryParams = $extraQueryParams; + omit !== $extraBodyParams && $self->extraBodyParams = $extraBodyParams; + null !== $transporter && $self->transporter = $transporter; + null !== $uriFactory && $self->uriFactory = $uriFactory; + null !== $streamFactory && $self->streamFactory = $streamFactory; + null !== $requestFactory && $self->requestFactory = $requestFactory; + + return $self; } public function withTimeout(float $timeout): self { - $obj = clone $this; - $obj->timeout = $timeout; + $self = clone $this; + $self->timeout = $timeout; - return $obj; + return $self; } public function withMaxRetries(int $maxRetries): self { - $obj = clone $this; - $obj->maxRetries = $maxRetries; + $self = clone $this; + $self->maxRetries = $maxRetries; - return $obj; + return $self; } public function withInitialRetryDelay(float $initialRetryDelay): self { - $obj = clone $this; - $obj->initialRetryDelay = $initialRetryDelay; + $self = clone $this; + $self->initialRetryDelay = $initialRetryDelay; - return $obj; + return $self; } public function withMaxRetryDelay(float $maxRetryDelay): self { - $obj = clone $this; - $obj->maxRetryDelay = $maxRetryDelay; + $self = clone $this; + $self->maxRetryDelay = $maxRetryDelay; - return $obj; + return $self; } /** @@ -159,10 +162,10 @@ public function withMaxRetryDelay(float $maxRetryDelay): self */ public function withExtraHeaders(array $extraHeaders): self { - $obj = clone $this; - $obj->extraHeaders = $extraHeaders; + $self = clone $this; + $self->extraHeaders = $extraHeaders; - return $obj; + return $self; } /** @@ -170,51 +173,51 @@ public function withExtraHeaders(array $extraHeaders): self */ public function withExtraQueryParams(array $extraQueryParams): self { - $obj = clone $this; - $obj->extraQueryParams = $extraQueryParams; + $self = clone $this; + $self->extraQueryParams = $extraQueryParams; - return $obj; + return $self; } public function withExtraBodyParams(mixed $extraBodyParams): self { - $obj = clone $this; - $obj->extraBodyParams = $extraBodyParams; + $self = clone $this; + $self->extraBodyParams = $extraBodyParams; - return $obj; + return $self; } public function withTransporter(ClientInterface $transporter): self { - $obj = clone $this; - $obj->transporter = $transporter; + $self = clone $this; + $self->transporter = $transporter; - return $obj; + return $self; } public function withUriFactory(UriFactoryInterface $uriFactory): self { - $obj = clone $this; - $obj->uriFactory = $uriFactory; + $self = clone $this; + $self->uriFactory = $uriFactory; - return $obj; + return $self; } public function withStreamFactory( StreamFactoryInterface $streamFactory ): self { - $obj = clone $this; - $obj->streamFactory = $streamFactory; + $self = clone $this; + $self->streamFactory = $streamFactory; - return $obj; + return $self; } public function withRequestFactory( RequestFactoryInterface $requestFactory ): self { - $obj = clone $this; - $obj->requestFactory = $requestFactory; + $self = clone $this; + $self->requestFactory = $requestFactory; - return $obj; + return $self; } } diff --git a/src/ServiceContracts/Documents/AttachmentsContract.php b/src/ServiceContracts/Documents/AttachmentsContract.php index 4c447db7..6e5ba135 100644 --- a/src/ServiceContracts/Documents/AttachmentsContract.php +++ b/src/ServiceContracts/Documents/AttachmentsContract.php @@ -5,10 +5,7 @@ namespace EInvoiceAPI\ServiceContracts\Documents; use EInvoiceAPI\Core\Exceptions\APIException; -use EInvoiceAPI\Documents\Attachments\AttachmentAddParams; -use EInvoiceAPI\Documents\Attachments\AttachmentDeleteParams; use EInvoiceAPI\Documents\Attachments\AttachmentDeleteResponse; -use EInvoiceAPI\Documents\Attachments\AttachmentRetrieveParams; use EInvoiceAPI\Documents\Attachments\DocumentAttachment; use EInvoiceAPI\RequestOptions; @@ -17,13 +14,11 @@ interface AttachmentsContract /** * @api * - * @param array|AttachmentRetrieveParams $params - * * @throws APIException */ public function retrieve( string $attachmentID, - array|AttachmentRetrieveParams $params, + string $documentID, ?RequestOptions $requestOptions = null, ): DocumentAttachment; @@ -42,26 +37,22 @@ public function list( /** * @api * - * @param array|AttachmentDeleteParams $params - * * @throws APIException */ public function delete( string $attachmentID, - array|AttachmentDeleteParams $params, + string $documentID, ?RequestOptions $requestOptions = null, ): AttachmentDeleteResponse; /** * @api * - * @param array|AttachmentAddParams $params - * * @throws APIException */ public function add( string $documentID, - array|AttachmentAddParams $params, - ?RequestOptions $requestOptions = null, + string $file, + ?RequestOptions $requestOptions = null ): DocumentAttachment; } diff --git a/src/ServiceContracts/Documents/AttachmentsRawContract.php b/src/ServiceContracts/Documents/AttachmentsRawContract.php new file mode 100644 index 00000000..a5fdf96d --- /dev/null +++ b/src/ServiceContracts/Documents/AttachmentsRawContract.php @@ -0,0 +1,74 @@ +|AttachmentRetrieveParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $attachmentID, + array|AttachmentRetrieveParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|AttachmentDeleteParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $attachmentID, + array|AttachmentDeleteParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|AttachmentAddParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function add( + string $documentID, + array|AttachmentAddParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/Documents/UblContract.php b/src/ServiceContracts/Documents/UblContract.php index 50365102..5a00dee4 100644 --- a/src/ServiceContracts/Documents/UblContract.php +++ b/src/ServiceContracts/Documents/UblContract.php @@ -6,7 +6,6 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Documents\Ubl\UblCreateFromUblParams; use EInvoiceAPI\Documents\Ubl\UblGetResponse; use EInvoiceAPI\RequestOptions; @@ -15,13 +14,11 @@ interface UblContract /** * @api * - * @param array|UblCreateFromUblParams $params - * * @throws APIException */ public function createFromUbl( - array|UblCreateFromUblParams $params, - ?RequestOptions $requestOptions = null, + string $file, + ?RequestOptions $requestOptions = null ): DocumentResponse; /** diff --git a/src/ServiceContracts/Documents/UblRawContract.php b/src/ServiceContracts/Documents/UblRawContract.php new file mode 100644 index 00000000..fbae019a --- /dev/null +++ b/src/ServiceContracts/Documents/UblRawContract.php @@ -0,0 +1,41 @@ +|UblCreateFromUblParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function createFromUbl( + array|UblCreateFromUblParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/DocumentsContract.php b/src/ServiceContracts/DocumentsContract.php index b00b99d8..0f475b25 100644 --- a/src/ServiceContracts/DocumentsContract.php +++ b/src/ServiceContracts/DocumentsContract.php @@ -5,12 +5,19 @@ namespace EInvoiceAPI\ServiceContracts; use EInvoiceAPI\Core\Exceptions\APIException; -use EInvoiceAPI\Documents\DocumentCreateFromPdfParams; -use EInvoiceAPI\Documents\DocumentCreateParams; +use EInvoiceAPI\Documents\CurrencyCode; +use EInvoiceAPI\Documents\DocumentAttachmentCreate; +use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\ReasonCode; +use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\TaxCode; +use EInvoiceAPI\Documents\DocumentCreateParams\Vatex; use EInvoiceAPI\Documents\DocumentDeleteResponse; +use EInvoiceAPI\Documents\DocumentDirection; use EInvoiceAPI\Documents\DocumentNewFromPdfResponse; use EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Documents\DocumentSendParams; +use EInvoiceAPI\Documents\DocumentType; +use EInvoiceAPI\Documents\PaymentDetailCreate; +use EInvoiceAPI\Documents\UnitOfMeasureCode; +use EInvoiceAPI\Inbox\DocumentState; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\Validate\UblDocumentValidation; @@ -19,13 +26,163 @@ interface DocumentsContract /** * @api * - * @param array|DocumentCreateParams $params + * @param list|null $allowances + * @param float|string|null $amountDue The amount due for payment. Must be positive and rounded to maximum 2 decimals + * @param list|null $attachments + * @param string|null $billingAddress The billing address (if different from customer address) + * @param string|null $billingAddressRecipient The recipient name at the billing address + * @param list|null $charges + * @param 'EUR'|'USD'|'GBP'|'JPY'|'CHF'|'CAD'|'AUD'|'NZD'|'CNY'|'INR'|'SEK'|'NOK'|'DKK'|'SGD'|'HKD'|CurrencyCode $currency Currency of the invoice (ISO 4217 currency code) + * @param string|null $customerAddress The address of the customer/buyer + * @param string|null $customerAddressRecipient The recipient name at the customer address + * @param string|null $customerCompanyID Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $customerEmail The email address of the customer + * @param string|null $customerID The unique identifier for the customer in your system + * @param string|null $customerName The company name of the customer/buyer + * @param string|null $customerTaxID Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * @param 'INBOUND'|'OUTBOUND'|DocumentDirection $direction The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType $documentType The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * @param string|\DateTimeInterface|null $dueDate The date when payment is due + * @param string|\DateTimeInterface|null $invoiceDate The date when the invoice was issued + * @param string|null $invoiceID The unique invoice identifier/number + * @param float|string|null $invoiceTotal The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, + * unitPrice?: float|string|null, + * }> $items At least one line item is required + * @param string|null $note Additional notes or comments for the invoice + * @param list|null $paymentDetails + * @param string|null $paymentTerm The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * @param float|string|null $previousUnpaidBalance The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals + * @param string|null $purchaseOrder The purchase order reference number + * @param string|null $remittanceAddress The address where payment should be sent or remitted to + * @param string|null $remittanceAddressRecipient The recipient name at the remittance address + * @param string|null $serviceAddress The address where services were performed or goods were delivered + * @param string|null $serviceAddressRecipient The recipient name at the service address + * @param string|\DateTimeInterface|null $serviceEndDate The end date of the service period or delivery period + * @param string|\DateTimeInterface|null $serviceStartDate The start date of the service period or delivery period + * @param string|null $shippingAddress The shipping/delivery address + * @param string|null $shippingAddressRecipient The recipient name at the shipping address + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState $state The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * @param float|string|null $subtotal The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals + * @param 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B'|\EInvoiceAPI\Documents\DocumentCreateParams\TaxCode $taxCode Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + * @param list|null $taxDetails + * @param float|string|null $totalDiscount The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals + * @param float|string|null $totalTax The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + * @param 'VATEX-EU-79-C'|'VATEX-EU-132'|'VATEX-EU-132-1A'|'VATEX-EU-132-1B'|'VATEX-EU-132-1C'|'VATEX-EU-132-1D'|'VATEX-EU-132-1E'|'VATEX-EU-132-1F'|'VATEX-EU-132-1G'|'VATEX-EU-132-1H'|'VATEX-EU-132-1I'|'VATEX-EU-132-1J'|'VATEX-EU-132-1K'|'VATEX-EU-132-1L'|'VATEX-EU-132-1M'|'VATEX-EU-132-1N'|'VATEX-EU-132-1O'|'VATEX-EU-132-1P'|'VATEX-EU-132-1Q'|'VATEX-EU-143'|'VATEX-EU-143-1A'|'VATEX-EU-143-1B'|'VATEX-EU-143-1C'|'VATEX-EU-143-1D'|'VATEX-EU-143-1E'|'VATEX-EU-143-1F'|'VATEX-EU-143-1FA'|'VATEX-EU-143-1G'|'VATEX-EU-143-1H'|'VATEX-EU-143-1I'|'VATEX-EU-143-1J'|'VATEX-EU-143-1K'|'VATEX-EU-143-1L'|'VATEX-EU-144'|'VATEX-EU-146-1E'|'VATEX-EU-148'|'VATEX-EU-148-A'|'VATEX-EU-148-B'|'VATEX-EU-148-C'|'VATEX-EU-148-D'|'VATEX-EU-148-E'|'VATEX-EU-148-F'|'VATEX-EU-148-G'|'VATEX-EU-151'|'VATEX-EU-151-1A'|'VATEX-EU-151-1AA'|'VATEX-EU-151-1B'|'VATEX-EU-151-1C'|'VATEX-EU-151-1D'|'VATEX-EU-151-1E'|'VATEX-EU-159'|'VATEX-EU-309'|'VATEX-EU-AE'|'VATEX-EU-D'|'VATEX-EU-F'|'VATEX-EU-G'|'VATEX-EU-I'|'VATEX-EU-IC'|'VATEX-EU-O'|'VATEX-EU-J'|'VATEX-FR-FRANCHISE'|'VATEX-FR-CNWVAT'|Vatex|null $vatex VATEX code list for VAT exemption reasons + * + * Agency: CEF + * Identifier: vatex + * @param string|null $vatexNote Textual explanation for VAT exemption + * @param string|null $vendorAddress The address of the vendor/seller + * @param string|null $vendorAddressRecipient The recipient name at the vendor address + * @param string|null $vendorCompanyID Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $vendorEmail The email address of the vendor + * @param string|null $vendorName The name of the vendor/seller/supplier + * @param string|null $vendorTaxID Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix * * @throws APIException */ public function create( - array|DocumentCreateParams $params, - ?RequestOptions $requestOptions = null + ?array $allowances = null, + float|string|null $amountDue = null, + ?array $attachments = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, + ?array $charges = null, + string|CurrencyCode|null $currency = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, + string|DocumentDirection|null $direction = null, + string|DocumentType|null $documentType = null, + string|\DateTimeInterface|null $dueDate = null, + string|\DateTimeInterface|null $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, + ?array $items = null, + ?string $note = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + string|\DateTimeInterface|null $serviceEndDate = null, + string|\DateTimeInterface|null $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, + string|DocumentState|null $state = null, + float|string|null $subtotal = null, + string|\EInvoiceAPI\Documents\DocumentCreateParams\TaxCode $taxCode = 'S', + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, + string|Vatex|null $vatex = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, + ?RequestOptions $requestOptions = null, ): DocumentResponse; /** @@ -51,25 +208,31 @@ public function delete( /** * @api * - * @param array|DocumentCreateFromPdfParams $params + * @param string $file Body param: + * @param string|null $customerTaxID Query param: + * @param string|null $vendorTaxID Query param: * * @throws APIException */ public function createFromPdf( - array|DocumentCreateFromPdfParams $params, + string $file, + ?string $customerTaxID = null, + ?string $vendorTaxID = null, ?RequestOptions $requestOptions = null, ): DocumentNewFromPdfResponse; /** * @api * - * @param array|DocumentSendParams $params - * * @throws APIException */ public function send( string $documentID, - array|DocumentSendParams $params, + ?string $email = null, + ?string $receiverPeppolID = null, + ?string $receiverPeppolScheme = null, + ?string $senderPeppolID = null, + ?string $senderPeppolScheme = null, ?RequestOptions $requestOptions = null, ): DocumentResponse; diff --git a/src/ServiceContracts/DocumentsRawContract.php b/src/ServiceContracts/DocumentsRawContract.php new file mode 100644 index 00000000..a4100a15 --- /dev/null +++ b/src/ServiceContracts/DocumentsRawContract.php @@ -0,0 +1,98 @@ +|DocumentCreateParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|DocumentCreateParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|DocumentCreateFromPdfParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function createFromPdf( + array|DocumentCreateFromPdfParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|DocumentSendParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function send( + string $documentID, + array|DocumentSendParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse + * + * @throws APIException + */ + public function validate( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/InboxContract.php b/src/ServiceContracts/InboxContract.php index 28387e1c..e101269e 100644 --- a/src/ServiceContracts/InboxContract.php +++ b/src/ServiceContracts/InboxContract.php @@ -6,10 +6,9 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Documents\DocumentResponse; +use EInvoiceAPI\Documents\DocumentType; use EInvoiceAPI\DocumentsNumberPage; -use EInvoiceAPI\Inbox\InboxListCreditNotesParams; -use EInvoiceAPI\Inbox\InboxListInvoicesParams; -use EInvoiceAPI\Inbox\InboxListParams; +use EInvoiceAPI\Inbox\DocumentState; use EInvoiceAPI\RequestOptions; interface InboxContract @@ -17,42 +16,60 @@ interface InboxContract /** * @api * - * @param array|InboxListParams $params + * @param string|\DateTimeInterface|null $dateFrom Filter by issue date (from) + * @param string|\DateTimeInterface|null $dateTo Filter by issue date (to) + * @param int $page Page number + * @param int $pageSize Number of items per page + * @param string|null $search Search in invoice number, seller/buyer names + * @param string|null $sender Filter by sender ID + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null $state Filter by document state + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null $type Filter by document type * * @return DocumentsNumberPage * * @throws APIException */ public function list( - array|InboxListParams $params, - ?RequestOptions $requestOptions = null + string|\DateTimeInterface|null $dateFrom = null, + string|\DateTimeInterface|null $dateTo = null, + int $page = 1, + int $pageSize = 20, + ?string $search = null, + ?string $sender = null, + string|DocumentState|null $state = null, + string|DocumentType|null $type = null, + ?RequestOptions $requestOptions = null, ): DocumentsNumberPage; /** * @api * - * @param array|InboxListCreditNotesParams $params + * @param int $page Page number + * @param int $pageSize Number of items per page * * @return DocumentsNumberPage * * @throws APIException */ public function listCreditNotes( - array|InboxListCreditNotesParams $params, - ?RequestOptions $requestOptions = null, + int $page = 1, + int $pageSize = 20, + ?RequestOptions $requestOptions = null ): DocumentsNumberPage; /** * @api * - * @param array|InboxListInvoicesParams $params + * @param int $page Page number + * @param int $pageSize Number of items per page * * @return DocumentsNumberPage * * @throws APIException */ public function listInvoices( - array|InboxListInvoicesParams $params, - ?RequestOptions $requestOptions = null, + int $page = 1, + int $pageSize = 20, + ?RequestOptions $requestOptions = null ): DocumentsNumberPage; } diff --git a/src/ServiceContracts/InboxRawContract.php b/src/ServiceContracts/InboxRawContract.php new file mode 100644 index 00000000..cd1328e4 --- /dev/null +++ b/src/ServiceContracts/InboxRawContract.php @@ -0,0 +1,59 @@ +|InboxListParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + array|InboxListParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|InboxListCreditNotesParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listCreditNotes( + array|InboxListCreditNotesParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|InboxListInvoicesParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listInvoices( + array|InboxListInvoicesParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/LookupContract.php b/src/ServiceContracts/LookupContract.php index 16fbbda9..ece31c39 100644 --- a/src/ServiceContracts/LookupContract.php +++ b/src/ServiceContracts/LookupContract.php @@ -7,8 +7,6 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Lookup\LookupGetParticipantsResponse; use EInvoiceAPI\Lookup\LookupGetResponse; -use EInvoiceAPI\Lookup\LookupRetrieveParams; -use EInvoiceAPI\Lookup\LookupRetrieveParticipantsParams; use EInvoiceAPI\RequestOptions; interface LookupContract @@ -16,24 +14,26 @@ interface LookupContract /** * @api * - * @param array|LookupRetrieveParams $params + * @param string $peppolID Peppol ID in the format `:`. Example: `0208:1018265814` for a Belgian company. * * @throws APIException */ public function retrieve( - array|LookupRetrieveParams $params, + string $peppolID, ?RequestOptions $requestOptions = null ): LookupGetResponse; /** * @api * - * @param array|LookupRetrieveParticipantsParams $params + * @param string $query Query to lookup + * @param string|null $countryCode Country code of the company to lookup. If not provided, the search will be global. * * @throws APIException */ public function retrieveParticipants( - array|LookupRetrieveParticipantsParams $params, + string $query, + ?string $countryCode = null, ?RequestOptions $requestOptions = null, ): LookupGetParticipantsResponse; } diff --git a/src/ServiceContracts/LookupRawContract.php b/src/ServiceContracts/LookupRawContract.php new file mode 100644 index 00000000..fd25beb9 --- /dev/null +++ b/src/ServiceContracts/LookupRawContract.php @@ -0,0 +1,44 @@ +|LookupRetrieveParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + array|LookupRetrieveParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|LookupRetrieveParticipantsParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieveParticipants( + array|LookupRetrieveParticipantsParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/MeRawContract.php b/src/ServiceContracts/MeRawContract.php new file mode 100644 index 00000000..4f60d42a --- /dev/null +++ b/src/ServiceContracts/MeRawContract.php @@ -0,0 +1,24 @@ + + * + * @throws APIException + */ + public function retrieve( + ?RequestOptions $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/OutboxContract.php b/src/ServiceContracts/OutboxContract.php index d1465e02..c1819c8e 100644 --- a/src/ServiceContracts/OutboxContract.php +++ b/src/ServiceContracts/OutboxContract.php @@ -6,9 +6,9 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Documents\DocumentResponse; +use EInvoiceAPI\Documents\DocumentType; use EInvoiceAPI\DocumentsNumberPage; -use EInvoiceAPI\Outbox\OutboxListDraftDocumentsParams; -use EInvoiceAPI\Outbox\OutboxListReceivedDocumentsParams; +use EInvoiceAPI\Inbox\DocumentState; use EInvoiceAPI\RequestOptions; interface OutboxContract @@ -16,28 +16,44 @@ interface OutboxContract /** * @api * - * @param array|OutboxListDraftDocumentsParams $params + * @param int $page Page number + * @param int $pageSize Number of items per page * * @return DocumentsNumberPage * * @throws APIException */ public function listDraftDocuments( - array|OutboxListDraftDocumentsParams $params, - ?RequestOptions $requestOptions = null, + int $page = 1, + int $pageSize = 20, + ?RequestOptions $requestOptions = null ): DocumentsNumberPage; /** * @api * - * @param array|OutboxListReceivedDocumentsParams $params + * @param string|\DateTimeInterface|null $dateFrom Filter by issue date (from) + * @param string|\DateTimeInterface|null $dateTo Filter by issue date (to) + * @param int $page Page number + * @param int $pageSize Number of items per page + * @param string|null $search Search in invoice number, seller/buyer names + * @param string|null $sender Filter by sender ID + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null $state Filter by document state + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null $type Filter by document type * * @return DocumentsNumberPage * * @throws APIException */ public function listReceivedDocuments( - array|OutboxListReceivedDocumentsParams $params, + string|\DateTimeInterface|null $dateFrom = null, + string|\DateTimeInterface|null $dateTo = null, + int $page = 1, + int $pageSize = 20, + ?string $search = null, + ?string $sender = null, + string|DocumentState|null $state = null, + string|DocumentType|null $type = null, ?RequestOptions $requestOptions = null, ): DocumentsNumberPage; } diff --git a/src/ServiceContracts/OutboxRawContract.php b/src/ServiceContracts/OutboxRawContract.php new file mode 100644 index 00000000..83bdcd94 --- /dev/null +++ b/src/ServiceContracts/OutboxRawContract.php @@ -0,0 +1,44 @@ +|OutboxListDraftDocumentsParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listDraftDocuments( + array|OutboxListDraftDocumentsParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|OutboxListReceivedDocumentsParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listReceivedDocuments( + array|OutboxListReceivedDocumentsParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/ValidateContract.php b/src/ServiceContracts/ValidateContract.php index 63dcac33..eaa70a20 100644 --- a/src/ServiceContracts/ValidateContract.php +++ b/src/ServiceContracts/ValidateContract.php @@ -5,48 +5,203 @@ namespace EInvoiceAPI\ServiceContracts; use EInvoiceAPI\Core\Exceptions\APIException; +use EInvoiceAPI\Documents\CurrencyCode; +use EInvoiceAPI\Documents\DocumentAttachmentCreate; +use EInvoiceAPI\Documents\DocumentDirection; +use EInvoiceAPI\Documents\DocumentType; +use EInvoiceAPI\Documents\PaymentDetailCreate; +use EInvoiceAPI\Documents\UnitOfMeasureCode; +use EInvoiceAPI\Inbox\DocumentState; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\Validate\UblDocumentValidation; -use EInvoiceAPI\Validate\ValidateValidateJsonParams; -use EInvoiceAPI\Validate\ValidateValidatePeppolIDParams; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\ReasonCode; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\TaxCode; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Vatex; use EInvoiceAPI\Validate\ValidateValidatePeppolIDResponse; -use EInvoiceAPI\Validate\ValidateValidateUblParams; interface ValidateContract { /** * @api * - * @param array|ValidateValidateJsonParams $params + * @param list|null $allowances + * @param float|string|null $amountDue The amount due for payment. Must be positive and rounded to maximum 2 decimals + * @param list|null $attachments + * @param string|null $billingAddress The billing address (if different from customer address) + * @param string|null $billingAddressRecipient The recipient name at the billing address + * @param list|null $charges + * @param 'EUR'|'USD'|'GBP'|'JPY'|'CHF'|'CAD'|'AUD'|'NZD'|'CNY'|'INR'|'SEK'|'NOK'|'DKK'|'SGD'|'HKD'|CurrencyCode $currency Currency of the invoice (ISO 4217 currency code) + * @param string|null $customerAddress The address of the customer/buyer + * @param string|null $customerAddressRecipient The recipient name at the customer address + * @param string|null $customerCompanyID Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $customerEmail The email address of the customer + * @param string|null $customerID The unique identifier for the customer in your system + * @param string|null $customerName The company name of the customer/buyer + * @param string|null $customerTaxID Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * @param 'INBOUND'|'OUTBOUND'|DocumentDirection $direction The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType $documentType The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * @param string|\DateTimeInterface|null $dueDate The date when payment is due + * @param string|\DateTimeInterface|null $invoiceDate The date when the invoice was issued + * @param string|null $invoiceID The unique invoice identifier/number + * @param float|string|null $invoiceTotal The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, + * unitPrice?: float|string|null, + * }> $items At least one line item is required + * @param string|null $note Additional notes or comments for the invoice + * @param list|null $paymentDetails + * @param string|null $paymentTerm The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * @param float|string|null $previousUnpaidBalance The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals + * @param string|null $purchaseOrder The purchase order reference number + * @param string|null $remittanceAddress The address where payment should be sent or remitted to + * @param string|null $remittanceAddressRecipient The recipient name at the remittance address + * @param string|null $serviceAddress The address where services were performed or goods were delivered + * @param string|null $serviceAddressRecipient The recipient name at the service address + * @param string|\DateTimeInterface|null $serviceEndDate The end date of the service period or delivery period + * @param string|\DateTimeInterface|null $serviceStartDate The start date of the service period or delivery period + * @param string|null $shippingAddress The shipping/delivery address + * @param string|null $shippingAddressRecipient The recipient name at the shipping address + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState $state The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * @param float|string|null $subtotal The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals + * @param 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B'|\EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode $taxCode Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + * @param list|null $taxDetails + * @param float|string|null $totalDiscount The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals + * @param float|string|null $totalTax The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + * @param 'VATEX-EU-79-C'|'VATEX-EU-132'|'VATEX-EU-132-1A'|'VATEX-EU-132-1B'|'VATEX-EU-132-1C'|'VATEX-EU-132-1D'|'VATEX-EU-132-1E'|'VATEX-EU-132-1F'|'VATEX-EU-132-1G'|'VATEX-EU-132-1H'|'VATEX-EU-132-1I'|'VATEX-EU-132-1J'|'VATEX-EU-132-1K'|'VATEX-EU-132-1L'|'VATEX-EU-132-1M'|'VATEX-EU-132-1N'|'VATEX-EU-132-1O'|'VATEX-EU-132-1P'|'VATEX-EU-132-1Q'|'VATEX-EU-143'|'VATEX-EU-143-1A'|'VATEX-EU-143-1B'|'VATEX-EU-143-1C'|'VATEX-EU-143-1D'|'VATEX-EU-143-1E'|'VATEX-EU-143-1F'|'VATEX-EU-143-1FA'|'VATEX-EU-143-1G'|'VATEX-EU-143-1H'|'VATEX-EU-143-1I'|'VATEX-EU-143-1J'|'VATEX-EU-143-1K'|'VATEX-EU-143-1L'|'VATEX-EU-144'|'VATEX-EU-146-1E'|'VATEX-EU-148'|'VATEX-EU-148-A'|'VATEX-EU-148-B'|'VATEX-EU-148-C'|'VATEX-EU-148-D'|'VATEX-EU-148-E'|'VATEX-EU-148-F'|'VATEX-EU-148-G'|'VATEX-EU-151'|'VATEX-EU-151-1A'|'VATEX-EU-151-1AA'|'VATEX-EU-151-1B'|'VATEX-EU-151-1C'|'VATEX-EU-151-1D'|'VATEX-EU-151-1E'|'VATEX-EU-159'|'VATEX-EU-309'|'VATEX-EU-AE'|'VATEX-EU-D'|'VATEX-EU-F'|'VATEX-EU-G'|'VATEX-EU-I'|'VATEX-EU-IC'|'VATEX-EU-O'|'VATEX-EU-J'|'VATEX-FR-FRANCHISE'|'VATEX-FR-CNWVAT'|Vatex|null $vatex VATEX code list for VAT exemption reasons + * + * Agency: CEF + * Identifier: vatex + * @param string|null $vatexNote Textual explanation for VAT exemption + * @param string|null $vendorAddress The address of the vendor/seller + * @param string|null $vendorAddressRecipient The recipient name at the vendor address + * @param string|null $vendorCompanyID Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $vendorEmail The email address of the vendor + * @param string|null $vendorName The name of the vendor/seller/supplier + * @param string|null $vendorTaxID Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix * * @throws APIException */ public function validateJson( - array|ValidateValidateJsonParams $params, + ?array $allowances = null, + float|string|null $amountDue = null, + ?array $attachments = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, + ?array $charges = null, + string|CurrencyCode|null $currency = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, + string|DocumentDirection|null $direction = null, + string|DocumentType|null $documentType = null, + string|\DateTimeInterface|null $dueDate = null, + string|\DateTimeInterface|null $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, + ?array $items = null, + ?string $note = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + string|\DateTimeInterface|null $serviceEndDate = null, + string|\DateTimeInterface|null $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, + string|DocumentState|null $state = null, + float|string|null $subtotal = null, + string|\EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode $taxCode = 'S', + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, + string|Vatex|null $vatex = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ?RequestOptions $requestOptions = null, ): UblDocumentValidation; /** * @api * - * @param array|ValidateValidatePeppolIDParams $params + * @param string $peppolID Peppol ID in the format `:`. Example: `0208:1018265814` for a Belgian company. * * @throws APIException */ public function validatePeppolID( - array|ValidateValidatePeppolIDParams $params, - ?RequestOptions $requestOptions = null, + string $peppolID, + ?RequestOptions $requestOptions = null ): ValidateValidatePeppolIDResponse; /** * @api * - * @param array|ValidateValidateUblParams $params - * * @throws APIException */ public function validateUbl( - array|ValidateValidateUblParams $params, - ?RequestOptions $requestOptions = null, + string $file, + ?RequestOptions $requestOptions = null ): UblDocumentValidation; } diff --git a/src/ServiceContracts/ValidateRawContract.php b/src/ServiceContracts/ValidateRawContract.php new file mode 100644 index 00000000..1de061e6 --- /dev/null +++ b/src/ServiceContracts/ValidateRawContract.php @@ -0,0 +1,59 @@ +|ValidateValidateJsonParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function validateJson( + array|ValidateValidateJsonParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|ValidateValidatePeppolIDParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function validatePeppolID( + array|ValidateValidatePeppolIDParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|ValidateValidateUblParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function validateUbl( + array|ValidateValidateUblParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/WebhooksContract.php b/src/ServiceContracts/WebhooksContract.php index 9af01e21..7e6c4db4 100644 --- a/src/ServiceContracts/WebhooksContract.php +++ b/src/ServiceContracts/WebhooksContract.php @@ -6,23 +6,23 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\RequestOptions; -use EInvoiceAPI\Webhooks\WebhookCreateParams; use EInvoiceAPI\Webhooks\WebhookDeleteResponse; use EInvoiceAPI\Webhooks\WebhookResponse; -use EInvoiceAPI\Webhooks\WebhookUpdateParams; interface WebhooksContract { /** * @api * - * @param array|WebhookCreateParams $params + * @param list $events * * @throws APIException */ public function create( - array|WebhookCreateParams $params, - ?RequestOptions $requestOptions = null + array $events, + string $url, + bool $enabled = true, + ?RequestOptions $requestOptions = null, ): WebhookResponse; /** @@ -38,13 +38,15 @@ public function retrieve( /** * @api * - * @param array|WebhookUpdateParams $params + * @param list|null $events * * @throws APIException */ public function update( string $webhookID, - array|WebhookUpdateParams $params, + ?bool $enabled = null, + ?array $events = null, + ?string $url = null, ?RequestOptions $requestOptions = null, ): WebhookResponse; diff --git a/src/ServiceContracts/WebhooksRawContract.php b/src/ServiceContracts/WebhooksRawContract.php new file mode 100644 index 00000000..cfe76fd0 --- /dev/null +++ b/src/ServiceContracts/WebhooksRawContract.php @@ -0,0 +1,78 @@ +|WebhookCreateParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|WebhookCreateParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $webhookID, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|WebhookUpdateParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $webhookID, + array|WebhookUpdateParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list(?RequestOptions $requestOptions = null): BaseResponse; + + /** + * @api + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $webhookID, + ?RequestOptions $requestOptions = null + ): BaseResponse; +} diff --git a/src/Services/Documents/AttachmentsRawService.php b/src/Services/Documents/AttachmentsRawService.php new file mode 100644 index 00000000..d018acaf --- /dev/null +++ b/src/Services/Documents/AttachmentsRawService.php @@ -0,0 +1,144 @@ + + * + * @throws APIException + */ + public function retrieve( + string $attachmentID, + array|AttachmentRetrieveParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = AttachmentRetrieveParams::parseRequest( + $params, + $requestOptions, + ); + $documentID = $parsed['documentID']; + unset($parsed['documentID']); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['api/documents/%1$s/attachments/%2$s', $documentID, $attachmentID], + options: $options, + convert: DocumentAttachment::class, + ); + } + + /** + * @api + * + * Get all attachments for an invoice or credit note + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['api/documents/%1$s/attachments', $documentID], + options: $requestOptions, + convert: new ListOf(DocumentAttachment::class), + ); + } + + /** + * @api + * + * Delete an attachment from an invoice or credit note + * + * @param array{documentID: string}|AttachmentDeleteParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $attachmentID, + array|AttachmentDeleteParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = AttachmentDeleteParams::parseRequest( + $params, + $requestOptions, + ); + $documentID = $parsed['documentID']; + unset($parsed['documentID']); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['api/documents/%1$s/attachments/%2$s', $documentID, $attachmentID], + options: $options, + convert: AttachmentDeleteResponse::class, + ); + } + + /** + * @api + * + * Add a new attachment to an invoice or credit note + * + * @param array{file: string}|AttachmentAddParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function add( + string $documentID, + array|AttachmentAddParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = AttachmentAddParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: ['api/documents/%1$s/attachments', $documentID], + headers: ['Content-Type' => 'multipart/form-data'], + body: (object) $parsed, + options: $options, + convert: DocumentAttachment::class, + ); + } +} diff --git a/src/Services/Documents/AttachmentsService.php b/src/Services/Documents/AttachmentsService.php index 46ece059..c64b9d9a 100644 --- a/src/Services/Documents/AttachmentsService.php +++ b/src/Services/Documents/AttachmentsService.php @@ -5,51 +5,45 @@ namespace EInvoiceAPI\Services\Documents; use EInvoiceAPI\Client; -use EInvoiceAPI\Core\Conversion\ListOf; use EInvoiceAPI\Core\Exceptions\APIException; -use EInvoiceAPI\Documents\Attachments\AttachmentAddParams; -use EInvoiceAPI\Documents\Attachments\AttachmentDeleteParams; use EInvoiceAPI\Documents\Attachments\AttachmentDeleteResponse; -use EInvoiceAPI\Documents\Attachments\AttachmentRetrieveParams; use EInvoiceAPI\Documents\Attachments\DocumentAttachment; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\Documents\AttachmentsContract; final class AttachmentsService implements AttachmentsContract { + /** + * @api + */ + public AttachmentsRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new AttachmentsRawService($client); + } /** * @api * * Get attachment details with for an invoice or credit note with link to download file (signed URL, valid for 1 hour) * - * @param array{document_id: string}|AttachmentRetrieveParams $params - * * @throws APIException */ public function retrieve( string $attachmentID, - array|AttachmentRetrieveParams $params, + string $documentID, ?RequestOptions $requestOptions = null, ): DocumentAttachment { - [$parsed, $options] = AttachmentRetrieveParams::parseRequest( - $params, - $requestOptions, - ); - $documentID = $parsed['document_id']; - unset($parsed['document_id']); - - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: ['api/documents/%1$s/attachments/%2$s', $documentID, $attachmentID], - options: $options, - convert: DocumentAttachment::class, - ); + $params = ['documentID' => $documentID]; + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieve($attachmentID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -65,13 +59,10 @@ public function list( string $documentID, ?RequestOptions $requestOptions = null ): array { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: ['api/documents/%1$s/attachments', $documentID], - options: $requestOptions, - convert: new ListOf(DocumentAttachment::class), - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list($documentID, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -79,29 +70,19 @@ public function list( * * Delete an attachment from an invoice or credit note * - * @param array{document_id: string}|AttachmentDeleteParams $params - * * @throws APIException */ public function delete( string $attachmentID, - array|AttachmentDeleteParams $params, + string $documentID, ?RequestOptions $requestOptions = null, ): AttachmentDeleteResponse { - [$parsed, $options] = AttachmentDeleteParams::parseRequest( - $params, - $requestOptions, - ); - $documentID = $parsed['document_id']; - unset($parsed['document_id']); - - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'delete', - path: ['api/documents/%1$s/attachments/%2$s', $documentID, $attachmentID], - options: $options, - convert: AttachmentDeleteResponse::class, - ); + $params = ['documentID' => $documentID]; + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($attachmentID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -109,28 +90,18 @@ public function delete( * * Add a new attachment to an invoice or credit note * - * @param array{file: string}|AttachmentAddParams $params - * * @throws APIException */ public function add( string $documentID, - array|AttachmentAddParams $params, - ?RequestOptions $requestOptions = null, + string $file, + ?RequestOptions $requestOptions = null ): DocumentAttachment { - [$parsed, $options] = AttachmentAddParams::parseRequest( - $params, - $requestOptions, - ); - - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: ['api/documents/%1$s/attachments', $documentID], - headers: ['Content-Type' => 'multipart/form-data'], - body: (object) $parsed, - options: $options, - convert: DocumentAttachment::class, - ); + $params = ['file' => $file]; + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->add($documentID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Services/Documents/UblRawService.php b/src/Services/Documents/UblRawService.php new file mode 100644 index 00000000..b5a08860 --- /dev/null +++ b/src/Services/Documents/UblRawService.php @@ -0,0 +1,76 @@ + + * + * @throws APIException + */ + public function createFromUbl( + array|UblCreateFromUblParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = UblCreateFromUblParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'api/documents/ubl', + headers: ['Content-Type' => 'multipart/form-data'], + body: (object) $parsed, + options: $options, + convert: DocumentResponse::class, + ); + } + + /** + * @api + * + * Get the UBL for an invoice or credit note + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['api/documents/%1$s/ubl', $documentID], + options: $requestOptions, + convert: UblGetResponse::class, + ); + } +} diff --git a/src/Services/Documents/UblService.php b/src/Services/Documents/UblService.php index 60c14877..f5704a0e 100644 --- a/src/Services/Documents/UblService.php +++ b/src/Services/Documents/UblService.php @@ -7,45 +7,42 @@ use EInvoiceAPI\Client; use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Documents\Ubl\UblCreateFromUblParams; use EInvoiceAPI\Documents\Ubl\UblGetResponse; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\Documents\UblContract; final class UblService implements UblContract { + /** + * @api + */ + public UblRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new UblRawService($client); + } /** * @api * * Create a new invoice or credit note from a UBL file * - * @param array{file: string}|UblCreateFromUblParams $params - * * @throws APIException */ public function createFromUbl( - array|UblCreateFromUblParams $params, + string $file, ?RequestOptions $requestOptions = null ): DocumentResponse { - [$parsed, $options] = UblCreateFromUblParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['file' => $file]; - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: 'api/documents/ubl', - headers: ['Content-Type' => 'multipart/form-data'], - body: (object) $parsed, - options: $options, - convert: DocumentResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->createFromUbl(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -59,12 +56,9 @@ public function get( string $documentID, ?RequestOptions $requestOptions = null ): UblGetResponse { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: ['api/documents/%1$s/ubl', $documentID], - options: $requestOptions, - convert: UblGetResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($documentID, requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Services/DocumentsRawService.php b/src/Services/DocumentsRawService.php new file mode 100644 index 00000000..4bc1e845 --- /dev/null +++ b/src/Services/DocumentsRawService.php @@ -0,0 +1,303 @@ +|null, + * amountDue?: float|string|null, + * attachments?: list|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, + * charges?: list|null, + * currency?: value-of, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, + * direction?: 'INBOUND'|'OUTBOUND'|DocumentDirection, + * documentType?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType, + * dueDate?: string|\DateTimeInterface|null, + * invoiceDate?: string|\DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: float|string|null, + * items?: list>|null, + * amount?: float|string|null, + * charges?: list>|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, + * unitPrice?: float|string|null, + * }>, + * note?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * previousUnpaidBalance?: float|string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: string|\DateTimeInterface|null, + * serviceStartDate?: string|\DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, + * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState, + * subtotal?: float|string|null, + * taxCode?: 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B'|DocumentCreateParams\TaxCode, + * taxDetails?: list|null, + * totalDiscount?: float|string|null, + * totalTax?: float|string|null, + * vatex?: value-of, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, + * }|DocumentCreateParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|DocumentCreateParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = DocumentCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'api/documents/', + body: (object) $parsed, + options: $options, + convert: DocumentResponse::class, + ); + } + + /** + * @api + * + * Get an invoice or credit note by ID + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['api/documents/%1$s', $documentID], + options: $requestOptions, + convert: DocumentResponse::class, + ); + } + + /** + * @api + * + * Delete an invoice or credit note + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['api/documents/%1$s', $documentID], + options: $requestOptions, + convert: DocumentDeleteResponse::class, + ); + } + + /** + * @api + * + * Create a new invoice or credit note from a PDF file. If the 'ubl_document' field is set in the response, it indicates that sufficient details were extracted from the PDF to automatically generate a valid UBL document ready for sending. If 'ubl_document' is not set, human intervention may be required to ensure compliance. + * + * @param array{ + * file: string, customerTaxID?: string|null, vendorTaxID?: string|null + * }|DocumentCreateFromPdfParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function createFromPdf( + array|DocumentCreateFromPdfParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = DocumentCreateFromPdfParams::parseRequest( + $params, + $requestOptions, + ); + $query_params = array_flip(['customer_tax_id', 'vendor_tax_id']); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'api/documents/pdf', + query: Util::array_transform_keys( + array_diff_key($parsed, $query_params), + [ + 'customerTaxID' => 'customer_tax_id', 'vendorTaxID' => 'vendor_tax_id', + ], + ), + headers: ['Content-Type' => 'multipart/form-data'], + body: (object) array_diff_key($parsed, $query_params), + options: $options, + convert: DocumentNewFromPdfResponse::class, + ); + } + + /** + * @api + * + * Send an invoice or credit note via Peppol + * + * @param array{ + * email?: string|null, + * receiverPeppolID?: string|null, + * receiverPeppolScheme?: string|null, + * senderPeppolID?: string|null, + * senderPeppolScheme?: string|null, + * }|DocumentSendParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function send( + string $documentID, + array|DocumentSendParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = DocumentSendParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: ['api/documents/%1$s/send', $documentID], + query: Util::array_transform_keys( + $parsed, + [ + 'receiverPeppolID' => 'receiver_peppol_id', + 'receiverPeppolScheme' => 'receiver_peppol_scheme', + 'senderPeppolID' => 'sender_peppol_id', + 'senderPeppolScheme' => 'sender_peppol_scheme', + ], + ), + options: $options, + convert: DocumentResponse::class, + ); + } + + /** + * @api + * + * Validate a UBL document according to Peppol BIS Billing 3.0 + * + * @return BaseResponse + * + * @throws APIException + */ + public function validate( + string $documentID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: ['api/documents/%1$s/validate', $documentID], + options: $requestOptions, + convert: UblDocumentValidation::class, + ); + } +} diff --git a/src/Services/DocumentsService.php b/src/Services/DocumentsService.php index e80763b9..b4379343 100644 --- a/src/Services/DocumentsService.php +++ b/src/Services/DocumentsService.php @@ -8,14 +8,13 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Documents\CurrencyCode; use EInvoiceAPI\Documents\DocumentAttachmentCreate; -use EInvoiceAPI\Documents\DocumentCreateFromPdfParams; -use EInvoiceAPI\Documents\DocumentCreateParams; +use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\ReasonCode; +use EInvoiceAPI\Documents\DocumentCreateParams\Allowance\TaxCode; use EInvoiceAPI\Documents\DocumentCreateParams\Vatex; use EInvoiceAPI\Documents\DocumentDeleteResponse; use EInvoiceAPI\Documents\DocumentDirection; use EInvoiceAPI\Documents\DocumentNewFromPdfResponse; use EInvoiceAPI\Documents\DocumentResponse; -use EInvoiceAPI\Documents\DocumentSendParams; use EInvoiceAPI\Documents\DocumentType; use EInvoiceAPI\Documents\PaymentDetailCreate; use EInvoiceAPI\Documents\UnitOfMeasureCode; @@ -28,6 +27,11 @@ final class DocumentsService implements DocumentsContract { + /** + * @api + */ + public DocumentsRawService $raw; + /** * @api */ @@ -43,6 +47,7 @@ final class DocumentsService implements DocumentsContract */ public function __construct(private Client $client) { + $this->raw = new DocumentsRawService($client); $this->attachments = new AttachmentsService($client); $this->ubl = new UblService($client); } @@ -52,116 +57,221 @@ public function __construct(private Client $client) * * Create a new invoice or credit note * - * @param array{ + * @param list|null $allowances + * @param float|string|null $amountDue The amount due for payment. Must be positive and rounded to maximum 2 decimals + * @param list|null $attachments + * @param string|null $billingAddress The billing address (if different from customer address) + * @param string|null $billingAddressRecipient The recipient name at the billing address + * @param list|null $charges + * @param 'EUR'|'USD'|'GBP'|'JPY'|'CHF'|'CAD'|'AUD'|'NZD'|'CNY'|'INR'|'SEK'|'NOK'|'DKK'|'SGD'|'HKD'|CurrencyCode $currency Currency of the invoice (ISO 4217 currency code) + * @param string|null $customerAddress The address of the customer/buyer + * @param string|null $customerAddressRecipient The recipient name at the customer address + * @param string|null $customerCompanyID Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $customerEmail The email address of the customer + * @param string|null $customerID The unique identifier for the customer in your system + * @param string|null $customerName The company name of the customer/buyer + * @param string|null $customerTaxID Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * @param 'INBOUND'|'OUTBOUND'|DocumentDirection $direction The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType $documentType The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * @param string|\DateTimeInterface|null $dueDate The date when payment is due + * @param string|\DateTimeInterface|null $invoiceDate The date when the invoice was issued + * @param string|null $invoiceID The unique invoice identifier/number + * @param float|string|null $invoiceTotal The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals + * @param list|null, - * amount_due?: float|string|null, - * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, + * amount?: float|string|null, * charges?: list|null, - * currency?: value-of, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, - * direction?: 'INBOUND'|'OUTBOUND'|DocumentDirection, - * document_type?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType, - * due_date?: string|\DateTimeInterface|null, - * invoice_date?: string|\DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: float|string|null, - * items?: list>|null, - * amount?: float|string|null, - * charges?: list>|null, - * date?: null|null, - * description?: string|null, - * product_code?: string|null, - * quantity?: float|string|null, - * tax?: float|string|null, - * tax_rate?: float|string|null, - * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, - * unit_price?: float|string|null, - * }>, - * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * previous_unpaid_balance?: float|string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: string|\DateTimeInterface|null, - * service_start_date?: string|\DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, - * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState, - * subtotal?: float|string|null, - * tax_code?: 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B', - * tax_details?: list|null, - * total_discount?: float|string|null, - * total_tax?: float|string|null, - * vatex?: value-of, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, - * }|DocumentCreateParams $params + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, + * unitPrice?: float|string|null, + * }> $items At least one line item is required + * @param string|null $note Additional notes or comments for the invoice + * @param list|null $paymentDetails + * @param string|null $paymentTerm The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * @param float|string|null $previousUnpaidBalance The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals + * @param string|null $purchaseOrder The purchase order reference number + * @param string|null $remittanceAddress The address where payment should be sent or remitted to + * @param string|null $remittanceAddressRecipient The recipient name at the remittance address + * @param string|null $serviceAddress The address where services were performed or goods were delivered + * @param string|null $serviceAddressRecipient The recipient name at the service address + * @param string|\DateTimeInterface|null $serviceEndDate The end date of the service period or delivery period + * @param string|\DateTimeInterface|null $serviceStartDate The start date of the service period or delivery period + * @param string|null $shippingAddress The shipping/delivery address + * @param string|null $shippingAddressRecipient The recipient name at the shipping address + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState $state The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * @param float|string|null $subtotal The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals + * @param 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B'|\EInvoiceAPI\Documents\DocumentCreateParams\TaxCode $taxCode Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + * @param list|null $taxDetails + * @param float|string|null $totalDiscount The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals + * @param float|string|null $totalTax The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + * @param 'VATEX-EU-79-C'|'VATEX-EU-132'|'VATEX-EU-132-1A'|'VATEX-EU-132-1B'|'VATEX-EU-132-1C'|'VATEX-EU-132-1D'|'VATEX-EU-132-1E'|'VATEX-EU-132-1F'|'VATEX-EU-132-1G'|'VATEX-EU-132-1H'|'VATEX-EU-132-1I'|'VATEX-EU-132-1J'|'VATEX-EU-132-1K'|'VATEX-EU-132-1L'|'VATEX-EU-132-1M'|'VATEX-EU-132-1N'|'VATEX-EU-132-1O'|'VATEX-EU-132-1P'|'VATEX-EU-132-1Q'|'VATEX-EU-143'|'VATEX-EU-143-1A'|'VATEX-EU-143-1B'|'VATEX-EU-143-1C'|'VATEX-EU-143-1D'|'VATEX-EU-143-1E'|'VATEX-EU-143-1F'|'VATEX-EU-143-1FA'|'VATEX-EU-143-1G'|'VATEX-EU-143-1H'|'VATEX-EU-143-1I'|'VATEX-EU-143-1J'|'VATEX-EU-143-1K'|'VATEX-EU-143-1L'|'VATEX-EU-144'|'VATEX-EU-146-1E'|'VATEX-EU-148'|'VATEX-EU-148-A'|'VATEX-EU-148-B'|'VATEX-EU-148-C'|'VATEX-EU-148-D'|'VATEX-EU-148-E'|'VATEX-EU-148-F'|'VATEX-EU-148-G'|'VATEX-EU-151'|'VATEX-EU-151-1A'|'VATEX-EU-151-1AA'|'VATEX-EU-151-1B'|'VATEX-EU-151-1C'|'VATEX-EU-151-1D'|'VATEX-EU-151-1E'|'VATEX-EU-159'|'VATEX-EU-309'|'VATEX-EU-AE'|'VATEX-EU-D'|'VATEX-EU-F'|'VATEX-EU-G'|'VATEX-EU-I'|'VATEX-EU-IC'|'VATEX-EU-O'|'VATEX-EU-J'|'VATEX-FR-FRANCHISE'|'VATEX-FR-CNWVAT'|Vatex|null $vatex VATEX code list for VAT exemption reasons + * + * Agency: CEF + * Identifier: vatex + * @param string|null $vatexNote Textual explanation for VAT exemption + * @param string|null $vendorAddress The address of the vendor/seller + * @param string|null $vendorAddressRecipient The recipient name at the vendor address + * @param string|null $vendorCompanyID Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $vendorEmail The email address of the vendor + * @param string|null $vendorName The name of the vendor/seller/supplier + * @param string|null $vendorTaxID Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix * * @throws APIException */ public function create( - array|DocumentCreateParams $params, - ?RequestOptions $requestOptions = null + ?array $allowances = null, + float|string|null $amountDue = null, + ?array $attachments = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, + ?array $charges = null, + string|CurrencyCode|null $currency = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, + string|DocumentDirection|null $direction = null, + string|DocumentType|null $documentType = null, + string|\DateTimeInterface|null $dueDate = null, + string|\DateTimeInterface|null $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, + ?array $items = null, + ?string $note = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + string|\DateTimeInterface|null $serviceEndDate = null, + string|\DateTimeInterface|null $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, + string|DocumentState|null $state = null, + float|string|null $subtotal = null, + string|\EInvoiceAPI\Documents\DocumentCreateParams\TaxCode $taxCode = 'S', + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, + string|Vatex|null $vatex = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, + ?RequestOptions $requestOptions = null, ): DocumentResponse { - [$parsed, $options] = DocumentCreateParams::parseRequest( - $params, - $requestOptions, - ); + $params = [ + 'allowances' => $allowances, + 'amountDue' => $amountDue, + 'attachments' => $attachments, + 'billingAddress' => $billingAddress, + 'billingAddressRecipient' => $billingAddressRecipient, + 'charges' => $charges, + 'currency' => $currency, + 'customerAddress' => $customerAddress, + 'customerAddressRecipient' => $customerAddressRecipient, + 'customerCompanyID' => $customerCompanyID, + 'customerEmail' => $customerEmail, + 'customerID' => $customerID, + 'customerName' => $customerName, + 'customerTaxID' => $customerTaxID, + 'direction' => $direction, + 'documentType' => $documentType, + 'dueDate' => $dueDate, + 'invoiceDate' => $invoiceDate, + 'invoiceID' => $invoiceID, + 'invoiceTotal' => $invoiceTotal, + 'items' => $items, + 'note' => $note, + 'paymentDetails' => $paymentDetails, + 'paymentTerm' => $paymentTerm, + 'previousUnpaidBalance' => $previousUnpaidBalance, + 'purchaseOrder' => $purchaseOrder, + 'remittanceAddress' => $remittanceAddress, + 'remittanceAddressRecipient' => $remittanceAddressRecipient, + 'serviceAddress' => $serviceAddress, + 'serviceAddressRecipient' => $serviceAddressRecipient, + 'serviceEndDate' => $serviceEndDate, + 'serviceStartDate' => $serviceStartDate, + 'shippingAddress' => $shippingAddress, + 'shippingAddressRecipient' => $shippingAddressRecipient, + 'state' => $state, + 'subtotal' => $subtotal, + 'taxCode' => $taxCode, + 'taxDetails' => $taxDetails, + 'totalDiscount' => $totalDiscount, + 'totalTax' => $totalTax, + 'vatex' => $vatex, + 'vatexNote' => $vatexNote, + 'vendorAddress' => $vendorAddress, + 'vendorAddressRecipient' => $vendorAddressRecipient, + 'vendorCompanyID' => $vendorCompanyID, + 'vendorEmail' => $vendorEmail, + 'vendorName' => $vendorName, + 'vendorTaxID' => $vendorTaxID, + ]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: 'api/documents/', - body: (object) $parsed, - options: $options, - convert: DocumentResponse::class, - ); + return $response->parse(); } /** @@ -175,13 +285,10 @@ public function retrieve( string $documentID, ?RequestOptions $requestOptions = null ): DocumentResponse { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: ['api/documents/%1$s', $documentID], - options: $requestOptions, - convert: DocumentResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieve($documentID, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -195,13 +302,10 @@ public function delete( string $documentID, ?RequestOptions $requestOptions = null ): DocumentDeleteResponse { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'delete', - path: ['api/documents/%1$s', $documentID], - options: $requestOptions, - convert: DocumentDeleteResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($documentID, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -209,32 +313,30 @@ public function delete( * * Create a new invoice or credit note from a PDF file. If the 'ubl_document' field is set in the response, it indicates that sufficient details were extracted from the PDF to automatically generate a valid UBL document ready for sending. If 'ubl_document' is not set, human intervention may be required to ensure compliance. * - * @param array{ - * file: string, customer_tax_id?: string|null, vendor_tax_id?: string|null - * }|DocumentCreateFromPdfParams $params + * @param string $file Body param: + * @param string|null $customerTaxID Query param: + * @param string|null $vendorTaxID Query param: * * @throws APIException */ public function createFromPdf( - array|DocumentCreateFromPdfParams $params, + string $file, + ?string $customerTaxID = null, + ?string $vendorTaxID = null, ?RequestOptions $requestOptions = null, ): DocumentNewFromPdfResponse { - [$parsed, $options] = DocumentCreateFromPdfParams::parseRequest( - $params, - $requestOptions, - ); - $query_params = array_flip(['customer_tax_id', 'vendor_tax_id']); + $params = [ + 'file' => $file, + 'customerTaxID' => $customerTaxID, + 'vendorTaxID' => $vendorTaxID, + ]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: 'api/documents/pdf', - query: array_diff_key($parsed, $query_params), - headers: ['Content-Type' => 'multipart/form-data'], - body: (object) array_diff_key($parsed, $query_params), - options: $options, - convert: DocumentNewFromPdfResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->createFromPdf(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -242,34 +344,31 @@ public function createFromPdf( * * Send an invoice or credit note via Peppol * - * @param array{ - * email?: string|null, - * receiver_peppol_id?: string|null, - * receiver_peppol_scheme?: string|null, - * sender_peppol_id?: string|null, - * sender_peppol_scheme?: string|null, - * }|DocumentSendParams $params - * * @throws APIException */ public function send( string $documentID, - array|DocumentSendParams $params, + ?string $email = null, + ?string $receiverPeppolID = null, + ?string $receiverPeppolScheme = null, + ?string $senderPeppolID = null, + ?string $senderPeppolScheme = null, ?RequestOptions $requestOptions = null, ): DocumentResponse { - [$parsed, $options] = DocumentSendParams::parseRequest( - $params, - $requestOptions, - ); + $params = [ + 'email' => $email, + 'receiverPeppolID' => $receiverPeppolID, + 'receiverPeppolScheme' => $receiverPeppolScheme, + 'senderPeppolID' => $senderPeppolID, + 'senderPeppolScheme' => $senderPeppolScheme, + ]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: ['api/documents/%1$s/send', $documentID], - query: $parsed, - options: $options, - convert: DocumentResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->send($documentID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -283,12 +382,9 @@ public function validate( string $documentID, ?RequestOptions $requestOptions = null ): UblDocumentValidation { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: ['api/documents/%1$s/validate', $documentID], - options: $requestOptions, - convert: UblDocumentValidation::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->validate($documentID, requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Services/InboxRawService.php b/src/Services/InboxRawService.php new file mode 100644 index 00000000..3895f637 --- /dev/null +++ b/src/Services/InboxRawService.php @@ -0,0 +1,137 @@ +> + * + * @throws APIException + */ + public function list( + array|InboxListParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = InboxListParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/inbox/', + query: Util::array_transform_keys( + $parsed, + [ + 'dateFrom' => 'date_from', + 'dateTo' => 'date_to', + 'pageSize' => 'page_size', + ], + ), + options: $options, + convert: DocumentResponse::class, + page: DocumentsNumberPage::class, + ); + } + + /** + * @api + * + * Retrieve a paginated list of received credit notes with filtering options. + * + * @param array{page?: int, pageSize?: int}|InboxListCreditNotesParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listCreditNotes( + array|InboxListCreditNotesParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = InboxListCreditNotesParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/inbox/credit-notes', + query: Util::array_transform_keys($parsed, ['pageSize' => 'page_size']), + options: $options, + convert: DocumentResponse::class, + page: DocumentsNumberPage::class, + ); + } + + /** + * @api + * + * Retrieve a paginated list of received invoices with filtering options. + * + * @param array{page?: int, pageSize?: int}|InboxListInvoicesParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listInvoices( + array|InboxListInvoicesParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = InboxListInvoicesParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/inbox/invoices', + query: Util::array_transform_keys($parsed, ['pageSize' => 'page_size']), + options: $options, + convert: DocumentResponse::class, + page: DocumentsNumberPage::class, + ); + } +} diff --git a/src/Services/InboxService.php b/src/Services/InboxService.php index 0701d746..6e7828c0 100644 --- a/src/Services/InboxService.php +++ b/src/Services/InboxService.php @@ -10,57 +10,70 @@ use EInvoiceAPI\Documents\DocumentType; use EInvoiceAPI\DocumentsNumberPage; use EInvoiceAPI\Inbox\DocumentState; -use EInvoiceAPI\Inbox\InboxListCreditNotesParams; -use EInvoiceAPI\Inbox\InboxListInvoicesParams; -use EInvoiceAPI\Inbox\InboxListParams; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\InboxContract; final class InboxService implements InboxContract { + /** + * @api + */ + public InboxRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new InboxRawService($client); + } /** * @api * * Retrieve a paginated list of received documents with filtering options including state, type, sender, date range, and text search. * - * @param array{ - * date_from?: string|\DateTimeInterface|null, - * date_to?: string|\DateTimeInterface|null, - * page?: int, - * page_size?: int, - * search?: string|null, - * sender?: string|null, - * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null, - * type?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null, - * }|InboxListParams $params + * @param string|\DateTimeInterface|null $dateFrom Filter by issue date (from) + * @param string|\DateTimeInterface|null $dateTo Filter by issue date (to) + * @param int $page Page number + * @param int $pageSize Number of items per page + * @param string|null $search Search in invoice number, seller/buyer names + * @param string|null $sender Filter by sender ID + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null $state Filter by document state + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null $type Filter by document type * * @return DocumentsNumberPage * * @throws APIException */ public function list( - array|InboxListParams $params, - ?RequestOptions $requestOptions = null + string|\DateTimeInterface|null $dateFrom = null, + string|\DateTimeInterface|null $dateTo = null, + int $page = 1, + int $pageSize = 20, + ?string $search = null, + ?string $sender = null, + string|DocumentState|null $state = null, + string|DocumentType|null $type = null, + ?RequestOptions $requestOptions = null, ): DocumentsNumberPage { - [$parsed, $options] = InboxListParams::parseRequest( - $params, - $requestOptions, - ); + $params = [ + 'dateFrom' => $dateFrom, + 'dateTo' => $dateTo, + 'page' => $page, + 'pageSize' => $pageSize, + 'search' => $search, + 'sender' => $sender, + 'state' => $state, + 'type' => $type, + ]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/inbox/', - query: $parsed, - options: $options, - convert: DocumentResponse::class, - page: DocumentsNumberPage::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -68,30 +81,26 @@ public function list( * * Retrieve a paginated list of received credit notes with filtering options. * - * @param array{page?: int, page_size?: int}|InboxListCreditNotesParams $params + * @param int $page Page number + * @param int $pageSize Number of items per page * * @return DocumentsNumberPage * * @throws APIException */ public function listCreditNotes( - array|InboxListCreditNotesParams $params, - ?RequestOptions $requestOptions = null, + int $page = 1, + int $pageSize = 20, + ?RequestOptions $requestOptions = null ): DocumentsNumberPage { - [$parsed, $options] = InboxListCreditNotesParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['page' => $page, 'pageSize' => $pageSize]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->listCreditNotes(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/inbox/credit-notes', - query: $parsed, - options: $options, - convert: DocumentResponse::class, - page: DocumentsNumberPage::class, - ); + return $response->parse(); } /** @@ -99,29 +108,25 @@ public function listCreditNotes( * * Retrieve a paginated list of received invoices with filtering options. * - * @param array{page?: int, page_size?: int}|InboxListInvoicesParams $params + * @param int $page Page number + * @param int $pageSize Number of items per page * * @return DocumentsNumberPage * * @throws APIException */ public function listInvoices( - array|InboxListInvoicesParams $params, - ?RequestOptions $requestOptions = null, + int $page = 1, + int $pageSize = 20, + ?RequestOptions $requestOptions = null ): DocumentsNumberPage { - [$parsed, $options] = InboxListInvoicesParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['page' => $page, 'pageSize' => $pageSize]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->listInvoices(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/inbox/invoices', - query: $parsed, - options: $options, - convert: DocumentResponse::class, - page: DocumentsNumberPage::class, - ); + return $response->parse(); } } diff --git a/src/Services/LookupRawService.php b/src/Services/LookupRawService.php new file mode 100644 index 00000000..dacf98b1 --- /dev/null +++ b/src/Services/LookupRawService.php @@ -0,0 +1,90 @@ +:`. The scheme is a 4-digit code representing the identifier scheme, and the id is the actual identifier value. For example, for a Belgian company it is `0208:0123456789` (where 0208 is the scheme for Belgian enterprises, followed by the 10 digits of the official BTW / KBO number). + * + * @param array{peppolID: string}|LookupRetrieveParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + array|LookupRetrieveParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = LookupRetrieveParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/lookup', + query: Util::array_transform_keys($parsed, ['peppolID' => 'peppol_id']), + options: $options, + convert: LookupGetResponse::class, + ); + } + + /** + * @api + * + * Lookup Peppol participants by name or other identifiers. You can limit the search to a specific country by providing the country code. + * + * @param array{ + * query: string, countryCode?: string|null + * }|LookupRetrieveParticipantsParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieveParticipants( + array|LookupRetrieveParticipantsParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = LookupRetrieveParticipantsParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/lookup/participants', + query: Util::array_transform_keys( + $parsed, + ['countryCode' => 'country_code'] + ), + options: $options, + convert: LookupGetParticipantsResponse::class, + ); + } +} diff --git a/src/Services/LookupService.php b/src/Services/LookupService.php index 7ba65566..0a2c91e6 100644 --- a/src/Services/LookupService.php +++ b/src/Services/LookupService.php @@ -8,44 +8,43 @@ use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\Lookup\LookupGetParticipantsResponse; use EInvoiceAPI\Lookup\LookupGetResponse; -use EInvoiceAPI\Lookup\LookupRetrieveParams; -use EInvoiceAPI\Lookup\LookupRetrieveParticipantsParams; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\LookupContract; final class LookupService implements LookupContract { + /** + * @api + */ + public LookupRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new LookupRawService($client); + } /** * @api * * Lookup Peppol ID. The peppol_id must be in the form of `:`. The scheme is a 4-digit code representing the identifier scheme, and the id is the actual identifier value. For example, for a Belgian company it is `0208:0123456789` (where 0208 is the scheme for Belgian enterprises, followed by the 10 digits of the official BTW / KBO number). * - * @param array{peppol_id: string}|LookupRetrieveParams $params + * @param string $peppolID Peppol ID in the format `:`. Example: `0208:1018265814` for a Belgian company. * * @throws APIException */ public function retrieve( - array|LookupRetrieveParams $params, + string $peppolID, ?RequestOptions $requestOptions = null ): LookupGetResponse { - [$parsed, $options] = LookupRetrieveParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['peppolID' => $peppolID]; + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieve(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/lookup', - query: $parsed, - options: $options, - convert: LookupGetResponse::class, - ); + return $response->parse(); } /** @@ -53,28 +52,23 @@ public function retrieve( * * Lookup Peppol participants by name or other identifiers. You can limit the search to a specific country by providing the country code. * - * @param array{ - * query: string, country_code?: string|null - * }|LookupRetrieveParticipantsParams $params + * @param string $query Query to lookup + * @param string|null $countryCode Country code of the company to lookup. If not provided, the search will be global. * * @throws APIException */ public function retrieveParticipants( - array|LookupRetrieveParticipantsParams $params, + string $query, + ?string $countryCode = null, ?RequestOptions $requestOptions = null, ): LookupGetParticipantsResponse { - [$parsed, $options] = LookupRetrieveParticipantsParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['query' => $query, 'countryCode' => $countryCode]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieveParticipants(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/lookup/participants', - query: $parsed, - options: $options, - convert: LookupGetParticipantsResponse::class, - ); + return $response->parse(); } } diff --git a/src/Services/MeRawService.php b/src/Services/MeRawService.php new file mode 100644 index 00000000..7a0c305f --- /dev/null +++ b/src/Services/MeRawService.php @@ -0,0 +1,42 @@ + + * + * @throws APIException + */ + public function retrieve( + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/me/', + options: $requestOptions, + convert: MeGetResponse::class, + ); + } +} diff --git a/src/Services/MeService.php b/src/Services/MeService.php index 8c912d73..1225213a 100644 --- a/src/Services/MeService.php +++ b/src/Services/MeService.php @@ -12,10 +12,18 @@ final class MeService implements MeContract { + /** + * @api + */ + public MeRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new MeRawService($client); + } /** * @api @@ -27,12 +35,9 @@ public function __construct(private Client $client) {} public function retrieve( ?RequestOptions $requestOptions = null ): MeGetResponse { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/me/', - options: $requestOptions, - convert: MeGetResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieve(requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Services/OutboxRawService.php b/src/Services/OutboxRawService.php new file mode 100644 index 00000000..cf04f416 --- /dev/null +++ b/src/Services/OutboxRawService.php @@ -0,0 +1,105 @@ +> + * + * @throws APIException + */ + public function listDraftDocuments( + array|OutboxListDraftDocumentsParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = OutboxListDraftDocumentsParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/outbox/drafts', + query: Util::array_transform_keys($parsed, ['pageSize' => 'page_size']), + options: $options, + convert: DocumentResponse::class, + page: DocumentsNumberPage::class, + ); + } + + /** + * @api + * + * Retrieve a paginated list of sent documents with filtering options including state, type, sender, date range, and text search. + * + * @param array{ + * dateFrom?: string|\DateTimeInterface|null, + * dateTo?: string|\DateTimeInterface|null, + * page?: int, + * pageSize?: int, + * search?: string|null, + * sender?: string|null, + * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null, + * type?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null, + * }|OutboxListReceivedDocumentsParams $params + * + * @return BaseResponse> + * + * @throws APIException + */ + public function listReceivedDocuments( + array|OutboxListReceivedDocumentsParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = OutboxListReceivedDocumentsParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/outbox/', + query: Util::array_transform_keys( + $parsed, + [ + 'dateFrom' => 'date_from', + 'dateTo' => 'date_to', + 'pageSize' => 'page_size', + ], + ), + options: $options, + convert: DocumentResponse::class, + page: DocumentsNumberPage::class, + ); + } +} diff --git a/src/Services/OutboxService.php b/src/Services/OutboxService.php index 0a52ae8e..4c8ffcde 100644 --- a/src/Services/OutboxService.php +++ b/src/Services/OutboxService.php @@ -10,47 +10,49 @@ use EInvoiceAPI\Documents\DocumentType; use EInvoiceAPI\DocumentsNumberPage; use EInvoiceAPI\Inbox\DocumentState; -use EInvoiceAPI\Outbox\OutboxListDraftDocumentsParams; -use EInvoiceAPI\Outbox\OutboxListReceivedDocumentsParams; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\OutboxContract; final class OutboxService implements OutboxContract { + /** + * @api + */ + public OutboxRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new OutboxRawService($client); + } /** * @api * * Retrieve a paginated list of draft documents with filtering options. * - * @param array{page?: int, page_size?: int}|OutboxListDraftDocumentsParams $params + * @param int $page Page number + * @param int $pageSize Number of items per page * * @return DocumentsNumberPage * * @throws APIException */ public function listDraftDocuments( - array|OutboxListDraftDocumentsParams $params, - ?RequestOptions $requestOptions = null, + int $page = 1, + int $pageSize = 20, + ?RequestOptions $requestOptions = null ): DocumentsNumberPage { - [$parsed, $options] = OutboxListDraftDocumentsParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['page' => $page, 'pageSize' => $pageSize]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/outbox/drafts', - query: $parsed, - options: $options, - convert: DocumentResponse::class, - page: DocumentsNumberPage::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->listDraftDocuments(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -58,38 +60,46 @@ public function listDraftDocuments( * * Retrieve a paginated list of sent documents with filtering options including state, type, sender, date range, and text search. * - * @param array{ - * date_from?: string|\DateTimeInterface|null, - * date_to?: string|\DateTimeInterface|null, - * page?: int, - * page_size?: int, - * search?: string|null, - * sender?: string|null, - * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null, - * type?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null, - * }|OutboxListReceivedDocumentsParams $params + * @param string|\DateTimeInterface|null $dateFrom Filter by issue date (from) + * @param string|\DateTimeInterface|null $dateTo Filter by issue date (to) + * @param int $page Page number + * @param int $pageSize Number of items per page + * @param string|null $search Search in invoice number, seller/buyer names + * @param string|null $sender Filter by sender ID + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState|null $state Filter by document state + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType|null $type Filter by document type * * @return DocumentsNumberPage * * @throws APIException */ public function listReceivedDocuments( - array|OutboxListReceivedDocumentsParams $params, + string|\DateTimeInterface|null $dateFrom = null, + string|\DateTimeInterface|null $dateTo = null, + int $page = 1, + int $pageSize = 20, + ?string $search = null, + ?string $sender = null, + string|DocumentState|null $state = null, + string|DocumentType|null $type = null, ?RequestOptions $requestOptions = null, ): DocumentsNumberPage { - [$parsed, $options] = OutboxListReceivedDocumentsParams::parseRequest( - $params, - $requestOptions, - ); + $params = [ + 'dateFrom' => $dateFrom, + 'dateTo' => $dateTo, + 'page' => $page, + 'pageSize' => $pageSize, + 'search' => $search, + 'sender' => $sender, + 'state' => $state, + 'type' => $type, + ]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->listReceivedDocuments(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/outbox/', - query: $parsed, - options: $options, - convert: DocumentResponse::class, - page: DocumentsNumberPage::class, - ); + return $response->parse(); } } diff --git a/src/Services/ValidateRawService.php b/src/Services/ValidateRawService.php new file mode 100644 index 00000000..fc51988e --- /dev/null +++ b/src/Services/ValidateRawService.php @@ -0,0 +1,211 @@ +|null, + * amountDue?: float|string|null, + * attachments?: list|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, + * charges?: list|null, + * currency?: value-of, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, + * direction?: 'INBOUND'|'OUTBOUND'|DocumentDirection, + * documentType?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType, + * dueDate?: string|\DateTimeInterface|null, + * invoiceDate?: string|\DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: float|string|null, + * items?: list>|null, + * amount?: float|string|null, + * charges?: list>|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, + * unitPrice?: float|string|null, + * }>, + * note?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * previousUnpaidBalance?: float|string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: string|\DateTimeInterface|null, + * serviceStartDate?: string|\DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, + * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState, + * subtotal?: float|string|null, + * taxCode?: 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B'|ValidateValidateJsonParams\TaxCode, + * taxDetails?: list|null, + * totalDiscount?: float|string|null, + * totalTax?: float|string|null, + * vatex?: value-of, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, + * }|ValidateValidateJsonParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function validateJson( + array|ValidateValidateJsonParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = ValidateValidateJsonParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'api/validate/json', + body: (object) $parsed, + options: $options, + convert: UblDocumentValidation::class, + ); + } + + /** + * @api + * + * Validate if a Peppol ID exists in the Peppol network and retrieve supported document types. The peppol_id must be in the form of `:`. The scheme is a 4-digit code representing the identifier scheme, and the id is the actual identifier value. For example, for a Belgian company it is `0208:0123456789` (where 0208 is the scheme for Belgian enterprises, followed by the 10 digits of the official BTW / KBO number). + * + * @param array{peppolID: string}|ValidateValidatePeppolIDParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function validatePeppolID( + array|ValidateValidatePeppolIDParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = ValidateValidatePeppolIDParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/validate/peppol-id', + query: Util::array_transform_keys($parsed, ['peppolID' => 'peppol_id']), + options: $options, + convert: ValidateValidatePeppolIDResponse::class, + ); + } + + /** + * @api + * + * Validate the correctness of a UBL document + * + * @param array{file: string}|ValidateValidateUblParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function validateUbl( + array|ValidateValidateUblParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = ValidateValidateUblParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'api/validate/ubl', + headers: ['Content-Type' => 'multipart/form-data'], + body: (object) $parsed, + options: $options, + convert: UblDocumentValidation::class, + ); + } +} diff --git a/src/Services/ValidateService.php b/src/Services/ValidateService.php index 6509684f..85608ec6 100644 --- a/src/Services/ValidateService.php +++ b/src/Services/ValidateService.php @@ -16,134 +16,246 @@ use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\ValidateContract; use EInvoiceAPI\Validate\UblDocumentValidation; -use EInvoiceAPI\Validate\ValidateValidateJsonParams; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\ReasonCode; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\TaxCode; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Vatex; -use EInvoiceAPI\Validate\ValidateValidatePeppolIDParams; use EInvoiceAPI\Validate\ValidateValidatePeppolIDResponse; -use EInvoiceAPI\Validate\ValidateValidateUblParams; final class ValidateService implements ValidateContract { + /** + * @api + */ + public ValidateRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new ValidateRawService($client); + } /** * @api * * Validate if the JSON document can be converted to a valid UBL document * - * @param array{ + * @param list|null $allowances + * @param float|string|null $amountDue The amount due for payment. Must be positive and rounded to maximum 2 decimals + * @param list|null $attachments + * @param string|null $billingAddress The billing address (if different from customer address) + * @param string|null $billingAddressRecipient The recipient name at the billing address + * @param list|null $charges + * @param 'EUR'|'USD'|'GBP'|'JPY'|'CHF'|'CAD'|'AUD'|'NZD'|'CNY'|'INR'|'SEK'|'NOK'|'DKK'|'SGD'|'HKD'|CurrencyCode $currency Currency of the invoice (ISO 4217 currency code) + * @param string|null $customerAddress The address of the customer/buyer + * @param string|null $customerAddressRecipient The recipient name at the customer address + * @param string|null $customerCompanyID Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $customerEmail The email address of the customer + * @param string|null $customerID The unique identifier for the customer in your system + * @param string|null $customerName The company name of the customer/buyer + * @param string|null $customerTaxID Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * @param 'INBOUND'|'OUTBOUND'|DocumentDirection $direction The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * @param 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType $documentType The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * @param string|\DateTimeInterface|null $dueDate The date when payment is due + * @param string|\DateTimeInterface|null $invoiceDate The date when the invoice was issued + * @param string|null $invoiceID The unique invoice identifier/number + * @param float|string|null $invoiceTotal The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals + * @param list|null, - * amount_due?: float|string|null, - * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, + * amount?: float|string|null, * charges?: list|null, - * currency?: value-of, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, - * direction?: 'INBOUND'|'OUTBOUND'|DocumentDirection, - * document_type?: 'INVOICE'|'CREDIT_NOTE'|'DEBIT_NOTE'|DocumentType, - * due_date?: string|\DateTimeInterface|null, - * invoice_date?: string|\DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: float|string|null, - * items?: list>|null, - * amount?: float|string|null, - * charges?: list>|null, - * date?: null|null, - * description?: string|null, - * product_code?: string|null, - * quantity?: float|string|null, - * tax?: float|string|null, - * tax_rate?: float|string|null, - * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, - * unit_price?: float|string|null, - * }>, - * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * previous_unpaid_balance?: float|string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: string|\DateTimeInterface|null, - * service_start_date?: string|\DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, - * state?: 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState, - * subtotal?: float|string|null, - * tax_code?: 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B', - * tax_details?: list|null, - * total_discount?: float|string|null, - * total_tax?: float|string|null, - * vatex?: value-of, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, - * }|ValidateValidateJsonParams $params + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: '10'|'11'|'13'|'14'|'15'|'20'|'21'|'22'|'23'|'24'|'25'|'27'|'28'|'33'|'34'|'35'|'37'|'38'|'40'|'41'|'56'|'57'|'58'|'59'|'60'|'61'|'74'|'77'|'80'|'81'|'85'|'87'|'89'|'91'|'1I'|'EA'|'E01'|'E07'|'E09'|'E10'|'E12'|'E14'|'E17'|'E20'|'E23'|'E25'|'E27'|'E31'|'E34'|'E35'|'E36'|'E37'|'E38'|'E39'|'E40'|'E41'|'E42'|'E43'|'E44'|'E45'|'E46'|'E47'|'E48'|'E49'|'E50'|'E51'|'E52'|'E53'|'E54'|'E55'|'E56'|'E57'|'E58'|'E60'|'E62'|'E65'|'E66'|'E67'|'E69'|'E70'|'E71'|'E73'|'E75'|'E76'|'2A'|'2B'|'2C'|'2G'|'2H'|'2I'|'2J'|'2K'|'2L'|'2M'|'2N'|'2P'|'2Q'|'2R'|'2U'|'2X'|'2Y'|'2Z'|'3B'|'3C'|'4C'|'4G'|'4H'|'4K'|'4L'|'4M'|'4N'|'4O'|'4P'|'4Q'|'4R'|'4T'|'4U'|'4W'|'4X'|'5A'|'5B'|'5E'|'5J'|'A10'|'A11'|'A12'|'A13'|'A14'|'A15'|'A16'|'A17'|'A18'|'A19'|'A2'|'A20'|'A21'|'A22'|'A23'|'A24'|'A26'|'A27'|'A28'|'A29'|'A3'|'A30'|'A31'|'A32'|'A33'|'A34'|'A35'|'A36'|'A37'|'A38'|'A39'|'A4'|'A40'|'A41'|'A42'|'A43'|'A44'|'A45'|'A46'|'A47'|'A48'|'A49'|'A5'|'A50'|'A51'|'A52'|'A53'|'A54'|'A55'|'A56'|'A57'|'A58'|'A59'|'A6'|'A60'|'A61'|'A62'|'A63'|'A64'|'A65'|'A66'|'A67'|'A68'|'A69'|'A7'|'A70'|'A71'|'A72'|'A73'|'A74'|'A75'|'A76'|'A77'|'A78'|'A79'|'A8'|'A80'|'A81'|'A82'|'A83'|'A84'|'A85'|'A86'|'A87'|'A88'|'A89'|'A9'|'A90'|'A91'|'A92'|'A93'|'A94'|'A95'|'A96'|'A97'|'A98'|'A99'|'ACR'|'AH'|'AI'|'AK'|'AMH'|'AMT'|'ANN'|'B1'|'B11'|'B12'|'B13'|'B14'|'B15'|'B16'|'B17'|'B18'|'B19'|'B20'|'B21'|'B22'|'B23'|'B24'|'B25'|'B26'|'B27'|'B28'|'B29'|'B3'|'B30'|'B31'|'B32'|'B33'|'B34'|'B35'|'B36'|'B37'|'B38'|'B39'|'B4'|'B40'|'B41'|'B42'|'B43'|'B44'|'B45'|'B46'|'B47'|'B48'|'B49'|'B5'|'B50'|'B52'|'B53'|'B54'|'B55'|'B56'|'B57'|'B58'|'B59'|'B6'|'B60'|'B61'|'B62'|'B63'|'B64'|'B65'|'B66'|'B67'|'B68'|'B69'|'B7'|'B70'|'B71'|'B72'|'B73'|'B74'|'B75'|'B76'|'B77'|'B78'|'B79'|'B8'|'B80'|'B81'|'B82'|'B83'|'B84'|'B85'|'B86'|'B87'|'B88'|'B89'|'B9'|'B90'|'B91'|'B92'|'B93'|'B94'|'B95'|'B96'|'B97'|'B98'|'B99'|'BAR'|'BB'|'BFT'|'BHP'|'BIL'|'BLD'|'BLL'|'BUA'|'BUI'|'C0'|'C10'|'C11'|'C12'|'C13'|'C14'|'C15'|'C16'|'C17'|'C18'|'C19'|'C20'|'C21'|'C22'|'C23'|'C24'|'C25'|'C26'|'C27'|'C28'|'C29'|'C30'|'C31'|'C32'|'C33'|'C34'|'C35'|'C36'|'C37'|'C38'|'C39'|'C40'|'C41'|'C42'|'C43'|'C44'|'C45'|'C46'|'C47'|'C48'|'C49'|'C50'|'C51'|'C52'|'C53'|'C54'|'C55'|'C56'|'C57'|'C58'|'C59'|'C60'|'C61'|'C63'|'C64'|'C65'|'C66'|'C67'|'C68'|'C69'|'C70'|'C71'|'C72'|'C73'|'C74'|'C75'|'C76'|'C77'|'C78'|'C79'|'C80'|'C81'|'C82'|'C83'|'C84'|'C85'|'C86'|'C87'|'C88'|'C89'|'C90'|'C91'|'C92'|'C93'|'C94'|'C95'|'C96'|'C97'|'C98'|'C99'|'CDL'|'CEL'|'CHU'|'CIU'|'CLT'|'CMK'|'CMQ'|'CMT'|'CNP'|'CNT'|'COU'|'CTG'|'CTN'|'CUR'|'CWA'|'CWI'|'DAN'|'DAY'|'DB'|'DD'|'DG'|'DI'|'DLT'|'DMK'|'DMQ'|'DMT'|'DPC'|'DPT'|'DRA'|'DZN'|'DZP'|'FOT'|'GLL'|'GLI'|'GRM'|'GRO'|'HUR'|'HTZ'|'INH'|'KGM'|'KMT'|'MTR'|'SMI'|'MIN'|'MON'|'ONZ'|'LBR'|'QT'|'SEC'|'FTK'|'INK'|'MTK'|'YDK'|'TNE'|'VLT'|'WTT'|'YRD'|'FTQ'|'INQ'|'MTQ'|'YDQ'|'HAR'|'KLT'|'MLT'|'MMT'|'KMK'|'MMK'|'XAA'|'XAB'|'XAC'|'XAD'|'XAE'|'XAF'|'XAG'|'XAH'|'XAI'|'XAJ'|'XAL'|'XAM'|'XAP'|'XAT'|'XAV'|'XB4'|'XBA'|'XBB'|'XBC'|'XBD'|'XBE'|'XBF'|'XBG'|'XBH'|'XBI'|'XBJ'|'XBK'|'XBL'|'XBM'|'XBN'|'XBO'|'XBP'|'XBQ'|'XBR'|'XBS'|'XBT'|'XBU'|'XBV'|'XBW'|'XBX'|'XBY'|'XBZ'|'XCA'|'XCB'|'XCC'|'XCD'|'XCE'|'XCF'|'XCG'|'XCH'|'XCI'|'XCJ'|'XCK'|'XCL'|'XCM'|'XCN'|'XCO'|'XCP'|'XCQ'|'XCR'|'XCS'|'XCT'|'XCU'|'XCV'|'XCW'|'XCX'|'XCY'|'XCZ'|'XDA'|'XDB'|'XDC'|'XDD'|'XDE'|'XDF'|'XDG'|'XDH'|'XDI'|'XDJ'|'XDK'|'XDL'|'XDM'|'XDN'|'XDP'|'XDQ'|'XDR'|'XDS'|'XDT'|'XDU'|'XDV'|'XDW'|'XDX'|'XDY'|'XDZ'|'XEA'|'XEB'|'XEC'|'XED'|'XEE'|'XEF'|'XEG'|'XEH'|'XEI'|'XEJ'|'XEK'|'XEL'|'XEM'|'XEN'|'XEP'|'XEQ'|'XER'|'XES'|'XET'|'XEU'|'XEV'|'XEW'|'XEX'|'XEY'|'XFB'|'XFC'|'XFD'|'XFE'|'XFF'|'XFG'|'XFH'|'XFI'|'XFJ'|'XFK'|'XFL'|'XFM'|'XFN'|'XFO'|'XFP'|'XFQ'|'XFR'|'XFS'|'XFT'|'XFU'|'XFV'|'XFW'|'XFX'|'XFY'|'XFZ'|'XGA'|'XGB'|'XGC'|'XGD'|'XGE'|'XGF'|'XGG'|'XGH'|'XGI'|'XGJ'|'XGK'|'XGL'|'XGM'|'XGN'|'XGO'|'XGP'|'XGQ'|'XGR'|'XGS'|'XGT'|'XGU'|'XGV'|'XGW'|'XGX'|'XGY'|'XGZ'|'XHA'|'XHB'|'XHC'|'XHD'|'XHE'|'XHF'|'XHG'|'XHH'|'XHI'|'XHJ'|'XHK'|'XHL'|'XHM'|'XHN'|'XHP'|'XHQ'|'XHR'|'XHS'|'XHT'|'XHU'|'XHV'|'XHW'|'XHX'|'XHY'|'XHZ'|'XIA'|'XIB'|'XIC'|'XID'|'XIE'|'XIF'|'XIG'|'XIH'|'XII'|'XIJ'|'XIK'|'XIL'|'XIM'|'XIN'|'XIO'|'XJA'|'XJB'|'XJC'|'XJD'|'XJE'|'XJF'|'XJG'|'XJH'|'XJI'|'XJJ'|'XJK'|'XJL'|'XJM'|'XJN'|'XJO'|'XJP'|'XJQ'|'XJR'|'XJS'|'XJT'|'XJU'|'XJV'|'XJW'|'XJX'|'XJY'|'XJZ'|'XLA'|'XLB'|'XLC'|'XLD'|'XLE'|'XLF'|'XLG'|'XLH'|'XLI'|'XLJ'|'XLK'|'XLL'|'XLM'|'XLN'|'XLO'|'XLP'|'XLQ'|'XLR'|'XLS'|'XLT'|'XLU'|'XLV'|'XLW'|'XLX'|'XLY'|'XLZ'|'XMA'|'XMB'|'XMC'|'XMD'|'XME'|'XMF'|'XMG'|'XMH'|'XMI'|'XMJ'|'XMK'|'XML'|'XMM'|'XMN'|'XMO'|'XMP'|'XMQ'|'XMR'|'XMS'|'XMT'|'XMU'|'XMV'|'XMW'|'XMX'|'XMY'|'XMZ'|'XNA'|'XNB'|'XNC'|'XND'|'XNE'|'XNF'|'XNG'|'XNH'|'XNI'|'XNJ'|'XNK'|'XNL'|'XNM'|'XOA'|'XOB'|'XOC'|'XOD'|'XOE'|'XOF'|'XOG'|'XOH'|'XOI'|'XOJ'|'XOK'|'XOL'|'XOM'|'XON'|'XOO'|'XOP'|'XOQ'|'XOR'|'XOS'|'XOT'|'XOU'|'XOV'|'XOW'|'XOX'|'XOY'|'XOZ'|'XP1'|'XP2'|'XP3'|'XP4'|'XPA'|'XPB'|'XPC'|'XPD'|'XPE'|'XPF'|'XPG'|'XPH'|'XPI'|'XPJ'|'XPK'|'XPL'|'XPM'|'XPN'|'XPO'|'XPP'|'XPQ'|'XPR'|'XPS'|'XPT'|'XPU'|'XPV'|'XPW'|'XPX'|'XPY'|'XPZ'|'XQA'|'XQB'|'XQC'|'XQD'|'XQE'|'XQF'|'XQG'|'XQH'|'XQI'|'XQJ'|'XQK'|'XQL'|'XQM'|'XQN'|'XQO'|'XQP'|'XQQ'|'XQR'|'XQS'|'XRD'|'XRE'|'XRF'|'XRG'|'XRH'|'XRI'|'XRJ'|'XRK'|'XRL'|'XRM'|'XRN'|'XRO'|'XRP'|'XRQ'|'XRR'|'XRS'|'XRT'|'XRU'|'XRV'|'XRW'|'XRX'|'XRY'|'XRZ'|'XSA'|'XSB'|'XSC'|'XSD'|'XSE'|'XSF'|'XSG'|'XSH'|'XSI'|'XSJ'|'XSK'|'XSL'|'XSM'|'XSN'|'XSO'|'XSP'|'XSQ'|'XSR'|'XSS'|'XST'|'XSU'|'XSV'|'XSW'|'XSX'|'XSY'|'XSZ'|'XTA'|'XTB'|'XTC'|'XTD'|'XTE'|'XTF'|'XTG'|'XTI'|'XTJ'|'XTK'|'XTL'|'XTM'|'XTN'|'XTO'|'XTR'|'XTS'|'XTT'|'XTU'|'XTV'|'XTW'|'XTX'|'XTY'|'XTZ'|'XUC'|'XUN'|'XVA'|'XVG'|'XVI'|'XVK'|'XVL'|'XVN'|'XVO'|'XVP'|'XVQ'|'XVR'|'XVS'|'XVY'|'XWA'|'XWB'|'XWC'|'XWD'|'XWF'|'XWG'|'XWH'|'XWJ'|'XWK'|'XWL'|'XWM'|'XWN'|'XWP'|'XWQ'|'XWR'|'XWS'|'XWT'|'XWU'|'XWV'|'XWW'|'XWX'|'XWY'|'XWZ'|'XXA'|'XXB'|'XXC'|'XXD'|'XXF'|'XXG'|'XXH'|'XXJ'|'XXK'|'XYA'|'XYB'|'XYC'|'XYD'|'XYF'|'XYG'|'XYH'|'XYJ'|'XYK'|'XYL'|'XYM'|'XYN'|'XYP'|'XYQ'|'XYR'|'XYS'|'XYT'|'XYV'|'XYW'|'XYX'|'XYY'|'XYZ'|'XZA'|'XZB'|'XZC'|'XZD'|'XZF'|'XZG'|'XZH'|'XZJ'|'XZK'|'XZL'|'XZM'|'XZN'|'XZP'|'XZQ'|'XZR'|'XZS'|'XZT'|'XZU'|'XZV'|'XZW'|'XZX'|'XZY'|'XZZ'|'ZZ'|'NAR'|'C62'|'LTR'|'H87'|UnitOfMeasureCode|null, + * unitPrice?: float|string|null, + * }> $items At least one line item is required + * @param string|null $note Additional notes or comments for the invoice + * @param list|null $paymentDetails + * @param string|null $paymentTerm The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * @param float|string|null $previousUnpaidBalance The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals + * @param string|null $purchaseOrder The purchase order reference number + * @param string|null $remittanceAddress The address where payment should be sent or remitted to + * @param string|null $remittanceAddressRecipient The recipient name at the remittance address + * @param string|null $serviceAddress The address where services were performed or goods were delivered + * @param string|null $serviceAddressRecipient The recipient name at the service address + * @param string|\DateTimeInterface|null $serviceEndDate The end date of the service period or delivery period + * @param string|\DateTimeInterface|null $serviceStartDate The start date of the service period or delivery period + * @param string|null $shippingAddress The shipping/delivery address + * @param string|null $shippingAddressRecipient The recipient name at the shipping address + * @param 'DRAFT'|'TRANSIT'|'FAILED'|'SENT'|'RECEIVED'|DocumentState $state The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * @param float|string|null $subtotal The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals + * @param 'AE'|'E'|'S'|'Z'|'G'|'O'|'K'|'L'|'M'|'B'|\EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode $taxCode Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + * @param list|null $taxDetails + * @param float|string|null $totalDiscount The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals + * @param float|string|null $totalTax The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + * @param 'VATEX-EU-79-C'|'VATEX-EU-132'|'VATEX-EU-132-1A'|'VATEX-EU-132-1B'|'VATEX-EU-132-1C'|'VATEX-EU-132-1D'|'VATEX-EU-132-1E'|'VATEX-EU-132-1F'|'VATEX-EU-132-1G'|'VATEX-EU-132-1H'|'VATEX-EU-132-1I'|'VATEX-EU-132-1J'|'VATEX-EU-132-1K'|'VATEX-EU-132-1L'|'VATEX-EU-132-1M'|'VATEX-EU-132-1N'|'VATEX-EU-132-1O'|'VATEX-EU-132-1P'|'VATEX-EU-132-1Q'|'VATEX-EU-143'|'VATEX-EU-143-1A'|'VATEX-EU-143-1B'|'VATEX-EU-143-1C'|'VATEX-EU-143-1D'|'VATEX-EU-143-1E'|'VATEX-EU-143-1F'|'VATEX-EU-143-1FA'|'VATEX-EU-143-1G'|'VATEX-EU-143-1H'|'VATEX-EU-143-1I'|'VATEX-EU-143-1J'|'VATEX-EU-143-1K'|'VATEX-EU-143-1L'|'VATEX-EU-144'|'VATEX-EU-146-1E'|'VATEX-EU-148'|'VATEX-EU-148-A'|'VATEX-EU-148-B'|'VATEX-EU-148-C'|'VATEX-EU-148-D'|'VATEX-EU-148-E'|'VATEX-EU-148-F'|'VATEX-EU-148-G'|'VATEX-EU-151'|'VATEX-EU-151-1A'|'VATEX-EU-151-1AA'|'VATEX-EU-151-1B'|'VATEX-EU-151-1C'|'VATEX-EU-151-1D'|'VATEX-EU-151-1E'|'VATEX-EU-159'|'VATEX-EU-309'|'VATEX-EU-AE'|'VATEX-EU-D'|'VATEX-EU-F'|'VATEX-EU-G'|'VATEX-EU-I'|'VATEX-EU-IC'|'VATEX-EU-O'|'VATEX-EU-J'|'VATEX-FR-FRANCHISE'|'VATEX-FR-CNWVAT'|Vatex|null $vatex VATEX code list for VAT exemption reasons + * + * Agency: CEF + * Identifier: vatex + * @param string|null $vatexNote Textual explanation for VAT exemption + * @param string|null $vendorAddress The address of the vendor/seller + * @param string|null $vendorAddressRecipient The recipient name at the vendor address + * @param string|null $vendorCompanyID Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. + * @param string|null $vendorEmail The email address of the vendor + * @param string|null $vendorName The name of the vendor/seller/supplier + * @param string|null $vendorTaxID Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix * * @throws APIException */ public function validateJson( - array|ValidateValidateJsonParams $params, + ?array $allowances = null, + float|string|null $amountDue = null, + ?array $attachments = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, + ?array $charges = null, + string|CurrencyCode|null $currency = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, + string|DocumentDirection|null $direction = null, + string|DocumentType|null $documentType = null, + string|\DateTimeInterface|null $dueDate = null, + string|\DateTimeInterface|null $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, + ?array $items = null, + ?string $note = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + string|\DateTimeInterface|null $serviceEndDate = null, + string|\DateTimeInterface|null $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, + string|DocumentState|null $state = null, + float|string|null $subtotal = null, + string|\EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode $taxCode = 'S', + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, + string|Vatex|null $vatex = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ?RequestOptions $requestOptions = null, ): UblDocumentValidation { - [$parsed, $options] = ValidateValidateJsonParams::parseRequest( - $params, - $requestOptions, - ); + $params = [ + 'allowances' => $allowances, + 'amountDue' => $amountDue, + 'attachments' => $attachments, + 'billingAddress' => $billingAddress, + 'billingAddressRecipient' => $billingAddressRecipient, + 'charges' => $charges, + 'currency' => $currency, + 'customerAddress' => $customerAddress, + 'customerAddressRecipient' => $customerAddressRecipient, + 'customerCompanyID' => $customerCompanyID, + 'customerEmail' => $customerEmail, + 'customerID' => $customerID, + 'customerName' => $customerName, + 'customerTaxID' => $customerTaxID, + 'direction' => $direction, + 'documentType' => $documentType, + 'dueDate' => $dueDate, + 'invoiceDate' => $invoiceDate, + 'invoiceID' => $invoiceID, + 'invoiceTotal' => $invoiceTotal, + 'items' => $items, + 'note' => $note, + 'paymentDetails' => $paymentDetails, + 'paymentTerm' => $paymentTerm, + 'previousUnpaidBalance' => $previousUnpaidBalance, + 'purchaseOrder' => $purchaseOrder, + 'remittanceAddress' => $remittanceAddress, + 'remittanceAddressRecipient' => $remittanceAddressRecipient, + 'serviceAddress' => $serviceAddress, + 'serviceAddressRecipient' => $serviceAddressRecipient, + 'serviceEndDate' => $serviceEndDate, + 'serviceStartDate' => $serviceStartDate, + 'shippingAddress' => $shippingAddress, + 'shippingAddressRecipient' => $shippingAddressRecipient, + 'state' => $state, + 'subtotal' => $subtotal, + 'taxCode' => $taxCode, + 'taxDetails' => $taxDetails, + 'totalDiscount' => $totalDiscount, + 'totalTax' => $totalTax, + 'vatex' => $vatex, + 'vatexNote' => $vatexNote, + 'vendorAddress' => $vendorAddress, + 'vendorAddressRecipient' => $vendorAddressRecipient, + 'vendorCompanyID' => $vendorCompanyID, + 'vendorEmail' => $vendorEmail, + 'vendorName' => $vendorName, + 'vendorTaxID' => $vendorTaxID, + ]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->validateJson(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: 'api/validate/json', - body: (object) $parsed, - options: $options, - convert: UblDocumentValidation::class, - ); + return $response->parse(); } /** @@ -151,27 +263,20 @@ public function validateJson( * * Validate if a Peppol ID exists in the Peppol network and retrieve supported document types. The peppol_id must be in the form of `:`. The scheme is a 4-digit code representing the identifier scheme, and the id is the actual identifier value. For example, for a Belgian company it is `0208:0123456789` (where 0208 is the scheme for Belgian enterprises, followed by the 10 digits of the official BTW / KBO number). * - * @param array{peppol_id: string}|ValidateValidatePeppolIDParams $params + * @param string $peppolID Peppol ID in the format `:`. Example: `0208:1018265814` for a Belgian company. * * @throws APIException */ public function validatePeppolID( - array|ValidateValidatePeppolIDParams $params, - ?RequestOptions $requestOptions = null, + string $peppolID, + ?RequestOptions $requestOptions = null ): ValidateValidatePeppolIDResponse { - [$parsed, $options] = ValidateValidatePeppolIDParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['peppolID' => $peppolID]; + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->validatePeppolID(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/validate/peppol-id', - query: $parsed, - options: $options, - convert: ValidateValidatePeppolIDResponse::class, - ); + return $response->parse(); } /** @@ -179,27 +284,17 @@ public function validatePeppolID( * * Validate the correctness of a UBL document * - * @param array{file: string}|ValidateValidateUblParams $params - * * @throws APIException */ public function validateUbl( - array|ValidateValidateUblParams $params, - ?RequestOptions $requestOptions = null, + string $file, + ?RequestOptions $requestOptions = null ): UblDocumentValidation { - [$parsed, $options] = ValidateValidateUblParams::parseRequest( - $params, - $requestOptions, - ); + $params = ['file' => $file]; + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->validateUbl(params: $params, requestOptions: $requestOptions); - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: 'api/validate/ubl', - headers: ['Content-Type' => 'multipart/form-data'], - body: (object) $parsed, - options: $options, - convert: UblDocumentValidation::class, - ); + return $response->parse(); } } diff --git a/src/Services/WebhooksRawService.php b/src/Services/WebhooksRawService.php new file mode 100644 index 00000000..e723a645 --- /dev/null +++ b/src/Services/WebhooksRawService.php @@ -0,0 +1,154 @@ +, url: string, enabled?: bool + * }|WebhookCreateParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|WebhookCreateParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = WebhookCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'api/webhooks/', + body: (object) $parsed, + options: $options, + convert: WebhookResponse::class, + ); + } + + /** + * @api + * + * Get a webhook by ID + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $webhookID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['api/webhooks/%1$s', $webhookID], + options: $requestOptions, + convert: WebhookResponse::class, + ); + } + + /** + * @api + * + * Update a webhook by ID + * + * @param array{ + * enabled?: bool|null, events?: list|null, url?: string|null + * }|WebhookUpdateParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $webhookID, + array|WebhookUpdateParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = WebhookUpdateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'put', + path: ['api/webhooks/%1$s', $webhookID], + body: (object) $parsed, + options: $options, + convert: WebhookResponse::class, + ); + } + + /** + * @api + * + * Get all webhooks for the current tenant + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list(?RequestOptions $requestOptions = null): BaseResponse + { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'api/webhooks/', + options: $requestOptions, + convert: new ListOf(WebhookResponse::class), + ); + } + + /** + * @api + * + * Delete a webhook + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $webhookID, + ?RequestOptions $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['api/webhooks/%1$s', $webhookID], + options: $requestOptions, + convert: WebhookDeleteResponse::class, + ); + } +} diff --git a/src/Services/WebhooksService.php b/src/Services/WebhooksService.php index a9852fcb..bed42833 100644 --- a/src/Services/WebhooksService.php +++ b/src/Services/WebhooksService.php @@ -5,50 +5,50 @@ namespace EInvoiceAPI\Services; use EInvoiceAPI\Client; -use EInvoiceAPI\Core\Conversion\ListOf; use EInvoiceAPI\Core\Exceptions\APIException; use EInvoiceAPI\RequestOptions; use EInvoiceAPI\ServiceContracts\WebhooksContract; -use EInvoiceAPI\Webhooks\WebhookCreateParams; use EInvoiceAPI\Webhooks\WebhookDeleteResponse; use EInvoiceAPI\Webhooks\WebhookResponse; -use EInvoiceAPI\Webhooks\WebhookUpdateParams; final class WebhooksService implements WebhooksContract { + /** + * @api + */ + public WebhooksRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new WebhooksRawService($client); + } /** * @api * * Create a new webhook * - * @param array{ - * events: list, url: string, enabled?: bool - * }|WebhookCreateParams $params + * @param list $events * * @throws APIException */ public function create( - array|WebhookCreateParams $params, - ?RequestOptions $requestOptions = null + array $events, + string $url, + bool $enabled = true, + ?RequestOptions $requestOptions = null, ): WebhookResponse { - [$parsed, $options] = WebhookCreateParams::parseRequest( - $params, - $requestOptions, - ); - - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'post', - path: 'api/webhooks/', - body: (object) $parsed, - options: $options, - convert: WebhookResponse::class, - ); + $params = ['events' => $events, 'url' => $url, 'enabled' => $enabled]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -62,13 +62,10 @@ public function retrieve( string $webhookID, ?RequestOptions $requestOptions = null ): WebhookResponse { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: ['api/webhooks/%1$s', $webhookID], - options: $requestOptions, - convert: WebhookResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieve($webhookID, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -76,30 +73,25 @@ public function retrieve( * * Update a webhook by ID * - * @param array{ - * enabled?: bool|null, events?: list|null, url?: string|null - * }|WebhookUpdateParams $params + * @param list|null $events * * @throws APIException */ public function update( string $webhookID, - array|WebhookUpdateParams $params, + ?bool $enabled = null, + ?array $events = null, + ?string $url = null, ?RequestOptions $requestOptions = null, ): WebhookResponse { - [$parsed, $options] = WebhookUpdateParams::parseRequest( - $params, - $requestOptions, - ); - - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'put', - path: ['api/webhooks/%1$s', $webhookID], - body: (object) $parsed, - options: $options, - convert: WebhookResponse::class, - ); + $params = ['enabled' => $enabled, 'events' => $events, 'url' => $url]; + // @phpstan-ignore-next-line function.impossibleType + $params = array_filter($params, callback: static fn ($v) => !is_null($v)); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->update($webhookID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -113,13 +105,10 @@ public function update( */ public function list(?RequestOptions $requestOptions = null): array { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'get', - path: 'api/webhooks/', - options: $requestOptions, - convert: new ListOf(WebhookResponse::class), - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -133,12 +122,9 @@ public function delete( string $webhookID, ?RequestOptions $requestOptions = null ): WebhookDeleteResponse { - // @phpstan-ignore-next-line return.type - return $this->client->request( - method: 'delete', - path: ['api/webhooks/%1$s', $webhookID], - options: $requestOptions, - convert: WebhookDeleteResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($webhookID, requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Validate/UblDocumentValidation.php b/src/Validate/UblDocumentValidation.php index 40e080c0..331f2a92 100644 --- a/src/Validate/UblDocumentValidation.php +++ b/src/Validate/UblDocumentValidation.php @@ -4,51 +4,49 @@ namespace EInvoiceAPI\Validate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; use EInvoiceAPI\Validate\UblDocumentValidation\Issue; +use EInvoiceAPI\Validate\UblDocumentValidation\Issue\Type; /** * @phpstan-type UblDocumentValidationShape = array{ * id: string, - * file_name: string|null, - * is_valid: bool, + * fileName: string|null, + * isValid: bool, * issues: list, - * ubl_document?: string|null, + * ublDocument?: string|null, * } */ -final class UblDocumentValidation implements BaseModel, ResponseConverter +final class UblDocumentValidation implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] + #[Required] public string $id; - #[Api] - public ?string $file_name; + #[Required('file_name')] + public ?string $fileName; - #[Api] - public bool $is_valid; + #[Required('is_valid')] + public bool $isValid; /** @var list $issues */ - #[Api(list: Issue::class)] + #[Required(list: Issue::class)] public array $issues; - #[Api(nullable: true, optional: true)] - public ?string $ubl_document; + #[Optional('ubl_document', nullable: true)] + public ?string $ublDocument; /** * `new UblDocumentValidation()` is missing required properties by the API. * * To enforce required parameters use * ``` - * UblDocumentValidation::with(id: ..., file_name: ..., is_valid: ..., issues: ...) + * UblDocumentValidation::with(id: ..., fileName: ..., isValid: ..., issues: ...) * ``` * * Otherwise ensure the following setters are called @@ -71,67 +69,83 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $issues + * @param list, + * flag?: string|null, + * location?: string|null, + * ruleID?: string|null, + * test?: string|null, + * }> $issues */ public static function with( string $id, - ?string $file_name, - bool $is_valid, + ?string $fileName, + bool $isValid, array $issues, - ?string $ubl_document = null, + ?string $ublDocument = null, ): self { - $obj = new self; + $self = new self; - $obj->id = $id; - $obj->file_name = $file_name; - $obj->is_valid = $is_valid; - $obj->issues = $issues; + $self['id'] = $id; + $self['fileName'] = $fileName; + $self['isValid'] = $isValid; + $self['issues'] = $issues; - null !== $ubl_document && $obj->ubl_document = $ubl_document; + null !== $ublDocument && $self['ublDocument'] = $ublDocument; - return $obj; + return $self; } public function withID(string $id): self { - $obj = clone $this; - $obj->id = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } public function withFileName(?string $fileName): self { - $obj = clone $this; - $obj->file_name = $fileName; + $self = clone $this; + $self['fileName'] = $fileName; - return $obj; + return $self; } public function withIsValid(bool $isValid): self { - $obj = clone $this; - $obj->is_valid = $isValid; + $self = clone $this; + $self['isValid'] = $isValid; - return $obj; + return $self; } /** - * @param list $issues + * @param list, + * flag?: string|null, + * location?: string|null, + * ruleID?: string|null, + * test?: string|null, + * }> $issues */ public function withIssues(array $issues): self { - $obj = clone $this; - $obj->issues = $issues; + $self = clone $this; + $self['issues'] = $issues; - return $obj; + return $self; } public function withUblDocument(?string $ublDocument): self { - $obj = clone $this; - $obj->ubl_document = $ublDocument; + $self = clone $this; + $self['ublDocument'] = $ublDocument; - return $obj; + return $self; } } diff --git a/src/Validate/UblDocumentValidation/Issue.php b/src/Validate/UblDocumentValidation/Issue.php index 2c874a68..8e15e545 100644 --- a/src/Validate/UblDocumentValidation/Issue.php +++ b/src/Validate/UblDocumentValidation/Issue.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Validate\UblDocumentValidation; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Validate\UblDocumentValidation\Issue\Type; @@ -16,7 +17,7 @@ * type: value-of, * flag?: string|null, * location?: string|null, - * rule_id?: string|null, + * ruleID?: string|null, * test?: string|null, * } */ @@ -25,26 +26,26 @@ final class Issue implements BaseModel /** @use SdkModel */ use SdkModel; - #[Api] + #[Required] public string $message; - #[Api] + #[Required] public string $schematron; /** @var value-of $type */ - #[Api(enum: Type::class)] + #[Required(enum: Type::class)] public string $type; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $flag; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $location; - #[Api(nullable: true, optional: true)] - public ?string $rule_id; + #[Optional('rule_id', nullable: true)] + public ?string $ruleID; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $test; /** @@ -79,37 +80,37 @@ public static function with( Type|string $type, ?string $flag = null, ?string $location = null, - ?string $rule_id = null, + ?string $ruleID = null, ?string $test = null, ): self { - $obj = new self; + $self = new self; - $obj->message = $message; - $obj->schematron = $schematron; - $obj['type'] = $type; + $self['message'] = $message; + $self['schematron'] = $schematron; + $self['type'] = $type; - null !== $flag && $obj->flag = $flag; - null !== $location && $obj->location = $location; - null !== $rule_id && $obj->rule_id = $rule_id; - null !== $test && $obj->test = $test; + null !== $flag && $self['flag'] = $flag; + null !== $location && $self['location'] = $location; + null !== $ruleID && $self['ruleID'] = $ruleID; + null !== $test && $self['test'] = $test; - return $obj; + return $self; } public function withMessage(string $message): self { - $obj = clone $this; - $obj->message = $message; + $self = clone $this; + $self['message'] = $message; - return $obj; + return $self; } public function withSchematron(string $schematron): self { - $obj = clone $this; - $obj->schematron = $schematron; + $self = clone $this; + $self['schematron'] = $schematron; - return $obj; + return $self; } /** @@ -117,41 +118,41 @@ public function withSchematron(string $schematron): self */ public function withType(Type|string $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } public function withFlag(?string $flag): self { - $obj = clone $this; - $obj->flag = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } public function withLocation(?string $location): self { - $obj = clone $this; - $obj->location = $location; + $self = clone $this; + $self['location'] = $location; - return $obj; + return $self; } public function withRuleID(?string $ruleID): self { - $obj = clone $this; - $obj->rule_id = $ruleID; + $self = clone $this; + $self['ruleID'] = $ruleID; - return $obj; + return $self; } public function withTest(?string $test): self { - $obj = clone $this; - $obj->test = $test; + $self = clone $this; + $self['test'] = $test; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams.php b/src/Validate/ValidateValidateJsonParams.php index 5931528b..d5797026 100644 --- a/src/Validate/ValidateValidateJsonParams.php +++ b/src/Validate/ValidateValidateJsonParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -13,11 +13,13 @@ use EInvoiceAPI\Documents\DocumentDirection; use EInvoiceAPI\Documents\DocumentType; use EInvoiceAPI\Documents\PaymentDetailCreate; +use EInvoiceAPI\Documents\UnitOfMeasureCode; use EInvoiceAPI\Inbox\DocumentState; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\ReasonCode; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\TaxCode; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Charge; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item; -use EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode; use EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxDetail; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Vatex; @@ -27,54 +29,94 @@ * @see EInvoiceAPI\Services\ValidateService::validateJson() * * @phpstan-type ValidateValidateJsonParamsShape = array{ - * allowances?: list|null, - * amount_due?: float|string|null, - * attachments?: list|null, - * billing_address?: string|null, - * billing_address_recipient?: string|null, - * charges?: list|null, + * allowances?: list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null, + * amountDue?: float|string|null, + * attachments?: list|null, + * billingAddress?: string|null, + * billingAddressRecipient?: string|null, + * charges?: list|null, + * taxCode?: value-of<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Charge\TaxCode>|null, + * taxRate?: float|string|null, + * }>|null, * currency?: CurrencyCode|value-of, - * customer_address?: string|null, - * customer_address_recipient?: string|null, - * customer_company_id?: string|null, - * customer_email?: string|null, - * customer_id?: string|null, - * customer_name?: string|null, - * customer_tax_id?: string|null, + * customerAddress?: string|null, + * customerAddressRecipient?: string|null, + * customerCompanyID?: string|null, + * customerEmail?: string|null, + * customerID?: string|null, + * customerName?: string|null, + * customerTaxID?: string|null, * direction?: DocumentDirection|value-of, - * document_type?: DocumentType|value-of, - * due_date?: \DateTimeInterface|null, - * invoice_date?: \DateTimeInterface|null, - * invoice_id?: string|null, - * invoice_total?: float|string|null, - * items?: list, + * documentType?: DocumentType|value-of, + * dueDate?: \DateTimeInterface|null, + * invoiceDate?: \DateTimeInterface|null, + * invoiceID?: string|null, + * invoiceTotal?: float|string|null, + * items?: list|null, + * amount?: float|string|null, + * charges?: list<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Charge>|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }>, * note?: string|null, - * payment_details?: list|null, - * payment_term?: string|null, - * previous_unpaid_balance?: float|string|null, - * purchase_order?: string|null, - * remittance_address?: string|null, - * remittance_address_recipient?: string|null, - * service_address?: string|null, - * service_address_recipient?: string|null, - * service_end_date?: \DateTimeInterface|null, - * service_start_date?: \DateTimeInterface|null, - * shipping_address?: string|null, - * shipping_address_recipient?: string|null, + * paymentDetails?: list|null, + * paymentTerm?: string|null, + * previousUnpaidBalance?: float|string|null, + * purchaseOrder?: string|null, + * remittanceAddress?: string|null, + * remittanceAddressRecipient?: string|null, + * serviceAddress?: string|null, + * serviceAddressRecipient?: string|null, + * serviceEndDate?: \DateTimeInterface|null, + * serviceStartDate?: \DateTimeInterface|null, + * shippingAddress?: string|null, + * shippingAddressRecipient?: string|null, * state?: DocumentState|value-of, * subtotal?: float|string|null, - * tax_code?: TaxCode|value-of, - * tax_details?: list|null, - * total_discount?: float|string|null, - * total_tax?: float|string|null, + * taxCode?: \EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode|value-of<\EInvoiceAPI\Validate\ValidateValidateJsonParams\TaxCode>, + * taxDetails?: list|null, + * totalDiscount?: float|string|null, + * totalTax?: float|string|null, * vatex?: null|Vatex|value-of, - * vatex_note?: string|null, - * vendor_address?: string|null, - * vendor_address_recipient?: string|null, - * vendor_company_id?: string|null, - * vendor_email?: string|null, - * vendor_name?: string|null, - * vendor_tax_id?: string|null, + * vatexNote?: string|null, + * vendorAddress?: string|null, + * vendorAddressRecipient?: string|null, + * vendorCompanyID?: string|null, + * vendorEmail?: string|null, + * vendorName?: string|null, + * vendorTaxID?: string|null, * } */ final class ValidateValidateJsonParams implements BaseModel @@ -84,33 +126,33 @@ final class ValidateValidateJsonParams implements BaseModel use SdkParams; /** @var list|null $allowances */ - #[Api(list: Allowance::class, nullable: true, optional: true)] + #[Optional(list: Allowance::class, nullable: true)] public ?array $allowances; /** * The amount due for payment. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $amount_due; + #[Optional('amount_due', nullable: true)] + public float|string|null $amountDue; /** @var list|null $attachments */ - #[Api(list: DocumentAttachmentCreate::class, nullable: true, optional: true)] + #[Optional(list: DocumentAttachmentCreate::class, nullable: true)] public ?array $attachments; /** * The billing address (if different from customer address). */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address; + #[Optional('billing_address', nullable: true)] + public ?string $billingAddress; /** * The recipient name at the billing address. */ - #[Api(nullable: true, optional: true)] - public ?string $billing_address_recipient; + #[Optional('billing_address_recipient', nullable: true)] + public ?string $billingAddressRecipient; /** @var list|null $charges */ - #[Api(list: Charge::class, nullable: true, optional: true)] + #[Optional(list: Charge::class, nullable: true)] public ?array $charges; /** @@ -118,212 +160,219 @@ final class ValidateValidateJsonParams implements BaseModel * * @var value-of|null $currency */ - #[Api(enum: CurrencyCode::class, optional: true)] + #[Optional(enum: CurrencyCode::class)] public ?string $currency; /** * The address of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address; + #[Optional('customer_address', nullable: true)] + public ?string $customerAddress; /** * The recipient name at the customer address. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_address_recipient; + #[Optional('customer_address_recipient', nullable: true)] + public ?string $customerAddressRecipient; /** * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_company_id; + #[Optional('customer_company_id', nullable: true)] + public ?string $customerCompanyID; /** * The email address of the customer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_email; + #[Optional('customer_email', nullable: true)] + public ?string $customerEmail; /** * The unique identifier for the customer in your system. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_id; + #[Optional('customer_id', nullable: true)] + public ?string $customerID; /** * The company name of the customer/buyer. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_name; + #[Optional('customer_name', nullable: true)] + public ?string $customerName; /** * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $customer_tax_id; + #[Optional('customer_tax_id', nullable: true)] + public ?string $customerTaxID; /** * The direction of the document: INBOUND (purchases) or OUTBOUND (sales). * * @var value-of|null $direction */ - #[Api(enum: DocumentDirection::class, optional: true)] + #[Optional(enum: DocumentDirection::class)] public ?string $direction; /** * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE. * - * @var value-of|null $document_type + * @var value-of|null $documentType */ - #[Api(enum: DocumentType::class, optional: true)] - public ?string $document_type; + #[Optional('document_type', enum: DocumentType::class)] + public ?string $documentType; /** * The date when payment is due. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $due_date; + #[Optional('due_date', nullable: true)] + public ?\DateTimeInterface $dueDate; /** * The date when the invoice was issued. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $invoice_date; + #[Optional('invoice_date', nullable: true)] + public ?\DateTimeInterface $invoiceDate; /** * The unique invoice identifier/number. */ - #[Api(nullable: true, optional: true)] - public ?string $invoice_id; + #[Optional('invoice_id', nullable: true)] + public ?string $invoiceID; /** * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + total_discount). Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $invoice_total; + #[Optional('invoice_total', nullable: true)] + public float|string|null $invoiceTotal; /** * At least one line item is required. * * @var list|null $items */ - #[Api(list: Item::class, optional: true)] + #[Optional(list: Item::class)] public ?array $items; /** * Additional notes or comments for the invoice. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $note; - /** @var list|null $payment_details */ - #[Api(list: PaymentDetailCreate::class, nullable: true, optional: true)] - public ?array $payment_details; + /** @var list|null $paymentDetails */ + #[Optional( + 'payment_details', + list: PaymentDetailCreate::class, + nullable: true + )] + public ?array $paymentDetails; /** * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30'). */ - #[Api(nullable: true, optional: true)] - public ?string $payment_term; + #[Optional('payment_term', nullable: true)] + public ?string $paymentTerm; /** * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $previous_unpaid_balance; + #[Optional('previous_unpaid_balance', nullable: true)] + public float|string|null $previousUnpaidBalance; /** * The purchase order reference number. */ - #[Api(nullable: true, optional: true)] - public ?string $purchase_order; + #[Optional('purchase_order', nullable: true)] + public ?string $purchaseOrder; /** * The address where payment should be sent or remitted to. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address; + #[Optional('remittance_address', nullable: true)] + public ?string $remittanceAddress; /** * The recipient name at the remittance address. */ - #[Api(nullable: true, optional: true)] - public ?string $remittance_address_recipient; + #[Optional('remittance_address_recipient', nullable: true)] + public ?string $remittanceAddressRecipient; /** * The address where services were performed or goods were delivered. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address; + #[Optional('service_address', nullable: true)] + public ?string $serviceAddress; /** * The recipient name at the service address. */ - #[Api(nullable: true, optional: true)] - public ?string $service_address_recipient; + #[Optional('service_address_recipient', nullable: true)] + public ?string $serviceAddressRecipient; /** * The end date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_end_date; + #[Optional('service_end_date', nullable: true)] + public ?\DateTimeInterface $serviceEndDate; /** * The start date of the service period or delivery period. */ - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $service_start_date; + #[Optional('service_start_date', nullable: true)] + public ?\DateTimeInterface $serviceStartDate; /** * The shipping/delivery address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address; + #[Optional('shipping_address', nullable: true)] + public ?string $shippingAddress; /** * The recipient name at the shipping address. */ - #[Api(nullable: true, optional: true)] - public ?string $shipping_address_recipient; + #[Optional('shipping_address_recipient', nullable: true)] + public ?string $shippingAddressRecipient; /** * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED. * * @var value-of|null $state */ - #[Api(enum: DocumentState::class, optional: true)] + #[Optional(enum: DocumentState::class)] public ?string $state; /** * The taxable base of the invoice. Should be the sum of all line items - allowances (for example commercial discounts) + charges with impact on VAT. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $subtotal; /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional( + 'tax_code', + enum: ValidateValidateJsonParams\TaxCode::class, + )] + public ?string $taxCode; - /** @var list|null $tax_details */ - #[Api(list: TaxDetail::class, nullable: true, optional: true)] - public ?array $tax_details; + /** @var list|null $taxDetails */ + #[Optional('tax_details', list: TaxDetail::class, nullable: true)] + public ?array $taxDetails; /** * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $total_discount; + #[Optional('total_discount', nullable: true)] + public float|string|null $totalDiscount; /** * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $total_tax; + #[Optional('total_tax', nullable: true)] + public float|string|null $totalTax; /** * VATEX code list for VAT exemption reasons. @@ -333,50 +382,50 @@ final class ValidateValidateJsonParams implements BaseModel * * @var value-of|null $vatex */ - #[Api(enum: Vatex::class, nullable: true, optional: true)] + #[Optional(enum: Vatex::class, nullable: true)] public ?string $vatex; /** * Textual explanation for VAT exemption. */ - #[Api(nullable: true, optional: true)] - public ?string $vatex_note; + #[Optional('vatex_note', nullable: true)] + public ?string $vatexNote; /** * The address of the vendor/seller. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address; + #[Optional('vendor_address', nullable: true)] + public ?string $vendorAddress; /** * The recipient name at the vendor address. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_address_recipient; + #[Optional('vendor_address_recipient', nullable: true)] + public ?string $vendorAddressRecipient; /** * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique Identifier) number. In the Netherlands this is the KVK number. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_company_id; + #[Optional('vendor_company_id', nullable: true)] + public ?string $vendorCompanyID; /** * The email address of the vendor. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_email; + #[Optional('vendor_email', nullable: true)] + public ?string $vendorEmail; /** * The name of the vendor/seller/supplier. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_name; + #[Optional('vendor_name', nullable: true)] + public ?string $vendorName; /** * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix. */ - #[Api(nullable: true, optional: true)] - public ?string $vendor_tax_id; + #[Optional('vendor_tax_id', nullable: true)] + public ?string $vendorTaxID; public function __construct() { @@ -388,132 +437,180 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $attachments - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances + * @param list|null $attachments + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges * @param CurrencyCode|value-of $currency * @param DocumentDirection|value-of $direction - * @param DocumentType|value-of $document_type - * @param list $items - * @param list|null $payment_details + * @param DocumentType|value-of $documentType + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }> $items + * @param list|null $paymentDetails * @param DocumentState|value-of $state - * @param TaxCode|value-of $tax_code - * @param list|null $tax_details + * @param ValidateValidateJsonParams\TaxCode|value-of $taxCode + * @param list|null $taxDetails * @param Vatex|value-of|null $vatex */ public static function with( ?array $allowances = null, - float|string|null $amount_due = null, + float|string|null $amountDue = null, ?array $attachments = null, - ?string $billing_address = null, - ?string $billing_address_recipient = null, + ?string $billingAddress = null, + ?string $billingAddressRecipient = null, ?array $charges = null, CurrencyCode|string|null $currency = null, - ?string $customer_address = null, - ?string $customer_address_recipient = null, - ?string $customer_company_id = null, - ?string $customer_email = null, - ?string $customer_id = null, - ?string $customer_name = null, - ?string $customer_tax_id = null, + ?string $customerAddress = null, + ?string $customerAddressRecipient = null, + ?string $customerCompanyID = null, + ?string $customerEmail = null, + ?string $customerID = null, + ?string $customerName = null, + ?string $customerTaxID = null, DocumentDirection|string|null $direction = null, - DocumentType|string|null $document_type = null, - ?\DateTimeInterface $due_date = null, - ?\DateTimeInterface $invoice_date = null, - ?string $invoice_id = null, - float|string|null $invoice_total = null, + DocumentType|string|null $documentType = null, + ?\DateTimeInterface $dueDate = null, + ?\DateTimeInterface $invoiceDate = null, + ?string $invoiceID = null, + float|string|null $invoiceTotal = null, ?array $items = null, ?string $note = null, - ?array $payment_details = null, - ?string $payment_term = null, - float|string|null $previous_unpaid_balance = null, - ?string $purchase_order = null, - ?string $remittance_address = null, - ?string $remittance_address_recipient = null, - ?string $service_address = null, - ?string $service_address_recipient = null, - ?\DateTimeInterface $service_end_date = null, - ?\DateTimeInterface $service_start_date = null, - ?string $shipping_address = null, - ?string $shipping_address_recipient = null, + ?array $paymentDetails = null, + ?string $paymentTerm = null, + float|string|null $previousUnpaidBalance = null, + ?string $purchaseOrder = null, + ?string $remittanceAddress = null, + ?string $remittanceAddressRecipient = null, + ?string $serviceAddress = null, + ?string $serviceAddressRecipient = null, + ?\DateTimeInterface $serviceEndDate = null, + ?\DateTimeInterface $serviceStartDate = null, + ?string $shippingAddress = null, + ?string $shippingAddressRecipient = null, DocumentState|string|null $state = null, float|string|null $subtotal = null, - TaxCode|string|null $tax_code = null, - ?array $tax_details = null, - float|string|null $total_discount = null, - float|string|null $total_tax = null, + ValidateValidateJsonParams\TaxCode|string|null $taxCode = null, + ?array $taxDetails = null, + float|string|null $totalDiscount = null, + float|string|null $totalTax = null, Vatex|string|null $vatex = null, - ?string $vatex_note = null, - ?string $vendor_address = null, - ?string $vendor_address_recipient = null, - ?string $vendor_company_id = null, - ?string $vendor_email = null, - ?string $vendor_name = null, - ?string $vendor_tax_id = null, + ?string $vatexNote = null, + ?string $vendorAddress = null, + ?string $vendorAddressRecipient = null, + ?string $vendorCompanyID = null, + ?string $vendorEmail = null, + ?string $vendorName = null, + ?string $vendorTaxID = null, ): self { - $obj = new self; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount_due && $obj->amount_due = $amount_due; - null !== $attachments && $obj->attachments = $attachments; - null !== $billing_address && $obj->billing_address = $billing_address; - null !== $billing_address_recipient && $obj->billing_address_recipient = $billing_address_recipient; - null !== $charges && $obj->charges = $charges; - null !== $currency && $obj['currency'] = $currency; - null !== $customer_address && $obj->customer_address = $customer_address; - null !== $customer_address_recipient && $obj->customer_address_recipient = $customer_address_recipient; - null !== $customer_company_id && $obj->customer_company_id = $customer_company_id; - null !== $customer_email && $obj->customer_email = $customer_email; - null !== $customer_id && $obj->customer_id = $customer_id; - null !== $customer_name && $obj->customer_name = $customer_name; - null !== $customer_tax_id && $obj->customer_tax_id = $customer_tax_id; - null !== $direction && $obj['direction'] = $direction; - null !== $document_type && $obj['document_type'] = $document_type; - null !== $due_date && $obj->due_date = $due_date; - null !== $invoice_date && $obj->invoice_date = $invoice_date; - null !== $invoice_id && $obj->invoice_id = $invoice_id; - null !== $invoice_total && $obj->invoice_total = $invoice_total; - null !== $items && $obj->items = $items; - null !== $note && $obj->note = $note; - null !== $payment_details && $obj->payment_details = $payment_details; - null !== $payment_term && $obj->payment_term = $payment_term; - null !== $previous_unpaid_balance && $obj->previous_unpaid_balance = $previous_unpaid_balance; - null !== $purchase_order && $obj->purchase_order = $purchase_order; - null !== $remittance_address && $obj->remittance_address = $remittance_address; - null !== $remittance_address_recipient && $obj->remittance_address_recipient = $remittance_address_recipient; - null !== $service_address && $obj->service_address = $service_address; - null !== $service_address_recipient && $obj->service_address_recipient = $service_address_recipient; - null !== $service_end_date && $obj->service_end_date = $service_end_date; - null !== $service_start_date && $obj->service_start_date = $service_start_date; - null !== $shipping_address && $obj->shipping_address = $shipping_address; - null !== $shipping_address_recipient && $obj->shipping_address_recipient = $shipping_address_recipient; - null !== $state && $obj['state'] = $state; - null !== $subtotal && $obj->subtotal = $subtotal; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_details && $obj->tax_details = $tax_details; - null !== $total_discount && $obj->total_discount = $total_discount; - null !== $total_tax && $obj->total_tax = $total_tax; - null !== $vatex && $obj['vatex'] = $vatex; - null !== $vatex_note && $obj->vatex_note = $vatex_note; - null !== $vendor_address && $obj->vendor_address = $vendor_address; - null !== $vendor_address_recipient && $obj->vendor_address_recipient = $vendor_address_recipient; - null !== $vendor_company_id && $obj->vendor_company_id = $vendor_company_id; - null !== $vendor_email && $obj->vendor_email = $vendor_email; - null !== $vendor_name && $obj->vendor_name = $vendor_name; - null !== $vendor_tax_id && $obj->vendor_tax_id = $vendor_tax_id; - - return $obj; + $self = new self; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amountDue && $self['amountDue'] = $amountDue; + null !== $attachments && $self['attachments'] = $attachments; + null !== $billingAddress && $self['billingAddress'] = $billingAddress; + null !== $billingAddressRecipient && $self['billingAddressRecipient'] = $billingAddressRecipient; + null !== $charges && $self['charges'] = $charges; + null !== $currency && $self['currency'] = $currency; + null !== $customerAddress && $self['customerAddress'] = $customerAddress; + null !== $customerAddressRecipient && $self['customerAddressRecipient'] = $customerAddressRecipient; + null !== $customerCompanyID && $self['customerCompanyID'] = $customerCompanyID; + null !== $customerEmail && $self['customerEmail'] = $customerEmail; + null !== $customerID && $self['customerID'] = $customerID; + null !== $customerName && $self['customerName'] = $customerName; + null !== $customerTaxID && $self['customerTaxID'] = $customerTaxID; + null !== $direction && $self['direction'] = $direction; + null !== $documentType && $self['documentType'] = $documentType; + null !== $dueDate && $self['dueDate'] = $dueDate; + null !== $invoiceDate && $self['invoiceDate'] = $invoiceDate; + null !== $invoiceID && $self['invoiceID'] = $invoiceID; + null !== $invoiceTotal && $self['invoiceTotal'] = $invoiceTotal; + null !== $items && $self['items'] = $items; + null !== $note && $self['note'] = $note; + null !== $paymentDetails && $self['paymentDetails'] = $paymentDetails; + null !== $paymentTerm && $self['paymentTerm'] = $paymentTerm; + null !== $previousUnpaidBalance && $self['previousUnpaidBalance'] = $previousUnpaidBalance; + null !== $purchaseOrder && $self['purchaseOrder'] = $purchaseOrder; + null !== $remittanceAddress && $self['remittanceAddress'] = $remittanceAddress; + null !== $remittanceAddressRecipient && $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; + null !== $serviceAddress && $self['serviceAddress'] = $serviceAddress; + null !== $serviceAddressRecipient && $self['serviceAddressRecipient'] = $serviceAddressRecipient; + null !== $serviceEndDate && $self['serviceEndDate'] = $serviceEndDate; + null !== $serviceStartDate && $self['serviceStartDate'] = $serviceStartDate; + null !== $shippingAddress && $self['shippingAddress'] = $shippingAddress; + null !== $shippingAddressRecipient && $self['shippingAddressRecipient'] = $shippingAddressRecipient; + null !== $state && $self['state'] = $state; + null !== $subtotal && $self['subtotal'] = $subtotal; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxDetails && $self['taxDetails'] = $taxDetails; + null !== $totalDiscount && $self['totalDiscount'] = $totalDiscount; + null !== $totalTax && $self['totalTax'] = $totalTax; + null !== $vatex && $self['vatex'] = $vatex; + null !== $vatexNote && $self['vatexNote'] = $vatexNote; + null !== $vendorAddress && $self['vendorAddress'] = $vendorAddress; + null !== $vendorAddressRecipient && $self['vendorAddressRecipient'] = $vendorAddressRecipient; + null !== $vendorCompanyID && $self['vendorCompanyID'] = $vendorCompanyID; + null !== $vendorEmail && $self['vendorEmail'] = $vendorEmail; + null !== $vendorName && $self['vendorName'] = $vendorName; + null !== $vendorTaxID && $self['vendorTaxID'] = $vendorTaxID; + + return $self; } /** - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -521,21 +618,26 @@ public function withAllowances(?array $allowances): self */ public function withAmountDue(float|string|null $amountDue): self { - $obj = clone $this; - $obj->amount_due = $amountDue; + $self = clone $this; + $self['amountDue'] = $amountDue; - return $obj; + return $self; } /** - * @param list|null $attachments + * @param list|null $attachments */ public function withAttachments(?array $attachments): self { - $obj = clone $this; - $obj->attachments = $attachments; + $self = clone $this; + $self['attachments'] = $attachments; - return $obj; + return $self; } /** @@ -543,10 +645,10 @@ public function withAttachments(?array $attachments): self */ public function withBillingAddress(?string $billingAddress): self { - $obj = clone $this; - $obj->billing_address = $billingAddress; + $self = clone $this; + $self['billingAddress'] = $billingAddress; - return $obj; + return $self; } /** @@ -555,21 +657,29 @@ public function withBillingAddress(?string $billingAddress): self public function withBillingAddressRecipient( ?string $billingAddressRecipient ): self { - $obj = clone $this; - $obj->billing_address_recipient = $billingAddressRecipient; + $self = clone $this; + $self['billingAddressRecipient'] = $billingAddressRecipient; - return $obj; + return $self; } /** - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -579,10 +689,10 @@ public function withCharges(?array $charges): self */ public function withCurrency(CurrencyCode|string $currency): self { - $obj = clone $this; - $obj['currency'] = $currency; + $self = clone $this; + $self['currency'] = $currency; - return $obj; + return $self; } /** @@ -590,10 +700,10 @@ public function withCurrency(CurrencyCode|string $currency): self */ public function withCustomerAddress(?string $customerAddress): self { - $obj = clone $this; - $obj->customer_address = $customerAddress; + $self = clone $this; + $self['customerAddress'] = $customerAddress; - return $obj; + return $self; } /** @@ -602,10 +712,10 @@ public function withCustomerAddress(?string $customerAddress): self public function withCustomerAddressRecipient( ?string $customerAddressRecipient ): self { - $obj = clone $this; - $obj->customer_address_recipient = $customerAddressRecipient; + $self = clone $this; + $self['customerAddressRecipient'] = $customerAddressRecipient; - return $obj; + return $self; } /** @@ -613,10 +723,10 @@ public function withCustomerAddressRecipient( */ public function withCustomerCompanyID(?string $customerCompanyID): self { - $obj = clone $this; - $obj->customer_company_id = $customerCompanyID; + $self = clone $this; + $self['customerCompanyID'] = $customerCompanyID; - return $obj; + return $self; } /** @@ -624,10 +734,10 @@ public function withCustomerCompanyID(?string $customerCompanyID): self */ public function withCustomerEmail(?string $customerEmail): self { - $obj = clone $this; - $obj->customer_email = $customerEmail; + $self = clone $this; + $self['customerEmail'] = $customerEmail; - return $obj; + return $self; } /** @@ -635,10 +745,10 @@ public function withCustomerEmail(?string $customerEmail): self */ public function withCustomerID(?string $customerID): self { - $obj = clone $this; - $obj->customer_id = $customerID; + $self = clone $this; + $self['customerID'] = $customerID; - return $obj; + return $self; } /** @@ -646,10 +756,10 @@ public function withCustomerID(?string $customerID): self */ public function withCustomerName(?string $customerName): self { - $obj = clone $this; - $obj->customer_name = $customerName; + $self = clone $this; + $self['customerName'] = $customerName; - return $obj; + return $self; } /** @@ -657,10 +767,10 @@ public function withCustomerName(?string $customerName): self */ public function withCustomerTaxID(?string $customerTaxID): self { - $obj = clone $this; - $obj->customer_tax_id = $customerTaxID; + $self = clone $this; + $self['customerTaxID'] = $customerTaxID; - return $obj; + return $self; } /** @@ -670,10 +780,10 @@ public function withCustomerTaxID(?string $customerTaxID): self */ public function withDirection(DocumentDirection|string $direction): self { - $obj = clone $this; - $obj['direction'] = $direction; + $self = clone $this; + $self['direction'] = $direction; - return $obj; + return $self; } /** @@ -683,10 +793,10 @@ public function withDirection(DocumentDirection|string $direction): self */ public function withDocumentType(DocumentType|string $documentType): self { - $obj = clone $this; - $obj['document_type'] = $documentType; + $self = clone $this; + $self['documentType'] = $documentType; - return $obj; + return $self; } /** @@ -694,10 +804,10 @@ public function withDocumentType(DocumentType|string $documentType): self */ public function withDueDate(?\DateTimeInterface $dueDate): self { - $obj = clone $this; - $obj->due_date = $dueDate; + $self = clone $this; + $self['dueDate'] = $dueDate; - return $obj; + return $self; } /** @@ -705,10 +815,10 @@ public function withDueDate(?\DateTimeInterface $dueDate): self */ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self { - $obj = clone $this; - $obj->invoice_date = $invoiceDate; + $self = clone $this; + $self['invoiceDate'] = $invoiceDate; - return $obj; + return $self; } /** @@ -716,10 +826,10 @@ public function withInvoiceDate(?\DateTimeInterface $invoiceDate): self */ public function withInvoiceID(?string $invoiceID): self { - $obj = clone $this; - $obj->invoice_id = $invoiceID; + $self = clone $this; + $self['invoiceID'] = $invoiceID; - return $obj; + return $self; } /** @@ -727,23 +837,35 @@ public function withInvoiceID(?string $invoiceID): self */ public function withInvoiceTotal(float|string|null $invoiceTotal): self { - $obj = clone $this; - $obj->invoice_total = $invoiceTotal; + $self = clone $this; + $self['invoiceTotal'] = $invoiceTotal; - return $obj; + return $self; } /** * At least one line item is required. * - * @param list $items + * @param list|null, + * amount?: float|string|null, + * charges?: list|null, + * date?: null|null, + * description?: string|null, + * productCode?: string|null, + * quantity?: float|string|null, + * tax?: float|string|null, + * taxRate?: float|string|null, + * unit?: value-of|null, + * unitPrice?: float|string|null, + * }> $items */ public function withItems(array $items): self { - $obj = clone $this; - $obj->items = $items; + $self = clone $this; + $self['items'] = $items; - return $obj; + return $self; } /** @@ -751,21 +873,26 @@ public function withItems(array $items): self */ public function withNote(?string $note): self { - $obj = clone $this; - $obj->note = $note; + $self = clone $this; + $self['note'] = $note; - return $obj; + return $self; } /** - * @param list|null $paymentDetails + * @param list|null $paymentDetails */ public function withPaymentDetails(?array $paymentDetails): self { - $obj = clone $this; - $obj->payment_details = $paymentDetails; + $self = clone $this; + $self['paymentDetails'] = $paymentDetails; - return $obj; + return $self; } /** @@ -773,10 +900,10 @@ public function withPaymentDetails(?array $paymentDetails): self */ public function withPaymentTerm(?string $paymentTerm): self { - $obj = clone $this; - $obj->payment_term = $paymentTerm; + $self = clone $this; + $self['paymentTerm'] = $paymentTerm; - return $obj; + return $self; } /** @@ -785,10 +912,10 @@ public function withPaymentTerm(?string $paymentTerm): self public function withPreviousUnpaidBalance( float|string|null $previousUnpaidBalance ): self { - $obj = clone $this; - $obj->previous_unpaid_balance = $previousUnpaidBalance; + $self = clone $this; + $self['previousUnpaidBalance'] = $previousUnpaidBalance; - return $obj; + return $self; } /** @@ -796,10 +923,10 @@ public function withPreviousUnpaidBalance( */ public function withPurchaseOrder(?string $purchaseOrder): self { - $obj = clone $this; - $obj->purchase_order = $purchaseOrder; + $self = clone $this; + $self['purchaseOrder'] = $purchaseOrder; - return $obj; + return $self; } /** @@ -807,10 +934,10 @@ public function withPurchaseOrder(?string $purchaseOrder): self */ public function withRemittanceAddress(?string $remittanceAddress): self { - $obj = clone $this; - $obj->remittance_address = $remittanceAddress; + $self = clone $this; + $self['remittanceAddress'] = $remittanceAddress; - return $obj; + return $self; } /** @@ -819,10 +946,10 @@ public function withRemittanceAddress(?string $remittanceAddress): self public function withRemittanceAddressRecipient( ?string $remittanceAddressRecipient ): self { - $obj = clone $this; - $obj->remittance_address_recipient = $remittanceAddressRecipient; + $self = clone $this; + $self['remittanceAddressRecipient'] = $remittanceAddressRecipient; - return $obj; + return $self; } /** @@ -830,10 +957,10 @@ public function withRemittanceAddressRecipient( */ public function withServiceAddress(?string $serviceAddress): self { - $obj = clone $this; - $obj->service_address = $serviceAddress; + $self = clone $this; + $self['serviceAddress'] = $serviceAddress; - return $obj; + return $self; } /** @@ -842,10 +969,10 @@ public function withServiceAddress(?string $serviceAddress): self public function withServiceAddressRecipient( ?string $serviceAddressRecipient ): self { - $obj = clone $this; - $obj->service_address_recipient = $serviceAddressRecipient; + $self = clone $this; + $self['serviceAddressRecipient'] = $serviceAddressRecipient; - return $obj; + return $self; } /** @@ -854,10 +981,10 @@ public function withServiceAddressRecipient( public function withServiceEndDate( ?\DateTimeInterface $serviceEndDate ): self { - $obj = clone $this; - $obj->service_end_date = $serviceEndDate; + $self = clone $this; + $self['serviceEndDate'] = $serviceEndDate; - return $obj; + return $self; } /** @@ -866,10 +993,10 @@ public function withServiceEndDate( public function withServiceStartDate( ?\DateTimeInterface $serviceStartDate ): self { - $obj = clone $this; - $obj->service_start_date = $serviceStartDate; + $self = clone $this; + $self['serviceStartDate'] = $serviceStartDate; - return $obj; + return $self; } /** @@ -877,10 +1004,10 @@ public function withServiceStartDate( */ public function withShippingAddress(?string $shippingAddress): self { - $obj = clone $this; - $obj->shipping_address = $shippingAddress; + $self = clone $this; + $self['shippingAddress'] = $shippingAddress; - return $obj; + return $self; } /** @@ -889,10 +1016,10 @@ public function withShippingAddress(?string $shippingAddress): self public function withShippingAddressRecipient( ?string $shippingAddressRecipient ): self { - $obj = clone $this; - $obj->shipping_address_recipient = $shippingAddressRecipient; + $self = clone $this; + $self['shippingAddressRecipient'] = $shippingAddressRecipient; - return $obj; + return $self; } /** @@ -902,10 +1029,10 @@ public function withShippingAddressRecipient( */ public function withState(DocumentState|string $state): self { - $obj = clone $this; - $obj['state'] = $state; + $self = clone $this; + $self['state'] = $state; - return $obj; + return $self; } /** @@ -913,34 +1040,37 @@ public function withState(DocumentState|string $state): self */ public function withSubtotal(float|string|null $subtotal): self { - $obj = clone $this; - $obj->subtotal = $subtotal; + $self = clone $this; + $self['subtotal'] = $subtotal; - return $obj; + return $self; } /** * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt). * - * @param TaxCode|value-of $taxCode + * @param ValidateValidateJsonParams\TaxCode|value-of $taxCode */ - public function withTaxCode(TaxCode|string $taxCode): self - { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + public function withTaxCode( + ValidateValidateJsonParams\TaxCode|string $taxCode + ): self { + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** - * @param list|null $taxDetails + * @param list|null $taxDetails */ public function withTaxDetails(?array $taxDetails): self { - $obj = clone $this; - $obj->tax_details = $taxDetails; + $self = clone $this; + $self['taxDetails'] = $taxDetails; - return $obj; + return $self; } /** @@ -948,10 +1078,10 @@ public function withTaxDetails(?array $taxDetails): self */ public function withTotalDiscount(float|string|null $totalDiscount): self { - $obj = clone $this; - $obj->total_discount = $totalDiscount; + $self = clone $this; + $self['totalDiscount'] = $totalDiscount; - return $obj; + return $self; } /** @@ -959,10 +1089,10 @@ public function withTotalDiscount(float|string|null $totalDiscount): self */ public function withTotalTax(float|string|null $totalTax): self { - $obj = clone $this; - $obj->total_tax = $totalTax; + $self = clone $this; + $self['totalTax'] = $totalTax; - return $obj; + return $self; } /** @@ -975,10 +1105,10 @@ public function withTotalTax(float|string|null $totalTax): self */ public function withVatex(Vatex|string|null $vatex): self { - $obj = clone $this; - $obj['vatex'] = $vatex; + $self = clone $this; + $self['vatex'] = $vatex; - return $obj; + return $self; } /** @@ -986,10 +1116,10 @@ public function withVatex(Vatex|string|null $vatex): self */ public function withVatexNote(?string $vatexNote): self { - $obj = clone $this; - $obj->vatex_note = $vatexNote; + $self = clone $this; + $self['vatexNote'] = $vatexNote; - return $obj; + return $self; } /** @@ -997,10 +1127,10 @@ public function withVatexNote(?string $vatexNote): self */ public function withVendorAddress(?string $vendorAddress): self { - $obj = clone $this; - $obj->vendor_address = $vendorAddress; + $self = clone $this; + $self['vendorAddress'] = $vendorAddress; - return $obj; + return $self; } /** @@ -1009,10 +1139,10 @@ public function withVendorAddress(?string $vendorAddress): self public function withVendorAddressRecipient( ?string $vendorAddressRecipient ): self { - $obj = clone $this; - $obj->vendor_address_recipient = $vendorAddressRecipient; + $self = clone $this; + $self['vendorAddressRecipient'] = $vendorAddressRecipient; - return $obj; + return $self; } /** @@ -1020,10 +1150,10 @@ public function withVendorAddressRecipient( */ public function withVendorCompanyID(?string $vendorCompanyID): self { - $obj = clone $this; - $obj->vendor_company_id = $vendorCompanyID; + $self = clone $this; + $self['vendorCompanyID'] = $vendorCompanyID; - return $obj; + return $self; } /** @@ -1031,10 +1161,10 @@ public function withVendorCompanyID(?string $vendorCompanyID): self */ public function withVendorEmail(?string $vendorEmail): self { - $obj = clone $this; - $obj->vendor_email = $vendorEmail; + $self = clone $this; + $self['vendorEmail'] = $vendorEmail; - return $obj; + return $self; } /** @@ -1042,10 +1172,10 @@ public function withVendorEmail(?string $vendorEmail): self */ public function withVendorName(?string $vendorName): self { - $obj = clone $this; - $obj->vendor_name = $vendorName; + $self = clone $this; + $self['vendorName'] = $vendorName; - return $obj; + return $self; } /** @@ -1053,9 +1183,9 @@ public function withVendorName(?string $vendorName): self */ public function withVendorTaxID(?string $vendorTaxID): self { - $obj = clone $this; - $obj->vendor_tax_id = $vendorTaxID; + $self = clone $this; + $self['vendorTaxID'] = $vendorTaxID; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams/Allowance.php b/src/Validate/ValidateValidateJsonParams/Allowance.php index 6d4537c4..7a07853e 100644 --- a/src/Validate/ValidateValidateJsonParams/Allowance.php +++ b/src/Validate/ValidateValidateJsonParams/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate\ValidateValidateJsonParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\TaxCode>|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Allowance\TaxCode>|null, + * taxRate?: float|string|null, * } */ final class Allowance implements BaseModel @@ -31,51 +31,51 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -87,29 +87,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -117,10 +117,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -128,10 +128,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -140,10 +140,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -151,10 +151,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -164,10 +164,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -178,10 +178,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string $taxCode, ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -189,9 +189,9 @@ public function withTaxCode( */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams/Charge.php b/src/Validate/ValidateValidateJsonParams/Charge.php index 268a164a..02791093 100644 --- a/src/Validate/ValidateValidateJsonParams/Charge.php +++ b/src/Validate/ValidateValidateJsonParams/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate\ValidateValidateJsonParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Charge\TaxCode>|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Charge\TaxCode>|null, + * taxRate?: float|string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,20 +67,20 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api( + #[Optional( + 'tax_code', enum: TaxCode::class, nullable: true, - optional: true, )] - public ?string $tax_code; + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -92,29 +92,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -122,10 +122,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -133,10 +133,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -145,10 +145,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -156,10 +156,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -169,10 +169,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -187,10 +187,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self public function withTaxCode( TaxCode|string|null $taxCode, ): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -198,9 +198,9 @@ public function withTaxCode( */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams/Item.php b/src/Validate/ValidateValidateJsonParams/Item.php index 1d206b2a..7b438856 100644 --- a/src/Validate/ValidateValidateJsonParams/Item.php +++ b/src/Validate/ValidateValidateJsonParams/Item.php @@ -4,11 +4,13 @@ namespace EInvoiceAPI\Validate\ValidateValidateJsonParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Documents\UnitOfMeasureCode; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Allowance; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Allowance\ReasonCode; +use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Allowance\TaxCode; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Charge; /** @@ -18,12 +20,12 @@ * charges?: list<\EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Charge>|null, * date?: null|null, * description?: string|null, - * product_code?: string|null, + * productCode?: string|null, * quantity?: float|string|null, * tax?: float|string|null, - * tax_rate?: float|string|null, + * taxRate?: float|string|null, * unit?: value-of|null, - * unit_price?: float|string|null, + * unitPrice?: float|string|null, * } */ final class Item implements BaseModel @@ -36,17 +38,16 @@ final class Item implements BaseModel * * @var list|null $allowances */ - #[Api( + #[Optional( list: Allowance::class, nullable: true, - optional: true, )] public ?array $allowances; /** * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** @@ -54,60 +55,59 @@ final class Item implements BaseModel * * @var list|null $charges */ - #[Api( + #[Optional( list: Charge::class, nullable: true, - optional: true, )] public ?array $charges; /** @var null|null $date */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public null $date; /** * The description of the line item. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The product code of the line item. */ - #[Api(nullable: true, optional: true)] - public ?string $product_code; + #[Optional('product_code', nullable: true)] + public ?string $productCode; /** * The quantity of items (goods or services) that is the subject of the line item. Must be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $quantity; /** * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be negative for credit notes or corrections. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $tax; /** * The VAT rate of the line item expressed as percentage with 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. * * @var value-of|null $unit */ - #[Api(enum: UnitOfMeasureCode::class, nullable: true, optional: true)] + #[Optional(enum: UnitOfMeasureCode::class, nullable: true)] public ?string $unit; /** * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting item price discount. Must be rounded to maximum 4 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $unit_price; + #[Optional('unit_price', nullable: true)] + public float|string|null $unitPrice; public function __construct() { @@ -119,8 +119,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list|null $allowances - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges * @param UnitOfMeasureCode|value-of|null $unit */ public static function with( @@ -129,42 +145,50 @@ public static function with( ?array $charges = null, null $date = null, ?string $description = null, - ?string $product_code = null, + ?string $productCode = null, float|string|null $quantity = null, float|string|null $tax = null, - float|string|null $tax_rate = null, + float|string|null $taxRate = null, UnitOfMeasureCode|string|null $unit = null, - float|string|null $unit_price = null, + float|string|null $unitPrice = null, ): self { - $obj = new self; - - $obj->date = $date; - - null !== $allowances && $obj->allowances = $allowances; - null !== $amount && $obj->amount = $amount; - null !== $charges && $obj->charges = $charges; - null !== $description && $obj->description = $description; - null !== $product_code && $obj->product_code = $product_code; - null !== $quantity && $obj->quantity = $quantity; - null !== $tax && $obj->tax = $tax; - null !== $tax_rate && $obj->tax_rate = $tax_rate; - null !== $unit && $obj['unit'] = $unit; - null !== $unit_price && $obj->unit_price = $unit_price; - - return $obj; + $self = new self; + + $self['date'] = $date; + + null !== $allowances && $self['allowances'] = $allowances; + null !== $amount && $self['amount'] = $amount; + null !== $charges && $self['charges'] = $charges; + null !== $description && $self['description'] = $description; + null !== $productCode && $self['productCode'] = $productCode; + null !== $quantity && $self['quantity'] = $quantity; + null !== $tax && $self['tax'] = $tax; + null !== $taxRate && $self['taxRate'] = $taxRate; + null !== $unit && $self['unit'] = $unit; + null !== $unitPrice && $self['unitPrice'] = $unitPrice; + + return $self; } /** * The allowances of the line item. * - * @param list|null $allowances + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $allowances */ public function withAllowances(?array $allowances): self { - $obj = clone $this; - $obj->allowances = $allowances; + $self = clone $this; + $self['allowances'] = $allowances; - return $obj; + return $self; } /** @@ -172,23 +196,31 @@ public function withAllowances(?array $allowances): self */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** * The charges of the line item. * - * @param list|null $charges + * @param list|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, + * }>|null $charges */ public function withCharges(?array $charges): self { - $obj = clone $this; - $obj->charges = $charges; + $self = clone $this; + $self['charges'] = $charges; - return $obj; + return $self; } /** @@ -196,10 +228,10 @@ public function withCharges(?array $charges): self */ public function withDate(null $date): self { - $obj = clone $this; - $obj->date = $date; + $self = clone $this; + $self['date'] = $date; - return $obj; + return $self; } /** @@ -207,10 +239,10 @@ public function withDate(null $date): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -218,10 +250,10 @@ public function withDescription(?string $description): self */ public function withProductCode(?string $productCode): self { - $obj = clone $this; - $obj->product_code = $productCode; + $self = clone $this; + $self['productCode'] = $productCode; - return $obj; + return $self; } /** @@ -229,10 +261,10 @@ public function withProductCode(?string $productCode): self */ public function withQuantity(float|string|null $quantity): self { - $obj = clone $this; - $obj->quantity = $quantity; + $self = clone $this; + $self['quantity'] = $quantity; - return $obj; + return $self; } /** @@ -240,10 +272,10 @@ public function withQuantity(float|string|null $quantity): self */ public function withTax(float|string|null $tax): self { - $obj = clone $this; - $obj->tax = $tax; + $self = clone $this; + $self['tax'] = $tax; - return $obj; + return $self; } /** @@ -251,10 +283,10 @@ public function withTax(float|string|null $tax): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -264,10 +296,10 @@ public function withTaxRate(float|string|null $taxRate): self */ public function withUnit(UnitOfMeasureCode|string|null $unit): self { - $obj = clone $this; - $obj['unit'] = $unit; + $self = clone $this; + $self['unit'] = $unit; - return $obj; + return $self; } /** @@ -275,9 +307,9 @@ public function withUnit(UnitOfMeasureCode|string|null $unit): self */ public function withUnitPrice(float|string|null $unitPrice): self { - $obj = clone $this; - $obj->unit_price = $unitPrice; + $self = clone $this; + $self['unitPrice'] = $unitPrice; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams/Item/Allowance.php b/src/Validate/ValidateValidateJsonParams/Item/Allowance.php index f44c46e6..3c6f5ad9 100644 --- a/src/Validate/ValidateValidateJsonParams/Item/Allowance.php +++ b/src/Validate/ValidateValidateJsonParams/Item/Allowance.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate\ValidateValidateJsonParams\Item; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Allowance\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type AllowanceShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, * } */ final class Allowance implements BaseModel @@ -31,48 +31,48 @@ final class Allowance implements BaseModel /** * The allowance amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the allowance percentage, to calculate the allowance amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the allowance. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Allowance reason codes for invoice discounts and charges. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * The VAT category code that applies to the allowance. * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -84,29 +84,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -114,10 +114,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -125,10 +125,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -137,10 +137,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -148,10 +148,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -161,10 +161,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -174,10 +174,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -185,9 +185,9 @@ public function withTaxCode(TaxCode|string $taxCode): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams/Item/Charge.php b/src/Validate/ValidateValidateJsonParams/Item/Charge.php index f888c588..141db725 100644 --- a/src/Validate/ValidateValidateJsonParams/Item/Charge.php +++ b/src/Validate/ValidateValidateJsonParams/Item/Charge.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate\ValidateValidateJsonParams\Item; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use EInvoiceAPI\Validate\ValidateValidateJsonParams\Item\Charge\ReasonCode; @@ -15,12 +15,12 @@ * * @phpstan-type ChargeShape = array{ * amount?: float|string|null, - * base_amount?: float|string|null, - * multiplier_factor?: float|string|null, + * baseAmount?: float|string|null, + * multiplierFactor?: float|string|null, * reason?: string|null, - * reason_code?: value-of|null, - * tax_code?: value-of|null, - * tax_rate?: float|string|null, + * reasonCode?: value-of|null, + * taxCode?: value-of|null, + * taxRate?: float|string|null, * } */ final class Charge implements BaseModel @@ -31,34 +31,34 @@ final class Charge implements BaseModel /** * The charge amount, without VAT. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The base amount that may be used, in conjunction with the charge percentage, to calculate the charge amount. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] - public float|string|null $base_amount; + #[Optional('base_amount', nullable: true)] + public float|string|null $baseAmount; /** * The percentage that may be used, in conjunction with the charge base amount, to calculate the charge amount. To state 20%, use value 20. */ - #[Api(nullable: true, optional: true)] - public float|string|null $multiplier_factor; + #[Optional('multiplier_factor', nullable: true)] + public float|string|null $multiplierFactor; /** * The reason for the charge. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * Charge reason codes for invoice charges and fees. * - * @var value-of|null $reason_code + * @var value-of|null $reasonCode */ - #[Api(enum: ReasonCode::class, nullable: true, optional: true)] - public ?string $reason_code; + #[Optional('reason_code', enum: ReasonCode::class, nullable: true)] + public ?string $reasonCode; /** * Duty or tax or fee category codes (Subset of UNCL5305). @@ -67,16 +67,16 @@ final class Charge implements BaseModel * Version: D.16B * Subset: OpenPEPPOL * - * @var value-of|null $tax_code + * @var value-of|null $taxCode */ - #[Api(enum: TaxCode::class, nullable: true, optional: true)] - public ?string $tax_code; + #[Optional('tax_code', enum: TaxCode::class, nullable: true)] + public ?string $taxCode; /** * The VAT rate, represented as percentage that applies to the charge. */ - #[Api(nullable: true, optional: true)] - public float|string|null $tax_rate; + #[Optional('tax_rate', nullable: true)] + public float|string|null $taxRate; public function __construct() { @@ -88,29 +88,29 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ReasonCode|value-of|null $reason_code - * @param TaxCode|value-of|null $tax_code + * @param ReasonCode|value-of|null $reasonCode + * @param TaxCode|value-of|null $taxCode */ public static function with( float|string|null $amount = null, - float|string|null $base_amount = null, - float|string|null $multiplier_factor = null, + float|string|null $baseAmount = null, + float|string|null $multiplierFactor = null, ?string $reason = null, - ReasonCode|string|null $reason_code = null, - TaxCode|string|null $tax_code = null, - float|string|null $tax_rate = null, + ReasonCode|string|null $reasonCode = null, + TaxCode|string|null $taxCode = null, + float|string|null $taxRate = null, ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $base_amount && $obj->base_amount = $base_amount; - null !== $multiplier_factor && $obj->multiplier_factor = $multiplier_factor; - null !== $reason && $obj->reason = $reason; - null !== $reason_code && $obj['reason_code'] = $reason_code; - null !== $tax_code && $obj['tax_code'] = $tax_code; - null !== $tax_rate && $obj->tax_rate = $tax_rate; + null !== $amount && $self['amount'] = $amount; + null !== $baseAmount && $self['baseAmount'] = $baseAmount; + null !== $multiplierFactor && $self['multiplierFactor'] = $multiplierFactor; + null !== $reason && $self['reason'] = $reason; + null !== $reasonCode && $self['reasonCode'] = $reasonCode; + null !== $taxCode && $self['taxCode'] = $taxCode; + null !== $taxRate && $self['taxRate'] = $taxRate; - return $obj; + return $self; } /** @@ -118,10 +118,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -129,10 +129,10 @@ public function withAmount(float|string|null $amount): self */ public function withBaseAmount(float|string|null $baseAmount): self { - $obj = clone $this; - $obj->base_amount = $baseAmount; + $self = clone $this; + $self['baseAmount'] = $baseAmount; - return $obj; + return $self; } /** @@ -141,10 +141,10 @@ public function withBaseAmount(float|string|null $baseAmount): self public function withMultiplierFactor( float|string|null $multiplierFactor ): self { - $obj = clone $this; - $obj->multiplier_factor = $multiplierFactor; + $self = clone $this; + $self['multiplierFactor'] = $multiplierFactor; - return $obj; + return $self; } /** @@ -152,10 +152,10 @@ public function withMultiplierFactor( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj->reason = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -165,10 +165,10 @@ public function withReason(?string $reason): self */ public function withReasonCode(ReasonCode|string|null $reasonCode): self { - $obj = clone $this; - $obj['reason_code'] = $reasonCode; + $self = clone $this; + $self['reasonCode'] = $reasonCode; - return $obj; + return $self; } /** @@ -182,10 +182,10 @@ public function withReasonCode(ReasonCode|string|null $reasonCode): self */ public function withTaxCode(TaxCode|string|null $taxCode): self { - $obj = clone $this; - $obj['tax_code'] = $taxCode; + $self = clone $this; + $self['taxCode'] = $taxCode; - return $obj; + return $self; } /** @@ -193,9 +193,9 @@ public function withTaxCode(TaxCode|string|null $taxCode): self */ public function withTaxRate(float|string|null $taxRate): self { - $obj = clone $this; - $obj->tax_rate = $taxRate; + $self = clone $this; + $self['taxRate'] = $taxRate; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateJsonParams/TaxDetail.php b/src/Validate/ValidateValidateJsonParams/TaxDetail.php index 8c46c116..e493fcce 100644 --- a/src/Validate/ValidateValidateJsonParams/TaxDetail.php +++ b/src/Validate/ValidateValidateJsonParams/TaxDetail.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate\ValidateValidateJsonParams; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class TaxDetail implements BaseModel /** * The tax amount for this tax category. Must be rounded to maximum 2 decimals. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public float|string|null $amount; /** * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00'). */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $rate; public function __construct() @@ -44,12 +44,12 @@ public static function with( float|string|null $amount = null, ?string $rate = null ): self { - $obj = new self; + $self = new self; - null !== $amount && $obj->amount = $amount; - null !== $rate && $obj->rate = $rate; + null !== $amount && $self['amount'] = $amount; + null !== $rate && $self['rate'] = $rate; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withAmount(float|string|null $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withAmount(float|string|null $amount): self */ public function withRate(?string $rate): self { - $obj = clone $this; - $obj->rate = $rate; + $self = clone $this; + $self['rate'] = $rate; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidatePeppolIDParams.php b/src/Validate/ValidateValidatePeppolIDParams.php index b9f5b0c8..90f9f769 100644 --- a/src/Validate/ValidateValidatePeppolIDParams.php +++ b/src/Validate/ValidateValidatePeppolIDParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -14,7 +14,7 @@ * * @see EInvoiceAPI\Services\ValidateService::validatePeppolID() * - * @phpstan-type ValidateValidatePeppolIDParamsShape = array{peppol_id: string} + * @phpstan-type ValidateValidatePeppolIDParamsShape = array{peppolID: string} */ final class ValidateValidatePeppolIDParams implements BaseModel { @@ -25,15 +25,15 @@ final class ValidateValidatePeppolIDParams implements BaseModel /** * Peppol ID in the format `:`. Example: `0208:1018265814` for a Belgian company. */ - #[Api] - public string $peppol_id; + #[Required] + public string $peppolID; /** * `new ValidateValidatePeppolIDParams()` is missing required properties by the API. * * To enforce required parameters use * ``` - * ValidateValidatePeppolIDParams::with(peppol_id: ...) + * ValidateValidatePeppolIDParams::with(peppolID: ...) * ``` * * Otherwise ensure the following setters are called @@ -52,13 +52,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(string $peppol_id): self + public static function with(string $peppolID): self { - $obj = new self; + $self = new self; - $obj->peppol_id = $peppol_id; + $self['peppolID'] = $peppolID; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $peppol_id): self */ public function withPeppolID(string $peppolID): self { - $obj = clone $this; - $obj->peppol_id = $peppolID; + $self = clone $this; + $self['peppolID'] = $peppolID; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidatePeppolIDResponse.php b/src/Validate/ValidateValidatePeppolIDResponse.php index bab86636..064a2f5a 100644 --- a/src/Validate/ValidateValidatePeppolIDResponse.php +++ b/src/Validate/ValidateValidatePeppolIDResponse.php @@ -4,11 +4,10 @@ namespace EInvoiceAPI\Validate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; use EInvoiceAPI\Validate\ValidateValidatePeppolIDResponse\BusinessCard; /** @@ -18,47 +17,45 @@ * including whether the ID is valid and what document types it supports. * * @phpstan-type ValidateValidatePeppolIDResponseShape = array{ - * business_card: BusinessCard|null, - * business_card_valid: bool, - * dns_valid: bool, - * is_valid: bool, - * supported_document_types?: list|null, + * businessCard: BusinessCard|null, + * businessCardValid: bool, + * dnsValid: bool, + * isValid: bool, + * supportedDocumentTypes?: list|null, * } */ -final class ValidateValidatePeppolIDResponse implements BaseModel, ResponseConverter +final class ValidateValidatePeppolIDResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Business card information for the Peppol ID. */ - #[Api] - public ?BusinessCard $business_card; + #[Required('business_card')] + public ?BusinessCard $businessCard; /** * Whether a business card is set at the SMP. */ - #[Api] - public bool $business_card_valid; + #[Required('business_card_valid')] + public bool $businessCardValid; /** * Whether the DNS resolves to a valid SMP. */ - #[Api] - public bool $dns_valid; + #[Required('dns_valid')] + public bool $dnsValid; /** * Whether the Peppol ID is valid and registered in the Peppol network. */ - #[Api] - public bool $is_valid; + #[Required('is_valid')] + public bool $isValid; - /** @var list|null $supported_document_types */ - #[Api(list: 'string', optional: true)] - public ?array $supported_document_types; + /** @var list|null $supportedDocumentTypes */ + #[Optional('supported_document_types', list: 'string')] + public ?array $supportedDocumentTypes; /** * `new ValidateValidatePeppolIDResponse()` is missing required properties by the API. @@ -66,7 +63,7 @@ final class ValidateValidatePeppolIDResponse implements BaseModel, ResponseConve * To enforce required parameters use * ``` * ValidateValidatePeppolIDResponse::with( - * business_card: ..., business_card_valid: ..., dns_valid: ..., is_valid: ... + * businessCard: ..., businessCardValid: ..., dnsValid: ..., isValid: ... * ) * ``` * @@ -90,36 +87,48 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $supported_document_types + * @param BusinessCard|array{ + * countryCode?: string|null, + * name?: string|null, + * registrationDate?: \DateTimeInterface|null, + * }|null $businessCard + * @param list $supportedDocumentTypes */ public static function with( - ?BusinessCard $business_card, - bool $business_card_valid, - bool $dns_valid, - bool $is_valid, - ?array $supported_document_types = null, + BusinessCard|array|null $businessCard, + bool $businessCardValid, + bool $dnsValid, + bool $isValid, + ?array $supportedDocumentTypes = null, ): self { - $obj = new self; + $self = new self; - $obj->business_card = $business_card; - $obj->business_card_valid = $business_card_valid; - $obj->dns_valid = $dns_valid; - $obj->is_valid = $is_valid; + $self['businessCard'] = $businessCard; + $self['businessCardValid'] = $businessCardValid; + $self['dnsValid'] = $dnsValid; + $self['isValid'] = $isValid; - null !== $supported_document_types && $obj->supported_document_types = $supported_document_types; + null !== $supportedDocumentTypes && $self['supportedDocumentTypes'] = $supportedDocumentTypes; - return $obj; + return $self; } /** * Business card information for the Peppol ID. + * + * @param BusinessCard|array{ + * countryCode?: string|null, + * name?: string|null, + * registrationDate?: \DateTimeInterface|null, + * }|null $businessCard */ - public function withBusinessCard(?BusinessCard $businessCard): self - { - $obj = clone $this; - $obj->business_card = $businessCard; + public function withBusinessCard( + BusinessCard|array|null $businessCard + ): self { + $self = clone $this; + $self['businessCard'] = $businessCard; - return $obj; + return $self; } /** @@ -127,10 +136,10 @@ public function withBusinessCard(?BusinessCard $businessCard): self */ public function withBusinessCardValid(bool $businessCardValid): self { - $obj = clone $this; - $obj->business_card_valid = $businessCardValid; + $self = clone $this; + $self['businessCardValid'] = $businessCardValid; - return $obj; + return $self; } /** @@ -138,10 +147,10 @@ public function withBusinessCardValid(bool $businessCardValid): self */ public function withDNSValid(bool $dnsValid): self { - $obj = clone $this; - $obj->dns_valid = $dnsValid; + $self = clone $this; + $self['dnsValid'] = $dnsValid; - return $obj; + return $self; } /** @@ -149,10 +158,10 @@ public function withDNSValid(bool $dnsValid): self */ public function withIsValid(bool $isValid): self { - $obj = clone $this; - $obj->is_valid = $isValid; + $self = clone $this; + $self['isValid'] = $isValid; - return $obj; + return $self; } /** @@ -161,9 +170,9 @@ public function withIsValid(bool $isValid): self public function withSupportedDocumentTypes( array $supportedDocumentTypes ): self { - $obj = clone $this; - $obj->supported_document_types = $supportedDocumentTypes; + $self = clone $this; + $self['supportedDocumentTypes'] = $supportedDocumentTypes; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidatePeppolIDResponse/BusinessCard.php b/src/Validate/ValidateValidatePeppolIDResponse/BusinessCard.php index 891934ff..eef6c39a 100644 --- a/src/Validate/ValidateValidatePeppolIDResponse/BusinessCard.php +++ b/src/Validate/ValidateValidatePeppolIDResponse/BusinessCard.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate\ValidateValidatePeppolIDResponse; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -12,9 +12,9 @@ * Business card information for the Peppol ID. * * @phpstan-type BusinessCardShape = array{ - * country_code?: string|null, + * countryCode?: string|null, * name?: string|null, - * registration_date?: \DateTimeInterface|null, + * registrationDate?: \DateTimeInterface|null, * } */ final class BusinessCard implements BaseModel @@ -22,14 +22,14 @@ final class BusinessCard implements BaseModel /** @use SdkModel */ use SdkModel; - #[Api(nullable: true, optional: true)] - public ?string $country_code; + #[Optional('country_code', nullable: true)] + public ?string $countryCode; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; - #[Api(nullable: true, optional: true)] - public ?\DateTimeInterface $registration_date; + #[Optional('registration_date', nullable: true)] + public ?\DateTimeInterface $registrationDate; public function __construct() { @@ -42,41 +42,41 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?string $country_code = null, + ?string $countryCode = null, ?string $name = null, - ?\DateTimeInterface $registration_date = null, + ?\DateTimeInterface $registrationDate = null, ): self { - $obj = new self; + $self = new self; - null !== $country_code && $obj->country_code = $country_code; - null !== $name && $obj->name = $name; - null !== $registration_date && $obj->registration_date = $registration_date; + null !== $countryCode && $self['countryCode'] = $countryCode; + null !== $name && $self['name'] = $name; + null !== $registrationDate && $self['registrationDate'] = $registrationDate; - return $obj; + return $self; } public function withCountryCode(?string $countryCode): self { - $obj = clone $this; - $obj->country_code = $countryCode; + $self = clone $this; + $self['countryCode'] = $countryCode; - return $obj; + return $self; } public function withName(?string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } public function withRegistrationDate( ?\DateTimeInterface $registrationDate ): self { - $obj = clone $this; - $obj->registration_date = $registrationDate; + $self = clone $this; + $self['registrationDate'] = $registrationDate; - return $obj; + return $self; } } diff --git a/src/Validate/ValidateValidateUblParams.php b/src/Validate/ValidateValidateUblParams.php index ebde8035..c83902bd 100644 --- a/src/Validate/ValidateValidateUblParams.php +++ b/src/Validate/ValidateValidateUblParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Validate; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -22,7 +22,7 @@ final class ValidateValidateUblParams implements BaseModel use SdkModel; use SdkParams; - #[Api] + #[Required] public string $file; /** @@ -51,18 +51,18 @@ public function __construct() */ public static function with(string $file): self { - $obj = new self; + $self = new self; - $obj->file = $file; + $self['file'] = $file; - return $obj; + return $self; } public function withFile(string $file): self { - $obj = clone $this; - $obj->file = $file; + $self = clone $this; + $self['file'] = $file; - return $obj; + return $self; } } diff --git a/src/Webhooks/WebhookCreateParams.php b/src/Webhooks/WebhookCreateParams.php index de0aeac1..49cd6327 100644 --- a/src/Webhooks/WebhookCreateParams.php +++ b/src/Webhooks/WebhookCreateParams.php @@ -4,7 +4,8 @@ namespace EInvoiceAPI\Webhooks; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -25,13 +26,13 @@ final class WebhookCreateParams implements BaseModel use SdkParams; /** @var list $events */ - #[Api(list: 'string')] + #[Required(list: 'string')] public array $events; - #[Api] + #[Required] public string $url; - #[Api(optional: true)] + #[Optional] public ?bool $enabled; /** @@ -65,14 +66,14 @@ public static function with( string $url, ?bool $enabled = null ): self { - $obj = new self; + $self = new self; - $obj->events = $events; - $obj->url = $url; + $self['events'] = $events; + $self['url'] = $url; - null !== $enabled && $obj->enabled = $enabled; + null !== $enabled && $self['enabled'] = $enabled; - return $obj; + return $self; } /** @@ -80,25 +81,25 @@ public static function with( */ public function withEvents(array $events): self { - $obj = clone $this; - $obj->events = $events; + $self = clone $this; + $self['events'] = $events; - return $obj; + return $self; } public function withURL(string $url): self { - $obj = clone $this; - $obj->url = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } public function withEnabled(bool $enabled): self { - $obj = clone $this; - $obj->enabled = $enabled; + $self = clone $this; + $self['enabled'] = $enabled; - return $obj; + return $self; } } diff --git a/src/Webhooks/WebhookDeleteResponse.php b/src/Webhooks/WebhookDeleteResponse.php index 3f7afd87..39a67c73 100644 --- a/src/Webhooks/WebhookDeleteResponse.php +++ b/src/Webhooks/WebhookDeleteResponse.php @@ -4,33 +4,29 @@ namespace EInvoiceAPI\Webhooks; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; /** * Model for webhook deletion. * - * @phpstan-type WebhookDeleteResponseShape = array{is_deleted: bool} + * @phpstan-type WebhookDeleteResponseShape = array{isDeleted: bool} */ -final class WebhookDeleteResponse implements BaseModel, ResponseConverter +final class WebhookDeleteResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] - public bool $is_deleted; + #[Required('is_deleted')] + public bool $isDeleted; /** * `new WebhookDeleteResponse()` is missing required properties by the API. * * To enforce required parameters use * ``` - * WebhookDeleteResponse::with(is_deleted: ...) + * WebhookDeleteResponse::with(isDeleted: ...) * ``` * * Otherwise ensure the following setters are called @@ -49,20 +45,20 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(bool $is_deleted): self + public static function with(bool $isDeleted): self { - $obj = new self; + $self = new self; - $obj->is_deleted = $is_deleted; + $self['isDeleted'] = $isDeleted; - return $obj; + return $self; } public function withIsDeleted(bool $isDeleted): self { - $obj = clone $this; - $obj->is_deleted = $isDeleted; + $self = clone $this; + $self['isDeleted'] = $isDeleted; - return $obj; + return $self; } } diff --git a/src/Webhooks/WebhookResponse.php b/src/Webhooks/WebhookResponse.php index 403ec09c..9db6d400 100644 --- a/src/Webhooks/WebhookResponse.php +++ b/src/Webhooks/WebhookResponse.php @@ -4,11 +4,10 @@ namespace EInvoiceAPI\Webhooks; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; -use EInvoiceAPI\Core\Concerns\SdkResponse; use EInvoiceAPI\Core\Contracts\BaseModel; -use EInvoiceAPI\Core\Conversion\Contracts\ResponseConverter; /** * Response model for webhook API endpoints. @@ -21,27 +20,25 @@ * enabled?: bool|null, * } */ -final class WebhookResponse implements BaseModel, ResponseConverter +final class WebhookResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] + #[Required] public string $id; /** @var list $events */ - #[Api(list: 'string')] + #[Required(list: 'string')] public array $events; - #[Api] + #[Required] public string $secret; - #[Api] + #[Required] public string $url; - #[Api(optional: true)] + #[Optional] public ?bool $enabled; /** @@ -81,24 +78,24 @@ public static function with( string $url, ?bool $enabled = null ): self { - $obj = new self; + $self = new self; - $obj->id = $id; - $obj->events = $events; - $obj->secret = $secret; - $obj->url = $url; + $self['id'] = $id; + $self['events'] = $events; + $self['secret'] = $secret; + $self['url'] = $url; - null !== $enabled && $obj->enabled = $enabled; + null !== $enabled && $self['enabled'] = $enabled; - return $obj; + return $self; } public function withID(string $id): self { - $obj = clone $this; - $obj->id = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -106,33 +103,33 @@ public function withID(string $id): self */ public function withEvents(array $events): self { - $obj = clone $this; - $obj->events = $events; + $self = clone $this; + $self['events'] = $events; - return $obj; + return $self; } public function withSecret(string $secret): self { - $obj = clone $this; - $obj->secret = $secret; + $self = clone $this; + $self['secret'] = $secret; - return $obj; + return $self; } public function withURL(string $url): self { - $obj = clone $this; - $obj->url = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } public function withEnabled(bool $enabled): self { - $obj = clone $this; - $obj->enabled = $enabled; + $self = clone $this; + $self['enabled'] = $enabled; - return $obj; + return $self; } } diff --git a/src/Webhooks/WebhookUpdateParams.php b/src/Webhooks/WebhookUpdateParams.php index 70becf73..9cb36276 100644 --- a/src/Webhooks/WebhookUpdateParams.php +++ b/src/Webhooks/WebhookUpdateParams.php @@ -4,7 +4,7 @@ namespace EInvoiceAPI\Webhooks; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Concerns\SdkParams; use EInvoiceAPI\Core\Contracts\BaseModel; @@ -24,14 +24,14 @@ final class WebhookUpdateParams implements BaseModel use SdkModel; use SdkParams; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?bool $enabled; /** @var list|null $events */ - #[Api(list: 'string', nullable: true, optional: true)] + #[Optional(list: 'string', nullable: true)] public ?array $events; - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $url; public function __construct() @@ -51,21 +51,21 @@ public static function with( ?array $events = null, ?string $url = null ): self { - $obj = new self; + $self = new self; - null !== $enabled && $obj->enabled = $enabled; - null !== $events && $obj->events = $events; - null !== $url && $obj->url = $url; + null !== $enabled && $self['enabled'] = $enabled; + null !== $events && $self['events'] = $events; + null !== $url && $self['url'] = $url; - return $obj; + return $self; } public function withEnabled(?bool $enabled): self { - $obj = clone $this; - $obj->enabled = $enabled; + $self = clone $this; + $self['enabled'] = $enabled; - return $obj; + return $self; } /** @@ -73,17 +73,17 @@ public function withEnabled(?bool $enabled): self */ public function withEvents(?array $events): self { - $obj = clone $this; - $obj->events = $events; + $self = clone $this; + $self['events'] = $events; - return $obj; + return $self; } public function withURL(?string $url): self { - $obj = clone $this; - $obj->url = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/tests/Core/TestModel.php b/tests/Core/TestModel.php index 4d934225..2308d030 100644 --- a/tests/Core/TestModel.php +++ b/tests/Core/TestModel.php @@ -2,7 +2,8 @@ namespace Tests\Core; -use EInvoiceAPI\Core\Attributes\Api; +use EInvoiceAPI\Core\Attributes\Optional; +use EInvoiceAPI\Core\Attributes\Required; use EInvoiceAPI\Core\Concerns\SdkModel; use EInvoiceAPI\Core\Contracts\BaseModel; use PHPUnit\Framework\Attributes\CoversNothing; @@ -14,17 +15,17 @@ class TestModel implements BaseModel /** @use SdkModel> */ use SdkModel; - #[Api] + #[Required] public string $name; - #[Api('age_years')] + #[Required('age_years')] public int $ageYears; /** @var list|null */ - #[Api(optional: true)] + #[Optional] public ?array $friends; - #[Api] + #[Required] public ?string $owner; /** diff --git a/tests/Services/Documents/AttachmentsTest.php b/tests/Services/Documents/AttachmentsTest.php index 2dcb3a72..68473222 100644 --- a/tests/Services/Documents/AttachmentsTest.php +++ b/tests/Services/Documents/AttachmentsTest.php @@ -37,7 +37,7 @@ public function testRetrieve(): void $result = $this->client->documents->attachments->retrieve( 'attachment_id', - ['document_id' => 'document_id'] + documentID: 'document_id' ); // @phpstan-ignore-next-line method.alreadyNarrowedType @@ -53,7 +53,7 @@ public function testRetrieveWithOptionalParams(): void $result = $this->client->documents->attachments->retrieve( 'attachment_id', - ['document_id' => 'document_id'] + documentID: 'document_id' ); // @phpstan-ignore-next-line method.alreadyNarrowedType @@ -82,7 +82,7 @@ public function testDelete(): void $result = $this->client->documents->attachments->delete( 'attachment_id', - ['document_id' => 'document_id'] + documentID: 'document_id' ); // @phpstan-ignore-next-line method.alreadyNarrowedType @@ -98,7 +98,7 @@ public function testDeleteWithOptionalParams(): void $result = $this->client->documents->attachments->delete( 'attachment_id', - ['document_id' => 'document_id'] + documentID: 'document_id' ); // @phpstan-ignore-next-line method.alreadyNarrowedType @@ -114,7 +114,7 @@ public function testAdd(): void $result = $this->client->documents->attachments->add( 'document_id', - ['file' => file_get_contents(__FILE__) ?: ''] + file: 'file' ); // @phpstan-ignore-next-line method.alreadyNarrowedType @@ -130,7 +130,7 @@ public function testAddWithOptionalParams(): void $result = $this->client->documents->attachments->add( 'document_id', - ['file' => file_get_contents(__FILE__) ?: ''] + file: 'file' ); // @phpstan-ignore-next-line method.alreadyNarrowedType diff --git a/tests/Services/Documents/UblTest.php b/tests/Services/Documents/UblTest.php index 4d259e60..9b511679 100644 --- a/tests/Services/Documents/UblTest.php +++ b/tests/Services/Documents/UblTest.php @@ -35,9 +35,7 @@ public function testCreateFromUbl(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->documents->ubl->createFromUbl([ - 'file' => file_get_contents(__FILE__) ?: '', - ]); + $result = $this->client->documents->ubl->createFromUbl(file: 'file'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(DocumentResponse::class, $result); @@ -50,9 +48,7 @@ public function testCreateFromUblWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->documents->ubl->createFromUbl([ - 'file' => file_get_contents(__FILE__) ?: '', - ]); + $result = $this->client->documents->ubl->createFromUbl(file: 'file'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(DocumentResponse::class, $result); diff --git a/tests/Services/DocumentsTest.php b/tests/Services/DocumentsTest.php index 938d6c25..a3cae784 100644 --- a/tests/Services/DocumentsTest.php +++ b/tests/Services/DocumentsTest.php @@ -37,7 +37,7 @@ public function testCreate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->documents->create([]); + $result = $this->client->documents->create(); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(DocumentResponse::class, $result); @@ -76,9 +76,7 @@ public function testCreateFromPdf(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->documents->createFromPdf([ - 'file' => file_get_contents(__FILE__) ?: '', - ]); + $result = $this->client->documents->createFromPdf(file: 'file'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(DocumentNewFromPdfResponse::class, $result); @@ -91,11 +89,11 @@ public function testCreateFromPdfWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->documents->createFromPdf([ - 'file' => file_get_contents(__FILE__) ?: '', - 'customer_tax_id' => 'customer_tax_id', - 'vendor_tax_id' => 'vendor_tax_id', - ]); + $result = $this->client->documents->createFromPdf( + file: 'file', + customerTaxID: 'customer_tax_id', + vendorTaxID: 'vendor_tax_id', + ); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(DocumentNewFromPdfResponse::class, $result); @@ -108,7 +106,7 @@ public function testSend(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->documents->send('document_id', []); + $result = $this->client->documents->send('document_id'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(DocumentResponse::class, $result); diff --git a/tests/Services/InboxTest.php b/tests/Services/InboxTest.php index a4078ac6..874b2de5 100644 --- a/tests/Services/InboxTest.php +++ b/tests/Services/InboxTest.php @@ -3,6 +3,7 @@ namespace Tests\Services; use EInvoiceAPI\Client; +use EInvoiceAPI\Documents\DocumentResponse; use EInvoiceAPI\DocumentsNumberPage; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; @@ -34,10 +35,15 @@ public function testList(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->inbox->list([]); + $page = $this->client->inbox->list(); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertInstanceOf(DocumentsNumberPage::class, $result); + $this->assertInstanceOf(DocumentsNumberPage::class, $page); + + if ($item = $page->getItems()[0] ?? null) { + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(DocumentResponse::class, $item); + } } #[Test] @@ -47,10 +53,15 @@ public function testListCreditNotes(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->inbox->listCreditNotes([]); + $page = $this->client->inbox->listCreditNotes(); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertInstanceOf(DocumentsNumberPage::class, $result); + $this->assertInstanceOf(DocumentsNumberPage::class, $page); + + if ($item = $page->getItems()[0] ?? null) { + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(DocumentResponse::class, $item); + } } #[Test] @@ -60,9 +71,14 @@ public function testListInvoices(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->inbox->listInvoices([]); + $page = $this->client->inbox->listInvoices(); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertInstanceOf(DocumentsNumberPage::class, $result); + $this->assertInstanceOf(DocumentsNumberPage::class, $page); + + if ($item = $page->getItems()[0] ?? null) { + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(DocumentResponse::class, $item); + } } } diff --git a/tests/Services/LookupTest.php b/tests/Services/LookupTest.php index 83526a24..12403afb 100644 --- a/tests/Services/LookupTest.php +++ b/tests/Services/LookupTest.php @@ -35,7 +35,7 @@ public function testRetrieve(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->lookup->retrieve(['peppol_id' => 'peppol_id']); + $result = $this->client->lookup->retrieve(peppolID: 'peppol_id'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(LookupGetResponse::class, $result); @@ -48,7 +48,7 @@ public function testRetrieveWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->lookup->retrieve(['peppol_id' => 'peppol_id']); + $result = $this->client->lookup->retrieve(peppolID: 'peppol_id'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(LookupGetResponse::class, $result); @@ -61,7 +61,7 @@ public function testRetrieveParticipants(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->lookup->retrieveParticipants(['query' => 'query']); + $result = $this->client->lookup->retrieveParticipants(query: 'query'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(LookupGetParticipantsResponse::class, $result); @@ -74,9 +74,10 @@ public function testRetrieveParticipantsWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->lookup->retrieveParticipants([ - 'query' => 'query', 'country_code' => 'country_code', - ]); + $result = $this->client->lookup->retrieveParticipants( + query: 'query', + countryCode: 'country_code' + ); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(LookupGetParticipantsResponse::class, $result); diff --git a/tests/Services/OutboxTest.php b/tests/Services/OutboxTest.php index ee7a52ce..6c3a593c 100644 --- a/tests/Services/OutboxTest.php +++ b/tests/Services/OutboxTest.php @@ -3,6 +3,7 @@ namespace Tests\Services; use EInvoiceAPI\Client; +use EInvoiceAPI\Documents\DocumentResponse; use EInvoiceAPI\DocumentsNumberPage; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; @@ -34,10 +35,15 @@ public function testListDraftDocuments(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->outbox->listDraftDocuments([]); + $page = $this->client->outbox->listDraftDocuments(); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertInstanceOf(DocumentsNumberPage::class, $result); + $this->assertInstanceOf(DocumentsNumberPage::class, $page); + + if ($item = $page->getItems()[0] ?? null) { + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(DocumentResponse::class, $item); + } } #[Test] @@ -47,9 +53,14 @@ public function testListReceivedDocuments(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->outbox->listReceivedDocuments([]); + $page = $this->client->outbox->listReceivedDocuments(); // @phpstan-ignore-next-line method.alreadyNarrowedType - $this->assertInstanceOf(DocumentsNumberPage::class, $result); + $this->assertInstanceOf(DocumentsNumberPage::class, $page); + + if ($item = $page->getItems()[0] ?? null) { + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(DocumentResponse::class, $item); + } } } diff --git a/tests/Services/ValidateTest.php b/tests/Services/ValidateTest.php index c4a42d5f..d84835dd 100644 --- a/tests/Services/ValidateTest.php +++ b/tests/Services/ValidateTest.php @@ -35,7 +35,7 @@ public function testValidateJson(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->validate->validateJson([]); + $result = $this->client->validate->validateJson(); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(UblDocumentValidation::class, $result); @@ -48,9 +48,7 @@ public function testValidatePeppolID(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->validate->validatePeppolID([ - 'peppol_id' => 'peppol_id', - ]); + $result = $this->client->validate->validatePeppolID(peppolID: 'peppol_id'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(ValidateValidatePeppolIDResponse::class, $result); @@ -63,9 +61,7 @@ public function testValidatePeppolIDWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->validate->validatePeppolID([ - 'peppol_id' => 'peppol_id', - ]); + $result = $this->client->validate->validatePeppolID(peppolID: 'peppol_id'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(ValidateValidatePeppolIDResponse::class, $result); @@ -78,9 +74,7 @@ public function testValidateUbl(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->validate->validateUbl([ - 'file' => file_get_contents(__FILE__) ?: '', - ]); + $result = $this->client->validate->validateUbl(file: 'file'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(UblDocumentValidation::class, $result); @@ -93,9 +87,7 @@ public function testValidateUblWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->validate->validateUbl([ - 'file' => file_get_contents(__FILE__) ?: '', - ]); + $result = $this->client->validate->validateUbl(file: 'file'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(UblDocumentValidation::class, $result); diff --git a/tests/Services/WebhooksTest.php b/tests/Services/WebhooksTest.php index 23f8283e..c2f4b9a0 100644 --- a/tests/Services/WebhooksTest.php +++ b/tests/Services/WebhooksTest.php @@ -35,9 +35,10 @@ public function testCreate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->webhooks->create([ - 'events' => ['string'], 'url' => 'https://example.com', - ]); + $result = $this->client->webhooks->create( + events: ['string'], + url: 'https://example.com' + ); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(WebhookResponse::class, $result); @@ -50,9 +51,11 @@ public function testCreateWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->webhooks->create([ - 'events' => ['string'], 'url' => 'https://example.com', 'enabled' => true, - ]); + $result = $this->client->webhooks->create( + events: ['string'], + url: 'https://example.com', + enabled: true + ); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(WebhookResponse::class, $result); @@ -78,7 +81,7 @@ public function testUpdate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->webhooks->update('webhook_id', []); + $result = $this->client->webhooks->update('webhook_id'); // @phpstan-ignore-next-line method.alreadyNarrowedType $this->assertInstanceOf(WebhookResponse::class, $result);