From e4c893c1f2ae5a09c453058ecb6799b8abc1e283 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Mon, 12 Apr 2021 20:42:44 +0100 Subject: [PATCH] updated API docs --- .../copilot/templates/copilot/_api_docs.html | 78 ++--- .../copilot/templates/copilot/display.html | 298 +----------------- .../copilot/templates/copilot/index.html | 141 +-------- 3 files changed, 32 insertions(+), 485 deletions(-) diff --git a/lnbits/extensions/copilot/templates/copilot/_api_docs.html b/lnbits/extensions/copilot/templates/copilot/_api_docs.html index 859eefe4..85527ce8 100644 --- a/lnbits/extensions/copilot/templates/copilot/_api_docs.html +++ b/lnbits/extensions/copilot/templates/copilot/_api_docs.html @@ -13,11 +13,11 @@ label="API info" :content-inset-level="0.5" > - + POST /satspay/api/v1/chargePOST /copilot/api/v1/copilot
Headers
{"X-Api-Key": <admin_key>}
@@ -27,25 +27,24 @@
Returns 200 OK (application/json)
- [<charge_object>, ...] + [<copilot_object>, ...]
Curl example
curl -X POST {{ request.url_root }}api/v1/charge -d - '{"onchainwallet": <string, watchonly_wallet_id>, - "description": <string>, "webhook":<string>, "time": - <integer>, "amount": <integer>, "lnbitswallet": - <string, lnbits_wallet_id>}' -H "Content-type: - application/json" -H "X-Api-Key: {{g.user.wallets[0].adminkey }}" + >curl -X POST {{ request.url_root }}api/v1/copilot -d '{"title": + <string>, "animation": <string>, + "show_message":<string>, "amount": <integer>, + "lnurl_title": <string>}' -H "Content-type: application/json" + -H "X-Api-Key: {{g.user.wallets[0].adminkey }}"
- + PUT - /satspay/api/v1/charge/<charge_id>
Headers
{"X-Api-Key": <admin_key>}
@@ -55,26 +54,26 @@
Returns 200 OK (application/json)
- [<charge_object>, ...] + [<copilot_object>, ...]
Curl example
curl -X POST {{ request.url_root }}api/v1/charge/<charge_id> - -d '{"onchainwallet": <string, watchonly_wallet_id>, - "description": <string>, "webhook":<string>, "time": - <integer>, "amount": <integer>, "lnbitswallet": - <string, lnbits_wallet_id>}' -H "Content-type: - application/json" -H "X-Api-Key: {{g.user.wallets[0].adminkey }}" + >curl -X POST {{ request.url_root + }}api/v1/copilot/<copilot_id> -d '{"title": <string>, + "animation": <string>, "show_message":<string>, + "amount": <integer>, "lnurl_title": <string>}' -H + "Content-type: application/json" -H "X-Api-Key: + {{g.user.wallets[0].adminkey }}"
- + GET - /satspay/api/v1/charge/<charge_id>
Headers
{"X-Api-Key": <invoice_key>}
@@ -84,20 +83,20 @@
Returns 200 OK (application/json)
- [<charge_object>, ...] + [<copilot_object>, ...]
Curl example
curl -X GET {{ request.url_root }}api/v1/charge/<charge_id> + >curl -X GET {{ request.url_root }}api/v1/copilot/<copilot_id> -H "X-Api-Key: {{ g.user.wallets[0].inkey }}"
- + GET /satspay/api/v1/chargesGET /copilot/api/v1/copilots
Headers
{"X-Api-Key": <invoice_key>}
@@ -107,10 +106,10 @@
Returns 200 OK (application/json)
- [<charge_object>, ...] + [<copilot_object>, ...]
Curl example
curl -X GET {{ request.url_root }}api/v1/charges -H "X-Api-Key: {{ + >curl -X GET {{ request.url_root }}api/v1/copilots -H "X-Api-Key: {{ g.user.wallets[0].inkey }}"
@@ -127,7 +126,7 @@ DELETE - /satspay/api/v1/charge/<charge_id>
Headers
{"X-Api-Key": <admin_key>}
@@ -136,34 +135,11 @@
Curl example
curl -X DELETE {{ request.url_root - }}api/v1/charge/<charge_id> -H "X-Api-Key: {{ + }}api/v1/copilot/<copilot_id> -H "X-Api-Key: {{ g.user.wallets[0].adminkey }}"
- - - - GET - /satspay/api/v1/charges/balance/<charge_id> -
- Body (application/json) -
-
- Returns 200 OK (application/json) -
- [<charge_object>, ...] -
Curl example
- curl -X GET {{ request.url_root - }}api/v1/charges/balance/<charge_id> -H "X-Api-Key: {{ - g.user.wallets[0].inkey }}" - -
-
-
diff --git a/lnbits/extensions/copilot/templates/copilot/display.html b/lnbits/extensions/copilot/templates/copilot/display.html index acee075f..da34a644 100644 --- a/lnbits/extensions/copilot/templates/copilot/display.html +++ b/lnbits/extensions/copilot/templates/copilot/display.html @@ -1,223 +1,5 @@ -{% extends "public.html" %} {% block page %} -
- -
-
-
{{ charge.description }}
-
-
-
-
Time elapsed
-
-
-
Charge paid
-
-
- - - - Awaiting payment... - - {% raw %} {{ newTimeLeft }} {% endraw %} - - - -
-
-
-
- Charge ID: {{ charge.id }} -
- {% raw %} Total to pay: {{ charge_amount }}sats
- Amount paid: {{ charge_balance }}

- Amount due: {{ charge_amount - charge_balance }}sats {% endraw %} -
-
- -
-
-
- - - bitcoin onchain payment method not available - - - - pay with lightning - -
-
- - - bitcoin lightning payment method not available - - - - pay onchain - -
-
- -
-
- - -
-
- -
-
- - -
-
-
- Pay this
- lightning-network invoice
-
- - - - - -
- Copy invoice -
-
-
-
-
- - -
-
- -
-
- - -
-
-
- Send {{ charge.amount }}sats
- to this onchain address
-
- - - - - -
- Copy address -
-
-
-
-
-
-
- -{% endblock %} {% block scripts %} +{% extends "public.html" %} {% block page %} {% endblock %} {% block scripts %} - {% endblock %} diff --git a/lnbits/extensions/copilot/templates/copilot/index.html b/lnbits/extensions/copilot/templates/copilot/index.html index 2dbeb9bd..a9be0591 100644 --- a/lnbits/extensions/copilot/templates/copilot/index.html +++ b/lnbits/extensions/copilot/templates/copilot/index.html @@ -377,145 +377,8 @@ } } }, - methods: { - cancelCopilot: function (data) { - var self = this - self.formDialogCopilot.data.description = '' - self.formDialogCopilot.data.onchainwallet = '' - self.formDialogCopilot.data.lnbitswallet = '' - self.formDialogCopilot.data.time = null - self.formDialogCopilot.data.amount = null - self.formDialogCopilot.data.webhook = '' - self.formDialogCopilot.data.completelink = '' - self.formDialogCopilot.show = false - }, - - getWalletLinks: function () { - var self = this - - LNbits.api - .request( - 'GET', - '/watchonly/api/v1/wallet', - this.g.user.wallets[0].inkey - ) - .then(function (response) { - for (i = 0; i < response.data.length; i++) { - self.walletLinks.push(response.data[i].id) - } - return - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - }, - closeFormDialog: function () { - this.formDialog.data = { - is_unique: false - } - }, - openQrCodeDialog: function (linkId) { - var self = this - var getAddresses = this.getAddresses - getAddresses(linkId) - self.current = linkId - self.Addresses.show = true - }, - getCopilots: function () { - var self = this - var getAddressBalance = this.getAddressBalance - - LNbits.api - .request( - 'GET', - '/copilot/api/v1/copilots', - this.g.user.wallets[0].inkey - ) - .then(function (response) { - self.CopilotLinks = response.data.map(mapCopilot) - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - }, - sendFormDataCopilot: function () { - var self = this - var wallet = this.g.user.wallets[0].adminkey - var data = this.formDialogCopilot.data - data.amount = parseInt(data.amount) - data.time = parseInt(data.time) - this.createCopilot(wallet, data) - }, - timerCount: function () { - self = this - var refreshIntervalId = setInterval(function () { - for (i = 0; i < self.CopilotLinks.length - 1; i++) { - if (self.CopilotLinks[i]['paid'] == 'True') { - setTimeout(function () { - LNbits.api - .request( - 'GET', - '/copilot/api/v1/copilots/balance/' + - self.CopilotLinks[i]['id'], - 'filla' - ) - .then(function (response) {}) - }, 2000) - } - } - self.getCopilots() - }, 20000) - }, - createCopilot: function (wallet, data) { - var self = this - - LNbits.api - .request('POST', '/copilot/api/v1/copilot', wallet, data) - .then(function (response) { - self.CopilotLinks.push(mapCopilot(response.data)) - self.formDialogCopilot.show = false - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - }, - - deleteCopilotLink: function (copilotId) { - var self = this - var link = _.findWhere(this.CopilotLinks, {id: copilotId}) - LNbits.utils - .confirmDialog('Are you sure you want to delete this pay link?') - .onOk(function () { - LNbits.api - .request( - 'DELETE', - '/copilot/api/v1/copilot/' + copilotId, - self.g.user.wallets[0].adminkey - ) - .then(function (response) { - self.CopilotLinks = _.reject(self.CopilotLinks, function (obj) { - return obj.id === copilotId - }) - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - }) - }, - exportcopilotCSV: function () { - var self = this - LNbits.utils.exportCSV(self.CopilotsTable.columns, this.CopilotLinks) - } - }, - created: function () { - var self = this - var getCopilots = this.getCopilots - getCopilots() - var getWalletLinks = this.getWalletLinks - getWalletLinks() - var timerCount = this.timerCount - timerCount() - } + methods: {}, + created: function () {} }) {% endblock %}