From ed20c75fd028cd8d96903ea30b225a6045243a27 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sun, 13 Jun 2021 12:58:46 +0100 Subject: [PATCH] added api docs --- lnbits/extensions/jukebox/static/js/index.js | 2 +- .../jukebox/templates/jukebox/_api_docs.html | 165 +++++----- .../jukebox/templates/jukebox/index.html | 289 ++++-------------- .../jukebox/templates/jukebox/jukebox.html | 19 +- lnbits/extensions/jukebox/views_api.py | 30 +- 5 files changed, 167 insertions(+), 338 deletions(-) diff --git a/lnbits/extensions/jukebox/static/js/index.js b/lnbits/extensions/jukebox/static/js/index.js index 6f1f56866..932e16708 100644 --- a/lnbits/extensions/jukebox/static/js/index.js +++ b/lnbits/extensions/jukebox/static/js/index.js @@ -93,7 +93,7 @@ new Vue({ getJukeboxes() { self = this LNbits.api - .request('GET', '/jukebox/api/v1/jukebox', self.g.user.wallets[0].inkey) + .request('GET', '/jukebox/api/v1/jukebox', self.g.user.wallets[0].adminkey) .then(function (response) { self.JukeboxLinks = response.data.map(mapJukebox) }) diff --git a/lnbits/extensions/jukebox/templates/jukebox/_api_docs.html b/lnbits/extensions/jukebox/templates/jukebox/_api_docs.html index f705aeadd..66c2dfcfd 100644 --- a/lnbits/extensions/jukebox/templates/jukebox/_api_docs.html +++ b/lnbits/extensions/jukebox/templates/jukebox/_api_docs.html @@ -1,124 +1,101 @@ - - - - To use this extension you need a Spotify client ID and client secret. You - get these by creating an app in the Spotify developers dashboard - here -

Select the playlists you want people to be able to pay for, - share the frontend page, profit :)

- Made by, benarc. Inspired by, - pirosb3. -
-
-
+ + To use this extension you need a Spotify client ID and client secret. You + get these by creating an app in the Spotify developers dashboard + here +

Select the playlists you want people to be able to pay for, + share the frontend page, profit :)

+ Made by, benarc. Inspired by, + pirosb3. +
- - + + + + + + + - POST + GET + /jukebox/api/v1/jukebox
Headers
- {"X-Api-Key": <invoice_key>}
-
Body (application/json)
-
Returns 201 OK
-
Curl example
- curl -X GET {{ request.url_root }}/jukebox/api/v1/jukebox/items -H - "Content-Type: application/json" -H "X-Api-Key: {{ - g.user.wallets[0].inkey }}" -d '{"name": <string>, - "description": <string>, "image": <data-uri string>, - "price": <integer>, "unit": <"sat" or "USD">}' - -
-
-
- - - - GET -
Headers
- {"X-Api-Key": <invoice_key>}
+ {"X-Api-Key": <admin_key>}
Body (application/json)
Returns 200 OK (application/json)
- {"id": <integer>, "wallet": <string>, "wordlist": - <string>, "items": [{"id": <integer>, "name": - <string>, "description": <string>, "image": - <string>, "enabled": <boolean>, "price": <integer>, - "unit": <string>, "lnurl": <string>}, ...]}< + [<jukebox_object>, ...]
Curl example
- curl -X GET {{ request.url_root }}/jukebox/api/v1/jukebox -H - "X-Api-Key: {{ g.user.wallets[0].inkey }}" + curl -X GET {{ request.url_root }}api/v1/jukebox -H "X-Api-Key: {{ + g.user.wallets[0].adminkey }}"
- + - PUT + GET + /jukebox/api/v1/jukebox/<juke_id>
Headers
- {"X-Api-Key": <invoice_key>}
+ {"X-Api-Key": <admin_key>}
Body (application/json)
-
Returns 200 OK
+
+ Returns 200 OK (application/json) +
+ <jukebox_object>
Curl example
- curl -X GET {{ request.url_root - }}/jukebox/api/v1/jukebox/items/<item_id> -H "Content-Type: - application/json" -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -d - '{"name": <string>, "description": <string>, "image": - <data-uri string>, "price": <integer>, "unit": <"sat" - or "USD">}' + curl -X GET {{ request.url_root }}api/v1/jukebox/<juke_id> -H "X-Api-Key: {{ + g.user.wallets[0].adminkey }}"
- + - DELETE + POST/PUT + /jukebox/api/v1/jukebox/
Headers
- {"X-Api-Key": <invoice_key>}
-
Body (application/json)
-
Returns 200 OK
+ {"X-Api-Key": <admin_key>}
+
+ Body (application/json) +
+
+ Returns 200 OK (application/json) +
+ <jukbox_object>
Curl example
- curl -X GET {{ request.url_root - }}/jukebox/api/v1/jukebox/items/<item_id> -H "X-Api-Key: {{ - g.user.wallets[0].inkey }}" + curl -X POST {{ request.url_root }}api/v1/jukebox/ -d + '{"user": <string, user_id>, + "title": <string>, "wallet":<string>, "sp_user": + <string, spotify_user_account>, "sp_secret": <string, spotify_user_secret>, "sp_access_token": + <string, not_required>, "sp_refresh_token": + <string, not_required>, "sp_device": <string, spotify_user_secret>, "sp_playlists": + <string, not_required>, "price": + <integer, not_required>}' -H "Content-type: + application/json" -H "X-Api-Key: {{g.user.wallets[0].adminkey }}"
-
+ + + + DELETE + /jukebox/api/v1/jukebox/<juke_id> +
Headers
+ {"X-Api-Key": <admin_key>}
+
Body (application/json)
+
+ Returns 200 OK (application/json) +
+ <jukebox_object> +
Curl example
+ curl -X DELETE {{ request.url_root }}api/v1/jukebox/<juke_id> -H "X-Api-Key: {{ + g.user.wallets[0].adminkey }}" + +
+
+
\ No newline at end of file diff --git a/lnbits/extensions/jukebox/templates/jukebox/index.html b/lnbits/extensions/jukebox/templates/jukebox/index.html index ca14ad96c..25cc49e52 100644 --- a/lnbits/extensions/jukebox/templates/jukebox/index.html +++ b/lnbits/extensions/jukebox/templates/jukebox/index.html @@ -4,36 +4,18 @@
- Add Spotify Jukebox + Add Spotify Jukebox {% raw %} - +