<?php
 declare(strict_types=1); namespace Square\Models; use stdClass; class CreateInvoiceRequest implements \JsonSerializable { private $invoice; private $idempotencyKey; public function __construct(Invoice $invoice) { $this->invoice = $invoice; } public function getInvoice(): Invoice { return $this->invoice; } public function setInvoice(Invoice $invoice): void { $this->invoice = $invoice; } public function getIdempotencyKey(): ?string { return $this->idempotencyKey; } public function setIdempotencyKey(?string $idempotencyKey): void { $this->idempotencyKey = $idempotencyKey; } #[\ReturnTypeWillChange] public function jsonSerialize(bool $asArrayWhenEmpty = false) { $json = []; $json['invoice'] = $this->invoice; if (isset($this->idempotencyKey)) { $json['idempotency_key'] = $this->idempotencyKey; } $json = array_filter($json, function ($val) { return $val !== null; }); return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; } } 