@spritz-finance/service-client 0.2.1 → 0.2.2

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 CHANGED
@@ -1,10 +1,10 @@
1
- interface GraphClientConfig {
2
- env: string;
3
- authEndpoint: string;
4
- graphEndpoint: string;
5
- verificationServiceEndpoint: string;
6
- transactionsServiceEndpoint: string;
7
- usersServiceEndpoint: string;
8
- }
9
- export declare const config: GraphClientConfig;
10
- export {};
1
+ interface GraphClientConfig {
2
+ env: string;
3
+ authEndpoint: string;
4
+ graphEndpoint: string;
5
+ verificationServiceEndpoint: string;
6
+ transactionsServiceEndpoint: string;
7
+ usersServiceEndpoint: string;
8
+ }
9
+ export declare const config: GraphClientConfig;
10
+ export {};
package/lib/config.js CHANGED
@@ -1,38 +1,38 @@
1
- "use strict";
2
- var _a, _b;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.config = void 0;
5
- const config_1 = require("@spritz-finance/config");
6
- const envConfigs = {
7
- base: {
8
- env: (_b = (_a = process.env.STAGE) !== null && _a !== void 0 ? _a : process.env.NODE_ENV) !== null && _b !== void 0 ? _b : 'dev',
9
- authEndpoint: 'https://auth-dev.spritz.finance/oauth2/token',
10
- graphEndpoint: 'https://api-dev.spritz.finance/graphql',
11
- verificationServiceEndpoint: 'https://api-dev.spritz.finance/verification',
12
- transactionsServiceEndpoint: 'https://api-dev.spritz.finance/transactions',
13
- usersServiceEndpoint: 'https://api-dev.spritz.finance/users',
14
- },
15
- test: {
16
- env: 'staging',
17
- authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
18
- graphEndpoint: 'https://api-staging.spritz.finance/graphql',
19
- verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
20
- transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
21
- usersServiceEndpoint: 'https://api-staging.spritz.finance/users',
22
- },
23
- staging: {
24
- authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
25
- graphEndpoint: 'https://api-staging.spritz.finance/graphql',
26
- verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
27
- transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
28
- usersServiceEndpoint: 'https://api-staging.spritz.finance/users',
29
- },
30
- production: {
31
- authEndpoint: 'https://auth.spritz.finance/oauth2/token',
32
- graphEndpoint: 'https://api.spritz.finance/graphql',
33
- verificationServiceEndpoint: 'https://api.spritz.finance/verification',
34
- transactionsServiceEndpoint: 'https://api.spritz.finance/transactions',
35
- usersServiceEndpoint: 'https://api.spritz.finance/users',
36
- },
37
- };
38
- exports.config = (0, config_1.setupEnvConfig)(envConfigs);
1
+ "use strict";
2
+ var _a, _b;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.config = void 0;
5
+ const config_1 = require("@spritz-finance/config");
6
+ const envConfigs = {
7
+ base: {
8
+ env: (_b = (_a = process.env.STAGE) !== null && _a !== void 0 ? _a : process.env.NODE_ENV) !== null && _b !== void 0 ? _b : 'dev',
9
+ authEndpoint: 'https://auth-dev.spritz.finance/oauth2/token',
10
+ graphEndpoint: 'https://api-dev.spritz.finance/graphql',
11
+ verificationServiceEndpoint: 'https://api-dev.spritz.finance/verification',
12
+ transactionsServiceEndpoint: 'https://api-dev.spritz.finance/transactions',
13
+ usersServiceEndpoint: 'https://api-dev.spritz.finance/users',
14
+ },
15
+ test: {
16
+ env: 'staging',
17
+ authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
18
+ graphEndpoint: 'https://api-staging.spritz.finance/graphql',
19
+ verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
20
+ transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
21
+ usersServiceEndpoint: 'https://api-staging.spritz.finance/users',
22
+ },
23
+ staging: {
24
+ authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
25
+ graphEndpoint: 'https://api-staging.spritz.finance/graphql',
26
+ verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
27
+ transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
28
+ usersServiceEndpoint: 'https://api-staging.spritz.finance/users',
29
+ },
30
+ production: {
31
+ authEndpoint: 'https://auth.spritz.finance/oauth2/token',
32
+ graphEndpoint: 'https://api.spritz.finance/graphql',
33
+ verificationServiceEndpoint: 'https://api.spritz.finance/verification',
34
+ transactionsServiceEndpoint: 'https://api.spritz.finance/transactions',
35
+ usersServiceEndpoint: 'https://api.spritz.finance/users',
36
+ },
37
+ };
38
+ exports.config = (0, config_1.setupEnvConfig)(envConfigs);
@@ -1 +1 @@
1
- export declare const getServiceCredentials: () => Promise<any>;
1
+ export declare const getServiceCredentials: () => Promise<any>;
@@ -1,49 +1,49 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.getServiceCredentials = void 0;
26
- const axios_1 = __importDefault(require("axios"));
27
- const qs = __importStar(require("qs"));
28
- const config_1 = require("./config");
29
- const params_1 = require("./params");
30
- const logger_1 = __importDefault(require("@spritz-finance/logger"));
31
- const getServiceCredentials = async () => {
32
- try {
33
- const clientIdParam = `/${config_1.config.env}/auth/serviceClientId`;
34
- const clientSecretParam = `/${config_1.config.env}/auth/serviceClientSecret`;
35
- const paramsByKey = await (0, params_1.getParams)([clientIdParam, clientSecretParam]);
36
- const { data } = await axios_1.default.post(config_1.config.authEndpoint, qs.stringify({
37
- grant_type: 'client_credentials',
38
- scope: 'spritz/service',
39
- client_id: paramsByKey[clientIdParam],
40
- client_secret: paramsByKey[clientSecretParam],
41
- }));
42
- return data;
43
- }
44
- catch (e) {
45
- logger_1.default.error(`Getting credentials failed`, e);
46
- throw e;
47
- }
48
- };
49
- exports.getServiceCredentials = getServiceCredentials;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.getServiceCredentials = void 0;
26
+ const axios_1 = __importDefault(require("axios"));
27
+ const qs = __importStar(require("qs"));
28
+ const config_1 = require("./config");
29
+ const params_1 = require("./params");
30
+ const logger_1 = __importDefault(require("@spritz-finance/logger"));
31
+ const getServiceCredentials = async () => {
32
+ try {
33
+ const clientIdParam = `/${config_1.config.env}/auth/serviceClientId`;
34
+ const clientSecretParam = `/${config_1.config.env}/auth/serviceClientSecret`;
35
+ const paramsByKey = await (0, params_1.getParams)([clientIdParam, clientSecretParam]);
36
+ const { data } = await axios_1.default.post(config_1.config.authEndpoint, qs.stringify({
37
+ grant_type: 'client_credentials',
38
+ scope: 'spritz/service',
39
+ client_id: paramsByKey[clientIdParam],
40
+ client_secret: paramsByKey[clientSecretParam],
41
+ }));
42
+ return data;
43
+ }
44
+ catch (e) {
45
+ logger_1.default.error(`Getting credentials failed`, e);
46
+ throw e;
47
+ }
48
+ };
49
+ exports.getServiceCredentials = getServiceCredentials;
@@ -1,15 +1,15 @@
1
- import { AxiosInstance } from 'axios';
2
- import { DocumentNode } from 'graphql';
3
- interface QueryParams<V = any> {
4
- query: DocumentNode;
5
- variables?: V;
6
- }
7
- export declare class GraphClient {
8
- client: AxiosInstance;
9
- constructor();
10
- query<Q = any, V = any>({ query, variables }: QueryParams<V>): Promise<{
11
- data: Q;
12
- errors?: any;
13
- }>;
14
- }
15
- export {};
1
+ import { AxiosInstance } from 'axios';
2
+ import { DocumentNode } from 'graphql';
3
+ interface QueryParams<V = any> {
4
+ query: DocumentNode;
5
+ variables?: V;
6
+ }
7
+ export declare class GraphClient {
8
+ client: AxiosInstance;
9
+ constructor();
10
+ query<Q = any, V = any>({ query, variables }: QueryParams<V>): Promise<{
11
+ data: Q;
12
+ errors?: any;
13
+ }>;
14
+ }
15
+ export {};
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphClient = void 0;
4
- const serviceClient_1 = require("./serviceClient");
5
- const config_1 = require("./config");
6
- const graphql_1 = require("graphql");
7
- class GraphClient {
8
- constructor() {
9
- this.client = (0, serviceClient_1.createServiceClient)({
10
- baseURL: config_1.config.graphEndpoint,
11
- });
12
- }
13
- async query({ query, variables }) {
14
- var _a, _b, _c;
15
- return this.client
16
- .post('', {
17
- query: (0, graphql_1.print)(query),
18
- variables,
19
- operationName: (_c = (_b = (_a = query === null || query === void 0 ? void 0 : query.definitions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.value,
20
- })
21
- .then((res) => res.data);
22
- }
23
- }
24
- exports.GraphClient = GraphClient;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphClient = void 0;
4
+ const serviceClient_1 = require("./serviceClient");
5
+ const config_1 = require("./config");
6
+ const graphql_1 = require("graphql");
7
+ class GraphClient {
8
+ constructor() {
9
+ this.client = (0, serviceClient_1.createServiceClient)({
10
+ baseURL: config_1.config.graphEndpoint,
11
+ });
12
+ }
13
+ async query({ query, variables }) {
14
+ var _a, _b, _c;
15
+ return this.client
16
+ .post('', {
17
+ query: (0, graphql_1.print)(query),
18
+ variables,
19
+ operationName: (_c = (_b = (_a = query === null || query === void 0 ? void 0 : query.definitions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.value,
20
+ })
21
+ .then((res) => res.data);
22
+ }
23
+ }
24
+ exports.GraphClient = GraphClient;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,29 +1,29 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const graphql_tag_1 = __importDefault(require("graphql-tag"));
7
- const graphClient_1 = require("./graphClient");
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
7
+ const graphClient_1 = require("./graphClient");
8
8
  const query = (0, graphql_tag_1.default) `
9
9
  query ASDF {
10
10
  getUsers {
11
11
  email
12
12
  }
13
13
  }
14
- `;
15
- describe('graphClient', () => {
16
- const client = new graphClient_1.GraphClient();
17
- it('should work', async () => {
18
- const { data, errors } = await client.query({
19
- query,
20
- });
21
- expect(errors).toBeFalsy();
22
- expect(data.getUsers).toEqual(expect.arrayContaining([
23
- expect.objectContaining({
24
- email: 'eliyahu@spritz.finance',
25
- }),
26
- ]));
27
- console.log(data === null || data === void 0 ? void 0 : data.getUsers);
28
- });
29
- });
14
+ `;
15
+ describe('graphClient', () => {
16
+ const client = new graphClient_1.GraphClient();
17
+ it('should work', async () => {
18
+ const { data, errors } = await client.query({
19
+ query,
20
+ });
21
+ expect(errors).toBeFalsy();
22
+ expect(data.getUsers).toEqual(expect.arrayContaining([
23
+ expect.objectContaining({
24
+ email: 'eliyahu@spritz.finance',
25
+ }),
26
+ ]));
27
+ console.log(data === null || data === void 0 ? void 0 : data.getUsers);
28
+ });
29
+ });
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './graphClient';
2
- export * from './credentials';
3
- export * from './serviceClient';
4
- export * from './verificationServiceClient';
5
- export * from './transactionsServiceClient';
6
- export * from './usersServiceClient';
1
+ export * from './graphClient';
2
+ export * from './credentials';
3
+ export * from './serviceClient';
4
+ export * from './verificationServiceClient';
5
+ export * from './transactionsServiceClient';
6
+ export * from './usersServiceClient';
package/lib/index.js CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./graphClient"), exports);
14
- __exportStar(require("./credentials"), exports);
15
- __exportStar(require("./serviceClient"), exports);
16
- __exportStar(require("./verificationServiceClient"), exports);
17
- __exportStar(require("./transactionsServiceClient"), exports);
18
- __exportStar(require("./usersServiceClient"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./graphClient"), exports);
14
+ __exportStar(require("./credentials"), exports);
15
+ __exportStar(require("./serviceClient"), exports);
16
+ __exportStar(require("./verificationServiceClient"), exports);
17
+ __exportStar(require("./transactionsServiceClient"), exports);
18
+ __exportStar(require("./usersServiceClient"), exports);
package/lib/params.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { SSM } from 'aws-sdk';
2
- export declare const getParams: (keys: string[]) => Promise<SSM.Parameter>;
1
+ import { SSM } from 'aws-sdk';
2
+ export declare const getParams: (keys: string[]) => Promise<SSM.Parameter>;
package/lib/params.js CHANGED
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getParams = void 0;
4
- const aws_sdk_1 = require("aws-sdk");
5
- const ssm = new aws_sdk_1.SSM({
6
- region: 'us-east-1',
7
- });
8
- const getParams = async (keys) => {
9
- const params = await ssm
10
- .getParameters({
11
- Names: keys,
12
- WithDecryption: true,
13
- })
14
- .promise();
15
- return params.Parameters.reduce((acc, val) => {
16
- return {
17
- ...acc,
18
- [val.Name]: val.Value,
19
- };
20
- }, {});
21
- };
22
- exports.getParams = getParams;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getParams = void 0;
4
+ const aws_sdk_1 = require("aws-sdk");
5
+ const ssm = new aws_sdk_1.SSM({
6
+ region: 'us-east-1',
7
+ });
8
+ const getParams = async (keys) => {
9
+ const params = await ssm
10
+ .getParameters({
11
+ Names: keys,
12
+ WithDecryption: true,
13
+ })
14
+ .promise();
15
+ return params.Parameters.reduce((acc, val) => {
16
+ return {
17
+ ...acc,
18
+ [val.Name]: val.Value,
19
+ };
20
+ }, {});
21
+ };
22
+ exports.getParams = getParams;
@@ -1,2 +1,2 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- export declare const createServiceClient: (config: AxiosRequestConfig) => import("axios").AxiosInstance;
1
+ import { AxiosRequestConfig } from 'axios';
2
+ export declare const createServiceClient: (config: AxiosRequestConfig) => import("axios").AxiosInstance;
@@ -1,25 +1,25 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createServiceClient = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const axios_token_interceptor_1 = __importDefault(require("axios-token-interceptor"));
9
- const credentials_1 = require("./credentials");
10
- const getMaxAge = (res) => {
11
- return res.expires_in * 1000;
12
- };
13
- const headerFormatter = (res) => {
14
- return 'Bearer ' + res.access_token;
15
- };
16
- const interceptor = function (tokenProvider, authenticate) {
17
- const getToken = tokenProvider.tokenCache(authenticate, { getMaxAge });
18
- return tokenProvider({ getToken, headerFormatter });
19
- };
20
- const createServiceClient = (config) => {
21
- const serviceClient = axios_1.default.create(config);
22
- serviceClient.interceptors.request.use(interceptor(axios_token_interceptor_1.default, credentials_1.getServiceCredentials));
23
- return serviceClient;
24
- };
25
- exports.createServiceClient = createServiceClient;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createServiceClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const axios_token_interceptor_1 = __importDefault(require("axios-token-interceptor"));
9
+ const credentials_1 = require("./credentials");
10
+ const getMaxAge = (res) => {
11
+ return res.expires_in * 1000;
12
+ };
13
+ const headerFormatter = (res) => {
14
+ return 'Bearer ' + res.access_token;
15
+ };
16
+ const interceptor = function (tokenProvider, authenticate) {
17
+ const getToken = tokenProvider.tokenCache(authenticate, { getMaxAge });
18
+ return tokenProvider({ getToken, headerFormatter });
19
+ };
20
+ const createServiceClient = (config) => {
21
+ const serviceClient = axios_1.default.create(config);
22
+ serviceClient.interceptors.request.use(interceptor(axios_token_interceptor_1.default, credentials_1.getServiceCredentials));
23
+ return serviceClient;
24
+ };
25
+ exports.createServiceClient = createServiceClient;
@@ -1,15 +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 {};
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, paymentReference: string): Promise<UtxoInvoice>;
14
+ }
15
+ export {};
@@ -1,21 +1,22 @@
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;
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, paymentReference) {
13
+ return this.client
14
+ .post(`/invoices`, {
15
+ network,
16
+ amount,
17
+ paymentReference,
18
+ })
19
+ .then((res) => res.data);
20
+ }
21
+ }
22
+ exports.TransactionsServiceClient = TransactionsServiceClient;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,10 +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
- });
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, '64283904a7ab475a6a2bc4b5');
8
+ console.log(data);
9
+ });
10
+ });
@@ -1,11 +1,11 @@
1
- import { AxiosInstance } from 'axios';
2
- interface User {
3
- id: string;
4
- email: string;
5
- }
6
- export declare class UsersServiceClient {
7
- client: AxiosInstance;
8
- constructor();
9
- findOrInitialize(email: string): Promise<User>;
10
- }
11
- export {};
1
+ import { AxiosInstance } from 'axios';
2
+ interface User {
3
+ id: string;
4
+ email: string;
5
+ }
6
+ export declare class UsersServiceClient {
7
+ client: AxiosInstance;
8
+ constructor();
9
+ findOrInitialize(email: string): Promise<User>;
10
+ }
11
+ export {};
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsersServiceClient = void 0;
4
- const config_1 = require("./config");
5
- const serviceClient_1 = require("./serviceClient");
6
- class UsersServiceClient {
7
- constructor() {
8
- this.client = (0, serviceClient_1.createServiceClient)({
9
- baseURL: config_1.config.usersServiceEndpoint,
10
- });
11
- }
12
- async findOrInitialize(email) {
13
- return this.client
14
- .post(`/find-or-initialize`, {
15
- email,
16
- })
17
- .then((res) => res.data);
18
- }
19
- }
20
- exports.UsersServiceClient = UsersServiceClient;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsersServiceClient = void 0;
4
+ const config_1 = require("./config");
5
+ const serviceClient_1 = require("./serviceClient");
6
+ class UsersServiceClient {
7
+ constructor() {
8
+ this.client = (0, serviceClient_1.createServiceClient)({
9
+ baseURL: config_1.config.usersServiceEndpoint,
10
+ });
11
+ }
12
+ async findOrInitialize(email) {
13
+ return this.client
14
+ .post(`/find-or-initialize`, {
15
+ email,
16
+ })
17
+ .then((res) => res.data);
18
+ }
19
+ }
20
+ exports.UsersServiceClient = UsersServiceClient;
@@ -1,39 +1,39 @@
1
- import { AxiosInstance } from 'axios';
2
- export declare type Verification = {
3
- id: string;
4
- userId: string;
5
- identity: {
6
- country?: string;
7
- status: string;
8
- updatedAt: string;
9
- user?: {
10
- firstName?: string;
11
- lastName?: string;
12
- email?: string;
13
- completedAt?: string;
14
- dob?: string;
15
- phone?: string;
16
- address?: {
17
- street: string;
18
- street2: string;
19
- city: string;
20
- subdivision: string;
21
- postalCode: string;
22
- countryCode: string;
23
- };
24
- };
25
- };
26
- bankAccount: {
27
- status: string;
28
- payableTypes: {
29
- country: string;
30
- type: string;
31
- provider: string;
32
- }[];
33
- };
34
- };
35
- export declare class VerificationServiceClient {
36
- client: AxiosInstance;
37
- constructor();
38
- getUserVerification(userId: string): Promise<Verification>;
39
- }
1
+ import { AxiosInstance } from 'axios';
2
+ export declare type Verification = {
3
+ id: string;
4
+ userId: string;
5
+ identity: {
6
+ country?: string;
7
+ status: string;
8
+ updatedAt: string;
9
+ user?: {
10
+ firstName?: string;
11
+ lastName?: string;
12
+ email?: string;
13
+ completedAt?: string;
14
+ dob?: string;
15
+ phone?: string;
16
+ address?: {
17
+ street: string;
18
+ street2: string;
19
+ city: string;
20
+ subdivision: string;
21
+ postalCode: string;
22
+ countryCode: string;
23
+ };
24
+ };
25
+ };
26
+ bankAccount: {
27
+ status: string;
28
+ payableTypes: {
29
+ country: string;
30
+ type: string;
31
+ provider: string;
32
+ }[];
33
+ };
34
+ };
35
+ export declare class VerificationServiceClient {
36
+ client: AxiosInstance;
37
+ constructor();
38
+ getUserVerification(userId: string): Promise<Verification>;
39
+ }
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VerificationServiceClient = void 0;
4
- const config_1 = require("./config");
5
- const serviceClient_1 = require("./serviceClient");
6
- class VerificationServiceClient {
7
- constructor() {
8
- this.client = (0, serviceClient_1.createServiceClient)({
9
- baseURL: config_1.config.verificationServiceEndpoint,
10
- });
11
- }
12
- async getUserVerification(userId) {
13
- return this.client.get(`/user/${userId}`).then((res) => res.data);
14
- }
15
- }
16
- exports.VerificationServiceClient = VerificationServiceClient;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerificationServiceClient = void 0;
4
+ const config_1 = require("./config");
5
+ const serviceClient_1 = require("./serviceClient");
6
+ class VerificationServiceClient {
7
+ constructor() {
8
+ this.client = (0, serviceClient_1.createServiceClient)({
9
+ baseURL: config_1.config.verificationServiceEndpoint,
10
+ });
11
+ }
12
+ async getUserVerification(userId) {
13
+ return this.client.get(`/user/${userId}`).then((res) => res.data);
14
+ }
15
+ }
16
+ exports.VerificationServiceClient = VerificationServiceClient;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const verificationServiceClient_1 = require("./verificationServiceClient");
4
- describe('VerificationServiceClient', () => {
5
- const client = new verificationServiceClient_1.VerificationServiceClient();
6
- it('should work', async () => {
7
- const data = await client.getUserVerification('641ae3aba7ab47603703e68a');
8
- console.log(data);
9
- });
10
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const verificationServiceClient_1 = require("./verificationServiceClient");
4
+ describe('VerificationServiceClient', () => {
5
+ const client = new verificationServiceClient_1.VerificationServiceClient();
6
+ it('should work', async () => {
7
+ const data = await client.getUserVerification('641ae3aba7ab47603703e68a');
8
+ console.log(data);
9
+ });
10
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/service-client",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Service client",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "coverageDirectory": "../coverage",
48
48
  "testEnvironment": "node"
49
49
  },
50
- "gitHead": "0bfb13ec3ac4e01ed2fe999468be222ddcf0ca33"
50
+ "gitHead": "db273605ccf80b57c595b1b6bcfa503d2d9db91c"
51
51
  }