Commit 3fc0136c authored by SpinShare's avatar SpinShare

added reviews and spinplays in api call

parent 6354cac6
...@@ -233,6 +233,16 @@ class APIController extends AbstractController ...@@ -233,6 +233,16 @@ class APIController extends AbstractController
$data['paths']['ogg'] = $baseUrl."/uploads/audio/".$result->getFileReference()."_0.ogg"; $data['paths']['ogg'] = $baseUrl."/uploads/audio/".$result->getFileReference()."_0.ogg";
$data['paths']['cover'] = $baseUrl."/uploads/cover/".$result->getFileReference().".png"; $data['paths']['cover'] = $baseUrl."/uploads/cover/".$result->getFileReference().".png";
$data['paths']['zip'] = $this->generateUrl('api.songs.download', array('id' => $result->getId()), UrlGeneratorInterface::ABSOLUTE_URL); $data['paths']['zip'] = $this->generateUrl('api.songs.download', array('id' => $result->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$data['views'] = $result->getViews();
$data['downloads'] = $result->getDownloads();
foreach($result->getReviews() as $review) {
$data['reviews'][] = $review->getJSON();
}
foreach($result->getSpinPlays() as $spinPlay) {
$data['spinPlays'][] = $spinPlay->getJSON();
}
$response = new JsonResponse(['version' => $this->apiVersion, 'status' => 200, 'data' => $data]); $response = new JsonResponse(['version' => $this->apiVersion, 'status' => 200, 'data' => $data]);
$response->headers->set('Access-Control-Allow-Origin', '*'); $response->headers->set('Access-Control-Allow-Origin', '*');
......
...@@ -114,4 +114,16 @@ class SongReview ...@@ -114,4 +114,16 @@ class SongReview
return $this; return $this;
} }
public function getJSON() {
$response = array(
'id' => $this->id,
'user' => $this->user->getJSON(),
'recommended' => $this->recommended,
'comment' => $this->comment,
'reviewDate' => $this->reviewDate
);
return $response;
}
} }
...@@ -132,4 +132,16 @@ class SongSpinPlay ...@@ -132,4 +132,16 @@ class SongSpinPlay
return $imgUrl; return $imgUrl;
} }
} }
public function getJSON() {
$response = array(
'id' => $this->id,
'user' => $this->user->getJSON(),
'videoUrl' => $this->videoUrl,
'submitDate' => $this->submitDate,
'isActive' => $this->isActive
);
return $response;
}
} }
...@@ -148,4 +148,16 @@ ...@@ -148,4 +148,16 @@
return $this; return $this;
} }
public function getJSON() {
$response = array(
'id' => $this->id,
'username' => $this->username,
'coverReference' => $this->coverReference,
'isVerified' => $this->isVerified,
'isPatreon' => $this->isPatreon
);
return $response;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment