Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Model/Core/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property string $name
* @property int $enabled
* @property string $system_url
* @property int|null $enable_ssl
* @property string|null $brand_colour
* @property string|null $frontend_logo
* @property string|null $frontend_logo_dark_mode
* @property string|null $website_url
* @property string|null $favicon
* @property string|null $favicon_dark_mode
* @property string $frontend_template
* @property string|null $operator_icon
* @property string|null $operator_template
* @property string $default_email
* @property string $global_email_header
* @property string $global_email_footer
* @property string $email_method
* @property string|null $smtp_host
* @property int|null $smtp_port
* @property string|null $smtp_encryption
* @property int|null $smtp_requires_auth
* @property string|null $smtp_auth_mech
* @property string|null $smtp_username
* @property string|null $smtp_password
* @property string|null $smtp_oauth
* @property string $default_country
* @property string $default_timezone
* @property string $date_format
* @property string $time_format
* @property string $default_language
* @property int $language_toggle
* @property int $created_at
* @property int $updated_at
* @property BrandTranslation[] $translations
*/
class Brand extends Model
{
/** @var array<string, string> */
Expand Down
5 changes: 5 additions & 0 deletions src/Model/Core/BrandTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use SupportPal\ApiClient\Model\Translation;

/**
* @property int $id
* @property string $name
* @property int $brand_id
*/
class BrandTranslation extends Translation
{
/** @var array<string, string> */
Expand Down
12 changes: 12 additions & 0 deletions src/Model/Core/IpBan.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property string|null $ip
* @property string|null $reason
* @property bool $event_user
* @property bool $event_operator
* @property bool $event_api
* @property int $type
* @property int|null $expiry
* @property int $created_at
* @property int $updated_at
*/
class IpBan extends Model
{
/** @var array<string, string> */
Expand Down
11 changes: 11 additions & 0 deletions src/Model/Core/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property string $name
* @property string $code
* @property bool $enabled
* @property bool $upgrade_available
* @property string|null $version
* @property int $created_at
* @property int $updated_at
* @property string $formatted_name
*/
class Language extends Model
{
/** @var array<string, string> */
Expand Down
9 changes: 9 additions & 0 deletions src/Model/Core/Request/CreateIpBan.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property string $ip
* @property string $reason
* @property int $type
* @property bool $event_user
* @property bool $event_operator
* @property bool $event_api
* @property int $expiry_time
*/
class CreateIpBan extends Model
{
/** @var array<string, string> */
Expand Down
6 changes: 6 additions & 0 deletions src/Model/Core/Request/CreateSpamRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property string $text
* @property int $type
* @property bool $event_message
* @property bool $event_comment
*/
class CreateSpamRule extends Model
{
/** @var array<string, string> */
Expand Down
7 changes: 7 additions & 0 deletions src/Model/Core/Request/CreateWhitelistedIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property string $ip
* @property string $description
* @property bool $event_user
* @property bool $event_operator
* @property bool $event_api
*/
class CreateWhitelistedIp extends Model
{
/** @var array<string, string> */
Expand Down
9 changes: 9 additions & 0 deletions src/Model/Core/SpamRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property string $text
* @property bool $event_message
* @property bool $event_comment
* @property int $type
* @property int $created_at
* @property int $updated_at
*/
class SpamRule extends Model
{
/** @var array<string, string> */
Expand Down
11 changes: 11 additions & 0 deletions src/Model/Core/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property string $hash
* @property string $filename
* @property string $folder
* @property string $mime
* @property string $size
* @property string|null $token
* @property string|null $session_id
* @property int $created_at
* @property int $updated_at
*/
class Upload extends Model
{
/** @var array<string, string> */
Expand Down
10 changes: 10 additions & 0 deletions src/Model/Core/WhitelistedIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property string|null $ip
* @property string|null $description
* @property bool $event_user
* @property bool $event_operator
* @property bool $event_api
* @property int $created_at
* @property int $updated_at
*/
class WhitelistedIp extends Model
{
/** @var array<string, string> */
Expand Down
64 changes: 64 additions & 0 deletions src/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,72 @@

namespace SupportPal\ApiClient\Model;

use function array_map;
use function class_exists;
use function is_array;
use function str_starts_with;
use function substr;

/**
* @method mixed __get(string $key)
* @method void __set(string $key, mixed $value)
* @method bool __isset(string $key)
* @method void __unset(string $key)
*/
abstract class Model extends \Jenssegers\Model\Model
{
/** @var string[] */
protected $guarded = [];

/**
* Cast an attribute to a native PHP type.
*/
protected function castAttribute(mixed $key, mixed $value): mixed
{
$castType = $this->casts[$key] ?? null;

if ($value === null || $castType === null) {
return $value;
}

if (is_array($value)) {
if (str_starts_with($castType, 'array:')) {
$className = substr($castType, 6);

if (class_exists($className)) {
return $this->castToArrayOfObjects($className, $value);
}
}

if (class_exists($castType)) {
return $this->castToObject($castType, $value);
}
}

return parent::castAttribute($key, $value);
}

/**
* @template T of object
* @param class-string<T> $className
* @param array<mixed> $value
* @return T
*/
private function castToObject(string $className, array $value): mixed
{
return new $className($value);
}

/**
* @template T of object
* @param class-string<T> $className
* @param array<mixed> $value
* @return array<int, T|mixed>
*/
private function castToArrayOfObjects(string $className, array $value): array
{
return array_map(function ($item) use ($className) {
return is_array($item) ? new $className($item) : $item;
}, $value);
}
}
24 changes: 24 additions & 0 deletions src/Model/SelfService/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property int|null $author_id
* @property string $title
* @property string $slug
* @property string|null $excerpt
* @property string $plain_text
* @property string $text
* @property string $purified_text
* @property int $published
* @property int|null $published_at
* @property int $protected
* @property int $pinned
* @property int $created_at
* @property int $updated_at
* @property int $views
* @property int $positive_rating
* @property int $total_rating
* @property ArticleTranslation[] $translations
* @property Category[] $categories
* @property Type[] $types
* @property Attachment[] $attachments
* @property Tag[] $tags
*/
class Article extends Model
{
/** @var array<string, string> */
Expand Down
9 changes: 9 additions & 0 deletions src/Model/SelfService/ArticleTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

use SupportPal\ApiClient\Model\Translation;

/**
* @property int $article_id
* @property string $title
* @property string $slug
* @property string|null $excerpt
* @property string $plain_text
* @property string $text
* @property string $purified_text
*/
class ArticleTranslation extends Translation
{
/** @var array<string, string> */
Expand Down
9 changes: 9 additions & 0 deletions src/Model/SelfService/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
use SupportPal\ApiClient\Model\Core\Upload;
use SupportPal\ApiClient\Model\Model;

/**
* @property string $upload_hash
* @property int $article_id
* @property string|null $locale
* @property string $original_name
* @property int $created_at
* @property int $updated_at
* @property Upload $upload
*/
class Attachment extends Model
{
/** @var array<string, string> */
Expand Down
15 changes: 15 additions & 0 deletions src/Model/SelfService/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@

use SupportPal\ApiClient\Model\Model;

/**
* @property int $id
* @property int $type_id
* @property int|null $parent_id
* @property string $name
* @property string $slug
* @property int $public
* @property int $parent_public
* @property int $created_at
* @property int $updated_at
* @property string $frontend_url
* @property Type $type
* @property CategoryTranslation[] $translations
* @property int $pinned
*/
class Category extends Model
{
/** @var array<string, string> */
Expand Down
5 changes: 5 additions & 0 deletions src/Model/SelfService/CategoryTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use SupportPal\ApiClient\Model\Translation;

/**
* @property int $category_id
* @property string $name
* @property string $slug
*/
class CategoryTranslation extends Translation
{
/** @var array<string,string> */
Expand Down
18 changes: 18 additions & 0 deletions src/Model/SelfService/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
use SupportPal\ApiClient\Model\Model;
use SupportPal\ApiClient\Model\User\User;

/**
* @property int $id
* @property int $article_id
* @property int $type_id
* @property int $author_id
* @property string $name
* @property string $text
* @property string $purified_text
* @property int|null $parent_id
* @property int|null $root_parent_id
* @property int $rating
* @property int $status
* @property int $notify_reply
* @property int $created_at
* @property int $updated_at
* @property int|null $deleted_at
* @property User $author
*/
class Comment extends Model
{
/** @var array<string, string> */
Expand Down
Loading