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

@ -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

@ -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

@ -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' => []
];
}
}