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
29 changes: 29 additions & 0 deletions src/Model/BlueskyLanguages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** The default post languages for a connection; up to three BCP-47 tags. */
final class BlueskyLanguages extends Model
{
/**
* @param array<int|string, mixed> $languages
*/
private function __construct(
array $raw,
public readonly array $languages,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::seq($data, 'languages'),
);
}
}
42 changes: 42 additions & 0 deletions src/Model/InstagramAudio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** A track a Reel can carry; $id travels as the audio_id platform setting. */
final class InstagramAudio extends Model
{
private function __construct(
array $raw,
public readonly string $id,
public readonly ?string $title,
public readonly ?string $artist,
public readonly ?int $durationMs,
public readonly ?string $audioType,
public readonly ?string $coverArtworkUrl,
public readonly ?string $previewUrl,
public readonly ?string $username,
public readonly ?bool $isAdsEligible,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::requiredStr($data, 'id'),
self::str($data, 'title'),
self::str($data, 'artist'),
self::int($data, 'duration_ms'),
self::str($data, 'audio_type'),
self::str($data, 'cover_artwork_url'),
self::str($data, 'preview_url'),
self::str($data, 'username'),
self::bool($data, 'is_ads_eligible'),
);
}
}
32 changes: 32 additions & 0 deletions src/Model/InstagramPublishingLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** What this account has published in the rolling window, and what is left. */
final class InstagramPublishingLimit extends Model
{
private function __construct(
array $raw,
public readonly int $quotaUsage,
public readonly ?int $quotaTotal,
public readonly ?int $quotaDurationSec,
public readonly ?int $remaining,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::int($data, 'quota_usage') ?? 0,
self::int($data, 'quota_total'),
self::int($data, 'quota_duration_sec'),
self::int($data, 'remaining'),
);
}
}
45 changes: 45 additions & 0 deletions src/Model/InstagramStory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** A story still inside its 24 hours; $insights is present only when asked for. */
final class InstagramStory extends Model
{
/**
* @param array<string, mixed>|null $insights
*/
private function __construct(
array $raw,
public readonly string $id,
public readonly ?string $mediaType,
public readonly ?string $mediaProductType,
public readonly ?string $permalink,
public readonly ?string $mediaUrl,
public readonly ?string $thumbnailUrl,
public readonly ?string $caption,
public readonly ?string $timestamp,
public readonly ?array $insights,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::requiredStr($data, 'id'),
self::str($data, 'media_type'),
self::str($data, 'media_product_type'),
self::str($data, 'permalink'),
self::str($data, 'media_url'),
self::str($data, 'thumbnail_url'),
self::str($data, 'caption'),
self::str($data, 'timestamp'),
self::nested($data, 'insights'),
);
}
}
31 changes: 31 additions & 0 deletions src/Model/InstagramStoryInsights.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** Insights for one story. */
final class InstagramStoryInsights extends Model
{
/**
* @param array<int|string, mixed> $insights
*/
private function __construct(
array $raw,
public readonly string $storyId,
public readonly array $insights,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::requiredStr($data, 'story_id'),
self::map($data, 'insights'),
);
}
}
36 changes: 36 additions & 0 deletions src/Model/LinkedInMention.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** An entity a post can mention; $annotation is what the post text carries. */
final class LinkedInMention extends Model
{
private function __construct(
array $raw,
public readonly string $urn,
public readonly string $name,
public readonly ?string $vanityName,
public readonly ?string $logoUrl,
public readonly ?string $type,
public readonly string $annotation,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::requiredStr($data, 'urn'),
self::requiredStr($data, 'name'),
self::str($data, 'vanity_name'),
self::str($data, 'logo_url'),
self::str($data, 'type'),
self::requiredStr($data, 'annotation'),
);
}
}
34 changes: 34 additions & 0 deletions src/Model/PinterestBoard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** A Pinterest board; $id travels as the board_id platform setting to pin to it. */
final class PinterestBoard extends Model
{
private function __construct(
array $raw,
public readonly string $id,
public readonly string $name,
public readonly ?string $privacy,
public readonly ?string $description,
public readonly ?string $image,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::requiredStr($data, 'id'),
self::requiredStr($data, 'name'),
self::str($data, 'privacy'),
self::str($data, 'description'),
self::str($data, 'image'),
);
}
}
43 changes: 43 additions & 0 deletions src/Model/TikTokCreatorInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** The switches TikTok enforces at publish time, set on the account itself. */
final class TikTokCreatorInfo extends Model
{
/**
* @param array<int|string, mixed> $privacyLevelOptions
*/
private function __construct(
array $raw,
public readonly ?string $username,
public readonly ?string $nickname,
public readonly ?string $avatarUrl,
public readonly array $privacyLevelOptions,
public readonly bool $commentDisabled,
public readonly bool $duetDisabled,
public readonly bool $stitchDisabled,
public readonly ?int $maxVideoPostDurationSec,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::str($data, 'username'),
self::str($data, 'nickname'),
self::str($data, 'avatar_url'),
self::seq($data, 'privacy_level_options'),
self::bool($data, 'comment_disabled') ?? false,
self::bool($data, 'duet_disabled') ?? false,
self::bool($data, 'stitch_disabled') ?? false,
self::int($data, 'max_video_post_duration_sec'),
);
}
}
36 changes: 36 additions & 0 deletions src/Model/TikTokMusic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** A track from TikTok's Commercial Music Library; `id` travels as the `music_id` platform setting. */
final class TikTokMusic extends Model
{
private function __construct(
array $raw,
public readonly string $id,
public readonly string $title,
public readonly ?string $author,
public readonly ?int $durationSec,
public readonly ?string $coverUrl,
public readonly ?string $previewUrl,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::str($data, 'id') ?? '',
self::str($data, 'title') ?? '',
self::str($data, 'author'),
self::int($data, 'duration_sec'),
self::str($data, 'cover_url'),
self::str($data, 'preview_url'),
);
}
}
34 changes: 34 additions & 0 deletions src/Model/TikTokPlace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Fopost\Sdk\Model;

/** A place a post can be tagged with; `id` travels as the `location_id` platform setting. */
final class TikTokPlace extends Model
{
private function __construct(
array $raw,
public readonly string $id,
public readonly string $name,
public readonly ?string $address,
public readonly ?string $city,
public readonly ?string $country,
) {
parent::__construct($raw);
}

public static function fromArray(mixed $data): static
{
$data = is_array($data) ? $data : [];

return new self(
$data,
self::str($data, 'id') ?? '',
self::str($data, 'name') ?? '',
self::str($data, 'address'),
self::str($data, 'city'),
self::str($data, 'country'),
);
}
}
Loading
Loading