@spritz-finance/service-client 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.d.ts +1 -0
- package/lib/config.js +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/transactionsServiceClient.d.ts +15 -0
- package/lib/transactionsServiceClient.js +21 -0
- package/lib/transactionsServiceClient.test.d.ts +1 -0
- package/lib/transactionsServiceClient.test.js +10 -0
- package/package.json +1 -1
package/lib/config.d.ts
CHANGED
package/lib/config.js
CHANGED
|
@@ -9,22 +9,26 @@ const envConfigs = {
|
|
|
9
9
|
authEndpoint: 'https://auth-dev.spritz.finance/oauth2/token',
|
|
10
10
|
graphEndpoint: 'https://api-dev.spritz.finance/graphql',
|
|
11
11
|
verificationServiceEndpoint: 'https://api-dev.spritz.finance/verification',
|
|
12
|
+
transactionsServiceEndpoint: 'https://api-dev.spritz.finance/transactions',
|
|
12
13
|
},
|
|
13
14
|
test: {
|
|
14
15
|
env: 'staging',
|
|
15
16
|
authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
|
|
16
17
|
graphEndpoint: 'https://api-staging.spritz.finance/graphql',
|
|
17
18
|
verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
|
|
19
|
+
transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
|
|
18
20
|
},
|
|
19
21
|
staging: {
|
|
20
22
|
authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
|
|
21
23
|
graphEndpoint: 'https://api-staging.spritz.finance/graphql',
|
|
22
24
|
verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
|
|
25
|
+
transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
|
|
23
26
|
},
|
|
24
27
|
production: {
|
|
25
28
|
authEndpoint: 'https://auth.spritz.finance/oauth2/token',
|
|
26
29
|
graphEndpoint: 'https://api.spritz.finance/graphql',
|
|
27
30
|
verificationServiceEndpoint: 'https://api.spritz.finance/verification',
|
|
31
|
+
transactionsServiceEndpoint: 'https://api.spritz.finance/transactions',
|
|
28
32
|
},
|
|
29
33
|
};
|
|
30
34
|
exports.config = (0, config_1.setupEnvConfig)(envConfigs);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -14,3 +14,4 @@ __exportStar(require("./graphClient"), exports);
|
|
|
14
14
|
__exportStar(require("./credentials"), exports);
|
|
15
15
|
__exportStar(require("./serviceClient"), exports);
|
|
16
16
|
__exportStar(require("./verificationServiceClient"), exports);
|
|
17
|
+
__exportStar(require("./transactionsServiceClient"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
interface UtxoInvoice {
|
|
3
|
+
network: string;
|
|
4
|
+
address: string;
|
|
5
|
+
expiry: string;
|
|
6
|
+
expired: boolean;
|
|
7
|
+
amountFiat: number;
|
|
8
|
+
amount: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class TransactionsServiceClient {
|
|
11
|
+
client: AxiosInstance;
|
|
12
|
+
constructor();
|
|
13
|
+
createPaymentInvoice(network: string, amount: number): Promise<UtxoInvoice>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionsServiceClient = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const serviceClient_1 = require("./serviceClient");
|
|
6
|
+
class TransactionsServiceClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.client = (0, serviceClient_1.createServiceClient)({
|
|
9
|
+
baseURL: config_1.config.transactionsServiceEndpoint,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async createPaymentInvoice(network, amount) {
|
|
13
|
+
return this.client
|
|
14
|
+
.post(`/invoices`, {
|
|
15
|
+
network,
|
|
16
|
+
amount,
|
|
17
|
+
})
|
|
18
|
+
.then((res) => res.data);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.TransactionsServiceClient = TransactionsServiceClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const transactionsServiceClient_1 = require("./transactionsServiceClient");
|
|
4
|
+
describe('TransactionsServiceClient', () => {
|
|
5
|
+
const client = new transactionsServiceClient_1.TransactionsServiceClient();
|
|
6
|
+
it('should work', async () => {
|
|
7
|
+
const data = await client.createPaymentInvoice('bitcoin-testnet', 100);
|
|
8
|
+
console.log(data);
|
|
9
|
+
});
|
|
10
|
+
});
|