Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
Backend Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SpinShare
Backend Server
Commits
636e8f4b
Commit
636e8f4b
authored
Sep 09, 2020
by
SpinShare
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api updates
parent
d9f70425
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
280 additions
and
82 deletions
+280
-82
docs/index.htm
docs/index.htm
+10
-3
docs/open-users.htm
docs/open-users.htm
+179
-62
src/Controller/API/APIUserController.php
src/Controller/API/APIUserController.php
+91
-17
No files found.
docs/index.htm
View file @
636e8f4b
...
...
@@ -134,12 +134,19 @@
<div
class=
"alert alert-primary"
role=
"alert"
>
<h4
class=
"alert-heading"
>
Last Update
</h4>
This documentation was last updated on 0
8/12/2020 at 15:01
CEST
This documentation was last updated on 0
9/09/2020 at 16:58
CEST
</div>
<div
class=
"card"
>
<h2
class=
"card-title"
>
08/12/2020
</h2>
Initial release.
<h2
class=
"card-title"
>
09/09/2020
</h2>
<ul>
<li>
Removed Charts, Reviews and SpinPlays from the UserDetail endpoint
</li>
<li>
Renamed the UserDetail endpoint to UserOverview
</li>
<li>
Added an endpoint for UserCharts
</li>
<li>
Added an endpoint for UserReviews
</li>
<li>
Added an endpoint for UserSpinPlays
</li>
<li>
Added counts of charts, reviews and spinplays to the UserOverview endpoint
</li>
</ul>
</div>
</div>
</div>
...
...
docs/open-users.htm
View file @
636e8f4b
...
...
@@ -119,8 +119,8 @@
</h1>
<div
class=
"card"
id=
"detail"
>
<h2
class=
"card-title"
>
Detail
</h2>
<p>
Returns
more detailled
information about a user.
</p>
<h2
class=
"card-title"
>
Overview
</h2>
<p>
Returns
a general overview of
information about a user.
</p>
<table
class=
"table table-bordered"
>
<tr>
...
...
@@ -146,7 +146,57 @@
"isVerified":true,
"isPatreon":null,
"avatar":"https:\/\/spinsha.re\/uploads\/avatar\/5ef8cddb50106.png",
"songs":[
"songs":0,
"reviews":0,
"spinplays":0,
"cards":[
{
"id":1,
"icon":"http:\/\/localhost\/www\/spinshare\/server\/public\/uploads\/card\/card_b4bcc0b27340a10b012a1ba8a6fd04b0.png",
"title":"SSSO Spring 2020 Player",
"description":"This card was given out to every player of the Spring 2020 SpinShare Speen Open tournament."
},
...
]
}
}
</pre>
<br
/>
<strong>
Output Body (Not Found)
</strong>
<pre
class=
"code"
>
{
"version":1,
"status":404,
"data":[]
}
</pre>
</div>
<div
class=
"card"
id=
"charts"
>
<h2
class=
"card-title"
>
Charts
</h2>
<p>
Returns all public charts of a user.
</p>
<table
class=
"table table-bordered"
>
<tr>
<th>
Method
</th>
<td>
GET
</td>
</tr>
<tr>
<th>
Endpoint
</th>
<td>
/user/
<code
class=
"code"
>
userID
</code>
/charts
</td>
</tr>
</table>
<br
/><br
/>
<strong>
Output Body (Success)
</strong>
<pre
class=
"code"
>
{
"version":1,
"status":200,
"data":{[
{
"id":1018,
"title":"Keyboard Combos",
...
...
@@ -163,8 +213,45 @@
"zip":"https:\/\/spinsha.re\/api\/song\/1018\/download"
},
...
],
"reviews":[
]}
}
</pre>
<br
/>
<strong>
Output Body (Not Found)
</strong>
<pre
class=
"code"
>
{
"version":1,
"status":404,
"data":[]
}
</pre>
</div>
<div
class=
"card"
id=
"reviews"
>
<h2
class=
"card-title"
>
Reviews
</h2>
<p>
Returns all reviews of a user.
</p>
<table
class=
"table table-bordered"
>
<tr>
<th>
Method
</th>
<td>
GET
</td>
</tr>
<tr>
<th>
Endpoint
</th>
<td>
/user/
<code
class=
"code"
>
userID
</code>
/reviews
</td>
</tr>
</table>
<br
/><br
/>
<strong>
Output Body (Success)
</strong>
<pre
class=
"code"
>
{
"version":1,
"status":200,
"data":{[
{
"id":22,
"user":{
...
...
@@ -183,8 +270,45 @@
}
},
...
],
"spinplays":[
]}
}
</pre>
<br
/>
<strong>
Output Body (Not Found)
</strong>
<pre
class=
"code"
>
{
"version":1,
"status":404,
"data":[]
}
</pre>
</div>
<div
class=
"card"
id=
"spinplays"
>
<h2
class=
"card-title"
>
SpinPlays
</h2>
<p>
Returns all SpinPlays of a user.
</p>
<table
class=
"table table-bordered"
>
<tr>
<th>
Method
</th>
<td>
GET
</td>
</tr>
<tr>
<th>
Endpoint
</th>
<td>
/user/
<code
class=
"code"
>
userID
</code>
/spinplays
</td>
</tr>
</table>
<br
/><br
/>
<strong>
Output Body (Success)
</strong>
<pre
class=
"code"
>
{
"version":1,
"status":200,
"data":{[
{
"id":13,
"user":{
...
...
@@ -204,17 +328,7 @@
"isActive":true
},
...
],
"cards":[
{
"id":1,
"icon":"http:\/\/localhost\/www\/spinshare\/server\/public\/uploads\/card\/card_b4bcc0b27340a10b012a1ba8a6fd04b0.png",
"title":"SSSO Spring 2020 Player",
"description":"This card was given out to every player of the Spring 2020 SpinShare Speen Open tournament."
},
...
]
}
]}
}
</pre>
...
...
@@ -235,7 +349,10 @@
<div
class=
"content"
>
<div
class=
"on-this-page-nav"
>
<div
class=
"title"
>
On this page
</div>
<a
href=
"#detail"
>
Detail
</a>
<a
href=
"#overview"
>
Overview
</a>
<a
href=
"#charts"
>
Charts
</a>
<a
href=
"#reviews"
>
Reviews
</a>
<a
href=
"#spinplays"
>
SpinPlays
</a>
</div>
</div>
</div>
...
...
src/Controller/API/APIUserController.php
View file @
636e8f4b
...
...
@@ -52,11 +52,48 @@ class APIUserController extends AbstractController
$resultsSpinPlays
=
$em
->
getRepository
(
SongSpinPlay
::
class
)
->
findBy
(
array
(
'user'
=>
$result
->
getId
(),
'isActive'
=>
true
),
array
(
'submitDate'
=>
'DESC'
));
$resultsCards
=
$em
->
getRepository
(
UserCard
::
class
)
->
findBy
(
array
(
'user'
=>
$result
->
getId
()),
array
(
'givenDate'
=>
'DESC'
));
$data
[
'songs'
]
=
[]
;
$data
[
'reviews'
]
=
[]
;
$data
[
'spinplays'
]
=
[]
;
$data
[
'songs'
]
=
count
(
$resultsSongs
)
;
$data
[
'reviews'
]
=
count
(
$resultsReviews
)
;
$data
[
'spinplays'
]
=
count
(
$resultsSpinPlays
)
;
$data
[
'cards'
]
=
[];
foreach
(
$resultsCards
as
$result
)
{
$oneResult
=
[];
$oneResult
[
'id'
]
=
$result
->
getId
();
$oneResult
[
'icon'
]
=
$baseUrl
.
"/uploads/card/"
.
$result
->
getCard
()
->
getIcon
();
$oneResult
[
'title'
]
=
$result
->
getCard
()
->
getTitle
();
$oneResult
[
'givenDate'
]
=
$result
->
getGivenDate
();
$oneResult
[
'description'
]
=
$result
->
getCard
()
->
getDescription
();
$data
[
'cards'
][]
=
$oneResult
;
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
$response
->
headers
->
set
(
'Access-Control-Allow-Origin'
,
'*'
);
return
$response
;
}
}
/**
* @Route("/api/user/{userId}/charts", name="api.users.detail.charts")
*/
public
function
userDetailCharts
(
Request
$request
,
int
$userId
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$result
=
$em
->
getRepository
(
User
::
class
)
->
findOneBy
(
array
(
'id'
=>
$userId
));
$baseUrl
=
$request
->
getScheme
()
.
'://'
.
$request
->
getHttpHost
()
.
$request
->
getBasePath
();
if
(
!
$result
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
404
,
'data'
=>
[]]);
$response
->
headers
->
set
(
'Access-Control-Allow-Origin'
,
'*'
);
return
$response
;
}
else
{
// Get User Lists
$resultsSongs
=
$em
->
getRepository
(
Song
::
class
)
->
findBy
(
array
(
'uploader'
=>
$result
->
getId
()),
array
(
'uploadDate'
=>
'DESC'
));
foreach
(
$resultsSongs
as
$result
)
{
$oneResult
=
[];
...
...
@@ -74,26 +111,63 @@ class APIUserController extends AbstractController
$oneResult
[
'cover'
]
=
$baseUrl
.
"/uploads/thumbnail/"
.
$result
->
getFileReference
()
.
".jpg"
;
$oneResult
[
'zip'
]
=
$this
->
generateUrl
(
'api.songs.download'
,
array
(
'id'
=>
$result
->
getId
()),
UrlGeneratorInterface
::
ABSOLUTE_URL
);
$data
[
'songs'
][]
=
$oneResult
;
$data
[]
=
$oneResult
;
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
$response
->
headers
->
set
(
'Access-Control-Allow-Origin'
,
'*'
);
return
$response
;
}
}
/**
* @Route("/api/user/{userId}/reviews", name="api.users.detail.reviews")
*/
public
function
userDetailReviews
(
Request
$request
,
int
$userId
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$result
=
$em
->
getRepository
(
User
::
class
)
->
findOneBy
(
array
(
'id'
=>
$userId
));
$baseUrl
=
$request
->
getScheme
()
.
'://'
.
$request
->
getHttpHost
()
.
$request
->
getBasePath
();
if
(
!
$result
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
404
,
'data'
=>
[]]);
$response
->
headers
->
set
(
'Access-Control-Allow-Origin'
,
'*'
);
return
$response
;
}
else
{
$resultsReviews
=
$em
->
getRepository
(
SongReview
::
class
)
->
findBy
(
array
(
'user'
=>
$result
->
getId
()),
array
(
'reviewDate'
=>
'DESC'
));
foreach
(
$resultsReviews
as
$result
)
{
$data
[
'reviews'
][
]
=
$result
->
getJSON
();
$data
[]
=
$result
->
getJSON
();
}
foreach
(
$resultsSpinPlays
as
$result
)
{
$data
[
'spinplays'
][]
=
$result
->
getJSON
();
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
$response
->
headers
->
set
(
'Access-Control-Allow-Origin'
,
'*'
);
return
$response
;
}
}
foreach
(
$resultsCards
as
$result
)
{
$oneResult
=
[];
/**
* @Route("/api/user/{userId}/spinplays", name="api.users.detail.spinplays")
*/
public
function
userDetailSpinPlays
(
Request
$request
,
int
$userId
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$oneResult
[
'id'
]
=
$result
->
getId
();
$oneResult
[
'icon'
]
=
$baseUrl
.
"/uploads/card/"
.
$result
->
getCard
()
->
getIcon
();
$oneResult
[
'title'
]
=
$result
->
getCard
()
->
getTitle
();
$oneResult
[
'description'
]
=
$result
->
getCard
()
->
getDescription
();
$result
=
$em
->
getRepository
(
User
::
class
)
->
findOneBy
(
array
(
'id'
=>
$userId
));
$baseUrl
=
$request
->
getScheme
()
.
'://'
.
$request
->
getHttpHost
()
.
$request
->
getBasePath
();
$data
[
'cards'
][]
=
$oneResult
;
if
(
!
$result
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
404
,
'data'
=>
[]]);
$response
->
headers
->
set
(
'Access-Control-Allow-Origin'
,
'*'
);
return
$response
;
}
else
{
$resultsSpinPlays
=
$em
->
getRepository
(
SongSpinPlay
::
class
)
->
findBy
(
array
(
'user'
=>
$result
->
getId
(),
'isActive'
=>
true
),
array
(
'submitDate'
=>
'DESC'
));
foreach
(
$resultsSpinPlays
as
$result
)
{
$data
[]
=
$result
->
getJSON
();
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment