Jelajahi Sumber

Add/update API transformers

Daniel Supernault 6 tahun lalu
induk
melakukan
547ac5c8f9

+ 23 - 23
app/Transformer/Api/AccountTransformer.php

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

+ 7 - 7
app/Transformer/Api/ApplicationTransformer.php

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

+ 28 - 0
app/Transformer/Api/AttachmentTransformer.php

@@ -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,
+		];
+	}
+}

+ 16 - 0
app/Transformer/Api/ContextTransformer.php

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

+ 9 - 9
app/Transformer/Api/EmojiTransformer.php

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

+ 20 - 0
app/Transformer/Api/FilterTransformer.php

@@ -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
+		];
+	}
+}

+ 7 - 7
app/Transformer/Api/HashtagTransformer.php

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

+ 14 - 14
app/Transformer/Api/MediaTransformer.php

@@ -10,20 +10,20 @@ class MediaTransformer 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,
+            '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,
         ];
     }
 }

+ 24 - 0
app/Transformer/Api/ResultsTransformer.php

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