├── .gitignore
├── lib
├── configs.js
├── utils
│ ├── index.js
│ ├── sales.js
│ └── balance.js
├── Resources
│ ├── Balance.js
│ ├── Sale.js
│ └── Checkout.js
├── index.js
├── api
│ ├── default.js
│ └── index.js
└── Client.js
├── index.js
├── package.json
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .npmrc
3 |
--------------------------------------------------------------------------------
/lib/configs.js:
--------------------------------------------------------------------------------
1 | export default {
2 |
3 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var resources = {
2 | Sale: require('./lib/Resources/Sale'),
3 | Checkout: require('./lib/Resources/Checkout')
4 | };
5 |
6 | module.exports = {
7 | Client: require('./lib/Client'),
8 | resources: resources,
9 | };
10 |
--------------------------------------------------------------------------------
/lib/utils/index.js:
--------------------------------------------------------------------------------
1 | const { cleanData, filterPaidInvoices } = require('./sales')
2 | const { getAllBalancesMultiWallet } = require('./balance')
3 |
4 | module.exports = {
5 | cleanData,
6 | filterPaidInvoices,
7 | getAllBalancesMultiWallet
8 | }
--------------------------------------------------------------------------------
/lib/Resources/Balance.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const api = require('../api'),
4 | utils = require('../utils')
5 |
6 | class Balance {
7 | /**
8 | * This callback type is called `requestCallback` and is displayed as a global symbol.
9 | *
10 | * @callback requestCallback
11 | * @param {Error} error
12 | * @param {object} response
13 | */
14 |
15 | async all(params, callback) {
16 | try {
17 | if (params.multiwallet) {
18 | utils.getAllBalancesMultiWallet(( wallets ) => {
19 | callback(null, wallets)
20 | })
21 | } else {
22 | utils.getAllBalancesMultiWallet((wallets) => {
23 | callback(null, wallets)
24 | })
25 | }
26 | } catch (error) {
27 | callback(error)
28 | }
29 | }
30 | }
31 |
32 | module.exports = new Balance()
--------------------------------------------------------------------------------
/lib/utils/sales.js:
--------------------------------------------------------------------------------
1 |
2 | function cleanData(arrayOfObjects) {
3 | for (const index in arrayOfObjects) {
4 | for (const key in arrayOfObjects[index]) {
5 | if (!arrayOfObjects[index][key] && arrayOfObjects[index][key] !== 0) {
6 | delete arrayOfObjects[index][key]
7 | } else if (key.includes('Date')) {
8 | arrayOfObjects[index][key] = new Date(
9 | arrayOfObjects[index][key]
10 | ).toLocaleDateString()
11 | }
12 | }
13 | }
14 |
15 | return arrayOfObjects
16 | }
17 |
18 | function filterPaidInvoices(invoices) {
19 | return invoices.filter(
20 | el =>
21 | el.InvoiceStatus === 'paid' ||
22 | el.InvoiceStatus === 'confirmed' ||
23 | el.InvoiceStatus === 'complete'
24 | )
25 | }
26 |
27 | module.exports = {
28 | cleanData,
29 | filterPaidInvoices
30 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "forgingblock.js",
3 | "version": "0.1.5",
4 | "description": "The Official ForgingBlock Library for Node.js",
5 | "keywords": [
6 | "API",
7 | "bitcoin",
8 | "forgingblock",
9 | "cryptocurrencies",
10 | "payments"
11 | ],
12 | "engines": {
13 | "node": ">=8.17.0",
14 | "npm": ">=5.6.0"
15 | },
16 | "homepage": "https://github.com/forgingblock/ForgingBlock-NodeJS",
17 | "repository": {
18 | "type": "git",
19 | "url": "git://github.com/forgingblock/ForgingBlock-NodeJS.git"
20 | },
21 | "main": "index.js",
22 | "scripts": {
23 | "lint": "eslint lib/** test/** index.js"
24 | },
25 | "author": "ForgingBlock",
26 | "license": "MIT",
27 | "dependencies": {
28 | "lodash": "4.17.19",
29 | "node-fetch": "^2.6.13",
30 | "object-assign": "2.0.0",
31 | "promise": "^8.0.1",
32 | "qs": "^6.14.0",
33 | "request": "^2.88.2",
34 | "secure-compare": "^3.0.1"
35 | },
36 | "devDependencies": {
37 | "chai": "3.5.0",
38 | "eslint": "4.18.2",
39 | "mocha": "^7.1.1",
40 | "nock": "^12.0.3",
41 | "nyc": "^15.0.1"
42 | },
43 | "directories": {
44 | "lib": "./lib"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/Resources/Sale.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const api = require('../api'),
4 | utils = require('../utils')
5 |
6 | class Sale {
7 | /**
8 | * This callback type is called `requestCallback` and is displayed as a global symbol.
9 | *
10 | * @callback requestCallback
11 | * @param {Error} error
12 | * @param {object} response
13 | */
14 |
15 | /**
16 | * @param {string} invoiceId - ID of the product/donation
17 | * @param {requestCallback} callback - The callback that handles the response.
18 | */
19 | async retrieve(invoiceId, callback) {
20 | try {
21 | let response = await api.checkInvoice({
22 | invoice: invoiceId
23 | })
24 |
25 | callback(null, response)
26 | } catch (error) {
27 | callback(error, null)
28 | }
29 | }
30 |
31 | async all(params, callback) {
32 | // var params = {
33 | // 'status': 'all'
34 | // };
35 | params = params || { status : 'all'}
36 | try {
37 | const payments = await api.getStoreInvoicesSimple({ full: true })
38 | const cleanedPayments = utils.cleanData(payments)
39 | const paidPayments = utils.filterPaidInvoices(cleanedPayments)
40 |
41 | callback(null, params.status === 'paid' ? paidPayments : cleanedPayments)
42 | } catch (error) {
43 | callback(error)
44 | }
45 | }
46 | }
47 |
48 | module.exports = new Sale()
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * ForgingBlock NodeJS Client
3 | *
4 | * Copyright (c) 2021-2022 Forging Technologies, Inc.
5 | * This file is open source and available under the MIT license.
6 | * See the LICENSE file for more info.
7 | */
8 |
9 | // import {KeyUtils} from './util/KeyUtils';
10 | // import {RESTcli} from './util/RESTcli';
11 | // import * as BitPayExceptions from "./Exceptions/index";
12 | // import * as Models from "./Model/index";
13 | import {Client} from './Client';
14 | // import {Config} from './Config';
15 | // import {Currency} from './Currency';
16 | // import {Facade} from './Facade';
17 | // import * as Env from './Env'
18 | // import * as InvoiceStatus from './Model/Invoice/InvoiceStatus';
19 | // import * as RefundStatus from './Model/Invoice/RefundStatus';
20 | // import * as RecipientStatus from './Model/Payout/RecipientStatus';
21 | // import * as RecipientReferenceMethod from './Model/Payout/RecipientReferenceMethod';
22 | // import * as PayoutStatus from './Model/Payout/PayoutStatus';
23 |
24 | // let Tokens = {} as Tokens;
25 |
26 | export {
27 | // KeyUtils,
28 | // RESTcli,
29 | // BitPayExceptions,
30 | // Models,
31 | // Tokens,
32 | // Config,
33 | // Env,
34 | // Facade,
35 | // Currency,
36 | Client,
37 | // InvoiceStatus,
38 | // RefundStatus,
39 | // RecipientStatus,
40 | // RecipientReferenceMethod,
41 | // PayoutStatus
42 | };
43 |
--------------------------------------------------------------------------------
/lib/utils/balance.js:
--------------------------------------------------------------------------------
1 | const ethers = require('ethers')
2 | const Client = require('../Client')
3 | const api = require('../api')
4 |
5 | async function getAllBalancesMultiWallet(cb) {
6 | let walletApi
7 |
8 | const clientObj = Client.getInstance()
9 | if (clientObj.getBaseApiUrl() === 'https://api.forgingblock.io/') {
10 | walletApi = 'https://wallet-api.forgingblock.io/'
11 | } else {
12 | walletApi = 'https://wallet-api-demo.forgingblock.io/'
13 | }
14 |
15 | const btc = await api.findBtcMultipleAddressBalance(walletApi, {})
16 | const eth = await api.findEthMultipleAddressBalance(walletApi, {})
17 |
18 | const balances = multiWalletBalanceSum(btc, eth)
19 |
20 | cb(balances)
21 |
22 | }
23 |
24 | const multiWalletBalanceSum = (btc, eth) => {
25 | const ethSum = getEthSum(eth)
26 | const btcSum = getBtcSum(btc)
27 |
28 | return {
29 | ...ethSum,
30 | ...btcSum
31 | }
32 | }
33 |
34 | const getEthSum = eth => {
35 | const ethBalances = {
36 | eth: 0,
37 | ethTokensUsdt: 0,
38 | ethTokensDai: 0,
39 | ethTokensLusd: 0
40 | }
41 |
42 | for (const i in eth) {
43 | ethBalances['eth'] += parseFloat(
44 | eth[i]['0x0000000000000000000000000000000000000000']
45 | )
46 |
47 | if (eth[i]['0x6b175474e89094c44da98b954eedeac495271d0f']) {
48 | ethBalances['ethTokensDai'] += parseFloat(
49 | eth[i]['0x6b175474e89094c44da98b954eedeac495271d0f']
50 | )
51 | }
52 |
53 | if (eth[i]['0x5f98805a4e8be255a32880fdec7f6728c6568ba0']) {
54 | ethBalances['ethTokensLusd'] += parseFloat(
55 | eth[i]['0x5f98805a4e8be255a32880fdec7f6728c6568ba0']
56 | )
57 | }
58 | }
59 |
60 | ethBalances['eth'] = ethers.utils.formatEther(ethBalances['eth'].toString())
61 | ethBalances['ethTokensUsdt'] = ethers.utils.formatUnits(
62 | ethBalances['ethTokensUsdt'].toString(),
63 | 6
64 | )
65 | ethBalances['ethTokensDai'] = ethers.utils.formatUnits(
66 | ethBalances['ethTokensDai'].toString(),
67 | 18
68 | )
69 | ethBalances['ethTokensLusd'] = ethers.utils.formatUnits(
70 | ethBalances['ethTokensLusd'].toString(),
71 | 18
72 | )
73 |
74 | return ethBalances
75 | }
76 |
77 | const getBtcSum = btc => {
78 | // TODO: get btc balances for multiwallet
79 | btc = btc.reduce(
80 | (acc, current) =>
81 | acc + parseFloat(current.confirmed) + parseFloat(current.unconfirmed),
82 | 0
83 | )
84 |
85 | return { btc }
86 | }
87 |
88 | module.exports = {
89 | getAllBalancesMultiWallet
90 | }
--------------------------------------------------------------------------------
/lib/api/default.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const fetch = require('node-fetch')
4 | const qs = require('qs')
5 | const Client = require('../Client')
6 |
7 | let auth = {}
8 | let baseURL = null
9 |
10 | function initAPI() {
11 | const clientObj = Client.getInstance()
12 |
13 | auth = {
14 | trade: clientObj.getTrade(),
15 | token: clientObj.getToken()
16 | }
17 |
18 | baseURL = clientObj.getBaseApiUrl() || 'https://api.forgingblock.io'
19 | baseURL = baseURL.replace(/\/+$/, '')
20 | }
21 |
22 | function joinUrl(base, path) {
23 | const p = String(path || '')
24 | if (!p) return base
25 | return p.startsWith('/') ? `${base}${p}` : `${base}/${p}`
26 | }
27 |
28 | async function handleResponse(res) {
29 | const contentType = res.headers?.get?.('content-type') || ''
30 |
31 | let data
32 | if (contentType.includes('application/json')) {
33 | data = await res.json().catch(() => null)
34 | } else {
35 | data = await res.text().catch(() => '')
36 | }
37 |
38 | if (res.status === 200) return data
39 |
40 | const err = new Error(
41 | typeof data === 'string' && data ? data : res.statusText
42 | )
43 | err.status = res.status
44 | err.data = data
45 | throw err
46 | }
47 |
48 | const buildPromise = (method, endPoint, data, config) => {
49 | if (!baseURL) initAPI()
50 |
51 | const upper = String(method || '').toUpperCase()
52 | const urlBase = joinUrl(baseURL, endPoint)
53 |
54 | const hasConfig = config !== undefined && config !== null
55 |
56 | let finalUrl = urlBase
57 | let body
58 |
59 | if (upper === 'GET') {
60 | const paramsObj = data && typeof data === 'object' ? data : {}
61 | const query = qs.stringify(
62 | { ...paramsObj, ...auth },
63 | { arrayFormat: 'indices' }
64 | )
65 | if (query) {
66 | finalUrl += (finalUrl.includes('?') ? '&' : '?') + query
67 | }
68 | } else {
69 | if (hasConfig && typeof data === 'string') {
70 | body = data
71 | } else {
72 | const dataObj = data && typeof data === 'object' ? data : {}
73 | body = qs.stringify(
74 | { ...dataObj, ...auth },
75 | { arrayFormat: 'indices' }
76 | )
77 | }
78 | }
79 |
80 | const headers = {
81 | 'Content-Type': 'application/x-www-form-urlencoded',
82 | ...(config?.headers || {})
83 | }
84 |
85 | const fetchOptions = {
86 | method: upper,
87 | headers,
88 | credentials: 'include',
89 | ...(config || {})
90 | }
91 |
92 | if (upper !== 'GET' && body !== undefined) {
93 | fetchOptions.body = body
94 | }
95 |
96 | return fetch(finalUrl, fetchOptions).then(handleResponse)
97 | }
98 |
99 | function apiGet(endPoint, config) {
100 | if (!baseURL) initAPI()
101 | return buildPromise('GET', endPoint, config, null)
102 | }
103 |
104 | function apiPost(endPoint, data, config) {
105 | if (!baseURL) initAPI()
106 | return buildPromise('POST', endPoint, data, config)
107 | }
108 |
109 | function apiPut(endPoint, data, config) {
110 | if (!baseURL) initAPI()
111 | return buildPromise('PUT', endPoint, data, config)
112 | }
113 |
114 | function apiDelete(endPoint, data, config) {
115 | if (!baseURL) initAPI()
116 | return buildPromise('DELETE', endPoint, data, config)
117 | }
118 |
119 | module.exports = {
120 | buildPromise,
121 | apiGet,
122 | apiPost,
123 | apiPut,
124 | apiDelete
125 | }
126 |
--------------------------------------------------------------------------------
/lib/Resources/Checkout.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const api = require('../api'),
4 | client = require('../Client')
5 |
6 | class Checkout {
7 |
8 | /**
9 | * @param {object} data - Data object for creating an item
10 | *
e.g. { amount:550, currency:rub, description:spoon, email:test@fastmail.mx, count:2 name:bestspoon }
11 | * @param {string} itemType - ["produсt" | "donation"]
12 | * @param {requestCallback} callback - The callback that handles the response.
13 | */
14 | async create(data, itemType, ipn, callback) {
15 | // amount=550¤cy=rub&description=spoon&email=test%40fastmail.mx&count=2&name=bestspoon
16 | itemType = itemType || 'product'
17 | try {
18 | let response
19 | const reqApi = itemType === 'donation' ? api.createCrowdfunding : api.createUrl
20 | if (ipn) {
21 | data.notification = ipn
22 | response = await reqApi(data)
23 | }
24 | if (!ipn) {
25 | response = await reqApi(data)
26 | }
27 |
28 | callback(null, response)
29 | } catch (error) {
30 | callback(error, null)
31 | }
32 | }
33 |
34 | /**
35 | * This callback type is called `requestCallback` and is displayed as a global symbol.
36 | *
37 | * @callback requestCallback
38 | * @param {Error} error
39 | * @param {object} response
40 | */
41 |
42 | /**
43 | * @param {string} itemId - ID of the product/donation
44 | * @param {string} itemType - ["produt" | "donation"]
45 | * @param {requestCallback} callback - The callback that handles the response.
46 | */
47 | async retrieve(itemId, itemType, callback) {
48 | itemType = itemType || 'product'
49 | try {
50 | const clientObj = client.getInstance()
51 | let response
52 |
53 | if (itemType === 'donation') {
54 | response = await api.checkCrowdfunding({ fund: itemId })
55 | response.url = clientObj.getBaseApiUrl() + 'fund/' + response.fund + '/' + response.amount
56 | } else {
57 | response = await api.checkUrl({ item: itemId })
58 | response.url = clientObj.getBaseApiUrl() + 'item/' + response.item
59 | }
60 |
61 | callback(null, response)
62 | } catch (error) {
63 | callback(error, null)
64 | }
65 | }
66 |
67 | /**
68 | * @param {object} data - Checkout data to be updated
69 | * @param {string} data.item - Item id of checkout
70 | * @param {string} data.name - Item name
71 | * @param {string} data.description - Item description
72 | * @param {number} data.count - Item count
73 | * @param {requestCallback} callback - The callback that handles the response.
74 | */
75 | async update(data, callback) {
76 | // item: 24ea53d945692da5f353b4cd323e7826, description: thebesttool, name: product1, count: 12
77 | try {
78 | try {
79 | let response
80 | response = await api.checkoutUpdate(data)
81 |
82 | callback(null, response)
83 | } catch (error) {
84 | callback(error, null)
85 | }
86 | } catch (error) {
87 | callback(error, null)
88 | }
89 | }
90 |
91 | delete(id, callback) {
92 | }
93 |
94 | list(params, callback) {
95 | // var params = {
96 | // 'limit': 2,
97 | // 'order': 'desc'
98 | // };
99 | }
100 |
101 | async all(params, callback) {
102 | try {
103 | const promises = [api.getPaymentsList(), api.getCrowdfundsList()]
104 | Promise.all(promises).then(response => {
105 | const obj = {}
106 | obj.products = response[0].items
107 | obj.donations = response[1].funds
108 | callback(null, obj)
109 | }).catch(err => {
110 | console.log(err);
111 | callback(err, null)
112 | })
113 | // const res = await api.getCrowdfundsList()
114 | } catch (error) {
115 | callback(error)
116 | }
117 | }
118 | }
119 |
120 | module.exports = new Checkout()
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ForgingBlock
2 |
3 | ForgingBlock is a peer-to-peer cryptocurrency payment system that facilitates developers in providing infrastructure similar to what is offered within the credit card payment industry. ForgingBlock offers APIs, libraries, and Ecommerce plugins to assist merchants and developers - who are familiar with the credit payment process – in adopting cryptocurrency, L2 networks & stable coins as a payment method with a minimal learning curve and easy adaptability.
4 |
5 | The official Node.js library for the [ForgingBlock API](https://api.forgingblock.io/docs/).
6 |
7 | npm Links : https://www.npmjs.com/package/forgingblock.js
8 |
9 | # Table of contents
10 | * [Node.js Versions](#node.js-version)
11 | * [Documentation](#documentation)
12 | * [Installation](#installation)
13 | * [Usage](#usage)
14 | * [Checkouts](#checkouts)
15 | * [Sales](#sales)
16 |
17 | ## Documentation
18 | For more details visit [ForgingBlock API Docs](https://api.forgingblock.io/docs/).
19 |
20 | To start using this library register an account on [ForgingBlock](https://dash.forgingblock.io/).
21 | You will find your ``Trade`` and ``Token`` keys from Settings.
22 |
23 | Next initialize a ``Client`` for interacting with the API. The required parameters to initialize a client are ``Trade`` and ``Token``, however, you can also pass in ``baseUrl``, ``apiVersion`` and ``timeout``.
24 |
25 | ``` js
26 | const forgingblock = require('forgingblock.js');
27 | const Client = forgingblock.Client;
28 | const Sale = forgingblock.resources.Sale;
29 | const Balance = forgingblock.resources.Balance;
30 |
31 | Client.init({
32 | trade: ,
33 | token:
34 | });
35 | ```
36 |
37 | The API resource class provides the following static methods: ``list, all, create, retrieve, updateById, deleteById``. Additionally, the API resource class also provides the following instance methods: ``save, delete, insert, update``.
38 |
39 | Each API method returns an ``ApiResource`` which represents the JSON response from the API.
40 | When the response data is parsed into objects, the appropriate ``ApiResource`` subclass will automatically be used.
41 |
42 | Parameters can be also be set post-initialization:
43 |
44 | ``` js
45 | var clientObj = Client.init(Trade, Token);
46 | clientObj.setRequestTimeout(3000);
47 | ```
48 |
49 |
50 | ## Installation
51 |
52 | Install with ``npm``:
53 | ``` sh
54 | npm install forgingblock.js --save
55 | ```
56 |
57 | ## Usage
58 | ``` js
59 | var forgingblock = require('forgingblock.js');
60 | var Client = forgingblock.Client;
61 |
62 | Client.init({
63 | trade: ,
64 | token:
65 | });
66 | ```
67 | ## Checkouts
68 | [Checkouts API docs](https://api.forgingblock.io/docs/#item-payment-urls--checkout-)
69 |
70 |
71 | ### Load checkout resource class
72 | ``` js
73 | var forgingblock = require('forgingblock.js');
74 | var Checkout = forgingblock.resources.Checkout;
75 | ```
76 | ### Retrieve
77 | checkout_type is of type string, and can accept either "product" or "donation"
78 | ``` js
79 | Checkout.retrieve(, , function (error, response) {
80 | console.log(error);
81 | console.log(response);
82 | });
83 | ```
84 | ### Create
85 | checkout_type is of type string, and can accept either "product" or "donation"
86 | ``` js
87 | var checkoutData = {
88 | amount: 550,
89 | currency: 'usd',
90 | description: 'Description for the product',
91 | email: 'test@fastmail.mx',
92 | count: 2,
93 | name: 'IPhone'
94 | };
95 | ```
96 |
97 | **IPN (Instant Payment Notification)**
98 | As a developer, you want to get notification on events when a payment is completed or rejected. That's where IPN (Instant Payment Notification) come in handy. IPN helps in receiving the success/error messages with payment status from the ForgingBlock server to your server.
99 |
100 | Provide `ipn` parameter with url (starting `https://` or `http://`) in order to receive IPN after invoice is expired.
101 |
102 | ```
103 | Checkout.create(checkoutData, , , function (error, response) {
104 | console.log(error);
105 | console.log(response);
106 | });
107 | ```
108 | ### Update
109 | ``` js
110 | var newParams = {
111 | description: 'thebesttool',
112 | name: 'product1',
113 | count: 12,
114 | item: '829f8bd302d0f2b24e8fe9b6d23ad494' // item or fund id is required
115 | };
116 |
117 | Checkout.update(newParams, function (error, response) {
118 | console.log(error);
119 | console.log(response);
120 | });
121 | ```
122 |
123 | ### Get all checkouts
124 | ``` js
125 | Checkout.all({}, function (error, list) {
126 | console.log(error);
127 | console.log(list);
128 | });
129 | ```
130 | ## Sales
131 | [Sales API docs](https://api.forgingblock.io/docs/#invoices-history)
132 |
133 | ### Load Sale resource class
134 | ``` js
135 | var forgingblock = require('forgingblock.js');
136 | var Sale = forgingblock.resources.Sale;
137 | ```
138 | ### Retrieve
139 | ``` js
140 | Sale.retrieve(, function (error, response) {
141 | console.log(error);
142 | console.log(response);
143 | });
144 | ```
145 |
146 | ### Get all sales
147 | ``` js
148 | Sale.all({}, function (error, response) {
149 | console.log(error);
150 | console.log(response);
151 | });
152 | ```
153 | // OR you can pass the status parameter to get only the paid invoices
154 | ``` js
155 | Sale.all({ status: 'paid' }, function (error, response) {
156 | console.log(error);
157 | console.log(response);
158 | });
159 | ```
160 |
--------------------------------------------------------------------------------
/lib/Client.js:
--------------------------------------------------------------------------------
1 | /*eslint no-console: 0 */
2 | 'use strict';
3 |
4 | var url = require('url'),
5 | request = require('request'),
6 | _ = require('lodash'),
7 | assign = require('object-assign'),
8 | qs = require('querystring') //,
9 | // buildApiError = require('./buildApiError'),
10 | // version = require('../package.json').version,
11 | // ApiResponse = require('./ApiResponse');
12 |
13 | var DEFAULT_TRADE = null;
14 | var DEFAULT_TOKEN = null;
15 | var DEFAULT_BASE_API_URL = 'https://api.forgingblock.io/';
16 | var DEFAULT_TIMEOUT = 3000;
17 |
18 | module.exports = (function (DEFAULT_TRADE, DEFAULT_TOKEN, DEFAULT_BASE_API_URL, DEFAULT_TIMEOUT) {
19 | var instance;
20 |
21 | function init(trade, token, baseApiUrl, timeout) {
22 |
23 | var CONFIG_PARAM_NAMES = {
24 | TRADE: 'trade',
25 | TOKEN: 'token',
26 | BASE_API_URL: 'baseApiUrl',
27 | TIMEOUT: 'timeout'
28 | };
29 | var config = {};
30 |
31 | config[CONFIG_PARAM_NAMES.TRADE] = DEFAULT_TRADE;
32 | config[CONFIG_PARAM_NAMES.TOKEN] = DEFAULT_TOKEN;
33 |
34 | config[CONFIG_PARAM_NAMES.BASE_API_URL] = DEFAULT_BASE_API_URL;
35 | config[CONFIG_PARAM_NAMES.TIMEOUT] = DEFAULT_TIMEOUT;
36 |
37 | function setParam(key, value) {
38 | config[key] = value;
39 | }
40 |
41 | function getParam(key) {
42 | return config[key];
43 | }
44 |
45 | function setTrade(tradeKey) {
46 | if (tradeKey) {
47 | setParam(CONFIG_PARAM_NAMES.TRADE, tradeKey);
48 | } else {
49 | throw new Error('Trade Key is required.');
50 | }
51 | }
52 |
53 | function getTrade() {
54 | return getParam(CONFIG_PARAM_NAMES.TRADE);
55 | }
56 |
57 | function setToken(token) {
58 | if (token) {
59 | setParam(CONFIG_PARAM_NAMES.TOKEN, token);
60 | }
61 | }
62 |
63 | function getToken() {
64 | return getParam(CONFIG_PARAM_NAMES.TOKEN);
65 | }
66 |
67 | function setRequestTimeout(timeout) {
68 | if (timeout) {
69 | setParam(CONFIG_PARAM_NAMES.TIMEOUT, timeout);
70 | }
71 | }
72 |
73 | function getRequestTimeout() {
74 | return getParam(CONFIG_PARAM_NAMES.TIMEOUT);
75 | }
76 |
77 | function setBaseApiUrl(baseApiUrl) {
78 | if (baseApiUrl) {
79 | var urlObj = url.parse(baseApiUrl);
80 |
81 | if (urlObj.protocol === 'http:') {
82 | var warning = 'WARNING: this client is sending a request to an insecure'
83 | + ' API endpoint. Any API request you make may expose your API key and'
84 | + ' secret to third parties. Consider using the default endpoint: ' + baseApiUrl;
85 |
86 | console.warn(warning);
87 | }
88 |
89 | setParam(CONFIG_PARAM_NAMES.BASE_API_URL, baseApiUrl);
90 | }
91 | }
92 |
93 | function getBaseApiUrl() {
94 | return getParam(CONFIG_PARAM_NAMES.BASE_API_URL);
95 | }
96 |
97 | setTrade(trade);
98 | setToken(token);
99 | setBaseApiUrl(baseApiUrl);
100 | setRequestTimeout(timeout);
101 |
102 | function generateReqOptions(url, body, method, headers) {
103 | var bodyStr = body ? JSON.stringify(body) : '';
104 | var options = {
105 | 'url': url,
106 | 'body': bodyStr,
107 | 'method': method,
108 | 'timeout': getRequestTimeout(),
109 | 'headers': {
110 | 'Content-Type': 'application/json',
111 | 'Accept': 'application/json',
112 | 'User-Agent': 'ForgingBlock ' + version,
113 | 'trade': getTrade(),
114 | 'token': getToken()
115 | }
116 | };
117 |
118 | options.headers = assign(options.headers, headers);
119 |
120 | return options;
121 | }
122 |
123 | function getFullUrlPath(path, params) {
124 | var baseUrl = getBaseApiUrl();
125 | var extraParams = '';
126 |
127 | if (params && !_.isEmpty(params)) {
128 | extraParams = '?' + qs.stringify(params);
129 | }
130 |
131 | return baseUrl + path + extraParams;
132 | }
133 |
134 | function makeRequest(options, callback) {
135 | console.log(options)
136 | request(options, function (error, response) {
137 | var apiResponse = new ApiResponse(response);
138 |
139 | if (!buildApiError(error, apiResponse, callback)) {
140 | callback(null, apiResponse);
141 | }
142 | });
143 | }
144 |
145 | return {
146 | setTrade: setTrade,
147 | getTrade: getTrade,
148 | setToken: setToken,
149 | getToken: getToken,
150 | setBaseApiUrl: setBaseApiUrl,
151 | getBaseApiUrl: getBaseApiUrl,
152 | setRequestTimeout: setRequestTimeout,
153 | getRequestTimeout: getRequestTimeout,
154 | getHttp: function (path, args, callback, headers) {
155 | var fullUrl = getFullUrlPath(path, args);
156 | var options = generateReqOptions(fullUrl, null, 'GET', headers);
157 |
158 | makeRequest(options, callback);
159 | },
160 | postHttp: function (path, data, callback, headers) {
161 | var fullUrl = getFullUrlPath(path);
162 | var options = generateReqOptions(fullUrl, data, 'POST', headers);
163 |
164 | makeRequest(options, callback);
165 | },
166 | putHttp: function (path, data, callback, headers) {
167 | var fullUrl = getFullUrlPath(path);
168 | var options = generateReqOptions(fullUrl, data, 'PUT', headers);
169 |
170 | makeRequest(options, callback);
171 | },
172 | deleteHttp: function (path, callback, headers) {
173 | var fullUrl = getFullUrlPath(path);
174 | var options = generateReqOptions(fullUrl, {}, 'DELETE', headers);
175 |
176 | makeRequest(options, callback);
177 | }
178 | };
179 | }
180 |
181 | return {
182 | init: function ({ trade, token, baseApiUrl, timeout }) {
183 | if (!instance) {
184 | instance = init(trade, token, baseApiUrl, timeout);
185 | } else {
186 | instance.setTrade(trade);
187 | instance.setBaseApiUrl(baseApiUrl);
188 | instance.setRequestTimeout(timeout);
189 | }
190 |
191 | return instance;
192 | },
193 | getInstance: function () {
194 | if (!instance) {
195 | throw new Error('Please init client first.');
196 | }
197 |
198 | return instance;
199 | }
200 | };
201 | })(DEFAULT_TRADE, DEFAULT_TOKEN, DEFAULT_BASE_API_URL, DEFAULT_TIMEOUT);
202 |
--------------------------------------------------------------------------------
/lib/api/index.js:
--------------------------------------------------------------------------------
1 | // const { apiGet, apiPost } = require('./default')
2 | const { apiGet, apiPost} = require('./default')
3 | const requestClient = require('request')
4 |
5 | // TODO: Remove unused api routes
6 | function btcBalance(url) {
7 | return new Promise((resolve, reject) => {
8 | let balance = '0'
9 |
10 | requestClient.get(
11 | {
12 | uri: url,
13 | json: true
14 | },
15 | (error, response, body) => {
16 | if (error) {
17 | console.error('error:', error)
18 | }
19 | balance =
20 | (Number(body.chain_stats.funded_txo_sum) -
21 | Number(body.chain_stats.spent_txo_sum)) *
22 | 0.00000001 +
23 | ''
24 | resolve(balance)
25 | }
26 | )
27 | })
28 | }
29 |
30 | function ethBalance(url) {
31 | return new Promise((resolve, reject) => {
32 | let balance = '0'
33 |
34 | requestClient.get(
35 | {
36 | uri: url,
37 | json: true
38 | },
39 | (error, response, body) => {
40 | if (error) {
41 | console.error('error:', error)
42 | }
43 | balance = Number(body.result) / 1000000000000000000 + ''
44 | resolve(balance)
45 | }
46 | )
47 | })
48 | }
49 |
50 | function ethTokenBalance(url, division) {
51 | return new Promise((resolve, reject) => {
52 | let balance = '0'
53 |
54 | requestClient.get(
55 | {
56 | uri: url,
57 | json: true
58 | },
59 | (error, response, body) => {
60 | if (error) {
61 | console.error('error:', error)
62 | }
63 | balance = Number(body.result) / Number(division) + ''
64 | resolve(balance)
65 | }
66 | )
67 | })
68 | }
69 |
70 | function xtzBalance(url) {
71 | return new Promise((resolve, reject) => {
72 | let balance = '0'
73 |
74 | requestClient.get(
75 | {
76 | uri: url,
77 | json: true
78 | },
79 | (error, response, body) => {
80 | if (error) {
81 | console.error('error:', error)
82 | }
83 | balance = Number(body.total_balance) + ''
84 | resolve(balance)
85 | }
86 | )
87 | })
88 | }
89 |
90 | function eosBalance(url, account) {
91 | return new Promise((resolve, reject) => {
92 | let balance = '0'
93 |
94 | requestClient.post(
95 | {
96 | uri: url,
97 | body: {
98 | account_name: account
99 | },
100 | json: true
101 | },
102 | (error, response, body) => {
103 | if (error) {
104 | console.error('error:', error)
105 | }
106 | if (
107 | typeof body.core_liquid_balance !== 'undefined' &&
108 | body.core_liquid_balance !== null
109 | ) {
110 | balance = body.core_liquid_balance.replace(/[^\d.-]/g, '')
111 | resolve(balance)
112 | } else {
113 | resolve(balance)
114 | }
115 | }
116 | )
117 | })
118 | }
119 |
120 | function eosTokenBalance(url, account, code, symbol) {
121 | return new Promise((resolve, reject) => {
122 | let balance = '0'
123 |
124 | requestClient.post(
125 | {
126 | uri: url,
127 | body: {
128 | code: code,
129 | account: account,
130 | symbol: symbol
131 | },
132 | json: true
133 | },
134 | (error, response, body) => {
135 | if (error) {
136 | console.error('error:', error)
137 | }
138 | if (typeof body !== 'undefined' && body.length > 0) {
139 | balance = body[0].replace(/[^\d.-]/g, '')
140 | resolve(balance)
141 | } else {
142 | resolve(balance)
143 | }
144 | }
145 | )
146 | })
147 | }
148 |
149 | function tuscBalance(url, account) {
150 | return new Promise((resolve, reject) => {
151 | let balance = 0
152 |
153 | requestClient.get(
154 | {
155 | uri: url + account,
156 | json: true
157 | },
158 | (error, response, body) => {
159 | if (error) {
160 | console.error('error:', error)
161 | }
162 | try {
163 | if (response.statusCode === 500) {
164 | balance = 0
165 | } else if (body.balances[0].asset_type === '1.3.0') {
166 | balance = Number(body.balances[0].balance) / 100000
167 | } else {
168 | balance = 0
169 | }
170 | } catch (err) {
171 | balance = 0
172 | }
173 | resolve(balance)
174 | }
175 | )
176 | })
177 | }
178 |
179 | function dgbBalance(url) {
180 | return new Promise((resolve, reject) => {
181 | let balance = '0'
182 |
183 | requestClient.get(
184 | {
185 | uri: url,
186 | json: true
187 | },
188 | (error, response, body) => {
189 | if (error) {
190 | console.error('error:', error)
191 | }
192 | balance = body.balance
193 | resolve(balance)
194 | }
195 | )
196 | })
197 | }
198 |
199 | function rddBalance(url) {
200 | return new Promise((resolve, reject) => {
201 | let balance = '0'
202 |
203 | requestClient.get(
204 | {
205 | uri: url,
206 | json: true
207 | },
208 | (error, response, body) => {
209 | if (error) {
210 | console.error('error:', error)
211 | }
212 | balance = body.balance
213 | resolve(balance)
214 | }
215 | )
216 | })
217 | }
218 |
219 | function rvnBalance(url) {
220 | return new Promise((resolve, reject) => {
221 | let balance = '0'
222 |
223 | requestClient.get(
224 | {
225 | uri: url,
226 | json: true
227 | },
228 | (error, response, body) => {
229 | if (error) {
230 | console.error('error:', error)
231 | }
232 | balance = body.balance
233 | resolve(balance)
234 | }
235 | )
236 | })
237 | }
238 |
239 | function xncBalance(url) {
240 | return new Promise((resolve, reject) => {
241 | let balance = '0'
242 |
243 | requestClient.get(
244 | {
245 | uri: url,
246 | json: true
247 | },
248 | (error, response, body) => {
249 | if (error) {
250 | console.error('error:', error)
251 | }
252 | balance = body.balance
253 | resolve(balance)
254 | }
255 | )
256 | })
257 | }
258 |
259 | function owcBalance(url) {
260 | return new Promise((resolve, reject) => {
261 | let balance = '0'
262 |
263 | requestClient.get(
264 | {
265 | uri: url,
266 | json: true
267 | },
268 | (error, response, body) => {
269 | if (error) {
270 | console.error('error:', error)
271 | }
272 | balance = body.balance
273 | resolve(balance)
274 | }
275 | )
276 | })
277 | }
278 |
279 | function ksmBalance(url, division) {
280 | return new Promise((resolve, reject) => {
281 | let balance = '0'
282 |
283 | requestClient.get(
284 | {
285 | uri: url,
286 | json: true
287 | },
288 | (error, response, body) => {
289 | if (error) {
290 | console.error('error:', error)
291 | }
292 | balance = Number(body.data.attributes.balance_total) / Number(division)
293 | resolve(balance)
294 | }
295 | )
296 | })
297 | }
298 |
299 | function cryptoRates() {
300 | return new Promise((resolve, reject) => {
301 | let result
302 |
303 | requestClient.get(
304 | {
305 | uri:
306 | 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,monero,bittorrent-2,dai,tether,tron,wink,tronweeklyjournal,tezos,bitcoin-cash,eos,everipedia,telos,digibyte,reddcoin,ravencoin,xenios,kusama,oduwa-coin,original-crypto-coin&vs_currencies=usd%2Cbtc',
307 | json: true
308 | },
309 | (error, response, body) => {
310 | if (error) {
311 | console.error('error:', error)
312 | }
313 | if (
314 | typeof body.bitcoin.usd !== 'undefined' &&
315 | body.bitcoin.usd !== null
316 | ) {
317 | result = body
318 | resolve(result)
319 | }
320 | }
321 | )
322 | })
323 | }
324 |
325 | function btcRate() {
326 | return new Promise((resolve, reject) => {
327 | let result
328 |
329 | requestClient.get(
330 | {
331 | uri:
332 | 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd%2Cbtc',
333 | json: true
334 | },
335 | (error, response, body) => {
336 | if (
337 | typeof body.bitcoin.usd !== 'undefined' &&
338 | body.bitcoin.usd !== null
339 | ) {
340 | result = body
341 | resolve(result)
342 | }
343 | }
344 | )
345 | })
346 | }
347 |
348 | // Multiwallet balances
349 | /* store= */
350 | function findEthMultipleAddressBalance(walletApi, data) {
351 | return apiPost(`${walletApi}v1/find-eth-multiple-address-balance`, data)
352 | }
353 | /* store= */
354 | function findBtcMultipleAddressBalance(walletApi, data) {
355 | return apiPost(
356 | `${walletApi}v1/find-btc-multiple-address-balance-internal`,
357 | data
358 | )
359 | }
360 |
361 | // send amount
362 | /*
363 | mnemonic
364 | amountToSend
365 | recipientAddress
366 | */
367 | function sendBtcAmountMultipleAddress(walletApi, data) {
368 | return apiPost(`${walletApi}v1/send-btc-amount-multiple-address`, data)
369 | }
370 |
371 | /**
372 | * orgAddress
373 | * recipientAddress
374 | * amountToSend
375 | * privateKey
376 | * contract
377 | * decimals
378 | */
379 | function sendEthTokenTransaction(walletApi, data) {
380 | return apiPost(`${walletApi}v1/send-eth-token-transaction`, data)
381 | }
382 |
383 | // auth
384 | function registerUser(data) {
385 | return apiPost('register', data)
386 | }
387 |
388 | function login(data) {
389 | return apiPost('signin', data)
390 | }
391 | function logout() {
392 | return apiGet('signout')
393 | }
394 | function resetPassword(data) {
395 | return apiPost('reset-password', data)
396 | }
397 |
398 | function changePassword(data) {
399 | return apiPost('change-password', data)
400 | }
401 |
402 | function cookieStatus() {
403 | return apiGet('cookie-status')
404 | }
405 |
406 | // wallets
407 | function connectWallet(data, name) {
408 | return apiPost('/v2/connect-wallet-' + name, data)
409 | }
410 |
411 | function linkBTCSingleAddress(data) {
412 | return apiPost('/connect-wallet-btc-single', data)
413 | }
414 |
415 | function connectEthPool(data) {
416 | return apiPost('/v2/connect-wallet-eth-pool', data)
417 | }
418 |
419 | function walletConnectionStatus() {
420 | return apiPost('wallet-connection-status')
421 | }
422 |
423 | function walletConnectionStatusStore(data) {
424 | return apiPost('v2/wallet-connection-status-store', data)
425 | }
426 |
427 | function walletHideCurrency(data) {
428 | return apiPost('/v2/wallet-hide-currency', data)
429 | }
430 |
431 | function walletDefaultCurrency(data) {
432 | return apiPost('/v2/wallet-default-currency', data)
433 | }
434 |
435 | // store
436 | function createStore(data) {
437 | return apiPost('/v2/create-store', data)
438 | }
439 |
440 | function changeStoreName(data) {
441 | return apiPost('change-store-name', data)
442 | }
443 |
444 | function storeAttachImage(data) {
445 | return apiPost('/v2/store-attach-image', data)
446 | }
447 |
448 | function getStoresList(data) {
449 | return apiPost('/v2/stores-list', data)
450 | }
451 |
452 | function removeStore(data) {
453 | return apiPost('remove-store', data)
454 | }
455 |
456 | function createPairing(data) {
457 | return apiPost('create-pairing', data)
458 | }
459 |
460 | // invoice
461 | function createInvoice(data) {
462 | return apiPost('create-invoice', data)
463 | }
464 |
465 | function checkInvoice(data) {
466 | return apiPost('check-invoice', data)
467 | }
468 |
469 | function getInvoices(data) {
470 | return apiPost('get-invoices', data)
471 | }
472 |
473 | // This one would work only for BTC and LTC
474 | function getInvoicePaymentDetails(invoiceId, paymentMethodId) {
475 | // CryptoCurrency code for paymentMethodId: BTC or LTC
476 | return apiGet(
477 | `invoice/status?invoiceId=${invoiceId}&paymentMethodId=${paymentMethodId}&_=1`
478 | )
479 | }
480 |
481 | function getInvoicePaymentDetailsDropDownCrypto(invoiceId, paymentMethodId) {
482 | // CryptoCurrency code for paymentMethodId: BTC, LTC, ETH, TRX, XMR, XTZ, BCH, EOS, DGB, RDD, RVN
483 | // This one actually could be used instead of getInvoicePaymentDetails, since more universal
484 | return apiGet(
485 | 'i/' +
486 | invoiceId +
487 | '/' +
488 | paymentMethodId +
489 | '/status?invoiceId=' +
490 | invoiceId +
491 | '&paymentMethodId=' +
492 | paymentMethodId +
493 | '&_=1'
494 | )
495 | }
496 |
497 | function getInvoicePaymentDetailsDropDownEthToken(invoiceId, paymentMethodId) {
498 | // Ethereum Tokens
499 | // CryptoCurrency code for paymentMethodId: DAI, USDT
500 | return apiGet(
501 | 'i/' +
502 | invoiceId +
503 | '/eth-token/' +
504 | paymentMethodId +
505 | '/status?invoiceId=' +
506 | invoiceId +
507 | '&paymentMethodId=' +
508 | paymentMethodId +
509 | '&_=1'
510 | )
511 | }
512 |
513 | function getInvoicePaymentDetailsDropDownTronToken(invoiceId, paymentMethodId) {
514 | // Tron Tokens
515 | // CryptoCurrency code for paymentMethodId: BTT, USDT
516 | return apiGet(
517 | 'i/' +
518 | invoiceId +
519 | '/tron-token/' +
520 | paymentMethodId +
521 | '/status?invoiceId=' +
522 | invoiceId +
523 | '&paymentMethodId=' +
524 | paymentMethodId +
525 | '&_=1'
526 | )
527 | }
528 |
529 | function getInvoicePaymentDetailsDropDownEosToken(invoiceId, paymentMethodId) {
530 | // EOS Tokens
531 | // CryptoCurrency code for paymentMethodId: IQ, TLOS
532 | return apiGet(
533 | 'i/' +
534 | invoiceId +
535 | '/eos-token/' +
536 | paymentMethodId +
537 | '/status?invoiceId=' +
538 | invoiceId +
539 | '&paymentMethodId=' +
540 | paymentMethodId +
541 | '&_=1'
542 | )
543 | }
544 |
545 | // history
546 | function getAllInvoices(data) {
547 | return apiPost('get-store-all-invoices', data)
548 | }
549 |
550 | function getStoreInvoices(data) {
551 | return apiPost('get-store-invoices', data)
552 | }
553 |
554 | function getStoreAllInvoices(data) {
555 | return apiPost('get-store-ln-invoices', data)
556 | }
557 |
558 | function getInvoicesSimple(data) {
559 | return apiPost('v2/invoices-simple', data)
560 | }
561 |
562 | function getStoreInvoicesSimple(data) {
563 | return apiPost('v2/invoices', data)
564 | }
565 |
566 | // payment URL
567 |
568 | function createUrl(data) {
569 | return apiPost('create-item-sale', data)
570 | }
571 |
572 | function checkUrl(data) {
573 | return apiPost('check-item', data)
574 | }
575 |
576 | function getPaymentsList(data) {
577 | return apiPost('items-list', data)
578 | }
579 | function checkoutUpdate(data) {
580 | return apiPost('v2/checkout-update', data)
581 | }
582 | function createCrowdfunding(data) {
583 | return apiPost('create-crowdfunding', data)
584 | }
585 |
586 | function createInvoiceForCrowdfunding(id, amount) {
587 | return apiGet('fund/' + id + '/' + amount)
588 | }
589 |
590 | function checkCrowdfunding(data) {
591 | return apiPost('check-crowdfunding', data)
592 | }
593 | function getCrowdfundsList(data) {
594 | return apiPost('crowdfunds-list', data)
595 | }
596 | // Account
597 | function newEmail(data) {
598 | return apiPost('change-email', data)
599 | }
600 |
601 | function newPassword(data) {
602 | return apiPost('change-password', data)
603 | }
604 |
605 | function getBusinessInfo(data) {
606 | return apiPost('get-business-details', data)
607 | }
608 |
609 | function postBusinessInfo(data) {
610 | return apiPost('provide-business-details', data)
611 | }
612 |
613 | function updateBusinessInfo(data) {
614 | return apiPost('/v2/update-business-details', data)
615 | }
616 |
617 | function getLogoStatus(data) {
618 | return apiPost('/v2/logo-status', data)
619 | }
620 |
621 | // INTEGRATION: Shopify
622 | function addShopifyStore(data) {
623 | return apiPost('/v2/add-shopify-store', data)
624 | }
625 |
626 | function addSourceShopifyStore(data) {
627 | return apiPost('/v2/add-source-shopify-store', data)
628 | }
629 |
630 | function getShopifyStoreSource(data) {
631 | return apiPost('/v2/get-shopify-store-source', data)
632 | }
633 |
634 | function removeSourceShopifyStore(data) {
635 | return apiPost('/v2/remove-source-shopify-store', data)
636 | }
637 |
638 | function storeTokenRetrieve(data) {
639 | return apiPost('/v2/store-token-retrieve', data)
640 | }
641 |
642 | // Images
643 |
644 | function uploadImage(data) {
645 | return apiPost('/upload-image', data, {
646 | headers: { 'Content-Type': 'multipart/form-data' }
647 | })
648 | }
649 |
650 | function uploadThumbnailImage(data) {
651 | return apiPost('/v2/upload-image-thumbnail', data, {
652 | headers: { 'Content-Type': 'multipart/form-data' }
653 | })
654 | }
655 |
656 | function attachImage(data) {
657 | return apiPost('/attach-image', data)
658 | }
659 |
660 | function getImage(data) {
661 | return apiPost('/get-image', data)
662 | }
663 |
664 | // Admin Dashboard routes
665 | function getAllUsersCount(data) {
666 | return apiPost('/v2/get-all-users-count', data)
667 | }
668 |
669 | function getAllUsersDetails(data) {
670 | return apiPost('/v2/get-all-users-details', data)
671 | }
672 |
673 | function updateBusinessDetailsUserEmailAdmin(data) {
674 | return apiPost('/v2/update-business-details-user-email-admin', data)
675 | }
676 |
677 | function getInvoicesAdmin(data) {
678 | return apiPost('/v2/get-invoices-admin', data)
679 | }
680 |
681 | function getBusinessDetailsAdmin(data) {
682 | return apiPost('/v2/get-business-details-admin', data)
683 | }
684 |
685 | function resetPasswordAdmin(data) {
686 | return apiPost('/v2/reset-password-admin', data)
687 | }
688 |
689 | function storesListAdmin(data) {
690 | return apiPost('/v2/stores-list-admin', data)
691 | }
692 |
693 | function setLockoutAdmin(data) {
694 | return apiPost('/v2/set-lockout-admin', data)
695 | }
696 |
697 | // PaymentForm
698 | function setPaymentForm(data) {
699 | return apiPost('/v2/set-payment-form', data)
700 | }
701 |
702 | module.exports = {
703 | btcBalance,
704 | ethBalance,
705 | ethTokenBalance,
706 | xtzBalance,
707 | eosBalance,
708 | eosTokenBalance,
709 | tuscBalance,
710 | dgbBalance,
711 | rddBalance,
712 | rvnBalance,
713 | ksmBalance,
714 | xncBalance,
715 | owcBalance,
716 | cryptoRates,
717 | btcRate,
718 | //
719 | findEthMultipleAddressBalance,
720 | findBtcMultipleAddressBalance,
721 | sendBtcAmountMultipleAddress,
722 | sendEthTokenTransaction,
723 | // auth
724 | registerUser,
725 | login,
726 | logout,
727 | resetPassword,
728 | changePassword,
729 | cookieStatus,
730 | // wallets
731 | connectWallet,
732 | walletConnectionStatus,
733 | walletConnectionStatusStore,
734 | walletHideCurrency,
735 | walletDefaultCurrency,
736 | // store
737 | createStore,
738 | changeStoreName,
739 | storeAttachImage,
740 | getStoresList,
741 | removeStore,
742 | createPairing,
743 | // invoice
744 | createInvoice,
745 | checkInvoice,
746 | getInvoices,
747 | getInvoicePaymentDetails,
748 | getInvoicePaymentDetailsDropDownCrypto,
749 | getInvoicePaymentDetailsDropDownEthToken,
750 | getInvoicePaymentDetailsDropDownTronToken,
751 | getInvoicePaymentDetailsDropDownEosToken,
752 | getAllInvoices,
753 | // history
754 | getStoreInvoices,
755 | getStoreAllInvoices,
756 | getInvoicesSimple,
757 | getStoreInvoicesSimple,
758 | // payment URL
759 | createUrl,
760 | checkUrl,
761 | getPaymentsList,
762 | checkoutUpdate,
763 | // crowdfunding
764 | createCrowdfunding,
765 | createInvoiceForCrowdfunding,
766 | checkCrowdfunding,
767 | getCrowdfundsList,
768 | // account
769 | newEmail,
770 | newPassword,
771 | getBusinessInfo,
772 | postBusinessInfo,
773 | updateBusinessInfo,
774 | linkBTCSingleAddress,
775 | connectEthPool,
776 | getLogoStatus,
777 |
778 | // INTEGRATION: Shopify
779 | addShopifyStore,
780 | addSourceShopifyStore,
781 | getShopifyStoreSource,
782 | removeSourceShopifyStore,
783 |
784 | storeTokenRetrieve,
785 |
786 | // Images
787 | uploadImage,
788 | uploadThumbnailImage,
789 | attachImage,
790 | getImage,
791 |
792 | // Admin Dashboard
793 | getAllUsersCount,
794 | getAllUsersDetails,
795 | updateBusinessDetailsUserEmailAdmin,
796 | getInvoicesAdmin,
797 | getBusinessDetailsAdmin,
798 | resetPasswordAdmin,
799 | storesListAdmin,
800 | setLockoutAdmin,
801 | // Payment Form
802 | setPaymentForm
803 | }
804 |
--------------------------------------------------------------------------------