@spritz-finance/service-client 0.2.64 → 0.2.65
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 +14 -0
- package/lib/config.js +54 -0
- package/lib/credentials.d.ts +1 -0
- package/lib/credentials.js +49 -0
- package/lib/exchangeRatesServiceClient.d.ts +12 -0
- package/lib/exchangeRatesServiceClient.js +23 -0
- package/lib/graphClient.d.ts +15 -0
- package/lib/graphClient.js +24 -0
- package/lib/graphClient.test.d.ts +1 -0
- package/lib/graphClient.test.js +29 -0
- package/lib/growthServiceClient.d.ts +6 -0
- package/lib/growthServiceClient.js +18 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +22 -0
- package/lib/liabilitiesServiceClient.d.ts +214 -0
- package/lib/liabilitiesServiceClient.js +112 -0
- package/lib/lib/graphClient/generated.d.ts +1811 -0
- package/lib/lib/graphClient/generated.js +203 -0
- package/lib/params.d.ts +2 -0
- package/lib/params.js +22 -0
- package/lib/payableAccountsServiceClient.d.ts +72 -0
- package/lib/payableAccountsServiceClient.js +52 -0
- package/lib/serviceClient.d.ts +2 -0
- package/lib/serviceClient.js +25 -0
- package/lib/transactionsServiceClient.d.ts +32 -0
- package/lib/transactionsServiceClient.js +36 -0
- package/lib/transactionsServiceClient.test.d.ts +1 -0
- package/lib/transactionsServiceClient.test.js +10 -0
- package/lib/usersServiceClient.d.ts +28 -0
- package/lib/usersServiceClient.js +40 -0
- package/lib/verificationServiceClient.d.ts +60 -0
- package/lib/verificationServiceClient.js +19 -0
- package/lib/verificationServiceClient.test.d.ts +1 -0
- package/lib/verificationServiceClient.test.js +10 -0
- package/package.json +2 -1
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface GraphClientConfig {
|
|
2
|
+
env: string;
|
|
3
|
+
authEndpoint: string;
|
|
4
|
+
graphEndpoint: string;
|
|
5
|
+
verificationServiceEndpoint: string;
|
|
6
|
+
transactionsServiceEndpoint: string;
|
|
7
|
+
usersServiceEndpoint: string;
|
|
8
|
+
liabilitiesServiceEndpoint: string;
|
|
9
|
+
payableAccountsServiceEndpoint: string;
|
|
10
|
+
growthServiceEndpoint: string;
|
|
11
|
+
exchangeRatesServiceEndpoint: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const config: GraphClientConfig;
|
|
14
|
+
export {};
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
liabilitiesServiceEndpoint: 'https://api-dev.spritz.finance/liabilities',
|
|
15
|
+
payableAccountsServiceEndpoint: 'https://api-dev.spritz.finance/payable-accounts',
|
|
16
|
+
growthServiceEndpoint: 'https://api-dev.spritz.finance/growth',
|
|
17
|
+
exchangeRatesServiceEndpoint: 'https://api-dev.spritz.finance/exchange-rates',
|
|
18
|
+
},
|
|
19
|
+
test: {
|
|
20
|
+
env: 'staging',
|
|
21
|
+
authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
|
|
22
|
+
graphEndpoint: 'https://api-staging.spritz.finance/router/graph',
|
|
23
|
+
verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
|
|
24
|
+
transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
|
|
25
|
+
usersServiceEndpoint: 'https://api-staging.spritz.finance/users',
|
|
26
|
+
liabilitiesServiceEndpoint: 'https://api-staging.spritz.finance/liabilities',
|
|
27
|
+
payableAccountsServiceEndpoint: 'https://api-staging.spritz.finance/payable-accounts',
|
|
28
|
+
growthServiceEndpoint: 'https://api-staging.spritz.finance/growth',
|
|
29
|
+
exchangeRatesServiceEndpoint: 'https://api-staging.spritz.finance/exchange-rates',
|
|
30
|
+
},
|
|
31
|
+
staging: {
|
|
32
|
+
authEndpoint: 'https://auth-staging.spritz.finance/oauth2/token',
|
|
33
|
+
graphEndpoint: 'https://api-staging.spritz.finance/router/graph',
|
|
34
|
+
verificationServiceEndpoint: 'https://api-staging.spritz.finance/verification',
|
|
35
|
+
transactionsServiceEndpoint: 'https://api-staging.spritz.finance/transactions',
|
|
36
|
+
usersServiceEndpoint: 'https://api-staging.spritz.finance/users',
|
|
37
|
+
liabilitiesServiceEndpoint: 'https://api-staging.spritz.finance/liabilities',
|
|
38
|
+
payableAccountsServiceEndpoint: 'https://api-staging.spritz.finance/payable-accounts',
|
|
39
|
+
growthServiceEndpoint: 'https://api-staging.spritz.finance/growth',
|
|
40
|
+
exchangeRatesServiceEndpoint: 'https://api-staging.spritz.finance/exchange-rates',
|
|
41
|
+
},
|
|
42
|
+
production: {
|
|
43
|
+
authEndpoint: 'https://auth.spritz.finance/oauth2/token',
|
|
44
|
+
graphEndpoint: 'https://api.spritz.finance/graphql',
|
|
45
|
+
verificationServiceEndpoint: 'https://api.spritz.finance/verification',
|
|
46
|
+
transactionsServiceEndpoint: 'https://api.spritz.finance/transactions',
|
|
47
|
+
usersServiceEndpoint: 'https://api.spritz.finance/users',
|
|
48
|
+
liabilitiesServiceEndpoint: 'https://api.spritz.finance/liabilities',
|
|
49
|
+
payableAccountsServiceEndpoint: 'https://api.spritz.finance/payable-accounts',
|
|
50
|
+
growthServiceEndpoint: 'https://api.spritz.finance/growth',
|
|
51
|
+
exchangeRatesServiceEndpoint: 'https://api.spritz.finance/exchange-rates',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
exports.config = (0, config_1.setupEnvConfig)(envConfigs);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getServiceCredentials: () => Promise<any>;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export interface ExchangeRate {
|
|
3
|
+
base: string;
|
|
4
|
+
target: string;
|
|
5
|
+
rate: number;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class ExchangeRatesServiceClient {
|
|
9
|
+
client: AxiosInstance;
|
|
10
|
+
constructor();
|
|
11
|
+
getLatestRate(target: string, base?: string): Promise<ExchangeRate>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExchangeRatesServiceClient = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const serviceClient_1 = require("./serviceClient");
|
|
6
|
+
class ExchangeRatesServiceClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.client = (0, serviceClient_1.createServiceClient)({
|
|
9
|
+
baseURL: config_1.config.exchangeRatesServiceEndpoint,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async getLatestRate(target, base = 'USD') {
|
|
13
|
+
return this.client
|
|
14
|
+
.get(`/latest`, {
|
|
15
|
+
params: {
|
|
16
|
+
target,
|
|
17
|
+
base,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
.then((res) => res.data);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ExchangeRatesServiceClient = ExchangeRatesServiceClient;
|
|
@@ -0,0 +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 {};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +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");
|
|
8
|
+
const query = (0, graphql_tag_1.default) `
|
|
9
|
+
query ASDF {
|
|
10
|
+
getUsers {
|
|
11
|
+
email
|
|
12
|
+
}
|
|
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
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrowthServiceClient = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const serviceClient_1 = require("./serviceClient");
|
|
6
|
+
class GrowthServiceClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.client = (0, serviceClient_1.createServiceClient)({
|
|
9
|
+
baseURL: config_1.config.growthServiceEndpoint,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async getUserReferrer(userId) {
|
|
13
|
+
return this.client
|
|
14
|
+
.get(`/referrals/referrer/${userId}`)
|
|
15
|
+
.then((res) => res.data);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.GrowthServiceClient = GrowthServiceClient;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './graphClient';
|
|
2
|
+
export * from './credentials';
|
|
3
|
+
export * from './serviceClient';
|
|
4
|
+
export * from './verificationServiceClient';
|
|
5
|
+
export * from './transactionsServiceClient';
|
|
6
|
+
export * from './usersServiceClient';
|
|
7
|
+
export * from './growthServiceClient';
|
|
8
|
+
export * from './liabilitiesServiceClient';
|
|
9
|
+
export * from './payableAccountsServiceClient';
|
|
10
|
+
export * from './exchangeRatesServiceClient';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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);
|
|
19
|
+
__exportStar(require("./growthServiceClient"), exports);
|
|
20
|
+
__exportStar(require("./liabilitiesServiceClient"), exports);
|
|
21
|
+
__exportStar(require("./payableAccountsServiceClient"), exports);
|
|
22
|
+
__exportStar(require("./exchangeRatesServiceClient"), exports);
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { CheckbookUser, CreateDirectPaymentInput, DirectPayment } from './lib/graphClient/generated';
|
|
3
|
+
import { ExternalBillInput } from './payableAccountsServiceClient';
|
|
4
|
+
export declare enum RewardProvider {
|
|
5
|
+
INTERNAL = "INTERNAL",
|
|
6
|
+
REFERRAL_ROCK = "REFERRAL_ROCK",
|
|
7
|
+
GROWSURF = "GROWSURF"
|
|
8
|
+
}
|
|
9
|
+
export declare enum RewardTransactionType {
|
|
10
|
+
CREDIT = "CREDIT",
|
|
11
|
+
DEBIT = "DEBIT"
|
|
12
|
+
}
|
|
13
|
+
export declare enum RewardCreditSource {
|
|
14
|
+
REFERRER_REWARD = "REFERRER_REWARD",
|
|
15
|
+
REFERRAL_REWARD = "REFERRAL_REWARD",
|
|
16
|
+
CONTEST = "CONTEST",
|
|
17
|
+
REFUND = "REFUND",
|
|
18
|
+
OTHER = "OTHER",
|
|
19
|
+
REVENUE_SHARE = "REVENUE_SHARE"
|
|
20
|
+
}
|
|
21
|
+
declare type Payment = {
|
|
22
|
+
_id: string;
|
|
23
|
+
accountId: string;
|
|
24
|
+
amount: number;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
directPaymentId: string;
|
|
27
|
+
feeAmount: number;
|
|
28
|
+
id: string;
|
|
29
|
+
paymentProvider: string;
|
|
30
|
+
rewardsAmount: number;
|
|
31
|
+
status: string;
|
|
32
|
+
subscriptionId: string | null;
|
|
33
|
+
type: string;
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
userId: string;
|
|
36
|
+
};
|
|
37
|
+
export declare type CheckbookCardResponse = {
|
|
38
|
+
userId: string;
|
|
39
|
+
externalId: string;
|
|
40
|
+
mask: string;
|
|
41
|
+
renderSecret: string;
|
|
42
|
+
number: string;
|
|
43
|
+
cvv: string;
|
|
44
|
+
expiryYear: string;
|
|
45
|
+
expiryMonth: string;
|
|
46
|
+
address: {
|
|
47
|
+
line_1: string;
|
|
48
|
+
city: string;
|
|
49
|
+
state: string;
|
|
50
|
+
zip: string;
|
|
51
|
+
};
|
|
52
|
+
phone: string;
|
|
53
|
+
email: string;
|
|
54
|
+
holder: string;
|
|
55
|
+
};
|
|
56
|
+
export interface RelatedCredit {
|
|
57
|
+
creditId: string;
|
|
58
|
+
amountSpent: number;
|
|
59
|
+
order: number;
|
|
60
|
+
}
|
|
61
|
+
export interface RewardTransaction {
|
|
62
|
+
_id: string;
|
|
63
|
+
amount: number;
|
|
64
|
+
remainingSpend: number;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
id: string;
|
|
67
|
+
nonce: number;
|
|
68
|
+
type: RewardTransactionType;
|
|
69
|
+
source?: RewardCreditSource;
|
|
70
|
+
provider?: RewardProvider;
|
|
71
|
+
relatedCredits?: RelatedCredit[];
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
userId: string;
|
|
74
|
+
context?: string;
|
|
75
|
+
}
|
|
76
|
+
declare type TEntityTypes = 'individual' | 'c_corporation' | 's_corporation' | 'llc' | 'partnership' | 'sole_proprietorship' | 'receive_only';
|
|
77
|
+
interface IEntityIndividual {
|
|
78
|
+
first_name: string | null;
|
|
79
|
+
last_name: string | null;
|
|
80
|
+
phone: string | null;
|
|
81
|
+
email: string | null;
|
|
82
|
+
dob: string | null;
|
|
83
|
+
ssn?: string;
|
|
84
|
+
}
|
|
85
|
+
interface IEntityAddress {
|
|
86
|
+
line1: string | null;
|
|
87
|
+
line2: string | null;
|
|
88
|
+
city: string | null;
|
|
89
|
+
state: string | null;
|
|
90
|
+
zip: string | null;
|
|
91
|
+
}
|
|
92
|
+
interface IEntityCorporationOwner {
|
|
93
|
+
first_name: string | null;
|
|
94
|
+
last_name: string | null;
|
|
95
|
+
phone: string | null;
|
|
96
|
+
email: string | null;
|
|
97
|
+
dob: string | null;
|
|
98
|
+
address: IEntityAddress;
|
|
99
|
+
}
|
|
100
|
+
interface IEntityCorporation {
|
|
101
|
+
name: string | null;
|
|
102
|
+
dba: string | null;
|
|
103
|
+
ein: string | null;
|
|
104
|
+
owners: IEntityCorporationOwner[];
|
|
105
|
+
}
|
|
106
|
+
interface IEntityReceiveOnly {
|
|
107
|
+
name: string;
|
|
108
|
+
phone: string | null;
|
|
109
|
+
email: string | null;
|
|
110
|
+
}
|
|
111
|
+
declare type TEntityCapabilities = 'payments:send' | 'payments:receive' | 'payments:limited-send' | 'data:retrieve' | 'data:sync';
|
|
112
|
+
declare type TEntityStatuses = 'active' | 'incomplete' | 'disabled';
|
|
113
|
+
interface IResourceError {
|
|
114
|
+
type: string;
|
|
115
|
+
code: number;
|
|
116
|
+
sub_type: string;
|
|
117
|
+
message: string;
|
|
118
|
+
}
|
|
119
|
+
interface IEntity {
|
|
120
|
+
id: string;
|
|
121
|
+
type: TEntityTypes;
|
|
122
|
+
individual: IEntityIndividual | null;
|
|
123
|
+
corporation: IEntityCorporation | null;
|
|
124
|
+
receive_only: IEntityReceiveOnly | null;
|
|
125
|
+
capabilities: TEntityCapabilities[];
|
|
126
|
+
available_capabilities: TEntityCapabilities[];
|
|
127
|
+
pending_capabilities: TEntityCapabilities[];
|
|
128
|
+
address: IEntityAddress;
|
|
129
|
+
status: TEntityStatuses;
|
|
130
|
+
error: IResourceError | null;
|
|
131
|
+
metadata: {} | null;
|
|
132
|
+
created_at: string;
|
|
133
|
+
updated_at: string;
|
|
134
|
+
}
|
|
135
|
+
interface MethodFiEntity extends IEntity {
|
|
136
|
+
userId: string;
|
|
137
|
+
}
|
|
138
|
+
interface IEntityCreateOpts {
|
|
139
|
+
type: TEntityTypes;
|
|
140
|
+
address?: IEntityAddress | null;
|
|
141
|
+
metadata?: {};
|
|
142
|
+
}
|
|
143
|
+
interface IEntityCorporationOwner {
|
|
144
|
+
first_name: string | null;
|
|
145
|
+
last_name: string | null;
|
|
146
|
+
phone: string | null;
|
|
147
|
+
email: string | null;
|
|
148
|
+
dob: string | null;
|
|
149
|
+
address: IEntityAddress;
|
|
150
|
+
}
|
|
151
|
+
interface IEntityCorporation {
|
|
152
|
+
name: string | null;
|
|
153
|
+
dba: string | null;
|
|
154
|
+
ein: string | null;
|
|
155
|
+
owners: IEntityCorporationOwner[];
|
|
156
|
+
}
|
|
157
|
+
export interface ICorporationCreateOpts extends IEntityCreateOpts {
|
|
158
|
+
type: 'c_corporation' | 's_corporation' | 'llc' | 'partnership' | 'sole_proprietorship';
|
|
159
|
+
corporation: Partial<IEntityCorporation>;
|
|
160
|
+
}
|
|
161
|
+
declare type CardTransaction = {
|
|
162
|
+
amount: number;
|
|
163
|
+
timestamp: Date;
|
|
164
|
+
description: string;
|
|
165
|
+
};
|
|
166
|
+
export declare type CreateEntityParams = Pick<IEntity, 'type' | 'individual' | 'corporation' | 'address'> & {
|
|
167
|
+
userId: string;
|
|
168
|
+
};
|
|
169
|
+
export declare type CreateCheckbookUserParams = {
|
|
170
|
+
email: string;
|
|
171
|
+
firstName: string;
|
|
172
|
+
lastName: string;
|
|
173
|
+
userId: string;
|
|
174
|
+
phone: string;
|
|
175
|
+
dob: string;
|
|
176
|
+
address: {
|
|
177
|
+
street?: string;
|
|
178
|
+
street2?: string;
|
|
179
|
+
city?: string;
|
|
180
|
+
subdivision?: string;
|
|
181
|
+
postalCode?: string;
|
|
182
|
+
countryCode?: string;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
export declare enum PaymentSource {
|
|
186
|
+
Web = "Web",
|
|
187
|
+
Mobile = "Mobile",
|
|
188
|
+
Integrator = "Integrator",
|
|
189
|
+
PaymentAddress = "PaymentAddress",
|
|
190
|
+
Subscription = "Subscription"
|
|
191
|
+
}
|
|
192
|
+
export interface CreateDirectPaymentArgs extends CreateDirectPaymentInput {
|
|
193
|
+
userId: string;
|
|
194
|
+
noFees?: boolean;
|
|
195
|
+
source?: PaymentSource;
|
|
196
|
+
}
|
|
197
|
+
export declare class LiabilitiesServiceClient {
|
|
198
|
+
client: AxiosInstance;
|
|
199
|
+
constructor();
|
|
200
|
+
getRewardTransaction(transactionId: string): Promise<RewardTransaction>;
|
|
201
|
+
createMethodFiEntity(args: CreateEntityParams): Promise<MethodFiEntity>;
|
|
202
|
+
getMethodFiEntity(userId: string): Promise<MethodFiEntity>;
|
|
203
|
+
createCheckbookUser(args: CreateCheckbookUserParams): Promise<CheckbookUser>;
|
|
204
|
+
getCheckbookUser(userId: string): Promise<CheckbookUser>;
|
|
205
|
+
createCheckbookVirtualCard(userId: string): Promise<CheckbookCardResponse>;
|
|
206
|
+
createUSBillFromAccountNumber(userId: string, accountNumber: string, merchantId: string): Promise<ExternalBillInput>;
|
|
207
|
+
getVirtualCardBalance(cardExternalId: string, userId: string): Promise<number>;
|
|
208
|
+
getVirtualCardTransactions(cardExternalId: string, userId: string): Promise<CardTransaction[]>;
|
|
209
|
+
canUserMakeTestPayment(userId: string): Promise<boolean>;
|
|
210
|
+
createDirectPayment(args: CreateDirectPaymentArgs): Promise<DirectPayment>;
|
|
211
|
+
validateDirectPayment(args: CreateDirectPaymentArgs): Promise<DirectPayment>;
|
|
212
|
+
getValidPaymentsForAccount(accountId: string): Promise<Payment[]>;
|
|
213
|
+
}
|
|
214
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiabilitiesServiceClient = exports.PaymentSource = exports.RewardCreditSource = exports.RewardTransactionType = exports.RewardProvider = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const serviceClient_1 = require("./serviceClient");
|
|
6
|
+
var RewardProvider;
|
|
7
|
+
(function (RewardProvider) {
|
|
8
|
+
RewardProvider["INTERNAL"] = "INTERNAL";
|
|
9
|
+
RewardProvider["REFERRAL_ROCK"] = "REFERRAL_ROCK";
|
|
10
|
+
RewardProvider["GROWSURF"] = "GROWSURF";
|
|
11
|
+
})(RewardProvider = exports.RewardProvider || (exports.RewardProvider = {}));
|
|
12
|
+
var RewardTransactionType;
|
|
13
|
+
(function (RewardTransactionType) {
|
|
14
|
+
RewardTransactionType["CREDIT"] = "CREDIT";
|
|
15
|
+
RewardTransactionType["DEBIT"] = "DEBIT";
|
|
16
|
+
})(RewardTransactionType = exports.RewardTransactionType || (exports.RewardTransactionType = {}));
|
|
17
|
+
var RewardCreditSource;
|
|
18
|
+
(function (RewardCreditSource) {
|
|
19
|
+
RewardCreditSource["REFERRER_REWARD"] = "REFERRER_REWARD";
|
|
20
|
+
RewardCreditSource["REFERRAL_REWARD"] = "REFERRAL_REWARD";
|
|
21
|
+
RewardCreditSource["CONTEST"] = "CONTEST";
|
|
22
|
+
RewardCreditSource["REFUND"] = "REFUND";
|
|
23
|
+
RewardCreditSource["OTHER"] = "OTHER";
|
|
24
|
+
RewardCreditSource["REVENUE_SHARE"] = "REVENUE_SHARE";
|
|
25
|
+
})(RewardCreditSource = exports.RewardCreditSource || (exports.RewardCreditSource = {}));
|
|
26
|
+
var PaymentSource;
|
|
27
|
+
(function (PaymentSource) {
|
|
28
|
+
PaymentSource["Web"] = "Web";
|
|
29
|
+
PaymentSource["Mobile"] = "Mobile";
|
|
30
|
+
PaymentSource["Integrator"] = "Integrator";
|
|
31
|
+
PaymentSource["PaymentAddress"] = "PaymentAddress";
|
|
32
|
+
PaymentSource["Subscription"] = "Subscription";
|
|
33
|
+
})(PaymentSource = exports.PaymentSource || (exports.PaymentSource = {}));
|
|
34
|
+
class LiabilitiesServiceClient {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.client = (0, serviceClient_1.createServiceClient)({
|
|
37
|
+
baseURL: config_1.config.liabilitiesServiceEndpoint,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async getRewardTransaction(transactionId) {
|
|
41
|
+
return this.client
|
|
42
|
+
.get(`/reward-transactions/${transactionId}`)
|
|
43
|
+
.then((res) => res.data);
|
|
44
|
+
}
|
|
45
|
+
async createMethodFiEntity(args) {
|
|
46
|
+
return this.client
|
|
47
|
+
.post(`/methodFi/entity2`, args)
|
|
48
|
+
.then((res) => res.data);
|
|
49
|
+
}
|
|
50
|
+
async getMethodFiEntity(userId) {
|
|
51
|
+
return this.client
|
|
52
|
+
.get(`/methodFi/entity/user/${userId}`)
|
|
53
|
+
.then((res) => res.data);
|
|
54
|
+
}
|
|
55
|
+
async createCheckbookUser(args) {
|
|
56
|
+
return this.client
|
|
57
|
+
.post(`/checkbook/user`, args)
|
|
58
|
+
.then((res) => res.data);
|
|
59
|
+
}
|
|
60
|
+
async getCheckbookUser(userId) {
|
|
61
|
+
return this.client
|
|
62
|
+
.get(`/checkbook/user/${userId}`)
|
|
63
|
+
.then((res) => res.data);
|
|
64
|
+
}
|
|
65
|
+
async createCheckbookVirtualCard(userId) {
|
|
66
|
+
return this.client
|
|
67
|
+
.post(`/virtual-card/create/${userId}`)
|
|
68
|
+
.then((res) => res.data);
|
|
69
|
+
}
|
|
70
|
+
async createUSBillFromAccountNumber(userId, accountNumber, merchantId) {
|
|
71
|
+
return this.client
|
|
72
|
+
.post(`/methodFi/bill/user/${userId}`, {
|
|
73
|
+
accountNumber,
|
|
74
|
+
merchantId,
|
|
75
|
+
})
|
|
76
|
+
.then((res) => res.data);
|
|
77
|
+
}
|
|
78
|
+
async getVirtualCardBalance(cardExternalId, userId) {
|
|
79
|
+
return this.client
|
|
80
|
+
.get(`/virtual-card/card/${cardExternalId}/balance?userId=${userId}`)
|
|
81
|
+
.then((res) => res.data);
|
|
82
|
+
}
|
|
83
|
+
async getVirtualCardTransactions(cardExternalId, userId) {
|
|
84
|
+
return this.client
|
|
85
|
+
.get(`/virtual-card/card/${cardExternalId}/transactions?userId=${userId}`)
|
|
86
|
+
.then((res) => res.data);
|
|
87
|
+
}
|
|
88
|
+
async canUserMakeTestPayment(userId) {
|
|
89
|
+
return this.client
|
|
90
|
+
.get(`/direct-payments/test-payment-available/user/${userId}`)
|
|
91
|
+
.then((res) => res.data);
|
|
92
|
+
}
|
|
93
|
+
async createDirectPayment(args) {
|
|
94
|
+
return this.client
|
|
95
|
+
.post(`/direct-payments`, args)
|
|
96
|
+
.then((res) => res.data);
|
|
97
|
+
}
|
|
98
|
+
async validateDirectPayment(args) {
|
|
99
|
+
return this.client
|
|
100
|
+
.post(`/direct-payments`, {
|
|
101
|
+
...args,
|
|
102
|
+
validateOnly: true,
|
|
103
|
+
})
|
|
104
|
+
.then((res) => res.data);
|
|
105
|
+
}
|
|
106
|
+
async getValidPaymentsForAccount(accountId) {
|
|
107
|
+
return this.client
|
|
108
|
+
.get(`/payments/valid-payments/account/${accountId}`)
|
|
109
|
+
.then((res) => res.data);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.LiabilitiesServiceClient = LiabilitiesServiceClient;
|