1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Add/update API transformers

This commit is contained in:
Daniel Supernault 2018-12-30 21:26:37 -07:00
parent 982aecb4cc
commit 547ac5c8f9
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
9 changed files with 148 additions and 60 deletions

View file

@ -7,27 +7,27 @@ use League\Fractal;
class AccountTransformer extends Fractal\TransformerAbstract class AccountTransformer extends Fractal\TransformerAbstract
{ {
public function transform(Profile $profile) public function transform(Profile $profile)
{ {
return [ return [
'id' => $profile->id, 'id' => $profile->id,
'username' => $profile->username, 'username' => $profile->username,
'acct' => $profile->username, 'acct' => $profile->username,
'display_name' => $profile->name, 'display_name' => $profile->name,
'locked' => (bool) $profile->is_private, 'locked' => (bool) $profile->is_private,
'created_at' => $profile->created_at->format('c'), 'created_at' => $profile->created_at->format('c'),
'followers_count' => $profile->followerCount(), 'followers_count' => $profile->followerCount(),
'following_count' => $profile->followingCount(), 'following_count' => $profile->followingCount(),
'statuses_count' => $profile->statusCount(), 'statuses_count' => $profile->statusCount(),
'note' => $profile->bio, 'note' => $profile->bio,
'url' => $profile->url(), 'url' => $profile->url(),
'avatar' => $profile->avatarUrl(), 'avatar' => $profile->avatarUrl(),
'avatar_static' => $profile->avatarUrl(), 'avatar_static' => $profile->avatarUrl(),
'header' => null, 'header' => null,
'header_static' => null, 'header_static' => null,
'moved' => null, 'moved' => null,
'fields' => null, 'fields' => null,
'bot' => null, 'bot' => null,
]; ];
} }
} }

View file

@ -6,11 +6,11 @@ use League\Fractal;
class ApplicationTransformer extends Fractal\TransformerAbstract class ApplicationTransformer extends Fractal\TransformerAbstract
{ {
public function transform() public function transform()
{ {
return [ return [
'name' => '', 'name' => '',
'website' => null, 'website' => null,
]; ];
} }
} }

View file

@ -0,0 +1,28 @@
<?php
namespace App\Transformer\Api;
use League\Fractal;
class AttachmentTransformer extends Fractal\TransformerAbstract
{
public function transform(Media $media)
{
return [
'id' => $media->id,
'type' => $media->activityVerb(),
'url' => $media->url(),
'remote_url' => null,
'preview_url' => $media->thumbnailUrl(),
'text_url' => null,
'meta' => null,
'description' => $media->caption,
'license' => $media->license,
'is_nsfw' => $media->is_nsfw,
'orientation' => $media->orientation,
'filter_name' => $media->filter_name,
'filter_class' => $media->filter_class,
'mime' => $media->mime,
];
}
}

View file

@ -0,0 +1,16 @@
<?php
namespace App\Transformer\Api;
use League\Fractal;
class ContextTransformer extends Fractal\TransformerAbstract
{
public function transform()
{
return [
'ancestors' => [],
'descendants' => []
];
}
}

View file

@ -6,13 +6,13 @@ use League\Fractal;
class EmojiTransformer extends Fractal\TransformerAbstract class EmojiTransformer extends Fractal\TransformerAbstract
{ {
public function transform($emoji) public function transform($emoji)
{ {
return [ return [
'shortcode' => '', 'shortcode' => '',
'static_url' => '', 'static_url' => '',
'url' => '', 'url' => '',
'visible_in_picker' => false 'visible_in_picker' => false
]; ];
} }
} }

View file

@ -0,0 +1,20 @@
<?php
namespace App\Transformer\Api;
use League\Fractal;
class FilterTransformer extends Fractal\TransformerAbstract
{
public function transform()
{
return [
'id' => (string) '',
'phrase' => (string) '',
'context' => [],
'expires_at' => null,
'irreversible' => (bool) false,
'whole_word' => (bool) false
];
}
}

View file

@ -7,11 +7,11 @@ use League\Fractal;
class HashtagTransformer extends Fractal\TransformerAbstract class HashtagTransformer extends Fractal\TransformerAbstract
{ {
public function transform(Hashtag $hashtag) public function transform(Hashtag $hashtag)
{ {
return [ return [
'name' => $hashtag->name, 'name' => $hashtag->name,
'url' => $hashtag->url(), 'url' => $hashtag->url(),
]; ];
} }
} }

View file

@ -10,20 +10,20 @@ class MediaTransformer extends Fractal\TransformerAbstract
public function transform(Media $media) public function transform(Media $media)
{ {
return [ return [
'id' => $media->id, 'id' => $media->id,
'type' => $media->activityVerb(), 'type' => $media->activityVerb(),
'url' => $media->url(), 'url' => $media->url(),
'remote_url' => null, 'remote_url' => null,
'preview_url' => $media->thumbnailUrl(), 'preview_url' => $media->thumbnailUrl(),
'text_url' => null, 'text_url' => null,
'meta' => null, 'meta' => null,
'description' => $media->caption, 'description' => $media->caption,
'license' => $media->license, 'license' => $media->license,
'is_nsfw' => $media->is_nsfw, 'is_nsfw' => $media->is_nsfw,
'orientation' => $media->orientation, 'orientation' => $media->orientation,
'filter_name' => $media->filter_name, 'filter_name' => $media->filter_name,
'filter_class' => $media->filter_class, 'filter_class' => $media->filter_class,
'mime' => $media->mime, 'mime' => $media->mime,
]; ];
} }
} }

View file

@ -0,0 +1,24 @@
<?php
namespace App\Transformer\Api;
use League\Fractal;
class ResultsTransformer extends Fractal\TransformerAbstract
{
protected $defaultIncludes = [
'account',
'mentions',
'media_attachments',
'tags',
];
public function transform()
{
return [
'accounts' => [],
'statuses' => [],
'hashtags' => []
];
}
}