*/ class PostApiV3TipitakaExportsRequest implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; /** * The original name of the model. * * @var string */ protected static $openAPIModelName = 'post_api_v3_tipitaka_exports_request'; /** * Array of property to type mappings. Used for (de)serialization * * @var string[] */ protected static $openAPITypes = [ 'channel' => 'string', 'work' => 'int', 'book' => 'int', 'para' => 'int', 'category' => 'int', 'format' => 'string' ]; /** * Array of property to format mappings. Used for (de)serialization * * @var string[] * @phpstan-var array * @psalm-var array */ protected static $openAPIFormats = [ 'channel' => null, 'work' => null, 'book' => null, 'para' => null, 'category' => null, 'format' => null ]; /** * Array of nullable properties. Used for (de)serialization * * @var boolean[] */ protected static array $openAPINullables = [ 'channel' => false, 'work' => false, 'book' => false, 'para' => false, 'category' => false, 'format' => false ]; /** * If a nullable field gets set to null, insert it here * * @var boolean[] */ protected array $openAPINullablesSetToNull = []; /** * Array of property to type mappings. Used for (de)serialization * * @return array */ public static function openAPITypes() { return self::$openAPITypes; } /** * Array of property to format mappings. Used for (de)serialization * * @return array */ public static function openAPIFormats() { return self::$openAPIFormats; } /** * Array of nullable properties * * @return array */ protected static function openAPINullables(): array { return self::$openAPINullables; } /** * Array of nullable field names deliberately set to null * * @return boolean[] */ private function getOpenAPINullablesSetToNull(): array { return $this->openAPINullablesSetToNull; } /** * Setter - Array of nullable field names deliberately set to null * * @param boolean[] $openAPINullablesSetToNull */ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void { $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; } /** * Checks if a property is nullable * * @param string $property * @return bool */ public static function isNullable(string $property): bool { return self::openAPINullables()[$property] ?? false; } /** * Checks if a nullable property is set to null. * * @param string $property * @return bool */ public function isNullableSetToNull(string $property): bool { return in_array($property, $this->getOpenAPINullablesSetToNull(), true); } /** * Array of attributes where the key is the local name, * and the value is the original name * * @var string[] */ protected static $attributeMap = [ 'channel' => 'channel', 'work' => 'work', 'book' => 'book', 'para' => 'para', 'category' => 'category', 'format' => 'format' ]; /** * Array of attributes to setter functions (for deserialization of responses) * * @var string[] */ protected static $setters = [ 'channel' => 'setChannel', 'work' => 'setWork', 'book' => 'setBook', 'para' => 'setPara', 'category' => 'setCategory', 'format' => 'setFormat' ]; /** * Array of attributes to getter functions (for serialization of requests) * * @var string[] */ protected static $getters = [ 'channel' => 'getChannel', 'work' => 'getWork', 'book' => 'getBook', 'para' => 'getPara', 'category' => 'getCategory', 'format' => 'getFormat' ]; /** * Array of attributes where the key is the local name, * and the value is the original name * * @return array */ public static function attributeMap() { return self::$attributeMap; } /** * Array of attributes to setter functions (for deserialization of responses) * * @return array */ public static function setters() { return self::$setters; } /** * Array of attributes to getter functions (for serialization of requests) * * @return array */ public static function getters() { return self::$getters; } /** * The original name of the model. * * @return string */ public function getModelName() { return self::$openAPIModelName; } public const FORMAT_HTML = 'html'; public const FORMAT_MARKDOWN = 'markdown'; public const FORMAT_EPUB = 'epub'; public const FORMAT_DOCX = 'docx'; public const FORMAT_OFFLINE = 'offline'; /** * Gets allowable values of the enum * * @return string[] */ public function getFormatAllowableValues() { return [ self::FORMAT_HTML, self::FORMAT_MARKDOWN, self::FORMAT_EPUB, self::FORMAT_DOCX, self::FORMAT_OFFLINE, ]; } /** * Associative array for storing property values * * @var mixed[] */ protected $container = []; /** * Constructor * * @param mixed[]|null $data Associated array of property values * initializing the model */ public function __construct(?array $data = null) { $this->setIfExists('channel', $data ?? [], null); $this->setIfExists('work', $data ?? [], null); $this->setIfExists('book', $data ?? [], null); $this->setIfExists('para', $data ?? [], null); $this->setIfExists('category', $data ?? [], null); $this->setIfExists('format', $data ?? [], null); } /** * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the * $this->openAPINullablesSetToNull array * * @param string $variableName * @param array $fields * @param mixed $defaultValue */ private function setIfExists(string $variableName, array $fields, $defaultValue): void { if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { $this->openAPINullablesSetToNull[] = $variableName; } $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** * Show all the invalid properties with reasons. * * @return array invalid properties with reasons */ public function listInvalidProperties() { $invalidProperties = []; if ($this->container['channel'] === null) { $invalidProperties[] = "'channel' can't be null"; } if ($this->container['format'] === null) { $invalidProperties[] = "'format' can't be null"; } $allowedValues = $this->getFormatAllowableValues(); if (!is_null($this->container['format']) && !in_array($this->container['format'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'format', must be one of '%s'", $this->container['format'], implode("', '", $allowedValues) ); } return $invalidProperties; } /** * Validate all the properties in the model * return true if all passed * * @return bool True if all properties are valid */ public function valid() { return count($this->listInvalidProperties()) === 0; } /** * Gets channel * * @return string */ public function getChannel() { return $this->container['channel']; } /** * Sets channel * * @param string $channel channel uid * * @return self */ public function setChannel($channel) { if (is_null($channel)) { throw new \InvalidArgumentException('non-nullable channel cannot be null'); } $this->container['channel'] = $channel; return $this; } /** * Gets work * * @return int|null */ public function getWork() { return $this->container['work']; } /** * Sets work * * @param int|null $work 作品(library 作品页 URL 里的 sn)。作品、category 只能给一个,都不给 = 整个 channel * * @return self */ public function setWork($work) { if (is_null($work)) { throw new \InvalidArgumentException('non-nullable work cannot be null'); } $this->container['work'] = $work; return $this; } /** * Gets book * * @return int|null */ public function getBook() { return $this->container['book']; } /** * Sets book * * @param int|null $book 用坐标指定作品:book + para 所在的那部作品(mobile 用,它不知道 sn)。与 para 同时给 * * @return self */ public function setBook($book) { if (is_null($book)) { throw new \InvalidArgumentException('non-nullable book cannot be null'); } $this->container['book'] = $book; return $this; } /** * Gets para * * @return int|null */ public function getPara() { return $this->container['para']; } /** * Sets para * * @param int|null $para 与 book 同时给,作品里的任一段落号(通常是作品起始段) * * @return self */ public function setPara($para) { if (is_null($para)) { throw new \InvalidArgumentException('non-nullable para cannot be null'); } $this->container['para'] = $para; return $this; } /** * Gets category * * @return int|null */ public function getCategory() { return $this->container['category']; } /** * Sets category * * @param int|null $category 分类 id(library 分类页 URL 里的 id),含后代分类 * * @return self */ public function setCategory($category) { if (is_null($category)) { throw new \InvalidArgumentException('non-nullable category cannot be null'); } $this->container['category'] = $category; return $this; } /** * Gets format * * @return string */ public function getFormat() { return $this->container['format']; } /** * Sets format * * @param string $format 文件格式 * * @return self */ public function setFormat($format) { if (is_null($format)) { throw new \InvalidArgumentException('non-nullable format cannot be null'); } $allowedValues = $this->getFormatAllowableValues(); if (!in_array($format, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for 'format', must be one of '%s'", $format, implode("', '", $allowedValues) ) ); } $this->container['format'] = $format; return $this; } /** * Returns true if offset exists. False otherwise. * * @param integer|string $offset Offset * * @return boolean */ public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } /** * Gets offset. * * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } /** * Sets value based on offset. * * @param int|null $offset Offset * @param mixed $value Value to be set * * @return void */ public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } /** * Unsets offset. * * @param integer|string $offset Offset * * @return void */ public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } /** * Serializes the object to a value that can be serialized natively by json_encode(). * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php * * @return mixed Returns data which can be serialized by json_encode(), which is a value * of any type other than a resource. */ #[\ReturnTypeWillChange] public function jsonSerialize() { return ObjectSerializer::sanitizeForSerialization($this); } /** * Gets the string presentation of the object * * @return string */ public function __toString() { return json_encode( ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT ); } /** * Gets a header-safe presentation of the object * * @return string */ public function toHeaderValue() { return json_encode(ObjectSerializer::sanitizeForSerialization($this)); } }