@cuenca-mx/cuenca-js 1.2.2 → 2.0.0-dev1
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/CHANGELOG.md +19 -0
- package/build/data-2b32d8f3.mjs +634 -0
- package/build/data-70e6af8d.cjs +680 -0
- package/build/dts/client/client.d.ts +86 -0
- package/build/dts/client/index.d.ts +1 -0
- package/build/dts/errors.d.ts +25 -0
- package/build/dts/helpers/case.d.ts +5 -0
- package/build/dts/helpers/data.d.ts +3 -0
- package/build/dts/helpers/env.d.ts +7 -0
- package/build/dts/index.d.ts +55 -0
- package/build/dts/jwt.d.ts +8 -0
- package/build/dts/models/account.d.ts +12 -0
- package/build/dts/models/alert.d.ts +32 -0
- package/build/dts/models/apiKey.d.ts +13 -0
- package/build/dts/models/arpc.d.ts +10 -0
- package/build/dts/models/balanceEntry.d.ts +15 -0
- package/build/dts/models/baseUser.d.ts +23 -0
- package/build/dts/models/billPayment.d.ts +10 -0
- package/build/dts/models/bridgeAccount.d.ts +27 -0
- package/build/dts/models/bridgeBankAccount.d.ts +16 -0
- package/build/dts/models/bridgeClabe.d.ts +12 -0
- package/build/dts/models/bridgeTransaction.d.ts +32 -0
- package/build/dts/models/card.d.ts +19 -0
- package/build/dts/models/cardActivation.d.ts +12 -0
- package/build/dts/models/cardTransaction.d.ts +15 -0
- package/build/dts/models/cardValidation.d.ts +19 -0
- package/build/dts/models/commission.d.ts +9 -0
- package/build/dts/models/deposit.d.ts +11 -0
- package/build/dts/models/file.d.ts +10 -0
- package/build/dts/models/fraudFundsTransfer.d.ts +9 -0
- package/build/dts/models/index.d.ts +41 -0
- package/build/dts/models/kycValidations.d.ts +22 -0
- package/build/dts/models/legalPerson.d.ts +10 -0
- package/build/dts/models/loginToken.d.ts +7 -0
- package/build/dts/models/operator.d.ts +17 -0
- package/build/dts/models/operatorLogin.d.ts +7 -0
- package/build/dts/models/partner.d.ts +25 -0
- package/build/dts/models/postalCode.d.ts +14 -0
- package/build/dts/models/saving.d.ts +11 -0
- package/build/dts/models/serviceProvider.d.ts +10 -0
- package/build/dts/models/session.d.ts +14 -0
- package/build/dts/models/statement.d.ts +10 -0
- package/build/dts/models/transaction.d.ts +7 -0
- package/build/dts/models/transactionalProfile.d.ts +14 -0
- package/build/dts/models/transfer.d.ts +15 -0
- package/build/dts/models/user.d.ts +42 -0
- package/build/dts/models/userCredential.d.ts +10 -0
- package/build/dts/models/userLogin.d.ts +9 -0
- package/build/dts/models/userReport.d.ts +48 -0
- package/build/dts/models/userTosAgreement.d.ts +13 -0
- package/build/dts/models/verification.d.ts +12 -0
- package/build/dts/models/wallet.d.ts +8 -0
- package/build/dts/models/walletTransaction.d.ts +10 -0
- package/build/dts/models/whatsAppTransfer.d.ts +16 -0
- package/build/dts/requests/addressUpdateRequest.d.ts +17 -0
- package/build/dts/requests/alertRequest.d.ts +31 -0
- package/build/dts/requests/apiKeyRequest.d.ts +9 -0
- package/build/dts/requests/arpcRequest.d.ts +16 -0
- package/build/dts/requests/base.d.ts +2 -0
- package/build/dts/requests/cardActivationRequest.d.ts +11 -0
- package/build/dts/requests/cardRequest.d.ts +18 -0
- package/build/dts/requests/cardValidationRequest.d.ts +15 -0
- package/build/dts/requests/fileUploadRequest.d.ts +12 -0
- package/build/dts/requests/fraudFundsTransferRequest.d.ts +13 -0
- package/build/dts/requests/index.d.ts +28 -0
- package/build/dts/requests/kycValidationsRequest.d.ts +10 -0
- package/build/dts/requests/legalPersonRequest.d.ts +33 -0
- package/build/dts/requests/operatorLoginRequest.d.ts +9 -0
- package/build/dts/requests/operatorRequest.d.ts +24 -0
- package/build/dts/requests/partnerUserRequest.d.ts +100 -0
- package/build/dts/requests/reportGenerateRequest.d.ts +8 -0
- package/build/dts/requests/savingRequest.d.ts +11 -0
- package/build/dts/requests/sessionRequest.d.ts +12 -0
- package/build/dts/requests/tosUpdateRequest.d.ts +11 -0
- package/build/dts/requests/transferRequest.d.ts +12 -0
- package/build/dts/requests/transferUpdateRequest.d.ts +8 -0
- package/build/dts/requests/userCredentialRequest.d.ts +15 -0
- package/build/dts/requests/userLoginRequest.d.ts +8 -0
- package/build/dts/requests/userReportCreateRequest.d.ts +9 -0
- package/build/dts/requests/userReportUpdateRequest.d.ts +28 -0
- package/build/dts/requests/userRequest.d.ts +39 -0
- package/build/dts/requests/verificationRequest.d.ts +17 -0
- package/build/dts/requests/walletTransactionRequest.d.ts +9 -0
- package/build/dts/resources/accounts.d.ts +33 -0
- package/build/dts/resources/alerts.d.ts +54 -0
- package/build/dts/resources/apiKeys.d.ts +63 -0
- package/build/dts/resources/arpc.d.ts +18 -0
- package/build/dts/resources/balanceEntries.d.ts +37 -0
- package/build/dts/resources/base.d.ts +135 -0
- package/build/dts/resources/billPayments.d.ts +34 -0
- package/build/dts/resources/bridgeAccounts.d.ts +49 -0
- package/build/dts/resources/bridgeBankAccounts.d.ts +33 -0
- package/build/dts/resources/bridgeClabes.d.ts +27 -0
- package/build/dts/resources/bridgeTransactions.d.ts +36 -0
- package/build/dts/resources/cardActivations.d.ts +19 -0
- package/build/dts/resources/cardTransactions.d.ts +34 -0
- package/build/dts/resources/cardValidations.d.ts +19 -0
- package/build/dts/resources/cards.d.ts +63 -0
- package/build/dts/resources/commissions.d.ts +34 -0
- package/build/dts/resources/deposits.d.ts +34 -0
- package/build/dts/resources/files.d.ts +30 -0
- package/build/dts/resources/fraudFundsTransfers.d.ts +18 -0
- package/build/dts/resources/index.d.ts +39 -0
- package/build/dts/resources/kycValidations.d.ts +53 -0
- package/build/dts/resources/legalPersons.d.ts +54 -0
- package/build/dts/resources/loginTokens.d.ts +17 -0
- package/build/dts/resources/operatorLogins.d.ts +19 -0
- package/build/dts/resources/operators.d.ts +54 -0
- package/build/dts/resources/partners.d.ts +54 -0
- package/build/dts/resources/postalCodes.d.ts +24 -0
- package/build/dts/resources/reports.d.ts +8 -0
- package/build/dts/resources/savings.d.ts +62 -0
- package/build/dts/resources/serviceProviders.d.ts +32 -0
- package/build/dts/resources/sessions.d.ts +43 -0
- package/build/dts/resources/statements.d.ts +44 -0
- package/build/dts/resources/transfers.d.ts +64 -0
- package/build/dts/resources/userCredentials.d.ts +30 -0
- package/build/dts/resources/userLogins.d.ts +28 -0
- package/build/dts/resources/userReports.d.ts +54 -0
- package/build/dts/resources/users.d.ts +56 -0
- package/build/dts/resources/usersTosAgreements.d.ts +16 -0
- package/build/dts/resources/verifications.d.ts +31 -0
- package/build/dts/resources/walletTransactions.d.ts +48 -0
- package/build/dts/resources/whatsAppTransfers.d.ts +34 -0
- package/build/dts/types/enums.d.ts +590 -0
- package/build/dts/types/identities/address.d.ts +25 -0
- package/build/dts/types/identities/alertLog.d.ts +11 -0
- package/build/dts/types/identities/audit.d.ts +10 -0
- package/build/dts/types/identities/businessDetails.d.ts +9 -0
- package/build/dts/types/identities/externalAccount.d.ts +8 -0
- package/build/dts/types/identities/index.d.ts +17 -0
- package/build/dts/types/identities/kycFile.d.ts +14 -0
- package/build/dts/types/identities/legalRepresentatives.d.ts +12 -0
- package/build/dts/types/identities/license.d.ts +10 -0
- package/build/dts/types/identities/moralOperation.d.ts +8 -0
- package/build/dts/types/identities/physicalPerson.d.ts +12 -0
- package/build/dts/types/identities/shareholderMoral.d.ts +12 -0
- package/build/dts/types/identities/shareholderPhysical.d.ts +9 -0
- package/build/dts/types/identities/tosAgreements.d.ts +10 -0
- package/build/dts/types/identities/transactionalProfileServices.d.ts +10 -0
- package/build/dts/types/identities/verificationError.d.ts +10 -0
- package/build/dts/types/identities/vulnerableActivity.d.ts +10 -0
- package/build/dts/types/index.d.ts +3 -0
- package/build/dts/types/queries/accountQuery.d.ts +4 -0
- package/build/dts/types/queries/alertQuery.d.ts +12 -0
- package/build/dts/types/queries/apiKeyQuery.d.ts +4 -0
- package/build/dts/types/queries/balanceEntryQuery.d.ts +5 -0
- package/build/dts/types/queries/billPaymentQuery.d.ts +4 -0
- package/build/dts/types/queries/bridgeAccountQuery.d.ts +4 -0
- package/build/dts/types/queries/bridgeBankAccountQuery.d.ts +4 -0
- package/build/dts/types/queries/bridgeQuery.d.ts +7 -0
- package/build/dts/types/queries/bridgeTransactionQuery.d.ts +6 -0
- package/build/dts/types/queries/cardTransactionQuery.d.ts +4 -0
- package/build/dts/types/queries/cardsQuery.d.ts +4 -0
- package/build/dts/types/queries/depositQuery.d.ts +5 -0
- package/build/dts/types/queries/index.d.ts +27 -0
- package/build/dts/types/queries/operatorQuery.d.ts +4 -0
- package/build/dts/types/queries/partnerQuery.d.ts +4 -0
- package/build/dts/types/queries/postalCodeQuery.d.ts +4 -0
- package/build/dts/types/queries/queryParams.d.ts +15 -0
- package/build/dts/types/queries/statementQuery.d.ts +6 -0
- package/build/dts/types/queries/transactionQuery.d.ts +4 -0
- package/build/dts/types/queries/transferQuery.d.ts +7 -0
- package/build/dts/types/queries/userQuery.d.ts +11 -0
- package/build/dts/types/queries/userReportQuery.d.ts +4 -0
- package/build/dts/types/queries/walletQuery.d.ts +4 -0
- package/build/dts/types/queries/walletTransactionQuery.d.ts +4 -0
- package/build/errors/index.cjs +10 -0
- package/build/errors/index.mjs +10 -1
- package/build/index.cjs +1373 -2885
- package/build/index.mjs +1375 -2886
- package/build/jwt/index.cjs +11 -8
- package/build/jwt/index.mjs +11 -8
- package/build/requests/index.cjs +9 -22
- package/build/requests/index.mjs +2 -26
- package/build/types/index.cjs +20 -56
- package/build/types/index.mjs +9 -34
- package/build/umd/cuenca.umd.js +1 -1
- package/build/vulnerableActivity-17f0ce66.mjs +278 -0
- package/build/vulnerableActivity-3cb7b0ed.cjs +299 -0
- package/build/walletTransactionRequest-7f10c2a2.mjs +496 -0
- package/build/walletTransactionRequest-dd13c569.cjs +529 -0
- package/errors/index.d.ts +1 -0
- package/jwt/index.d.ts +1 -0
- package/package.json +26 -8
- package/requests/index.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/build/data-1fd00e5c.mjs +0 -1199
- package/build/data-72c37b60.cjs +0 -1240
- package/build/vulnerableActivity-7cc1734f.cjs +0 -867
- package/build/vulnerableActivity-bd344332.mjs +0 -831
- package/build/walletTransactionRequest-05d5305a.mjs +0 -1512
- package/build/walletTransactionRequest-c6a5c64d.cjs +0 -1539
package/build/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { CuencaResponseException, CuencaException, NoResultFound, MultipleResultsFound, InvalidPassword } from './errors/index.mjs';
|
|
1
|
+
import Buffer, { Buffer as Buffer$1 } from 'buffer';
|
|
2
|
+
import { CuencaException, CuencaResponseException, NoResultFound, MultipleResultsFound, PaginationError, InvalidPassword } from './errors/index.mjs';
|
|
4
3
|
import { Jwt } from './jwt/index.mjs';
|
|
5
|
-
import { P as Phase, F as FileFormat,
|
|
6
|
-
import { A as AlertLog, a as Address, K as KYCFile, T as TOSAgreements,
|
|
7
|
-
import { A as AlertUpdateRequest, a as ApiKeyUpdateRequest, b as ArpcRequest, U as UserUpdateRequest, C as CardActivationRequest, c as CardRequest, d as CardUpdateRequest, e as CardValidationRequest, F as FraudFundsTransferRequest, K as KYCValidationsRequest, P as PartnerUserRequest, R as ReportGenerateRequest, S as SavingRequest,
|
|
4
|
+
import { P as Phase, F as FileFormat, c as coerceDatesWithDefaults, a as camelize, d as dateToUTC, C as CardStatus } from './data-2b32d8f3.mjs';
|
|
5
|
+
import { A as AlertLog, a as Address, K as KYCFile, T as TOSAgreements, L as LegalRepresentatives, b as TransactionalProfileServices, c as Audit, B as BusinessDetails, E as ExternalAccount, d as License, S as ShareholderMoral, V as VulnerableActivity, t as toParams, e as toQueryString, f as toParams$1, g as toQueryString$1, v as validateStatementQuery } from './vulnerableActivity-17f0ce66.mjs';
|
|
6
|
+
import { A as AlertUpdateRequest, a as ApiKeyUpdateRequest, b as ArpcRequest, U as UserUpdateRequest, C as CardActivationRequest, c as CardRequest, d as CardUpdateRequest, e as CardValidationRequest, F as FileUploadRequest, f as FraudFundsTransferRequest, K as KYCValidationsRequest, L as LegalPersonRequest, g as LegalPersonUpdateRequest, O as OperatorLoginRequest, h as OperatorRequest, i as OperatorUpdateRequest, P as PartnerUserRequest, R as ReportGenerateRequest, S as SavingRequest, j as SessionRequest, T as TransferRequest, k as TransferUpdateRequest, l as UserCredentialRequest, m as UserCredentialUpdateRequest, n as UserLoginRequest, o as UserReportCreateRequest, p as UserReportUpdateRequest, V as VerificationRequest, q as VerificationAttemptRequest, W as WalletTransactionRequest } from './walletTransactionRequest-7f10c2a2.mjs';
|
|
8
7
|
|
|
9
8
|
/* global window */
|
|
10
9
|
|
|
@@ -17,7 +16,139 @@ const isNode =
|
|
|
17
16
|
|
|
18
17
|
const runtimeEnv = { isBrowser, isNode };
|
|
19
18
|
|
|
20
|
-
const name="@cuenca-mx/cuenca-js";const version="
|
|
19
|
+
const name="@cuenca-mx/cuenca-js";const version="2.0.0-dev1";const description="Cuenca client for JS";const main="./build/index.cjs";const module="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const types="./build/dts/index.d.ts";const sideEffects=false;const files=["build/**/*","errors/**/*","jwt/**/*","requests/**/*","types/**/*"];const exports={".":{types:"./build/dts/index.d.ts","import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{types:"./build/dts/errors.d.ts","import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{types:"./build/dts/jwt.d.ts","import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{types:"./build/dts/requests/index.d.ts","import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{types:"./build/dts/types/index.d.ts","import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.2.0";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const engines={node:">=20"};const scripts={build:"rm -rf build/ tsconfig.tsbuildinfo && yarn rollup --config && yarn tsc -p tsconfig.json && yarn tsc-alias -p tsconfig.json --outDir build/dts",test:"vitest run --coverage",publish:"yarn build && yarn npm publish",dev:"rm -rf build/ && yarn rollup --config && yarn node ../example.cjs",example:"yarn node ../example.cjs"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1","@rollup/plugin-typescript":"^11.1.6","@vitest/coverage-v8":"^1.6.0",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2","tsc-alias":"^1.8.10",typescript:"^4.9.5","vite-tsconfig-paths":"^4.3.2",vitest:"^1.6.0"};const dependencies={buffer:"^6.0.3"};var pkg = {name:name,version:version,description:description,main:main,module:module,browser:browser,types:types,sideEffects:sideEffects,files:files,exports:exports,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,engines:engines,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
|
|
20
|
+
|
|
21
|
+
/* global FormData */
|
|
22
|
+
|
|
23
|
+
const DEFAULT_TIMEOUT_MS = 45000;
|
|
24
|
+
|
|
25
|
+
const cloneAndSerializeDates = (value) => {
|
|
26
|
+
if (value instanceof Date) return value.toISOString();
|
|
27
|
+
if (Array.isArray(value)) return value.map(cloneAndSerializeDates);
|
|
28
|
+
if (
|
|
29
|
+
value !== null &&
|
|
30
|
+
typeof value === 'object' &&
|
|
31
|
+
value.constructor === Object
|
|
32
|
+
) {
|
|
33
|
+
const out = {};
|
|
34
|
+
Object.keys(value).forEach((key) => {
|
|
35
|
+
out[key] = cloneAndSerializeDates(value[key]);
|
|
36
|
+
});
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function buildUrl(baseURL, url, params) {
|
|
43
|
+
const target = new URL(url, baseURL);
|
|
44
|
+
if (params) {
|
|
45
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
46
|
+
if (value === null || value === undefined) return;
|
|
47
|
+
target.searchParams.append(key, value);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return target.toString();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function parseBody(response, responseType) {
|
|
54
|
+
if (responseType === 'arraybuffer') return response.arrayBuffer();
|
|
55
|
+
if (responseType === 'blob') return response.blob();
|
|
56
|
+
const contentType = response.headers.get('content-type') || '';
|
|
57
|
+
if (contentType.includes('application/json')) {
|
|
58
|
+
const text = await response.text();
|
|
59
|
+
return text ? JSON.parse(text) : {};
|
|
60
|
+
}
|
|
61
|
+
if (
|
|
62
|
+
contentType.includes('application/pdf') ||
|
|
63
|
+
contentType.includes('application/octet-stream')
|
|
64
|
+
) {
|
|
65
|
+
return response.arrayBuffer();
|
|
66
|
+
}
|
|
67
|
+
return response.text();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function fetchTransport({
|
|
71
|
+
baseURL,
|
|
72
|
+
url,
|
|
73
|
+
method = 'GET',
|
|
74
|
+
headers = {},
|
|
75
|
+
params,
|
|
76
|
+
data,
|
|
77
|
+
responseType,
|
|
78
|
+
timeout = DEFAULT_TIMEOUT_MS,
|
|
79
|
+
signal: externalSignal,
|
|
80
|
+
}) {
|
|
81
|
+
const fullUrl = buildUrl(baseURL, url, params);
|
|
82
|
+
const outgoingHeaders = { ...headers };
|
|
83
|
+
|
|
84
|
+
let body;
|
|
85
|
+
if (data !== null && data !== undefined) {
|
|
86
|
+
if (typeof FormData !== 'undefined' && data instanceof FormData) {
|
|
87
|
+
body = data;
|
|
88
|
+
Object.keys(outgoingHeaders)
|
|
89
|
+
.filter((key) => key.toLowerCase() === 'content-type')
|
|
90
|
+
.forEach((key) => delete outgoingHeaders[key]);
|
|
91
|
+
} else if (typeof data === 'string' || data instanceof ArrayBuffer) {
|
|
92
|
+
body = data;
|
|
93
|
+
} else {
|
|
94
|
+
body = JSON.stringify(data);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const controller = new AbortController();
|
|
99
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
100
|
+
if (externalSignal) {
|
|
101
|
+
if (externalSignal.aborted) controller.abort();
|
|
102
|
+
else
|
|
103
|
+
externalSignal.addEventListener('abort', () => controller.abort(), {
|
|
104
|
+
once: true,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let response;
|
|
109
|
+
try {
|
|
110
|
+
response = await fetch(fullUrl, {
|
|
111
|
+
method,
|
|
112
|
+
headers: outgoingHeaders,
|
|
113
|
+
body,
|
|
114
|
+
signal: controller.signal,
|
|
115
|
+
});
|
|
116
|
+
} catch (error) {
|
|
117
|
+
const err = new Error(error.message || 'Network error');
|
|
118
|
+
err.request = {};
|
|
119
|
+
err.errno = error.errno ?? error.cause?.errno;
|
|
120
|
+
err.code =
|
|
121
|
+
error.code ??
|
|
122
|
+
error.cause?.code ??
|
|
123
|
+
(error.name === 'AbortError' ? 'ETIMEDOUT' : undefined);
|
|
124
|
+
throw err;
|
|
125
|
+
} finally {
|
|
126
|
+
clearTimeout(timer);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
let errorData;
|
|
131
|
+
try {
|
|
132
|
+
errorData = await parseBody(response, responseType);
|
|
133
|
+
} catch (parseErr) {
|
|
134
|
+
errorData = await response.text().catch(() => null);
|
|
135
|
+
}
|
|
136
|
+
const err = new Error(`HTTP ${response.status}`);
|
|
137
|
+
err.response = {
|
|
138
|
+
data: errorData,
|
|
139
|
+
status: response.status,
|
|
140
|
+
headers: response.headers,
|
|
141
|
+
};
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const responseData = await parseBody(response, responseType);
|
|
146
|
+
return {
|
|
147
|
+
data: responseData,
|
|
148
|
+
status: response.status,
|
|
149
|
+
headers: response.headers,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
21
152
|
|
|
22
153
|
class Client {
|
|
23
154
|
constructor({
|
|
@@ -29,10 +160,10 @@ class Client {
|
|
|
29
160
|
this.phase = phase;
|
|
30
161
|
this.basicAuth = { apiKey, apiSecret };
|
|
31
162
|
this.jwtToken = null;
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
163
|
+
this._defaultHeaders = { 'Accept-Language': language };
|
|
164
|
+
this._sessionHeaders = {};
|
|
165
|
+
this._timeout = DEFAULT_TIMEOUT_MS;
|
|
166
|
+
this._session = { request: (config) => fetchTransport(config) };
|
|
36
167
|
}
|
|
37
168
|
|
|
38
169
|
get session() {
|
|
@@ -40,9 +171,16 @@ class Client {
|
|
|
40
171
|
}
|
|
41
172
|
|
|
42
173
|
get origin() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
:
|
|
174
|
+
const hostByPhase = {
|
|
175
|
+
[Phase.Sandbox]: 'sandbox.cuenca.com',
|
|
176
|
+
[Phase.Stage]: 'api.stage.cuenca.com',
|
|
177
|
+
[Phase.Api]: 'api.cuenca.com',
|
|
178
|
+
};
|
|
179
|
+
const host = hostByPhase[this.phase];
|
|
180
|
+
if (!host) {
|
|
181
|
+
throw new CuencaException(`Unsupported phase: ${this.phase}`);
|
|
182
|
+
}
|
|
183
|
+
return `https://${host}`;
|
|
46
184
|
}
|
|
47
185
|
|
|
48
186
|
get authHeader() {
|
|
@@ -55,44 +193,37 @@ class Client {
|
|
|
55
193
|
}
|
|
56
194
|
|
|
57
195
|
addHeadersToRequest(obj) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
196
|
+
const previous = {};
|
|
197
|
+
Object.keys(obj).forEach((key) => {
|
|
198
|
+
previous[key] = Object.prototype.hasOwnProperty.call(
|
|
199
|
+
this._sessionHeaders,
|
|
200
|
+
key,
|
|
201
|
+
)
|
|
202
|
+
? this._sessionHeaders[key]
|
|
203
|
+
: undefined;
|
|
204
|
+
this._sessionHeaders[key] = obj[key];
|
|
65
205
|
});
|
|
66
206
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
207
|
+
eject: () => {
|
|
208
|
+
Object.keys(previous).forEach((key) => {
|
|
209
|
+
if (previous[key] === undefined) delete this._sessionHeaders[key];
|
|
210
|
+
else this._sessionHeaders[key] = previous[key];
|
|
211
|
+
});
|
|
212
|
+
},
|
|
69
213
|
};
|
|
70
214
|
}
|
|
71
215
|
|
|
72
216
|
deleteRequestHeader(header) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return currentConfig;
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
interceptorId,
|
|
83
|
-
eject: () => this._session.interceptors.request.eject(interceptorId),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
addConfigToRequest(obj) {
|
|
88
|
-
const interceptorId = this._session.interceptors.request.use((config) => {
|
|
89
|
-
const currentConfig = config;
|
|
90
|
-
Object.keys(obj).forEach((k) => (currentConfig[k] = obj[k]));
|
|
91
|
-
return currentConfig;
|
|
92
|
-
});
|
|
217
|
+
const hadPrevious = Object.prototype.hasOwnProperty.call(
|
|
218
|
+
this._sessionHeaders,
|
|
219
|
+
header,
|
|
220
|
+
);
|
|
221
|
+
const previous = hadPrevious ? this._sessionHeaders[header] : undefined;
|
|
222
|
+
delete this._sessionHeaders[header];
|
|
93
223
|
return {
|
|
94
|
-
|
|
95
|
-
|
|
224
|
+
eject: () => {
|
|
225
|
+
if (hadPrevious) this._sessionHeaders[header] = previous;
|
|
226
|
+
},
|
|
96
227
|
};
|
|
97
228
|
}
|
|
98
229
|
|
|
@@ -122,20 +253,27 @@ class Client {
|
|
|
122
253
|
}
|
|
123
254
|
}
|
|
124
255
|
|
|
125
|
-
async get({ endpoint, format, params }) {
|
|
126
|
-
return this.request({ endpoint, format, params });
|
|
256
|
+
async get({ endpoint, format, params, headers, responseType }) {
|
|
257
|
+
return this.request({ endpoint, format, params, headers, responseType });
|
|
127
258
|
}
|
|
128
259
|
|
|
129
|
-
async post({ endpoint, data, multipart }) {
|
|
130
|
-
return this.request({
|
|
260
|
+
async post({ endpoint, data, multipart, headers, responseType }) {
|
|
261
|
+
return this.request({
|
|
262
|
+
method: 'POST',
|
|
263
|
+
endpoint,
|
|
264
|
+
data,
|
|
265
|
+
multipart,
|
|
266
|
+
headers,
|
|
267
|
+
responseType,
|
|
268
|
+
});
|
|
131
269
|
}
|
|
132
270
|
|
|
133
|
-
async patch({ endpoint, data }) {
|
|
134
|
-
return this.request({ method: 'PATCH', endpoint, data });
|
|
271
|
+
async patch({ endpoint, data, headers }) {
|
|
272
|
+
return this.request({ method: 'PATCH', endpoint, data, headers });
|
|
135
273
|
}
|
|
136
274
|
|
|
137
|
-
async delete({ endpoint, data }) {
|
|
138
|
-
return this.request({ method: 'DELETE', endpoint, data });
|
|
275
|
+
async delete({ endpoint, data, headers }) {
|
|
276
|
+
return this.request({ method: 'DELETE', endpoint, data, headers });
|
|
139
277
|
}
|
|
140
278
|
|
|
141
279
|
async request({
|
|
@@ -145,14 +283,21 @@ class Client {
|
|
|
145
283
|
method = 'GET',
|
|
146
284
|
multipart = false,
|
|
147
285
|
params = null,
|
|
286
|
+
headers: extraHeaders = null,
|
|
287
|
+
responseType,
|
|
288
|
+
timeout,
|
|
289
|
+
signal,
|
|
148
290
|
}) {
|
|
149
|
-
|
|
291
|
+
if (this.jwtToken && this.jwtToken.isExpired) {
|
|
292
|
+
this.jwtToken = await Jwt.create(this);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const headers = { ...this._defaultHeaders, ...this._sessionHeaders };
|
|
150
296
|
|
|
151
297
|
if (!multipart) {
|
|
152
|
-
headers =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
};
|
|
298
|
+
headers['Content-Type'] = 'application/json';
|
|
299
|
+
// FileFormat is a string union (ADR #61 / enums #62) — not `{ value }`.
|
|
300
|
+
headers.Accept = format;
|
|
156
301
|
}
|
|
157
302
|
|
|
158
303
|
if (this.authHeader) {
|
|
@@ -168,32 +313,29 @@ class Client {
|
|
|
168
313
|
}
|
|
169
314
|
|
|
170
315
|
if (this.jwtToken) {
|
|
171
|
-
if (this.jwtToken.isExpired) {
|
|
172
|
-
this.jwtToken = await Jwt.create(this);
|
|
173
|
-
}
|
|
174
316
|
headers['X-Cuenca-Token'] = this.jwtToken.token;
|
|
175
317
|
}
|
|
176
|
-
const headersInterceptor = this.addHeadersToRequest(headers);
|
|
177
318
|
|
|
178
|
-
|
|
319
|
+
if (extraHeaders) Object.assign(headers, extraHeaders);
|
|
320
|
+
|
|
321
|
+
let modifiedData = data;
|
|
179
322
|
if (modifiedData && !multipart) {
|
|
180
|
-
|
|
181
|
-
if (modifiedData[k] instanceof Date) {
|
|
182
|
-
modifiedData[k] = modifiedData[k].toISOString();
|
|
183
|
-
}
|
|
184
|
-
});
|
|
323
|
+
modifiedData = cloneAndSerializeDates(data);
|
|
185
324
|
}
|
|
186
325
|
|
|
187
|
-
const configInterceptor = this.addConfigToRequest({
|
|
188
|
-
method,
|
|
189
|
-
params,
|
|
190
|
-
data: modifiedData,
|
|
191
|
-
url: endpoint,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
let response;
|
|
195
326
|
try {
|
|
196
|
-
response = await this._session.request({
|
|
327
|
+
const response = await this._session.request({
|
|
328
|
+
baseURL: this.origin,
|
|
329
|
+
url: endpoint,
|
|
330
|
+
method,
|
|
331
|
+
headers,
|
|
332
|
+
params,
|
|
333
|
+
data: modifiedData,
|
|
334
|
+
responseType,
|
|
335
|
+
timeout: timeout ?? this._timeout,
|
|
336
|
+
signal,
|
|
337
|
+
});
|
|
338
|
+
return response.data;
|
|
197
339
|
} catch (error) {
|
|
198
340
|
if (error.response) {
|
|
199
341
|
throw new CuencaResponseException(
|
|
@@ -201,2940 +343,1287 @@ class Client {
|
|
|
201
343
|
error.response.status,
|
|
202
344
|
);
|
|
203
345
|
} else if (error.request) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
);
|
|
346
|
+
const code = error.code ?? error.name ?? 'ENETWORK';
|
|
347
|
+
const errno = error.errno ?? 'unknown';
|
|
348
|
+
throw new CuencaException(`No response received: ${errno}: ${code}`);
|
|
207
349
|
} else {
|
|
208
350
|
throw new CuencaException(error.message);
|
|
209
351
|
}
|
|
210
|
-
} finally {
|
|
211
|
-
headersInterceptor.eject();
|
|
212
|
-
configInterceptor.eject();
|
|
213
352
|
}
|
|
214
|
-
|
|
215
|
-
return response.data;
|
|
216
353
|
}
|
|
217
354
|
}
|
|
218
355
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
this.institutionName = institutionName;
|
|
225
|
-
this.name = name;
|
|
226
|
-
this.userId = userId;
|
|
227
|
-
}
|
|
356
|
+
const Account = {
|
|
357
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
358
|
+
'createdAt',
|
|
359
|
+
]),
|
|
360
|
+
};
|
|
228
361
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
362
|
+
const Alert = {
|
|
363
|
+
fromObject: (obj) => {
|
|
364
|
+
const camelized = camelize(obj);
|
|
365
|
+
const changeLog = obj.change_log;
|
|
366
|
+
return coerceDatesWithDefaults({
|
|
367
|
+
...camelized,
|
|
368
|
+
changeLog: changeLog && Array.isArray(changeLog) && changeLog.length > 0
|
|
369
|
+
? changeLog.map(AlertLog.fromObject)
|
|
370
|
+
: undefined,
|
|
371
|
+
}, ['createdAt', 'updatedAt', 'transactionDate', 'committeeMeetingDate']);
|
|
372
|
+
},
|
|
373
|
+
};
|
|
239
374
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
description,
|
|
253
|
-
hasQuestionnaire,
|
|
254
|
-
id,
|
|
255
|
-
institutionName,
|
|
256
|
-
level,
|
|
257
|
-
name,
|
|
258
|
-
period,
|
|
259
|
-
periodNumber,
|
|
260
|
-
status,
|
|
261
|
-
sourceType,
|
|
262
|
-
transactionDate,
|
|
263
|
-
type,
|
|
264
|
-
typeOfFilter,
|
|
265
|
-
userId,
|
|
266
|
-
updatedAt,
|
|
267
|
-
}) {
|
|
268
|
-
this.accountNumber = accountNumber;
|
|
269
|
-
this.actualPeriodCount = actualPeriodCount;
|
|
270
|
-
this.actualPeriodSum = actualPeriodSum;
|
|
271
|
-
this.agent = agent;
|
|
272
|
-
this.aggregationType = aggregationType;
|
|
273
|
-
this.comments = comments;
|
|
274
|
-
this.committeeMeetingDate = dateToUTC(committeeMeetingDate);
|
|
275
|
-
this.createdAt = dateToUTC(createdAt);
|
|
276
|
-
this.questionnaireId = questionnaireId;
|
|
277
|
-
this.description = description;
|
|
278
|
-
this.hasQuestionnaire = hasQuestionnaire;
|
|
279
|
-
this.id = id;
|
|
280
|
-
this.institutionName = institutionName;
|
|
281
|
-
this.level = enumValueFromString(MLIndicatorLevel, level);
|
|
282
|
-
this.name = name;
|
|
283
|
-
this.period = enumValueFromString(MLIndicatorPeriod, period);
|
|
284
|
-
this.periodNumber = periodNumber;
|
|
285
|
-
this.status = enumValueFromString(AlertStatus, status);
|
|
286
|
-
this.sourceType = enumValueFromString(SourceAlertType, sourceType);
|
|
287
|
-
this.transactionDate = dateToUTC(transactionDate);
|
|
288
|
-
this.type = enumValueFromString(MLIndicatorType, type);
|
|
289
|
-
this.typeOfFilter = enumValueFromString(PLDFilterType, typeOfFilter);
|
|
290
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
291
|
-
this.userId = userId;
|
|
292
|
-
this.changeLog = changeLog;
|
|
293
|
-
}
|
|
375
|
+
const ApiKey = {
|
|
376
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
377
|
+
'createdAt',
|
|
378
|
+
'deactivatedAt',
|
|
379
|
+
'updatedAt',
|
|
380
|
+
]),
|
|
381
|
+
isActive: (apiKey) => {
|
|
382
|
+
const todayUTC = dateToUTC(Date.now());
|
|
383
|
+
return (!apiKey.deactivatedAt ||
|
|
384
|
+
apiKey.deactivatedAt.getTime() > todayUTC.getTime());
|
|
385
|
+
},
|
|
386
|
+
};
|
|
294
387
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
description,
|
|
299
|
-
id,
|
|
300
|
-
level,
|
|
301
|
-
name,
|
|
302
|
-
period,
|
|
303
|
-
status,
|
|
304
|
-
type,
|
|
305
|
-
...obj
|
|
306
|
-
}) =>
|
|
307
|
-
new Alert({
|
|
308
|
-
agent,
|
|
309
|
-
comments,
|
|
310
|
-
description,
|
|
311
|
-
id,
|
|
312
|
-
level,
|
|
313
|
-
name,
|
|
314
|
-
period,
|
|
315
|
-
status,
|
|
316
|
-
type,
|
|
317
|
-
accountNumber: obj.account_number,
|
|
318
|
-
actualPeriodCount: obj.actual_period_count,
|
|
319
|
-
actualPeriodSum: obj.actual_period_sum,
|
|
320
|
-
aggregationType: obj.aggregation_type,
|
|
321
|
-
changeLog: obj.change_log,
|
|
322
|
-
committeeMeetingDate: obj.committee_meeting_date,
|
|
323
|
-
createdAt: obj.created_at,
|
|
324
|
-
questionnaireId: obj.questionnaire_id,
|
|
325
|
-
hasQuestionnaire: obj.has_questionnaire,
|
|
326
|
-
institutionName: obj.institution_name,
|
|
327
|
-
periodNumber: obj.period_number,
|
|
328
|
-
sourceType: obj.source_type,
|
|
329
|
-
transactionDate: obj.transaction_date,
|
|
330
|
-
typeOfFilter: obj.type_of_filter,
|
|
331
|
-
updatedAt: obj.updated_at,
|
|
332
|
-
userId: obj.user_id,
|
|
333
|
-
});
|
|
388
|
+
const Arpc = {
|
|
389
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), ['createdAt']),
|
|
390
|
+
};
|
|
334
391
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
392
|
+
const BalanceEntry = {
|
|
393
|
+
// The wire calls this field `type`; the model calls it `entryType`.
|
|
394
|
+
fromObject: (obj) => {
|
|
395
|
+
const { type, ...rest } = obj;
|
|
396
|
+
const camelized = camelize(rest);
|
|
397
|
+
return coerceDatesWithDefaults({ ...camelized, entryType: type }, [
|
|
398
|
+
'createdAt',
|
|
399
|
+
]);
|
|
400
|
+
},
|
|
401
|
+
};
|
|
338
402
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
403
|
+
const BillPayment = {
|
|
404
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
405
|
+
'createdAt',
|
|
406
|
+
]),
|
|
407
|
+
};
|
|
344
408
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
409
|
+
// Empty objects (`{}`) are treated the same as absent — mirrors the old
|
|
410
|
+
// setters' `Object.keys(value).length === 0` guard.
|
|
411
|
+
const nonEmpty = (value) => value && typeof value === 'object' && Object.keys(value).length > 0
|
|
412
|
+
? value
|
|
413
|
+
: undefined;
|
|
414
|
+
const BridgeAccount = {
|
|
415
|
+
fromObject: (obj) => {
|
|
416
|
+
const camelized = camelize(obj);
|
|
417
|
+
const address = nonEmpty(obj.address);
|
|
418
|
+
const govtId = nonEmpty(obj.govt_id);
|
|
419
|
+
const proofOfAddress = nonEmpty(obj.proof_of_address);
|
|
420
|
+
const termsOfService = nonEmpty(obj.terms_of_service);
|
|
421
|
+
return coerceDatesWithDefaults({
|
|
422
|
+
...camelized,
|
|
423
|
+
address: address ? Address.fromObject(address) : undefined,
|
|
424
|
+
govtId: govtId ? KYCFile.fromObject(govtId) : undefined,
|
|
425
|
+
proofOfAddress: proofOfAddress
|
|
426
|
+
? KYCFile.fromObject(proofOfAddress)
|
|
427
|
+
: undefined,
|
|
428
|
+
termsOfService: termsOfService
|
|
429
|
+
? TOSAgreements.fromObject(termsOfService)
|
|
430
|
+
: undefined,
|
|
431
|
+
}, ['createdAt', 'updatedAt']);
|
|
432
|
+
},
|
|
433
|
+
};
|
|
354
434
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
deactivatedAt: obj.deactivated_at,
|
|
361
|
-
userId: obj.user_id,
|
|
362
|
-
updatedAt: obj.updated_at,
|
|
363
|
-
});
|
|
435
|
+
const BridgeBankAccount = {
|
|
436
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
437
|
+
'createdAt',
|
|
438
|
+
]),
|
|
439
|
+
};
|
|
364
440
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
441
|
+
const BridgeClabe = {
|
|
442
|
+
// `account` is derived from `account_uri` (`/accounts/AC01` -> `AC01`),
|
|
443
|
+
// not a straight rename.
|
|
444
|
+
fromObject: (obj) => {
|
|
445
|
+
const { account_uri: accountUri, ...rest } = obj;
|
|
446
|
+
const camelized = camelize(rest);
|
|
447
|
+
return {
|
|
448
|
+
...camelized,
|
|
449
|
+
account: typeof accountUri === 'string' ? accountUri.split('/')[2] : undefined,
|
|
450
|
+
};
|
|
451
|
+
},
|
|
452
|
+
};
|
|
372
453
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
this.isValidArqc = isValidArqc;
|
|
379
|
-
}
|
|
454
|
+
const BridgeTransaction = {
|
|
455
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
456
|
+
'createdAt',
|
|
457
|
+
]),
|
|
458
|
+
};
|
|
380
459
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
});
|
|
388
|
-
}
|
|
460
|
+
const Card = {
|
|
461
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
462
|
+
'createdAt',
|
|
463
|
+
'updatedAt',
|
|
464
|
+
]),
|
|
465
|
+
};
|
|
389
466
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
entryType,
|
|
396
|
-
fundingInstrumentUri,
|
|
397
|
-
id,
|
|
398
|
-
name,
|
|
399
|
-
relatedTransactionUri,
|
|
400
|
-
rollingBalance,
|
|
401
|
-
}) {
|
|
402
|
-
this.amount = amount;
|
|
403
|
-
this.createdAt = dateToUTC(createdAt);
|
|
404
|
-
this.descriptor = descriptor;
|
|
405
|
-
this.entryType = enumValueFromString(EntryType, entryType);
|
|
406
|
-
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
407
|
-
this.id = id;
|
|
408
|
-
this.name = name;
|
|
409
|
-
this.relatedTransactionUri = relatedTransactionUri;
|
|
410
|
-
this.rollingBalance = rollingBalance;
|
|
411
|
-
}
|
|
467
|
+
const CardActivation = {
|
|
468
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
469
|
+
'createdAt',
|
|
470
|
+
]),
|
|
471
|
+
};
|
|
412
472
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
473
|
+
const CardTransaction = {
|
|
474
|
+
// Three wire keys don't follow the usual snake_case rename:
|
|
475
|
+
// `error_type` -> cardErrorType, `card_last4` -> cardLastFour,
|
|
476
|
+
// `related_card_transaction` -> relatedCardTransactionsUris. `metadata`
|
|
477
|
+
// is opaque passthrough data and must not be recursively camelized.
|
|
478
|
+
fromObject: (obj) => {
|
|
479
|
+
const { error_type: cardErrorType, card_last4: cardLastFour, related_card_transaction: relatedCardTransactionsUris, metadata, ...rest } = obj;
|
|
480
|
+
const camelized = camelize(rest);
|
|
481
|
+
return coerceDatesWithDefaults({
|
|
482
|
+
...camelized,
|
|
483
|
+
cardErrorType,
|
|
484
|
+
cardLastFour,
|
|
485
|
+
relatedCardTransactionsUris,
|
|
486
|
+
metadata,
|
|
487
|
+
}, ['createdAt']);
|
|
488
|
+
},
|
|
489
|
+
};
|
|
426
490
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
this.userId = userId;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
491
|
+
const CardValidation = {
|
|
492
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
493
|
+
'createdAt',
|
|
494
|
+
]),
|
|
495
|
+
isActive: (validation) => validation.cardStatus === CardStatus.Active,
|
|
496
|
+
};
|
|
436
497
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
descriptor,
|
|
443
|
-
id,
|
|
444
|
-
providerUri,
|
|
445
|
-
status,
|
|
446
|
-
userId,
|
|
447
|
-
}) {
|
|
448
|
-
super({
|
|
449
|
-
amount,
|
|
450
|
-
createdAt,
|
|
451
|
-
descriptor,
|
|
452
|
-
status,
|
|
453
|
-
userId,
|
|
454
|
-
});
|
|
455
|
-
this.accountNumber = accountNumber;
|
|
456
|
-
this.id = id;
|
|
457
|
-
this.providerUri = providerUri;
|
|
458
|
-
}
|
|
498
|
+
const Commission = {
|
|
499
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
500
|
+
'createdAt',
|
|
501
|
+
]),
|
|
502
|
+
};
|
|
459
503
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
status,
|
|
466
|
-
accountNumber: obj.account_number,
|
|
467
|
-
createdAt: obj.created_at,
|
|
468
|
-
providerUri: obj.provider_uri,
|
|
469
|
-
userId: obj.user_id,
|
|
470
|
-
});
|
|
471
|
-
}
|
|
504
|
+
const Deposit = {
|
|
505
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
506
|
+
'createdAt',
|
|
507
|
+
]),
|
|
508
|
+
};
|
|
472
509
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
createdAt,
|
|
477
|
-
updatedAt,
|
|
478
|
-
names,
|
|
479
|
-
firstSurname,
|
|
480
|
-
secondSurname,
|
|
481
|
-
dateOfBirth,
|
|
482
|
-
countryOfBirth,
|
|
483
|
-
rfc,
|
|
484
|
-
curp,
|
|
485
|
-
userId,
|
|
486
|
-
gender,
|
|
487
|
-
phoneNumber,
|
|
488
|
-
emailAddress,
|
|
489
|
-
clientClabe,
|
|
490
|
-
govtId,
|
|
491
|
-
proofOfAddress,
|
|
492
|
-
status,
|
|
493
|
-
termsOfService,
|
|
494
|
-
address,
|
|
495
|
-
}) {
|
|
496
|
-
this.id = id;
|
|
497
|
-
this.createdAt = dateToUTC(createdAt);
|
|
498
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
499
|
-
this.emailAddress = emailAddress;
|
|
500
|
-
this.clientClabe = clientClabe;
|
|
501
|
-
this.govtId = govtId;
|
|
502
|
-
this.names = names;
|
|
503
|
-
this.firstSurname = firstSurname;
|
|
504
|
-
this.secondSurname = secondSurname;
|
|
505
|
-
this.dateOfBirth = dateOfBirth;
|
|
506
|
-
this.countryOfBirth = countryOfBirth;
|
|
507
|
-
this.rfc = rfc;
|
|
508
|
-
this.curp = curp;
|
|
509
|
-
this.userId = userId;
|
|
510
|
-
this.gender = gender;
|
|
511
|
-
this.phoneNumber = phoneNumber;
|
|
512
|
-
this.proofOfAddress = proofOfAddress;
|
|
513
|
-
this.status = enumValueFromString(BridgeAccountStatus, status);
|
|
514
|
-
this.termsOfService = termsOfService;
|
|
515
|
-
this.address = address;
|
|
516
|
-
}
|
|
510
|
+
const File = {
|
|
511
|
+
fromObject: (obj) => camelize(obj),
|
|
512
|
+
};
|
|
517
513
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
status,
|
|
522
|
-
id: obj.id,
|
|
523
|
-
createdAt: obj.created_at,
|
|
524
|
-
updatedAt: obj.updated_at,
|
|
525
|
-
clientClabe: obj.client_clabe,
|
|
526
|
-
names: obj.names,
|
|
527
|
-
firstSurname: obj.first_surname,
|
|
528
|
-
secondSurname: obj.second_surname,
|
|
529
|
-
dateOfBirth: obj.date_of_birth,
|
|
530
|
-
countryOfBirth: obj.country_of_birth,
|
|
531
|
-
rfc: obj.rfc,
|
|
532
|
-
curp: obj.curp,
|
|
533
|
-
userId: obj.user_id,
|
|
534
|
-
gender: obj.gender,
|
|
535
|
-
govtId: obj.govt_id,
|
|
536
|
-
emailAddress: obj.email_address,
|
|
537
|
-
phoneNumber: obj.phone_number,
|
|
538
|
-
proofOfAddress: obj.proof_of_address,
|
|
539
|
-
termsOfService: obj.terms_of_service,
|
|
540
|
-
});
|
|
514
|
+
const FraudFundsTransfer = {
|
|
515
|
+
fromObject: (obj) => camelize(obj),
|
|
516
|
+
};
|
|
541
517
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
518
|
+
const KYCValidations = {
|
|
519
|
+
fromObject: (obj) => {
|
|
520
|
+
const camelized = camelize(obj);
|
|
521
|
+
return coerceDatesWithDefaults({ ...camelized, filesUri: camelized.filesUri || [] }, ['createdAt', 'updatedAt', 'deactivatedAt']);
|
|
522
|
+
},
|
|
523
|
+
};
|
|
545
524
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
525
|
+
const BaseUser = {
|
|
526
|
+
fromObject: (obj) => {
|
|
527
|
+
const camelized = camelize(obj);
|
|
528
|
+
return coerceDatesWithDefaults({
|
|
529
|
+
...camelized,
|
|
530
|
+
address: obj.address
|
|
531
|
+
? Address.fromObject(obj.address)
|
|
532
|
+
: undefined,
|
|
533
|
+
}, ['createdAt', 'updatedAt']);
|
|
534
|
+
},
|
|
535
|
+
};
|
|
550
536
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
537
|
+
const LegalPerson = {
|
|
538
|
+
fromObject: (obj) => {
|
|
539
|
+
const base = BaseUser.fromObject(obj);
|
|
540
|
+
const camelized = camelize(obj);
|
|
541
|
+
return coerceDatesWithDefaults({
|
|
542
|
+
...camelized,
|
|
543
|
+
...base,
|
|
544
|
+
legalRepresentatives: obj.legal_representatives
|
|
545
|
+
? obj.legal_representatives.map(LegalRepresentatives.fromObject)
|
|
546
|
+
: undefined,
|
|
547
|
+
}, ['createdAt', 'updatedAt']);
|
|
548
|
+
},
|
|
549
|
+
};
|
|
554
550
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
551
|
+
const LoginToken = {
|
|
552
|
+
fromObject: (obj) => ({
|
|
553
|
+
id: obj.id,
|
|
554
|
+
}),
|
|
555
|
+
};
|
|
559
556
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
const Operator = {
|
|
558
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
559
|
+
'createdAt',
|
|
560
|
+
'updatedAt',
|
|
561
|
+
]),
|
|
562
|
+
};
|
|
563
563
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
564
|
+
const OperatorLogin = {
|
|
565
|
+
fromObject: (obj) => camelize(obj),
|
|
566
|
+
};
|
|
568
567
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
568
|
+
const TransactionalProfile = {
|
|
569
|
+
fromObject: (obj) => {
|
|
570
|
+
const camelized = camelize(obj);
|
|
571
|
+
return {
|
|
572
|
+
...camelized,
|
|
573
|
+
deposits: obj.deposits
|
|
574
|
+
? TransactionalProfileServices.fromObject(obj.deposits)
|
|
575
|
+
: undefined,
|
|
576
|
+
withdrawal: obj.withdrawal
|
|
577
|
+
? TransactionalProfileServices.fromObject(obj.withdrawal)
|
|
578
|
+
: undefined,
|
|
579
|
+
};
|
|
580
|
+
},
|
|
581
|
+
};
|
|
572
582
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
583
|
+
const toLegalRepresentatives = (obj) => {
|
|
584
|
+
const value = obj.legal_representatives;
|
|
585
|
+
return value ? value.map(LegalRepresentatives.fromObject) : undefined;
|
|
586
|
+
};
|
|
587
|
+
const toTransactionalProfile = (obj) => {
|
|
588
|
+
const value = obj.transactional_profile;
|
|
589
|
+
return value ? TransactionalProfile.fromObject(value) : undefined;
|
|
590
|
+
};
|
|
591
|
+
const Partner = {
|
|
592
|
+
fromObject: (obj) => {
|
|
593
|
+
const base = BaseUser.fromObject(obj);
|
|
594
|
+
const camelized = camelize(obj);
|
|
595
|
+
return coerceDatesWithDefaults({
|
|
596
|
+
...camelized,
|
|
597
|
+
...base,
|
|
598
|
+
audit: obj.audit
|
|
599
|
+
? Audit.fromObject(obj.audit)
|
|
600
|
+
: undefined,
|
|
601
|
+
businessDetails: obj.business_details
|
|
602
|
+
? BusinessDetails.fromObject(obj.business_details)
|
|
603
|
+
: undefined,
|
|
604
|
+
externalAccount: obj.external_account
|
|
605
|
+
? ExternalAccount.fromObject(obj.external_account)
|
|
606
|
+
: undefined,
|
|
607
|
+
license: obj.license
|
|
608
|
+
? License.fromObject(obj.license)
|
|
609
|
+
: undefined,
|
|
610
|
+
shareholders: obj.shareholders
|
|
611
|
+
? obj.shareholders.map(ShareholderMoral.fromObject)
|
|
612
|
+
: undefined,
|
|
613
|
+
legalRepresentatives: toLegalRepresentatives(obj),
|
|
614
|
+
transactionalProfile: toTransactionalProfile(obj),
|
|
615
|
+
vulnerableActivity: obj.vulnerable_activity
|
|
616
|
+
? VulnerableActivity.fromObject(obj.vulnerable_activity)
|
|
617
|
+
: undefined,
|
|
618
|
+
}, ['incorporationDate']);
|
|
619
|
+
},
|
|
620
|
+
};
|
|
578
621
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
firstName,
|
|
586
|
-
id,
|
|
587
|
-
names,
|
|
588
|
-
rfc,
|
|
589
|
-
secondSurname,
|
|
590
|
-
status,
|
|
591
|
-
}) {
|
|
592
|
-
this.clabe = clabe;
|
|
593
|
-
this.createdAt = dateToUTC(createdAt);
|
|
594
|
-
this.curp = curp;
|
|
595
|
-
this.error = error;
|
|
596
|
-
this.firstName = firstName;
|
|
597
|
-
this.id = id;
|
|
598
|
-
this.names = names;
|
|
599
|
-
this.rfc = rfc;
|
|
600
|
-
this.secondSurname = secondSurname;
|
|
601
|
-
this.status = enumValueFromString(BridgeBankAccountStatus, status);
|
|
602
|
-
}
|
|
622
|
+
const PostalCode = {
|
|
623
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
624
|
+
'createdAt',
|
|
625
|
+
'updatedAt',
|
|
626
|
+
]),
|
|
627
|
+
};
|
|
603
628
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
...obj
|
|
613
|
-
}) =>
|
|
614
|
-
new BridgeBankAccount({
|
|
615
|
-
clabe,
|
|
616
|
-
curp,
|
|
617
|
-
error,
|
|
618
|
-
id,
|
|
619
|
-
names,
|
|
620
|
-
rfc,
|
|
621
|
-
status,
|
|
622
|
-
createdAt: obj.created_at,
|
|
623
|
-
firstName: obj.first_name,
|
|
624
|
-
secondSurname: obj.second_surname,
|
|
625
|
-
});
|
|
626
|
-
}
|
|
629
|
+
const Saving = {
|
|
630
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
631
|
+
'createdAt',
|
|
632
|
+
'deactivatedAt',
|
|
633
|
+
'goalDate',
|
|
634
|
+
'updatedAt',
|
|
635
|
+
]),
|
|
636
|
+
};
|
|
627
637
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
638
|
+
const ServiceProvider = {
|
|
639
|
+
fromObject: (obj) => {
|
|
640
|
+
const camelized = camelize(obj);
|
|
641
|
+
return {
|
|
642
|
+
...camelized,
|
|
643
|
+
categories: camelized.categories == null ? [] : camelized.categories,
|
|
644
|
+
};
|
|
645
|
+
},
|
|
646
|
+
};
|
|
637
647
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
account: obj.account_uri.split('/')[2],
|
|
645
|
-
platformId: obj.platform_id,
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
+
const Session = {
|
|
649
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
650
|
+
'createdAt',
|
|
651
|
+
'expiresAt',
|
|
652
|
+
]),
|
|
653
|
+
};
|
|
648
654
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
type,
|
|
655
|
-
status,
|
|
656
|
-
accountUri,
|
|
657
|
-
quoteUri,
|
|
658
|
-
currency,
|
|
659
|
-
network,
|
|
660
|
-
sourceWallet,
|
|
661
|
-
destinationWallet,
|
|
662
|
-
bankAccountUri,
|
|
663
|
-
cuencaId,
|
|
664
|
-
cuentaOrdenante,
|
|
665
|
-
cuentaBeneficiario,
|
|
666
|
-
nombreOrdenante,
|
|
667
|
-
claveRastreo,
|
|
668
|
-
rfcCurpOrdenante,
|
|
669
|
-
concepto,
|
|
670
|
-
referenciaNumerica,
|
|
671
|
-
signature,
|
|
672
|
-
trackingLink,
|
|
673
|
-
fromCurrency,
|
|
674
|
-
toCurrency,
|
|
675
|
-
fromAmount,
|
|
676
|
-
toAmount,
|
|
677
|
-
}) {
|
|
678
|
-
this.id = id;
|
|
679
|
-
this.createdAt = dateToUTC(createdAt);
|
|
680
|
-
this.platformId = platformId;
|
|
681
|
-
this.type = enumValueFromString(BridgeTransactionType, type);
|
|
682
|
-
this.status = enumValueFromString(TransactionStatus, status);
|
|
683
|
-
this.accountUri = accountUri;
|
|
684
|
-
this.quoteUri = quoteUri;
|
|
685
|
-
this.currency = enumValueFromString(Currency, currency);
|
|
686
|
-
this.network = enumValueFromString(Network, network);
|
|
687
|
-
this.sourceWallet = sourceWallet;
|
|
688
|
-
this.destinationWallet = destinationWallet;
|
|
689
|
-
this.bankAccountUri = bankAccountUri;
|
|
690
|
-
this.cuencaId = cuencaId;
|
|
691
|
-
this.cuentaOrdenante = cuentaOrdenante;
|
|
692
|
-
this.cuentaBeneficiario = cuentaBeneficiario;
|
|
693
|
-
this.nombreOrdenante = nombreOrdenante;
|
|
694
|
-
this.claveRastreo = claveRastreo;
|
|
695
|
-
this.rfcCurpOrdenante = rfcCurpOrdenante;
|
|
696
|
-
this.concepto = concepto;
|
|
697
|
-
this.referenciaNumerica = referenciaNumerica;
|
|
698
|
-
this.signature = signature;
|
|
699
|
-
this.trackingLink = trackingLink;
|
|
700
|
-
this.fromCurrency = enumValueFromString(Currency, fromCurrency);
|
|
701
|
-
this.toCurrency = enumValueFromString(Currency, toCurrency);
|
|
702
|
-
this.fromAmount = fromAmount;
|
|
703
|
-
this.toAmount = toAmount;
|
|
704
|
-
}
|
|
655
|
+
const Statement = {
|
|
656
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
657
|
+
'createdAt',
|
|
658
|
+
]),
|
|
659
|
+
};
|
|
705
660
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
signature,
|
|
713
|
-
...obj
|
|
714
|
-
}) =>
|
|
715
|
-
new BridgeTransaction({
|
|
716
|
-
id: obj.id,
|
|
717
|
-
createdAt: obj.created_at,
|
|
718
|
-
platformId: obj.platform_id,
|
|
719
|
-
accountUri: obj.account_uri,
|
|
720
|
-
quoteUri: obj.quote_uri,
|
|
721
|
-
sourceWallet: obj.source_wallet,
|
|
722
|
-
destinationWallet: obj.destination_wallet,
|
|
723
|
-
bankAccountUri: obj.bank_account_uri,
|
|
724
|
-
cuencaId: obj.cuenca_id,
|
|
725
|
-
cuentaOrdenante: obj.cuenta_ordenante,
|
|
726
|
-
cuentaBeneficiario: obj.cuenta_beneficiario,
|
|
727
|
-
nombreOrdenante: obj.nombre_ordenante,
|
|
728
|
-
claveRastreo: obj.clave_rastreo,
|
|
729
|
-
rfcCurpOrdenante: obj.rfc_curp_ordenante,
|
|
730
|
-
referenciaNumerica: obj.referencia_numerica,
|
|
731
|
-
trackingLink: obj.tracking_link,
|
|
732
|
-
fromCurrency: obj.from_currency,
|
|
733
|
-
toCurrency: obj.to_currency,
|
|
734
|
-
fromAmount: obj.from_amount,
|
|
735
|
-
toAmount: obj.to_amount,
|
|
736
|
-
type,
|
|
737
|
-
status,
|
|
738
|
-
currency,
|
|
739
|
-
network,
|
|
740
|
-
concepto,
|
|
741
|
-
signature,
|
|
742
|
-
});
|
|
743
|
-
}
|
|
661
|
+
const Transfer = {
|
|
662
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
663
|
+
'createdAt',
|
|
664
|
+
'updatedAt',
|
|
665
|
+
]),
|
|
666
|
+
};
|
|
744
667
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
this.expYear = expYear;
|
|
765
|
-
this.fundingType = enumValueFromString(CardFundingType, fundingType);
|
|
766
|
-
this.id = id;
|
|
767
|
-
this.issuer = enumValueFromString(CardIssuer, issuer);
|
|
768
|
-
this.number = number;
|
|
769
|
-
this.pin = pin;
|
|
770
|
-
this.status = enumValueFromString(CardStatus, status);
|
|
771
|
-
this.type = enumValueFromString(CardType, type);
|
|
772
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
773
|
-
this.userId = userId;
|
|
774
|
-
}
|
|
668
|
+
const wrapKycFile = (value) => value ? KYCFile.fromObject(value) : undefined;
|
|
669
|
+
const User = {
|
|
670
|
+
fromObject: (obj) => {
|
|
671
|
+
const camelized = camelize(obj);
|
|
672
|
+
return coerceDatesWithDefaults({
|
|
673
|
+
...camelized,
|
|
674
|
+
address: obj.address
|
|
675
|
+
? Address.fromObject(obj.address)
|
|
676
|
+
: undefined,
|
|
677
|
+
govtId: wrapKycFile(obj.govt_id),
|
|
678
|
+
proofOfAddress: wrapKycFile(obj.proof_of_address),
|
|
679
|
+
proofOfLife: wrapKycFile(obj.proof_of_life),
|
|
680
|
+
curpDocument: wrapKycFile(obj.curp_document),
|
|
681
|
+
termsOfService: obj.terms_of_service
|
|
682
|
+
? TOSAgreements.fromObject(obj.terms_of_service)
|
|
683
|
+
: undefined,
|
|
684
|
+
}, ['createdAt', 'updatedAt']);
|
|
685
|
+
},
|
|
686
|
+
};
|
|
775
687
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
status,
|
|
783
|
-
type,
|
|
784
|
-
...obj
|
|
785
|
-
}) =>
|
|
786
|
-
new Card({
|
|
787
|
-
cvv2,
|
|
788
|
-
id,
|
|
789
|
-
issuer,
|
|
790
|
-
number,
|
|
791
|
-
pin,
|
|
792
|
-
status,
|
|
793
|
-
type,
|
|
794
|
-
createdAt: obj.created_at,
|
|
795
|
-
expMonth: obj.exp_month,
|
|
796
|
-
expYear: obj.exp_year,
|
|
797
|
-
fundingType: obj.funding_type,
|
|
798
|
-
updatedAt: obj.updated_at,
|
|
799
|
-
userId: obj.user_id,
|
|
800
|
-
});
|
|
801
|
-
}
|
|
688
|
+
const UserCredential = {
|
|
689
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
690
|
+
'createdAt',
|
|
691
|
+
'updatedAt',
|
|
692
|
+
]),
|
|
693
|
+
};
|
|
802
694
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
this.ipAddress = ipAddress;
|
|
809
|
-
this.success = success;
|
|
810
|
-
this.userId = userId;
|
|
811
|
-
}
|
|
695
|
+
const UserLogin = {
|
|
696
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
697
|
+
'lastLoginAt',
|
|
698
|
+
]),
|
|
699
|
+
};
|
|
812
700
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
success,
|
|
817
|
-
cardUri: obj.card_uri,
|
|
818
|
-
createdAt: obj.created_at,
|
|
819
|
-
ipAddress: obj.ip_address,
|
|
820
|
-
userId: obj.user_id,
|
|
821
|
-
});
|
|
822
|
-
}
|
|
701
|
+
const UserReport = {
|
|
702
|
+
fromObject: (obj) => camelize(obj),
|
|
703
|
+
};
|
|
823
704
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
cardUri,
|
|
831
|
-
createdAt,
|
|
832
|
-
descriptor,
|
|
833
|
-
metadata,
|
|
834
|
-
network,
|
|
835
|
-
relatedCardTransactionsUris,
|
|
836
|
-
status,
|
|
837
|
-
type,
|
|
838
|
-
userId,
|
|
839
|
-
}) {
|
|
840
|
-
super({
|
|
841
|
-
amount,
|
|
842
|
-
createdAt,
|
|
843
|
-
descriptor,
|
|
844
|
-
status,
|
|
845
|
-
userId,
|
|
846
|
-
});
|
|
847
|
-
this.cardErrorType = enumValueFromString(CardErrorType, cardErrorType);
|
|
848
|
-
this.cardLastFour = cardLastFour;
|
|
849
|
-
this.cardType = enumValueFromString(CardType, cardType);
|
|
850
|
-
this.cardUri = cardUri;
|
|
851
|
-
this.metadata = metadata;
|
|
852
|
-
this.network = network;
|
|
853
|
-
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
854
|
-
this.type = enumValueFromString(CardTransactionType, type);
|
|
855
|
-
}
|
|
705
|
+
const UserTosAgreement = {
|
|
706
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
707
|
+
'createdAt',
|
|
708
|
+
'updatedAt',
|
|
709
|
+
]),
|
|
710
|
+
};
|
|
856
711
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
type,
|
|
864
|
-
...obj
|
|
865
|
-
}) =>
|
|
866
|
-
new CardTransaction({
|
|
867
|
-
amount,
|
|
868
|
-
descriptor,
|
|
869
|
-
metadata,
|
|
870
|
-
network,
|
|
871
|
-
status,
|
|
872
|
-
type,
|
|
873
|
-
cardErrorType: obj.error_type,
|
|
874
|
-
cardLastFour: obj.card_last4,
|
|
875
|
-
cardType: obj.card_type,
|
|
876
|
-
cardUri: obj.card_uri,
|
|
877
|
-
createdAt: obj.created_at,
|
|
878
|
-
relatedCardTransactionsUris: obj.related_card_transaction,
|
|
879
|
-
userId: obj.user_id,
|
|
880
|
-
});
|
|
881
|
-
}
|
|
712
|
+
const Verification = {
|
|
713
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
714
|
+
'createdAt',
|
|
715
|
+
'updatedAt',
|
|
716
|
+
]),
|
|
717
|
+
};
|
|
882
718
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
createdAt,
|
|
889
|
-
isExpired,
|
|
890
|
-
isPinAttemptsExceeded,
|
|
891
|
-
isValidCvv,
|
|
892
|
-
isValidCvv2,
|
|
893
|
-
isValidExpDate,
|
|
894
|
-
isValidIcvv,
|
|
895
|
-
isValidPinBlock,
|
|
896
|
-
userId,
|
|
897
|
-
}) {
|
|
898
|
-
this.cardStatus = enumValueFromString(CardStatus, cardStatus);
|
|
899
|
-
this.cardType = enumValueFromString(CardType, cardType);
|
|
900
|
-
this.cardUri = cardUri;
|
|
901
|
-
this.createdAt = dateToUTC(createdAt);
|
|
902
|
-
this.isExpired = isExpired;
|
|
903
|
-
this.isPinAttemptsExceeded = isPinAttemptsExceeded;
|
|
904
|
-
this.isValidCvv = isValidCvv;
|
|
905
|
-
this.isValidCvv2 = isValidCvv2;
|
|
906
|
-
this.isValidExpDate = isValidExpDate;
|
|
907
|
-
this.isValidIcvv = isValidIcvv;
|
|
908
|
-
this.isValidPinBlock = isValidPinBlock;
|
|
909
|
-
this.userId = userId;
|
|
910
|
-
}
|
|
719
|
+
const WalletTransaction = {
|
|
720
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
721
|
+
'createdAt',
|
|
722
|
+
]),
|
|
723
|
+
};
|
|
911
724
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
isPinAttemptsExceeded: obj.is_pin_attempts_exceeded,
|
|
920
|
-
isValidCvv: obj.is_valid_cvv,
|
|
921
|
-
isValidCvv2: obj.is_valid_cvv2,
|
|
922
|
-
isValidExpDate: obj.is_valid_exp_date,
|
|
923
|
-
isValidIcvv: obj.is_valid_icvv,
|
|
924
|
-
isValidPinBlock: obj.is_valid_pin_block,
|
|
925
|
-
userId: obj.user_id,
|
|
926
|
-
});
|
|
725
|
+
const WhatsAppTransfer = {
|
|
726
|
+
fromObject: (obj) => coerceDatesWithDefaults(camelize(obj), [
|
|
727
|
+
'createdAt',
|
|
728
|
+
'expiresAt',
|
|
729
|
+
'updatedAt',
|
|
730
|
+
]),
|
|
731
|
+
};
|
|
927
732
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
733
|
+
const encodeCursor = (uri) => Buffer$1.from(uri, 'utf8').toString('base64url');
|
|
734
|
+
const decodeCursor = (cursor) => Buffer$1.from(cursor, 'base64url').toString('utf8');
|
|
735
|
+
class Resource {
|
|
736
|
+
constructor(client, path, fromObject) {
|
|
737
|
+
this.client = client;
|
|
738
|
+
this.path = path;
|
|
739
|
+
this.fromObject = fromObject;
|
|
740
|
+
}
|
|
741
|
+
// eslint-disable-next-line class-methods-use-this
|
|
742
|
+
toParams(query) {
|
|
743
|
+
return toParams(query);
|
|
744
|
+
}
|
|
745
|
+
// eslint-disable-next-line class-methods-use-this
|
|
746
|
+
toQueryString(query) {
|
|
747
|
+
return toQueryString(query);
|
|
748
|
+
}
|
|
931
749
|
}
|
|
932
|
-
|
|
933
|
-
class
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}) {
|
|
943
|
-
super({
|
|
944
|
-
amount,
|
|
945
|
-
createdAt,
|
|
946
|
-
descriptor,
|
|
947
|
-
status,
|
|
948
|
-
userId,
|
|
949
|
-
});
|
|
950
|
-
this.relatedTransactionUri = relatedTransactionUri;
|
|
951
|
-
this.type = enumValueFromString(CommissionType, type);
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
955
|
-
new Commission({
|
|
956
|
-
amount,
|
|
957
|
-
descriptor,
|
|
958
|
-
status,
|
|
959
|
-
type,
|
|
960
|
-
createdAt: obj.created_at,
|
|
961
|
-
relatedTransactionUri: obj.related_transaction_uri,
|
|
962
|
-
userId: obj.user_id,
|
|
963
|
-
});
|
|
750
|
+
function Retrievable(Base) {
|
|
751
|
+
return class extends Base {
|
|
752
|
+
async retrieve(id) {
|
|
753
|
+
const response = await this.client.get({
|
|
754
|
+
endpoint: `/${this.path}/${id}`,
|
|
755
|
+
});
|
|
756
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
757
|
+
return this.fromObject(response);
|
|
758
|
+
}
|
|
759
|
+
};
|
|
964
760
|
}
|
|
965
|
-
|
|
966
|
-
class
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
761
|
+
function Creatable(Base) {
|
|
762
|
+
return class extends Base {
|
|
763
|
+
async _create(data) {
|
|
764
|
+
const response = await this.client.post({
|
|
765
|
+
endpoint: `/${this.path}`,
|
|
766
|
+
data,
|
|
767
|
+
});
|
|
768
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
769
|
+
return this.fromObject(response);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
function Updateable(Base) {
|
|
774
|
+
return class extends Base {
|
|
775
|
+
async _update(id, data) {
|
|
776
|
+
const response = await this.client.patch({
|
|
777
|
+
endpoint: `/${this.path}/${id}`,
|
|
778
|
+
data,
|
|
779
|
+
});
|
|
780
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
781
|
+
return this.fromObject(response);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
function Uploadable(Base) {
|
|
786
|
+
return class extends Base {
|
|
787
|
+
async _upload(data) {
|
|
788
|
+
const response = await this.client.post({
|
|
789
|
+
endpoint: `/${this.path}`,
|
|
790
|
+
data,
|
|
791
|
+
multipart: true,
|
|
792
|
+
});
|
|
793
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
794
|
+
return this.fromObject(response);
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function Deactivable(Base) {
|
|
799
|
+
return class extends Base {
|
|
800
|
+
async _deactivate(id, data = {}) {
|
|
801
|
+
const response = await this.client.delete({
|
|
802
|
+
endpoint: `/${this.path}/${id}`,
|
|
803
|
+
data,
|
|
804
|
+
});
|
|
805
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
806
|
+
return this.fromObject(response);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function Downlodable(Base) {
|
|
811
|
+
return class extends Base {
|
|
812
|
+
async _download(id, format, responseType) {
|
|
813
|
+
const config = { endpoint: `/${this.path}/${id}` };
|
|
814
|
+
if (format !== undefined)
|
|
815
|
+
config.format = format;
|
|
816
|
+
if (responseType !== undefined)
|
|
817
|
+
config.responseType = responseType;
|
|
818
|
+
return this.client.get(config);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
const MAX_PAGES = 10000;
|
|
823
|
+
function Queryable(Base) {
|
|
824
|
+
return class extends Base {
|
|
825
|
+
async one(query = {}) {
|
|
826
|
+
const { items } = (await this.client.get({
|
|
827
|
+
endpoint: `/${this.path}`,
|
|
828
|
+
// TODO(cuenca-js#64-followup): tighten generic bound to preserve Q through toParams — currently downcast to QueryParams.
|
|
829
|
+
params: this.toParams({
|
|
830
|
+
...query,
|
|
831
|
+
limit: 2,
|
|
832
|
+
}),
|
|
833
|
+
}));
|
|
834
|
+
if (!items || items.length === 0)
|
|
835
|
+
throw new NoResultFound();
|
|
836
|
+
if (items.length > 1)
|
|
837
|
+
throw new MultipleResultsFound();
|
|
838
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
839
|
+
return this.fromObject(items[0]);
|
|
840
|
+
}
|
|
841
|
+
async first(query = {}) {
|
|
842
|
+
const { items } = (await this.client.get({
|
|
843
|
+
endpoint: `/${this.path}`,
|
|
844
|
+
// TODO(cuenca-js#64-followup): tighten generic bound to preserve Q through toParams — currently downcast to QueryParams.
|
|
845
|
+
params: this.toParams({
|
|
846
|
+
...query,
|
|
847
|
+
limit: 1,
|
|
848
|
+
}),
|
|
849
|
+
}));
|
|
850
|
+
if (!items || items.length === 0)
|
|
851
|
+
return null;
|
|
852
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
853
|
+
return this.fromObject(items[0]);
|
|
854
|
+
}
|
|
855
|
+
async count(query = {}) {
|
|
856
|
+
const params = {
|
|
857
|
+
// TODO(cuenca-js#64-followup): tighten generic bound to preserve Q through toParams — currently downcast to QueryParams.
|
|
858
|
+
...this.toParams(query),
|
|
859
|
+
count: 1,
|
|
860
|
+
};
|
|
861
|
+
const { count } = (await this.client.get({
|
|
862
|
+
endpoint: `/${this.path}`,
|
|
863
|
+
params,
|
|
864
|
+
}));
|
|
865
|
+
return count ?? 0;
|
|
866
|
+
}
|
|
867
|
+
async page(query, cursor) {
|
|
868
|
+
// TODO(cuenca-js#64-followup): tighten generic bound to preserve Q through toQueryString — currently downcast to QueryParams.
|
|
869
|
+
const actualQuery = (query ?? {});
|
|
870
|
+
const normalized = cursor && cursor.length > 0 ? decodeCursor(cursor) : null;
|
|
871
|
+
const endpoint = normalized ?? `/${this.path}?${this.toQueryString(actualQuery)}`;
|
|
872
|
+
const response = (await this.client.get({ endpoint }));
|
|
873
|
+
// Cast justified: fromObject typing on Base narrows to M — TS can't prove it structurally.
|
|
874
|
+
const items = (response.items ?? []).map((item) => this.fromObject(item));
|
|
875
|
+
return {
|
|
876
|
+
items,
|
|
877
|
+
nextCursor: response.next_page_uri
|
|
878
|
+
? encodeCursor(response.next_page_uri)
|
|
879
|
+
: null,
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
async *all(query = {}) {
|
|
883
|
+
const seen = new Set();
|
|
884
|
+
let cursor;
|
|
885
|
+
let pageCount = 0;
|
|
886
|
+
while (true) {
|
|
887
|
+
/* v8 ignore next 5 */
|
|
888
|
+
if (pageCount >= MAX_PAGES) {
|
|
889
|
+
throw new PaginationError(`Pagination exceeded ${MAX_PAGES} pages; aborting`);
|
|
890
|
+
}
|
|
891
|
+
pageCount += 1;
|
|
892
|
+
// eslint-disable-next-line no-await-in-loop
|
|
893
|
+
const { items, nextCursor } = await this.page(query, cursor);
|
|
894
|
+
if (nextCursor) {
|
|
895
|
+
if (nextCursor === cursor || seen.has(nextCursor)) {
|
|
896
|
+
throw new PaginationError(`Repeated next_page_uri: ${nextCursor}`);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
900
|
+
for (const item of items)
|
|
901
|
+
yield item;
|
|
902
|
+
if (!nextCursor)
|
|
903
|
+
return;
|
|
904
|
+
seen.add(nextCursor);
|
|
905
|
+
cursor = nextCursor;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Extracts the top-level path segment(s) from a resource URI, supporting nested paths
|
|
912
|
+
* (e.g. `/bridge/accounts/AC123` → `bridge/accounts`).
|
|
913
|
+
*
|
|
914
|
+
* NOT supported: sub-resource URIs like `/accounts/AC1/refund` — these return
|
|
915
|
+
* `accounts/AC1` which is not a valid resource key. If the API introduces
|
|
916
|
+
* sub-resources, extend this helper.
|
|
917
|
+
*/
|
|
918
|
+
function getResourcePath(uri) {
|
|
919
|
+
if (!uri)
|
|
920
|
+
return null;
|
|
921
|
+
const match = uri.match(/^\/([^?]+)\/[^/?]+(?:\?.*)?$/);
|
|
922
|
+
if (!match)
|
|
923
|
+
return null;
|
|
924
|
+
return match[1];
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
class AccountResource extends Retrievable(Queryable(Resource)) {
|
|
928
|
+
constructor(client) {
|
|
929
|
+
super(client, 'accounts', Account.fromObject);
|
|
930
|
+
}
|
|
1003
931
|
}
|
|
932
|
+
var AccountResource$1 = AccountResource;
|
|
1004
933
|
|
|
1005
|
-
class
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
934
|
+
class AlertResource extends Creatable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
935
|
+
constructor(client) {
|
|
936
|
+
super(client, 'alerts', Alert.fromObject);
|
|
937
|
+
}
|
|
938
|
+
async create(req) {
|
|
939
|
+
return this._create(AlertUpdateRequest.toCleanObject(req));
|
|
940
|
+
}
|
|
941
|
+
async update(alertId, req) {
|
|
942
|
+
return this._update(alertId, AlertUpdateRequest.toCleanObject(req));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
var AlertResource$1 = AlertResource;
|
|
1012
946
|
|
|
1013
|
-
|
|
1014
|
-
|
|
947
|
+
class ApiKeyResource extends Creatable(Deactivable(Queryable(Retrievable(Updateable(Resource))))) {
|
|
948
|
+
constructor(client) {
|
|
949
|
+
super(client, 'api_keys', ApiKey.fromObject);
|
|
950
|
+
}
|
|
951
|
+
async create() {
|
|
952
|
+
return this._create({});
|
|
953
|
+
}
|
|
954
|
+
async deactivate(apiKeyId, minutes = 0) {
|
|
955
|
+
// Sends { minutes: 0 } as request body on DELETE. The cuenca backend interprets
|
|
956
|
+
// this as "revoke immediately". Previous implementation omitted the body entirely;
|
|
957
|
+
// if backend behavior differs, revisit this default (cuenca-js#64 review).
|
|
958
|
+
return this._deactivate(apiKeyId, { minutes });
|
|
959
|
+
}
|
|
960
|
+
async update(apiKeyId, metadata, userId = 'me') {
|
|
961
|
+
return this._update(apiKeyId, ApiKeyUpdateRequest.toCleanObject({ userId, metadata }));
|
|
962
|
+
}
|
|
1015
963
|
}
|
|
964
|
+
var ApiKeyResource$1 = ApiKeyResource;
|
|
1016
965
|
|
|
1017
|
-
class
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
966
|
+
class ArpcResource extends Creatable(Resource) {
|
|
967
|
+
constructor(client) {
|
|
968
|
+
super(client, 'arpc', Arpc.fromObject);
|
|
969
|
+
}
|
|
970
|
+
async create(req) {
|
|
971
|
+
return this._create(ArpcRequest.toObject(req));
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
var ArpcResource$1 = ArpcResource;
|
|
975
|
+
|
|
976
|
+
const RELATED_TRANSACTION_FACTORIES$1 = {
|
|
977
|
+
bill_payments: BillPayment.fromObject,
|
|
978
|
+
card_transactions: CardTransaction.fromObject,
|
|
979
|
+
commissions: Commission.fromObject,
|
|
980
|
+
deposits: Deposit.fromObject,
|
|
981
|
+
savings: Saving.fromObject,
|
|
982
|
+
transfers: Transfer.fromObject,
|
|
983
|
+
wallet_transactions: WalletTransaction.fromObject,
|
|
984
|
+
whatsapp_transfers: WhatsAppTransfer.fromObject,
|
|
985
|
+
};
|
|
986
|
+
const FUNDING_INSTRUMENT_FACTORIES = {
|
|
987
|
+
...RELATED_TRANSACTION_FACTORIES$1,
|
|
988
|
+
accounts: Account.fromObject,
|
|
989
|
+
cards: Card.fromObject,
|
|
990
|
+
'bridge/accounts': BridgeAccount.fromObject,
|
|
991
|
+
};
|
|
992
|
+
class BalanceEntryResource extends Queryable(Retrievable(Resource)) {
|
|
993
|
+
constructor(client) {
|
|
994
|
+
super(client, 'balance_entries', BalanceEntry.fromObject);
|
|
995
|
+
}
|
|
996
|
+
async relatedTransaction(relatedTransactionUri) {
|
|
997
|
+
const path = getResourcePath(relatedTransactionUri);
|
|
998
|
+
if (!path)
|
|
999
|
+
return null;
|
|
1000
|
+
const factory = RELATED_TRANSACTION_FACTORIES$1[path];
|
|
1001
|
+
if (!factory)
|
|
1002
|
+
return null;
|
|
1003
|
+
const response = await this.client.get({ endpoint: relatedTransactionUri });
|
|
1004
|
+
return factory(response);
|
|
1005
|
+
}
|
|
1006
|
+
async fundingInstrument(fundingInstrumentUri) {
|
|
1007
|
+
const path = getResourcePath(fundingInstrumentUri);
|
|
1008
|
+
if (!path)
|
|
1009
|
+
return null;
|
|
1010
|
+
const factory = FUNDING_INSTRUMENT_FACTORIES[path];
|
|
1011
|
+
if (!factory)
|
|
1012
|
+
return null;
|
|
1013
|
+
const response = await this.client.get({ endpoint: fundingInstrumentUri });
|
|
1014
|
+
return factory(response);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
var BalanceEntryResource$1 = BalanceEntryResource;
|
|
1023
1018
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1019
|
+
class BillPaymentResource extends Queryable(Retrievable(Resource)) {
|
|
1020
|
+
constructor(client) {
|
|
1021
|
+
super(client, 'bill_payments', BillPayment.fromObject);
|
|
1022
|
+
}
|
|
1023
|
+
async serviceProvider(providerUri) {
|
|
1024
|
+
if (!providerUri)
|
|
1025
|
+
return null;
|
|
1026
|
+
const response = await this.client.get({ endpoint: providerUri });
|
|
1027
|
+
return ServiceProvider.fromObject(response);
|
|
1028
|
+
}
|
|
1030
1029
|
}
|
|
1030
|
+
var BillPaymentResource$1 = BillPaymentResource;
|
|
1031
1031
|
|
|
1032
|
-
class
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
providerUrl,
|
|
1050
|
-
}) {
|
|
1051
|
-
this.id = id;
|
|
1052
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1053
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1054
|
-
this.deactivatedAt = dateToUTC(deactivatedAt);
|
|
1055
|
-
this.platformId = platformId;
|
|
1056
|
-
this.filesUri = filesUri || [];
|
|
1057
|
-
this.userId = userId;
|
|
1058
|
-
this.verificationId = verificationId;
|
|
1059
|
-
this.identityId = identityId;
|
|
1060
|
-
this.govtIdStatus = enumValueFromString(VerificationStatus, govtIdStatus);
|
|
1061
|
-
this.proofOfAddressStatus = enumValueFromString(
|
|
1062
|
-
VerificationStatus,
|
|
1063
|
-
proofOfAddressStatus,
|
|
1064
|
-
);
|
|
1065
|
-
this.proofOfLifeStatus = enumValueFromString(
|
|
1066
|
-
VerificationStatus,
|
|
1067
|
-
proofOfLifeStatus,
|
|
1068
|
-
);
|
|
1069
|
-
this.sourceType = enumValueFromString(KYCValidationSource, sourceType);
|
|
1070
|
-
this.flowId = flowId;
|
|
1071
|
-
this.status = enumValueFromString(VerificationStatus, status);
|
|
1072
|
-
this.providerUrl = providerUrl;
|
|
1073
|
-
}
|
|
1032
|
+
class BridgeAccountResource extends Queryable(Retrievable(Updateable(Resource))) {
|
|
1033
|
+
constructor(client) {
|
|
1034
|
+
super(client, 'bridge/accounts', BridgeAccount.fromObject);
|
|
1035
|
+
}
|
|
1036
|
+
async update({ userId = 'me', ...req }) {
|
|
1037
|
+
return this._update(userId, UserUpdateRequest.toCleanObject(req));
|
|
1038
|
+
}
|
|
1039
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1040
|
+
toParams(query) {
|
|
1041
|
+
return toParams$1(query);
|
|
1042
|
+
}
|
|
1043
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1044
|
+
toQueryString(query) {
|
|
1045
|
+
return toQueryString$1(query);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
var BridgeAccountResource$1 = BridgeAccountResource;
|
|
1074
1049
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
createdAt: obj.created_at,
|
|
1080
|
-
updatedAt: obj.updated_at,
|
|
1081
|
-
deactivatedAt: obj.deactivated_at,
|
|
1082
|
-
platformId: obj.platform_id,
|
|
1083
|
-
filesUri: obj.files_uri,
|
|
1084
|
-
userId: obj.user_id,
|
|
1085
|
-
verificationId: obj.verification_id,
|
|
1086
|
-
identityId: obj.identity_id,
|
|
1087
|
-
govtIdStatus: obj.govt_id_status,
|
|
1088
|
-
proofOfAddressStatus: obj.proof_of_address_status,
|
|
1089
|
-
proofOfLifeStatus: obj.proof_of_life_status,
|
|
1090
|
-
sourceType: obj.source_type,
|
|
1091
|
-
flowId: obj.flow_id,
|
|
1092
|
-
providerUrl: obj.provider_url,
|
|
1093
|
-
});
|
|
1050
|
+
class BridgeBankAccountResource extends Retrievable(Queryable(Resource)) {
|
|
1051
|
+
constructor(client) {
|
|
1052
|
+
super(client, 'bridge/bank_accounts', BridgeBankAccount.fromObject);
|
|
1053
|
+
}
|
|
1094
1054
|
}
|
|
1055
|
+
var BridgeBankAccountResource$1 = BridgeBankAccountResource;
|
|
1095
1056
|
|
|
1096
|
-
class
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1057
|
+
class BridgeClabeResource extends Queryable(Resource) {
|
|
1058
|
+
constructor(client) {
|
|
1059
|
+
super(client, 'bridge/clabes', BridgeClabe.fromObject);
|
|
1060
|
+
}
|
|
1061
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1062
|
+
toParams(query) {
|
|
1063
|
+
return toParams$1(query);
|
|
1064
|
+
}
|
|
1065
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1066
|
+
toQueryString(query) {
|
|
1067
|
+
return toQueryString$1(query);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
var BridgeClabeResource$1 = BridgeClabeResource;
|
|
1100
1071
|
|
|
1101
|
-
|
|
1072
|
+
class BridgeTransactionResource extends Retrievable(Queryable(Resource)) {
|
|
1073
|
+
constructor(client) {
|
|
1074
|
+
super(client, 'bridge/transactions', BridgeTransaction.fromObject);
|
|
1075
|
+
}
|
|
1076
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1077
|
+
toParams(query) {
|
|
1078
|
+
return toParams$1(query);
|
|
1079
|
+
}
|
|
1080
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1081
|
+
toQueryString(query) {
|
|
1082
|
+
return toQueryString$1(query);
|
|
1083
|
+
}
|
|
1102
1084
|
}
|
|
1085
|
+
var BridgeTransactionResource$1 = BridgeTransactionResource;
|
|
1103
1086
|
|
|
1104
|
-
class
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1087
|
+
class CardActivationResource extends Creatable(Resource) {
|
|
1088
|
+
constructor(client) {
|
|
1089
|
+
super(client, 'card_activations', CardActivation.fromObject);
|
|
1090
|
+
}
|
|
1091
|
+
async create(req) {
|
|
1092
|
+
return this._create(CardActivationRequest.toCleanObject(req));
|
|
1093
|
+
}
|
|
1094
|
+
async card(cardUri) {
|
|
1095
|
+
if (!cardUri)
|
|
1096
|
+
return null;
|
|
1097
|
+
const response = await this.client.get({ endpoint: cardUri });
|
|
1098
|
+
return Card.fromObject(response);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
var CardActivationResource$1 = CardActivationResource;
|
|
1115
1102
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
get withdrawal() {
|
|
1133
|
-
return this._withdrawal;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
set withdrawal(value) {
|
|
1137
|
-
if (!value) return;
|
|
1138
|
-
this._withdrawal = TransactionalProfileServices.fromObject(value);
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
static fromObject = ({ currency, deposits, withdrawal, ...obj }) =>
|
|
1142
|
-
new TransactionalProfile({
|
|
1143
|
-
currency,
|
|
1144
|
-
deposits,
|
|
1145
|
-
withdrawal,
|
|
1146
|
-
payersNum: obj.payers_num,
|
|
1147
|
-
recipientsNum: obj.recipients_num,
|
|
1148
|
-
monthlyAmount: obj.monthly_amount,
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
class BaseUser {
|
|
1153
|
-
constructor({
|
|
1154
|
-
address,
|
|
1155
|
-
clabe,
|
|
1156
|
-
emailAddress,
|
|
1157
|
-
id,
|
|
1158
|
-
level,
|
|
1159
|
-
meta,
|
|
1160
|
-
nationality,
|
|
1161
|
-
platformId,
|
|
1162
|
-
phoneNumber,
|
|
1163
|
-
requiredLevel,
|
|
1164
|
-
rfc,
|
|
1165
|
-
status,
|
|
1166
|
-
createdAt,
|
|
1167
|
-
updatedAt,
|
|
1168
|
-
userType,
|
|
1169
|
-
}) {
|
|
1170
|
-
this.address = address;
|
|
1171
|
-
this.clabe = clabe;
|
|
1172
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1173
|
-
this.emailAddress = emailAddress;
|
|
1174
|
-
this.id = id;
|
|
1175
|
-
this.level = level;
|
|
1176
|
-
this.meta = meta;
|
|
1177
|
-
this.nationality = nationality;
|
|
1178
|
-
this.platformId = platformId;
|
|
1179
|
-
this.phoneNumber = phoneNumber;
|
|
1180
|
-
this.requiredLevel = requiredLevel;
|
|
1181
|
-
this.rfc = rfc;
|
|
1182
|
-
this.status = enumValueFromString(UserStatus, status);
|
|
1183
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1184
|
-
this.userType = userType;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
get address() {
|
|
1188
|
-
return this._address;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
set address(value) {
|
|
1192
|
-
if (!value) return;
|
|
1193
|
-
this._address = Address.fromObject(value);
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
static fromObject = ({
|
|
1197
|
-
address,
|
|
1198
|
-
clabe,
|
|
1199
|
-
id,
|
|
1200
|
-
level,
|
|
1201
|
-
nationality,
|
|
1202
|
-
rfc,
|
|
1203
|
-
status,
|
|
1204
|
-
...obj
|
|
1205
|
-
}) =>
|
|
1206
|
-
new BaseUser({
|
|
1207
|
-
address,
|
|
1208
|
-
clabe,
|
|
1209
|
-
id,
|
|
1210
|
-
level,
|
|
1211
|
-
meta: obj.meta,
|
|
1212
|
-
nationality,
|
|
1213
|
-
rfc,
|
|
1214
|
-
status,
|
|
1215
|
-
createdAt: obj.created_at,
|
|
1216
|
-
emailAddress: obj.email_address,
|
|
1217
|
-
phoneNumber: obj.phone_number,
|
|
1218
|
-
platformId: obj.platform_id,
|
|
1219
|
-
requiredLevel: obj.required_level,
|
|
1220
|
-
updatedAt: obj.updated_at,
|
|
1221
|
-
userType: obj.user_type,
|
|
1222
|
-
});
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
class Partner extends BaseUser {
|
|
1226
|
-
constructor({
|
|
1227
|
-
address,
|
|
1228
|
-
audit,
|
|
1229
|
-
businessDetails,
|
|
1230
|
-
businessModel,
|
|
1231
|
-
businessName,
|
|
1232
|
-
clabe,
|
|
1233
|
-
createdAt,
|
|
1234
|
-
documentationUrl,
|
|
1235
|
-
emailAddress,
|
|
1236
|
-
externalAccount,
|
|
1237
|
-
folio,
|
|
1238
|
-
id,
|
|
1239
|
-
incorporationDate,
|
|
1240
|
-
legalName,
|
|
1241
|
-
legalRepresentatives,
|
|
1242
|
-
level,
|
|
1243
|
-
license,
|
|
1244
|
-
meta,
|
|
1245
|
-
nationality,
|
|
1246
|
-
phoneNumber,
|
|
1247
|
-
platformId,
|
|
1248
|
-
requiredLevel,
|
|
1249
|
-
rfc,
|
|
1250
|
-
shareholders,
|
|
1251
|
-
status,
|
|
1252
|
-
transactionalProfile,
|
|
1253
|
-
updatedAt,
|
|
1254
|
-
userId,
|
|
1255
|
-
userType,
|
|
1256
|
-
vulnerableActivity,
|
|
1257
|
-
webSite,
|
|
1258
|
-
}) {
|
|
1259
|
-
super({
|
|
1260
|
-
address,
|
|
1261
|
-
clabe,
|
|
1262
|
-
emailAddress,
|
|
1263
|
-
rfc,
|
|
1264
|
-
id,
|
|
1265
|
-
level,
|
|
1266
|
-
meta,
|
|
1267
|
-
nationality,
|
|
1268
|
-
platformId,
|
|
1269
|
-
phoneNumber,
|
|
1270
|
-
requiredLevel,
|
|
1271
|
-
status,
|
|
1272
|
-
createdAt,
|
|
1273
|
-
updatedAt,
|
|
1274
|
-
userType,
|
|
1275
|
-
});
|
|
1276
|
-
this.audit = audit;
|
|
1277
|
-
this.businessModel = businessModel;
|
|
1278
|
-
this.businessName = businessName;
|
|
1279
|
-
this.businessDetails = businessDetails;
|
|
1280
|
-
this.documentationUrl = documentationUrl;
|
|
1281
|
-
this.incorporationDate = dateToUTC(incorporationDate);
|
|
1282
|
-
this.externalAccount = externalAccount;
|
|
1283
|
-
this.folio = folio;
|
|
1284
|
-
this.legalName = legalName;
|
|
1285
|
-
this.license = license;
|
|
1286
|
-
this.shareholders = shareholders;
|
|
1287
|
-
this.legalRepresentatives = legalRepresentatives;
|
|
1288
|
-
this.transactionalProfile = transactionalProfile;
|
|
1289
|
-
this.userId = userId;
|
|
1290
|
-
this.vulnerableActivity = vulnerableActivity;
|
|
1291
|
-
this.webSite = webSite;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
get shareholders() {
|
|
1295
|
-
return this._shareholders;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
set shareholders(value) {
|
|
1299
|
-
if (!value) return;
|
|
1300
|
-
this._shareholders = value.map((sh) => ShareholderMoral.fromObject(sh));
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
get legalRepresentatives() {
|
|
1304
|
-
return this._legalRepresentatives;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
set legalRepresentatives(value) {
|
|
1308
|
-
if (!value) return;
|
|
1309
|
-
this._legalRepresentatives = value.map((lr) =>
|
|
1310
|
-
LegalRepresentatives.fromObject(lr),
|
|
1311
|
-
);
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
get externalAccount() {
|
|
1315
|
-
return this._externalAccount;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
set externalAccount(value) {
|
|
1319
|
-
if (!value) return;
|
|
1320
|
-
this._externalAccount = ExternalAccount.fromObject(value);
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
get vulnerableActivity() {
|
|
1324
|
-
return this._vulnerableActivity;
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
set vulnerableActivity(value) {
|
|
1328
|
-
if (!value) return;
|
|
1329
|
-
this._vulnerableActivity = VulnerableActivity.fromObject(value);
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
get audit() {
|
|
1333
|
-
return this._audit;
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
set audit(value) {
|
|
1337
|
-
if (!value) return;
|
|
1338
|
-
this._audit = Audit.fromObject(value);
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
get license() {
|
|
1342
|
-
return this._license;
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
set license(value) {
|
|
1346
|
-
if (!value) return;
|
|
1347
|
-
this._license = License.fromObject(value);
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
get transactionalProfile() {
|
|
1351
|
-
return this._transactionalProfile;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
set transactionalProfile(value) {
|
|
1355
|
-
if (!value) return;
|
|
1356
|
-
this._transactionalProfile = TransactionalProfile.fromObject(value);
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
get businessDetails() {
|
|
1360
|
-
return this._businessDetails;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
set businessDetails(value) {
|
|
1364
|
-
if (!value) return;
|
|
1365
|
-
this._businessDetails = BusinessDetails.fromObject(value);
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
static fromObject = ({
|
|
1369
|
-
audit,
|
|
1370
|
-
address,
|
|
1371
|
-
clabe,
|
|
1372
|
-
folio,
|
|
1373
|
-
id,
|
|
1374
|
-
level,
|
|
1375
|
-
license,
|
|
1376
|
-
nationality,
|
|
1377
|
-
rfc,
|
|
1378
|
-
status,
|
|
1379
|
-
shareholders,
|
|
1380
|
-
...obj
|
|
1381
|
-
}) =>
|
|
1382
|
-
new Partner({
|
|
1383
|
-
address,
|
|
1384
|
-
audit,
|
|
1385
|
-
clabe,
|
|
1386
|
-
folio,
|
|
1387
|
-
id,
|
|
1388
|
-
level,
|
|
1389
|
-
license,
|
|
1390
|
-
nationality,
|
|
1391
|
-
rfc,
|
|
1392
|
-
shareholders,
|
|
1393
|
-
status,
|
|
1394
|
-
legalName: obj.legal_name,
|
|
1395
|
-
legalRepresentatives: obj.legal_representatives,
|
|
1396
|
-
businessModel: obj.business_model,
|
|
1397
|
-
businessName: obj.business_name,
|
|
1398
|
-
businessDetails: obj.business_details,
|
|
1399
|
-
createdAt: obj.created_at,
|
|
1400
|
-
documentationUrl: obj.documentation_url,
|
|
1401
|
-
emailAddress: obj.email_address,
|
|
1402
|
-
externalAccount: obj.external_account,
|
|
1403
|
-
incorporationDate: obj.incorporation_date,
|
|
1404
|
-
meta: obj.meta,
|
|
1405
|
-
phoneNumber: obj.phone_number,
|
|
1406
|
-
platformId: obj.platform_id,
|
|
1407
|
-
requiredLevel: obj.required_level,
|
|
1408
|
-
transactionalProfile: obj.transactional_profile,
|
|
1409
|
-
updatedAt: obj.updated_at,
|
|
1410
|
-
userId: obj.user_id,
|
|
1411
|
-
userType: obj.user_type,
|
|
1412
|
-
vulnerableActivity: obj.vulnerable_activity,
|
|
1413
|
-
webSite: obj.web_site,
|
|
1414
|
-
});
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
class PostalCode {
|
|
1418
|
-
constructor({
|
|
1419
|
-
id,
|
|
1420
|
-
postalCode,
|
|
1421
|
-
colonia,
|
|
1422
|
-
city,
|
|
1423
|
-
state,
|
|
1424
|
-
country,
|
|
1425
|
-
createdAt,
|
|
1426
|
-
updatedAt,
|
|
1427
|
-
}) {
|
|
1428
|
-
this.id = id;
|
|
1429
|
-
this.postalCode = postalCode;
|
|
1430
|
-
this.colonia = colonia;
|
|
1431
|
-
this.city = city;
|
|
1432
|
-
this.state = enumValueFromString(State, state);
|
|
1433
|
-
this.country = enumValueFromString(Country, country);
|
|
1434
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1435
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
static fromObject = ({ id, colonia, city, state, country, ...obj }) =>
|
|
1439
|
-
new PostalCode({
|
|
1440
|
-
id,
|
|
1441
|
-
colonia,
|
|
1442
|
-
city,
|
|
1443
|
-
state,
|
|
1444
|
-
country,
|
|
1445
|
-
postalCode: obj.postal_code,
|
|
1446
|
-
createdAt: obj.created_at,
|
|
1447
|
-
updatedAt: obj.updated_at,
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
class Wallet {
|
|
1452
|
-
constructor({ balance, createdAt, deactivatedAt, id, userId, updatedAt }) {
|
|
1453
|
-
this.balance = balance;
|
|
1454
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1455
|
-
this.deactivatedAt = dateToUTC(deactivatedAt);
|
|
1456
|
-
this.id = id;
|
|
1457
|
-
this.userId = userId;
|
|
1458
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
class Saving extends Wallet {
|
|
1463
|
-
constructor({
|
|
1464
|
-
balance,
|
|
1465
|
-
category,
|
|
1466
|
-
createdAt,
|
|
1467
|
-
deactivatedAt,
|
|
1468
|
-
goalAmount,
|
|
1469
|
-
goalDate,
|
|
1470
|
-
id,
|
|
1471
|
-
name,
|
|
1472
|
-
userId,
|
|
1473
|
-
updatedAt,
|
|
1474
|
-
}) {
|
|
1475
|
-
super({
|
|
1476
|
-
balance,
|
|
1477
|
-
createdAt,
|
|
1478
|
-
deactivatedAt,
|
|
1479
|
-
id,
|
|
1480
|
-
userId,
|
|
1481
|
-
updatedAt,
|
|
1482
|
-
});
|
|
1483
|
-
this.category = enumValueFromString(SavingCategory, category);
|
|
1484
|
-
this.goalAmount = goalAmount;
|
|
1485
|
-
this.goalDate = dateToUTC(goalDate);
|
|
1486
|
-
this.name = name;
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
static fromObject = ({ balance, category, id, name, ...obj }) =>
|
|
1490
|
-
new Saving({
|
|
1491
|
-
balance,
|
|
1492
|
-
category,
|
|
1493
|
-
id,
|
|
1494
|
-
name,
|
|
1495
|
-
createdAt: obj.created_at,
|
|
1496
|
-
deactivatedAt: obj.deactivated_at,
|
|
1497
|
-
goalAmount: obj.goal_amount,
|
|
1498
|
-
goalDate: obj.goal_date,
|
|
1499
|
-
userId: obj.user_id,
|
|
1500
|
-
updatedAt: obj.updated_at,
|
|
1501
|
-
});
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
const categoriesFromString = (categoriesList) => {
|
|
1505
|
-
if (categoriesList == null) return [];
|
|
1506
|
-
return categoriesList.map((category) =>
|
|
1507
|
-
enumValueFromString(ServiceProviderCategory, category),
|
|
1508
|
-
);
|
|
1509
|
-
};
|
|
1510
|
-
|
|
1511
|
-
class ServiceProvider {
|
|
1512
|
-
constructor({ categories, id, name, providerKey }) {
|
|
1513
|
-
this.categories = categoriesFromString(categories);
|
|
1514
|
-
this.id = id;
|
|
1515
|
-
this.name = name;
|
|
1516
|
-
this.providerKey = providerKey;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
static fromObject = ({ categories, id, name, ...obj }) =>
|
|
1520
|
-
new ServiceProvider({
|
|
1521
|
-
categories,
|
|
1522
|
-
id,
|
|
1523
|
-
name,
|
|
1524
|
-
providerKey: obj.provider_key,
|
|
1525
|
-
});
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
class Session {
|
|
1529
|
-
constructor({
|
|
1530
|
-
createdAt,
|
|
1531
|
-
expiresAt,
|
|
1532
|
-
failureUrl,
|
|
1533
|
-
id,
|
|
1534
|
-
platformId,
|
|
1535
|
-
successUrl,
|
|
1536
|
-
type,
|
|
1537
|
-
userId,
|
|
1538
|
-
}) {
|
|
1539
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1540
|
-
this.expiresAt = dateToUTC(expiresAt);
|
|
1541
|
-
this.failureUrl = failureUrl;
|
|
1542
|
-
this.id = id;
|
|
1543
|
-
this.platformId = platformId;
|
|
1544
|
-
this.successUrl = successUrl;
|
|
1545
|
-
this.type = enumValueFromString(SessionType, type);
|
|
1546
|
-
this.userId = userId;
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
static fromObject = ({ id, type, ...obj }) =>
|
|
1550
|
-
new Session({
|
|
1551
|
-
id,
|
|
1552
|
-
type,
|
|
1553
|
-
createdAt: obj.created_at,
|
|
1554
|
-
expiresAt: obj.expires_at,
|
|
1555
|
-
failureUrl: obj.failure_url,
|
|
1556
|
-
platformId: obj.platform_id,
|
|
1557
|
-
successUrl: obj.success_url,
|
|
1558
|
-
userId: obj.user_id,
|
|
1559
|
-
});
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
class Statement {
|
|
1563
|
-
constructor({ createdAt, id, month, year }) {
|
|
1564
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1565
|
-
this.id = id;
|
|
1566
|
-
this.month = month;
|
|
1567
|
-
this.year = year;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
static fromObject = ({ id, month, year, ...obj }) =>
|
|
1571
|
-
new Statement({
|
|
1572
|
-
id,
|
|
1573
|
-
month,
|
|
1574
|
-
year,
|
|
1575
|
-
createdAt: obj.created_at,
|
|
1576
|
-
});
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
class Transfer extends Transaction {
|
|
1580
|
-
constructor({
|
|
1581
|
-
accountNumber,
|
|
1582
|
-
amount,
|
|
1583
|
-
createdAt,
|
|
1584
|
-
descriptor,
|
|
1585
|
-
destinationUri,
|
|
1586
|
-
id,
|
|
1587
|
-
idempotencyKey,
|
|
1588
|
-
network,
|
|
1589
|
-
recipientName,
|
|
1590
|
-
status,
|
|
1591
|
-
trackingKey,
|
|
1592
|
-
updatedAt,
|
|
1593
|
-
userId,
|
|
1594
|
-
}) {
|
|
1595
|
-
super({
|
|
1596
|
-
amount,
|
|
1597
|
-
createdAt,
|
|
1598
|
-
descriptor,
|
|
1599
|
-
status,
|
|
1600
|
-
userId,
|
|
1601
|
-
});
|
|
1602
|
-
this.accountNumber = accountNumber;
|
|
1603
|
-
this.destinationUri = destinationUri;
|
|
1604
|
-
this.id = id;
|
|
1605
|
-
this.idempotencyKey = idempotencyKey;
|
|
1606
|
-
this.network = enumValueFromString(TransferNetwork, network);
|
|
1607
|
-
this.recipientName = recipientName;
|
|
1608
|
-
this.trackingKey = trackingKey;
|
|
1609
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
1613
|
-
new Transfer({
|
|
1614
|
-
amount,
|
|
1615
|
-
descriptor,
|
|
1616
|
-
id,
|
|
1617
|
-
network,
|
|
1618
|
-
status,
|
|
1619
|
-
accountNumber: obj.account_number,
|
|
1620
|
-
createdAt: obj.created_at,
|
|
1621
|
-
destinationUri: obj.destination_uri,
|
|
1622
|
-
idempotencyKey: obj.idempotency_key,
|
|
1623
|
-
recipientName: obj.recipient_name,
|
|
1624
|
-
trackingKey: obj.tracking_key,
|
|
1625
|
-
updatedAt: obj.updated_at,
|
|
1626
|
-
userId: obj.user_id,
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
class User {
|
|
1631
|
-
constructor({
|
|
1632
|
-
address,
|
|
1633
|
-
blacklistValidationStatus,
|
|
1634
|
-
clabe,
|
|
1635
|
-
countryOfBirth,
|
|
1636
|
-
createdAt,
|
|
1637
|
-
curp,
|
|
1638
|
-
curpDocument,
|
|
1639
|
-
dateOfBirth,
|
|
1640
|
-
emailAddress,
|
|
1641
|
-
firstSurname,
|
|
1642
|
-
gender,
|
|
1643
|
-
govtId,
|
|
1644
|
-
id,
|
|
1645
|
-
isDormant,
|
|
1646
|
-
isFraud,
|
|
1647
|
-
isPldBlocked,
|
|
1648
|
-
isSecurityMode,
|
|
1649
|
-
level,
|
|
1650
|
-
names,
|
|
1651
|
-
nationality,
|
|
1652
|
-
phoneNumber,
|
|
1653
|
-
profession,
|
|
1654
|
-
proofOfAddress,
|
|
1655
|
-
proofOfLife,
|
|
1656
|
-
requiredLevel,
|
|
1657
|
-
rfc,
|
|
1658
|
-
secondSurname,
|
|
1659
|
-
stateOfBirth,
|
|
1660
|
-
status,
|
|
1661
|
-
termsOfService,
|
|
1662
|
-
updatedAt,
|
|
1663
|
-
userTosAgreementsId,
|
|
1664
|
-
userType,
|
|
1665
|
-
verificationId,
|
|
1666
|
-
fiscalRegimeCode,
|
|
1667
|
-
}) {
|
|
1668
|
-
this.address = address;
|
|
1669
|
-
this.blacklistValidationStatus = enumValueFromString(
|
|
1670
|
-
VerificationStatus,
|
|
1671
|
-
blacklistValidationStatus,
|
|
1672
|
-
);
|
|
1673
|
-
this.clabe = clabe;
|
|
1674
|
-
this.countryOfBirth = countryOfBirth;
|
|
1675
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1676
|
-
this.curp = curp;
|
|
1677
|
-
this.curpDocument = curpDocument;
|
|
1678
|
-
this.dateOfBirth = dateOfBirth;
|
|
1679
|
-
this.emailAddress = emailAddress;
|
|
1680
|
-
this.firstSurname = firstSurname;
|
|
1681
|
-
this.gender = gender;
|
|
1682
|
-
this.id = id;
|
|
1683
|
-
this.isDormant = isDormant;
|
|
1684
|
-
this.isFraud = isFraud;
|
|
1685
|
-
this.isPldBlocked = isPldBlocked;
|
|
1686
|
-
this.isSecurityMode = isSecurityMode;
|
|
1687
|
-
this.level = level;
|
|
1688
|
-
this.names = names;
|
|
1689
|
-
this.nationality = nationality;
|
|
1690
|
-
this.phoneNumber = phoneNumber;
|
|
1691
|
-
this.profession = profession;
|
|
1692
|
-
this.govtId = govtId;
|
|
1693
|
-
this.proofOfAddress = proofOfAddress;
|
|
1694
|
-
this.proofOfLife = proofOfLife;
|
|
1695
|
-
this.requiredLevel = requiredLevel;
|
|
1696
|
-
this.rfc = rfc;
|
|
1697
|
-
this.secondSurname = secondSurname;
|
|
1698
|
-
this.stateOfBirth = stateOfBirth;
|
|
1699
|
-
this.status = enumValueFromString(UserStatus, status);
|
|
1700
|
-
this.termsOfService = termsOfService;
|
|
1701
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1702
|
-
this.userTosAgreementsId = userTosAgreementsId;
|
|
1703
|
-
this.userType = userType;
|
|
1704
|
-
this.verificationId = verificationId;
|
|
1705
|
-
this.fiscalRegimeCode = enumValueFromString(
|
|
1706
|
-
SATRegimeCode,
|
|
1707
|
-
fiscalRegimeCode,
|
|
1708
|
-
);
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
get address() {
|
|
1712
|
-
return this._address;
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
set address(value) {
|
|
1716
|
-
if (!value) return;
|
|
1717
|
-
this._address = Address.fromObject(value);
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
get proofOfAddress() {
|
|
1721
|
-
return this._proofOfAddress;
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
set proofOfAddress(value) {
|
|
1725
|
-
if (!value) return;
|
|
1726
|
-
this._proofOfAddress = KYCFile.fromObject(value);
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
get proofOfLife() {
|
|
1730
|
-
return this._proofOfLife;
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
set proofOfLife(value) {
|
|
1734
|
-
if (!value) return;
|
|
1735
|
-
this._proofOfLife = KYCFile.fromObject(value);
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
get govtId() {
|
|
1739
|
-
return this._govtId;
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
set govtId(value) {
|
|
1743
|
-
if (!value) return;
|
|
1744
|
-
this._govtId = KYCFile.fromObject(value);
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
get termsOfService() {
|
|
1748
|
-
return this._termsOfService;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
set termsOfService(value) {
|
|
1752
|
-
if (!value) return;
|
|
1753
|
-
this._termsOfService = TOSAgreements.fromObject(value);
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
get curpDocument() {
|
|
1757
|
-
return this._curpDocument;
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
set curpDocument(value) {
|
|
1761
|
-
if (!value) return;
|
|
1762
|
-
this._curpDocument = KYCFile.fromObject(value);
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
static fromObject = ({
|
|
1766
|
-
address,
|
|
1767
|
-
clabe,
|
|
1768
|
-
curp,
|
|
1769
|
-
gender,
|
|
1770
|
-
id,
|
|
1771
|
-
level,
|
|
1772
|
-
names,
|
|
1773
|
-
nationality,
|
|
1774
|
-
profession,
|
|
1775
|
-
rfc,
|
|
1776
|
-
status,
|
|
1777
|
-
...obj
|
|
1778
|
-
}) =>
|
|
1779
|
-
new User({
|
|
1780
|
-
address,
|
|
1781
|
-
clabe,
|
|
1782
|
-
curp,
|
|
1783
|
-
gender,
|
|
1784
|
-
id,
|
|
1785
|
-
level,
|
|
1786
|
-
names,
|
|
1787
|
-
nationality,
|
|
1788
|
-
profession,
|
|
1789
|
-
rfc,
|
|
1790
|
-
status,
|
|
1791
|
-
blacklistValidationStatus: obj.blacklist_validation_status,
|
|
1792
|
-
countryOfBirth: obj.country_of_birth,
|
|
1793
|
-
createdAt: obj.created_at,
|
|
1794
|
-
curpDocument: obj.curp_document,
|
|
1795
|
-
dateOfBirth: obj.date_of_birth,
|
|
1796
|
-
emailAddress: obj.email_address,
|
|
1797
|
-
firstSurname: obj.first_surname,
|
|
1798
|
-
govtId: obj.govt_id,
|
|
1799
|
-
isDormant: obj.is_dormant,
|
|
1800
|
-
isFraud: obj.is_fraud,
|
|
1801
|
-
isPldBlocked: obj.is_pld_blocked,
|
|
1802
|
-
isSecurityMode: obj.is_security_mode,
|
|
1803
|
-
phoneNumber: obj.phone_number,
|
|
1804
|
-
proofOfAddress: obj.proof_of_address,
|
|
1805
|
-
proofOfLife: obj.proof_of_life,
|
|
1806
|
-
requiredLevel: obj.required_level,
|
|
1807
|
-
secondSurname: obj.second_surname,
|
|
1808
|
-
stateOfBirth: obj.state_of_birth,
|
|
1809
|
-
termsOfService: obj.terms_of_service,
|
|
1810
|
-
updatedAt: obj.updated_at,
|
|
1811
|
-
userTosAgreementsId: obj.user_tos_agreements_id,
|
|
1812
|
-
userType: obj.user_type,
|
|
1813
|
-
verificationId: obj.verification_id,
|
|
1814
|
-
fiscalRegimeCode: obj.fiscal_regime_code,
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
class UserCredential {
|
|
1819
|
-
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
1820
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1821
|
-
this.id = id;
|
|
1822
|
-
this.isActive = isActive;
|
|
1823
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
static fromObject = ({ id, ...obj }) =>
|
|
1827
|
-
new UserCredential({
|
|
1828
|
-
id,
|
|
1829
|
-
createdAt: obj.created_at,
|
|
1830
|
-
isActive: obj.is_active,
|
|
1831
|
-
updatedAt: obj.updated_at,
|
|
1832
|
-
});
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
class UserLogin {
|
|
1836
|
-
constructor({ id, lastLoginAt, success }) {
|
|
1837
|
-
this.id = id;
|
|
1838
|
-
this.lastLoginAt = dateToUTC(lastLoginAt);
|
|
1839
|
-
this.success = success;
|
|
1840
|
-
}
|
|
1841
|
-
|
|
1842
|
-
static fromObject = ({ id, success, ...obj }) =>
|
|
1843
|
-
new UserLogin({
|
|
1844
|
-
id,
|
|
1845
|
-
success,
|
|
1846
|
-
lastLoginAt: obj.last_login_at,
|
|
1847
|
-
});
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
class UserReport {
|
|
1851
|
-
constructor({
|
|
1852
|
-
actividadEconomica,
|
|
1853
|
-
apellidoMaterno,
|
|
1854
|
-
apellidoMaternoContraparte,
|
|
1855
|
-
apellidoPaterno,
|
|
1856
|
-
apellidoPaternoContraparte,
|
|
1857
|
-
calleDomicilio,
|
|
1858
|
-
ciudadPoblacion,
|
|
1859
|
-
codigoPostal,
|
|
1860
|
-
colonia,
|
|
1861
|
-
committeeMeetingDate,
|
|
1862
|
-
correoElectronico,
|
|
1863
|
-
cuentaClabeContraparte,
|
|
1864
|
-
curp,
|
|
1865
|
-
descripcionOperacion,
|
|
1866
|
-
entidadFederativaDomicilio,
|
|
1867
|
-
fechaNacimientoConstitucion,
|
|
1868
|
-
genero,
|
|
1869
|
-
id,
|
|
1870
|
-
institucionFinanciera,
|
|
1871
|
-
institucionFinancieraContraparte,
|
|
1872
|
-
instrumentoMonetario,
|
|
1873
|
-
isEditable,
|
|
1874
|
-
mainAlertId,
|
|
1875
|
-
mainAlertUri,
|
|
1876
|
-
nacionalidadCuentaAsociada,
|
|
1877
|
-
nacionalidadCuentaContraparte,
|
|
1878
|
-
nivelCuenta,
|
|
1879
|
-
nombre,
|
|
1880
|
-
nombreContraparte,
|
|
1881
|
-
numeroCuentaProyecto,
|
|
1882
|
-
paisNacionalidad,
|
|
1883
|
-
prioridadReporte,
|
|
1884
|
-
razonDenominacionContraparte,
|
|
1885
|
-
razonInusual,
|
|
1886
|
-
regimen,
|
|
1887
|
-
rfc,
|
|
1888
|
-
telefono,
|
|
1889
|
-
tipoOperacionItf,
|
|
1890
|
-
tipoOperacionPerfil,
|
|
1891
|
-
tipoPersona,
|
|
1892
|
-
tipoPersonaContraparte,
|
|
1893
|
-
userId,
|
|
1894
|
-
}) {
|
|
1895
|
-
this.actividadEconomica = actividadEconomica;
|
|
1896
|
-
this.apellidoMaterno = apellidoMaterno;
|
|
1897
|
-
this.apellidoMaternoContraparte = apellidoMaternoContraparte;
|
|
1898
|
-
this.apellidoPaterno = apellidoPaterno;
|
|
1899
|
-
this.apellidoPaternoContraparte = apellidoPaternoContraparte;
|
|
1900
|
-
this.calleDomicilio = calleDomicilio;
|
|
1901
|
-
this.ciudadPoblacion = ciudadPoblacion;
|
|
1902
|
-
this.codigoPostal = codigoPostal;
|
|
1903
|
-
this.colonia = colonia;
|
|
1904
|
-
this.committeeMeetingDate = committeeMeetingDate;
|
|
1905
|
-
this.correoElectronico = correoElectronico;
|
|
1906
|
-
this.cuentaClabeContraparte = cuentaClabeContraparte;
|
|
1907
|
-
this.curp = curp;
|
|
1908
|
-
this.descripcionOperacion = descripcionOperacion;
|
|
1909
|
-
this.entidadFederativaDomicilio = entidadFederativaDomicilio;
|
|
1910
|
-
this.fechaNacimientoConstitucion = fechaNacimientoConstitucion;
|
|
1911
|
-
this.genero = genero;
|
|
1912
|
-
this.id = id;
|
|
1913
|
-
this.institucionFinanciera = institucionFinanciera;
|
|
1914
|
-
this.institucionFinancieraContraparte = institucionFinancieraContraparte;
|
|
1915
|
-
this.instrumentoMonetario = instrumentoMonetario;
|
|
1916
|
-
this.isEditable = isEditable;
|
|
1917
|
-
this.mainAlertId = mainAlertId;
|
|
1918
|
-
this.mainAlertUri = mainAlertUri;
|
|
1919
|
-
this.nacionalidadCuentaAsociada = nacionalidadCuentaAsociada;
|
|
1920
|
-
this.nacionalidadCuentaContraparte = nacionalidadCuentaContraparte;
|
|
1921
|
-
this.nivelCuenta = nivelCuenta;
|
|
1922
|
-
this.nombre = nombre;
|
|
1923
|
-
this.nombreContraparte = nombreContraparte;
|
|
1924
|
-
this.numeroCuentaProyecto = numeroCuentaProyecto;
|
|
1925
|
-
this.paisNacionalidad = paisNacionalidad;
|
|
1926
|
-
this.prioridadReporte = prioridadReporte;
|
|
1927
|
-
this.razonDenominacionContraparte = razonDenominacionContraparte;
|
|
1928
|
-
this.razonInusual = razonInusual;
|
|
1929
|
-
this.regimen = regimen;
|
|
1930
|
-
this.rfc = rfc;
|
|
1931
|
-
this.telefono = telefono;
|
|
1932
|
-
this.tipoOperacionItf = tipoOperacionItf;
|
|
1933
|
-
this.tipoOperacionPerfil = tipoOperacionPerfil;
|
|
1934
|
-
this.tipoPersona = tipoPersona;
|
|
1935
|
-
this.tipoPersonaContraparte = tipoPersonaContraparte;
|
|
1936
|
-
this.userId = userId;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
static fromObject = ({ id, user_id: userId, ...obj }) =>
|
|
1940
|
-
new UserReport({
|
|
1941
|
-
id,
|
|
1942
|
-
userId,
|
|
1943
|
-
actividadEconomica: obj.actividad_economica,
|
|
1944
|
-
apellidoMaterno: obj.apellido_materno,
|
|
1945
|
-
apellidoMaternoContraparte: obj.apellido_materno_contraparte,
|
|
1946
|
-
apellidoPaterno: obj.apellido_paterno,
|
|
1947
|
-
apellidoPaternoContraparte: obj.apellido_paterno_contraparte,
|
|
1948
|
-
calleDomicilio: obj.calle_domicilio,
|
|
1949
|
-
ciudadPoblacion: obj.ciudad_poblacion,
|
|
1950
|
-
codigoPostal: obj.codigo_postal,
|
|
1951
|
-
colonia: obj.colonia,
|
|
1952
|
-
committeeMeetingDate: obj.committee_meeting_date,
|
|
1953
|
-
correoElectronico: obj.correo_electronico,
|
|
1954
|
-
cuentaClabeContraparte: obj.cuenta_clabe_contraparte,
|
|
1955
|
-
curp: obj.curp,
|
|
1956
|
-
descripcionOperacion: obj.descripcion_operacion,
|
|
1957
|
-
entidadFederativaDomicilio: obj.entidad_federativa_domicilio,
|
|
1958
|
-
fechaNacimientoConstitucion: obj.fecha_nacimiento_constitucion,
|
|
1959
|
-
genero: obj.genero,
|
|
1960
|
-
institucionFinanciera: obj.institucion_financiera,
|
|
1961
|
-
institucionFinancieraContraparte: obj.institucion_financiera_contraparte,
|
|
1962
|
-
instrumentoMonetario: obj.instrumento_monetario,
|
|
1963
|
-
isEditable: obj.is_editable,
|
|
1964
|
-
mainAlertId: obj.main_alert_id,
|
|
1965
|
-
mainAlertUri: obj.main_alert_uri,
|
|
1966
|
-
nacionalidadCuentaAsociada: obj.nacionalidad_cuenta_asociada,
|
|
1967
|
-
nacionalidadCuentaContraparte: obj.nacionalidad_cuenta_contraparte,
|
|
1968
|
-
nivelCuenta: obj.nivel_cuenta,
|
|
1969
|
-
nombre: obj.nombre,
|
|
1970
|
-
nombreContraparte: obj.nombre_contraparte,
|
|
1971
|
-
numeroCuentaProyecto: obj.numero_cuenta_proyecto,
|
|
1972
|
-
paisNacionalidad: obj.pais_nacionalidad,
|
|
1973
|
-
prioridadReporte: obj.prioridad_reporte,
|
|
1974
|
-
razonDenominacionContraparte: obj.razon_denominacion_contraparte,
|
|
1975
|
-
razonInusual: obj.razon_inusual,
|
|
1976
|
-
regimen: obj.regimen,
|
|
1977
|
-
rfc: obj.rfc,
|
|
1978
|
-
telefono: obj.telefono,
|
|
1979
|
-
tipoOperacionItf: obj.tipo_operacion_itf,
|
|
1980
|
-
tipoOperacionPerfil: obj.tipo_operacion_perfil,
|
|
1981
|
-
tipoPersona: obj.tipo_persona,
|
|
1982
|
-
tipoPersonaContraparte: obj.tipo_persona_contraparte,
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
class UserTosAgreement {
|
|
1987
|
-
constructor({ createdAt, id, ip, location, type, updatedAt, version }) {
|
|
1988
|
-
this.createdAt = dateToUTC(createdAt);
|
|
1989
|
-
this.id = id;
|
|
1990
|
-
this.ip = ip;
|
|
1991
|
-
this.location = location;
|
|
1992
|
-
this.type = type;
|
|
1993
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
1994
|
-
this.version = version;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
static fromObject = ({ id, ip, location, type, version, ...obj }) =>
|
|
1998
|
-
new UserTosAgreement({
|
|
1999
|
-
id,
|
|
2000
|
-
ip,
|
|
2001
|
-
location,
|
|
2002
|
-
type,
|
|
2003
|
-
version,
|
|
2004
|
-
createdAt: obj.created_at,
|
|
2005
|
-
updatedAt: obj.updated_at,
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
class Verification {
|
|
2010
|
-
constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
|
|
2011
|
-
this.createdAt = dateToUTC(createdAt);
|
|
2012
|
-
this.id = id;
|
|
2013
|
-
this.platformId = platformId;
|
|
2014
|
-
this.recipient = recipient;
|
|
2015
|
-
this.type = enumValueFromString(VerificationType, type);
|
|
2016
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
2017
|
-
}
|
|
2018
|
-
|
|
2019
|
-
static fromObject = ({ id, recipient, type, ...obj }) =>
|
|
2020
|
-
new Verification({
|
|
2021
|
-
id,
|
|
2022
|
-
recipient,
|
|
2023
|
-
type,
|
|
2024
|
-
createdAt: obj.created_at,
|
|
2025
|
-
platformId: obj.platform_id,
|
|
2026
|
-
updatedAt: obj.updated_at,
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
class WalletTransaction extends Transaction {
|
|
2031
|
-
constructor({
|
|
2032
|
-
amount,
|
|
2033
|
-
createdAt,
|
|
2034
|
-
descriptor,
|
|
2035
|
-
id,
|
|
2036
|
-
status,
|
|
2037
|
-
transactionType,
|
|
2038
|
-
userId,
|
|
2039
|
-
walletUri,
|
|
2040
|
-
}) {
|
|
2041
|
-
super({
|
|
2042
|
-
amount,
|
|
2043
|
-
createdAt,
|
|
2044
|
-
descriptor,
|
|
2045
|
-
status,
|
|
2046
|
-
userId,
|
|
2047
|
-
});
|
|
2048
|
-
this.id = id;
|
|
2049
|
-
this.transactionType = enumValueFromString(
|
|
2050
|
-
WalletTransactionType,
|
|
2051
|
-
transactionType,
|
|
2052
|
-
);
|
|
2053
|
-
this.walletUri = walletUri;
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
static fromObject = ({ amount, descriptor, id, status, ...obj }) =>
|
|
2057
|
-
new WalletTransaction({
|
|
2058
|
-
amount,
|
|
2059
|
-
descriptor,
|
|
2060
|
-
id,
|
|
2061
|
-
status,
|
|
2062
|
-
createdAt: obj.created_at,
|
|
2063
|
-
transactionType: obj.transaction_type,
|
|
2064
|
-
userId: obj.user_id,
|
|
2065
|
-
walletUri: obj.wallet_uri,
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
class WhatsAppTransfer extends Transaction {
|
|
2070
|
-
constructor({
|
|
2071
|
-
amount,
|
|
2072
|
-
claimUrl,
|
|
2073
|
-
createdAt,
|
|
2074
|
-
descriptor,
|
|
2075
|
-
destinationUri,
|
|
2076
|
-
expiresAt,
|
|
2077
|
-
id,
|
|
2078
|
-
network,
|
|
2079
|
-
phoneNumber,
|
|
2080
|
-
recipientName,
|
|
2081
|
-
status,
|
|
2082
|
-
trackingKey,
|
|
2083
|
-
updatedAt,
|
|
2084
|
-
userId,
|
|
2085
|
-
}) {
|
|
2086
|
-
super({
|
|
2087
|
-
amount,
|
|
2088
|
-
createdAt,
|
|
2089
|
-
descriptor,
|
|
2090
|
-
status,
|
|
2091
|
-
userId,
|
|
2092
|
-
});
|
|
2093
|
-
this.claimUrl = claimUrl;
|
|
2094
|
-
this.destinationUri = destinationUri;
|
|
2095
|
-
this.id = id;
|
|
2096
|
-
this.expiresAt = dateToUTC(expiresAt);
|
|
2097
|
-
this.network = enumValueFromString(TransferNetwork, network);
|
|
2098
|
-
this.phoneNumber = phoneNumber;
|
|
2099
|
-
this.recipientName = recipientName;
|
|
2100
|
-
this.trackingKey = trackingKey;
|
|
2101
|
-
this.updatedAt = dateToUTC(updatedAt);
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
2105
|
-
new WhatsAppTransfer({
|
|
2106
|
-
amount,
|
|
2107
|
-
descriptor,
|
|
2108
|
-
id,
|
|
2109
|
-
network,
|
|
2110
|
-
status,
|
|
2111
|
-
createdAt: obj.created_at,
|
|
2112
|
-
claimUrl: obj.claim_url,
|
|
2113
|
-
destinationUri: obj.destination_uri,
|
|
2114
|
-
expiresAt: obj.expires_at,
|
|
2115
|
-
phoneNumber: obj.phone_number,
|
|
2116
|
-
recipientName: obj.recipient_name,
|
|
2117
|
-
trackingKey: obj.tracking_key,
|
|
2118
|
-
updatedAt: obj.updated_at,
|
|
2119
|
-
userId: obj.user_id,
|
|
2120
|
-
});
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
class MixinBuilder {
|
|
2124
|
-
constructor(superclass) {
|
|
2125
|
-
this.superclass = superclass;
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
with(...mixins) {
|
|
2129
|
-
return mixins.reduce((c, mixin) => mixin(c), this.superclass);
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
const mix = (superclass) => new MixinBuilder(superclass);
|
|
2134
|
-
|
|
2135
|
-
const getModelFromPath = (path, obj) => {
|
|
2136
|
-
const mapper = {
|
|
2137
|
-
accounts: () => Account.fromObject(obj),
|
|
2138
|
-
alerts: () => Alert.fromObject(obj),
|
|
2139
|
-
api_keys: () => ApiKey.fromObject(obj),
|
|
2140
|
-
arpc: () => Arpc.fromObject(obj),
|
|
2141
|
-
balance_entries: () => BalanceEntry.fromObject(obj),
|
|
2142
|
-
bill_payments: () => BillPayment.fromObject(obj),
|
|
2143
|
-
'bridge/accounts': () => BridgeAccount.fromObject(obj),
|
|
2144
|
-
'bridge/bank_accounts': () => BridgeBankAccount.fromObject(obj),
|
|
2145
|
-
'bridge/clabes': () => BridgeClabe.fromObject(obj),
|
|
2146
|
-
'bridge/kyc_validations': () => KYCValidations.fromObject(obj),
|
|
2147
|
-
'bridge/sessions': () => Session.fromObject(obj),
|
|
2148
|
-
'bridge/transactions': () => BridgeTransaction.fromObject(obj),
|
|
2149
|
-
cards: () => Card.fromObject(obj),
|
|
2150
|
-
card_activations: () => CardActivation.fromObject(obj),
|
|
2151
|
-
card_transactions: () => CardTransaction.fromObject(obj),
|
|
2152
|
-
card_validations: () => CardValidation.fromObject(obj),
|
|
2153
|
-
commissions: () => Commission.fromObject(obj),
|
|
2154
|
-
deposits: () => Deposit.fromObject(obj),
|
|
2155
|
-
files: () => File.fromObject(obj),
|
|
2156
|
-
'support/transfer_fraud_funds': () => FraudFundsTransfer.fromObject(obj),
|
|
2157
|
-
kyc_validations: () => KYCValidations.fromObject(obj),
|
|
2158
|
-
login_tokens: () => LoginToken.fromObject(obj),
|
|
2159
|
-
partners: () => Partner.fromObject(obj),
|
|
2160
|
-
postal_codes: () => PostalCode.fromObject(obj),
|
|
2161
|
-
savings: () => Saving.fromObject(obj),
|
|
2162
|
-
service_providers: () => ServiceProvider.fromObject(obj),
|
|
2163
|
-
sessions: () => Session.fromObject(obj),
|
|
2164
|
-
statements: () => Statement.fromObject(obj),
|
|
2165
|
-
transfers: () => Transfer.fromObject(obj),
|
|
2166
|
-
users: () => User.fromObject(obj),
|
|
2167
|
-
user_credentials: () => UserCredential.fromObject(obj),
|
|
2168
|
-
user_logins: () => UserLogin.fromObject(obj),
|
|
2169
|
-
user_reports: () => UserReport.fromObject(obj),
|
|
2170
|
-
users_tos_agreements: () => UserTosAgreement.fromObject(obj),
|
|
2171
|
-
verifications: () => Verification.fromObject(obj),
|
|
2172
|
-
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
2173
|
-
whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
|
|
2174
|
-
};
|
|
2175
|
-
|
|
2176
|
-
return mapper[path]();
|
|
2177
|
-
};
|
|
2178
|
-
|
|
2179
|
-
const getResource = (uri) => {
|
|
2180
|
-
if (uri === null || uri === '') return null;
|
|
2181
|
-
const regExp = '/(.*?)/';
|
|
2182
|
-
const matches = uri.match(regExp);
|
|
2183
|
-
if (matches === null) return null;
|
|
2184
|
-
return matches[0].replaceAll('/', '');
|
|
2185
|
-
};
|
|
2186
|
-
|
|
2187
|
-
class Resource {
|
|
2188
|
-
constructor(path, QueryParams, client) {
|
|
2189
|
-
this.path = path;
|
|
2190
|
-
this.QueryParams = QueryParams;
|
|
2191
|
-
this.client = client;
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
|
|
2195
|
-
const Retrievable = (SuperClass) =>
|
|
2196
|
-
class Retrievable extends SuperClass {
|
|
2197
|
-
async retrieve(id) {
|
|
2198
|
-
const response = await this.client.get({
|
|
2199
|
-
endpoint: `/${this.path}/${id}`,
|
|
2200
|
-
});
|
|
2201
|
-
return getModelFromPath(this.path, response);
|
|
2202
|
-
}
|
|
2203
|
-
};
|
|
2204
|
-
|
|
2205
|
-
const Creatable = (SuperClass) =>
|
|
2206
|
-
class Creatable extends SuperClass {
|
|
2207
|
-
async _create(data) {
|
|
2208
|
-
const response = await this.client.post({
|
|
2209
|
-
endpoint: `/${this.path}`,
|
|
2210
|
-
data,
|
|
2211
|
-
});
|
|
2212
|
-
return getModelFromPath(this.path, response);
|
|
2213
|
-
}
|
|
2214
|
-
};
|
|
2215
|
-
|
|
2216
|
-
const Updateable = (SuperClass) =>
|
|
2217
|
-
class Updateable extends SuperClass {
|
|
2218
|
-
async _update(id, data) {
|
|
2219
|
-
const response = await this.client.patch({
|
|
2220
|
-
endpoint: `/${this.path}/${id}`,
|
|
2221
|
-
data,
|
|
2222
|
-
});
|
|
2223
|
-
const model = getModelFromPath(this.path, response);
|
|
2224
|
-
return model;
|
|
2225
|
-
}
|
|
2226
|
-
};
|
|
2227
|
-
|
|
2228
|
-
const Uploadable = (SuperClass) =>
|
|
2229
|
-
class Uploadable extends SuperClass {
|
|
2230
|
-
async _upload(data) {
|
|
2231
|
-
const response = await this.client.post({
|
|
2232
|
-
endpoint: `/${this.path}`,
|
|
2233
|
-
data,
|
|
2234
|
-
multipart: true,
|
|
2235
|
-
});
|
|
2236
|
-
const model = getModelFromPath(this.path, response);
|
|
2237
|
-
return model;
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
|
|
2241
|
-
const Deactivable = (SuperClass) =>
|
|
2242
|
-
class Deactivable extends SuperClass {
|
|
2243
|
-
async _deactivate(id, data) {
|
|
2244
|
-
const response = await this.client.delete({
|
|
2245
|
-
endpoint: `/${this.path}/${id}`,
|
|
2246
|
-
data,
|
|
2247
|
-
});
|
|
2248
|
-
const model = getModelFromPath(this.path, response);
|
|
2249
|
-
return model;
|
|
2250
|
-
}
|
|
2251
|
-
};
|
|
2252
|
-
|
|
2253
|
-
const Downlodable = (SuperClass) =>
|
|
2254
|
-
class Downlodable extends SuperClass {
|
|
2255
|
-
async _download(id, format) {
|
|
2256
|
-
const byteString = await this.client.get({
|
|
2257
|
-
endpoint: `/${this.path}/${id}`,
|
|
2258
|
-
format,
|
|
2259
|
-
});
|
|
2260
|
-
return byteString;
|
|
2261
|
-
}
|
|
2262
|
-
};
|
|
2263
|
-
|
|
2264
|
-
const Queryable = (SuperClass) =>
|
|
2265
|
-
class Queryable extends SuperClass {
|
|
2266
|
-
async one(queryParams = new this.QueryParams({})) {
|
|
2267
|
-
const { items } = await this.client.get({
|
|
2268
|
-
endpoint: `/${this.path}`,
|
|
2269
|
-
params: queryParams.toParams(),
|
|
2270
|
-
});
|
|
2271
|
-
|
|
2272
|
-
if (!items || !items.length) throw new NoResultFound();
|
|
2273
|
-
if (items.length > 1) throw new MultipleResultsFound();
|
|
2274
|
-
|
|
2275
|
-
const [item] = items;
|
|
2276
|
-
const model = getModelFromPath(this.path, item);
|
|
2277
|
-
return model;
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
async first(queryParams = new this.QueryParams({})) {
|
|
2281
|
-
const { items } = await this.client.get({
|
|
2282
|
-
endpoint: `/${this.path}`,
|
|
2283
|
-
params: queryParams.toParams(),
|
|
2284
|
-
});
|
|
2285
|
-
|
|
2286
|
-
if (!items || !items[0]) return null;
|
|
2287
|
-
|
|
2288
|
-
const [item] = items;
|
|
2289
|
-
const model = getModelFromPath(this.path, item);
|
|
2290
|
-
return model;
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
|
-
async count(queryParams = new this.QueryParams({})) {
|
|
2294
|
-
const qP = queryParams;
|
|
2295
|
-
qP.count = true;
|
|
2296
|
-
const { count } = await this.client.get({
|
|
2297
|
-
endpoint: `/${this.path}`,
|
|
2298
|
-
params: queryParams.toParams(),
|
|
2299
|
-
});
|
|
2300
|
-
return count || 0;
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2303
|
-
async *all(queryParams = new this.QueryParams({})) {
|
|
2304
|
-
let nextPageUri = `/${this.path}?${queryParams.toQueryString()}`;
|
|
2305
|
-
while (nextPageUri) {
|
|
2306
|
-
// eslint-disable-next-line no-await-in-loop
|
|
2307
|
-
const page = await this.client.get({ endpoint: nextPageUri });
|
|
2308
|
-
if (page.items) {
|
|
2309
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2310
|
-
for (const item of page.items) {
|
|
2311
|
-
const model = getModelFromPath(this.path, item);
|
|
2312
|
-
yield model;
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
nextPageUri = page.next_page_uri;
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
};
|
|
2319
|
-
|
|
2320
|
-
class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
2321
|
-
constructor(client) {
|
|
2322
|
-
super('accounts', AccountQuery, client);
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
|
|
2326
|
-
class AlertResource extends mix(Resource).with(
|
|
2327
|
-
Creatable,
|
|
2328
|
-
Queryable,
|
|
2329
|
-
Retrievable,
|
|
2330
|
-
Updateable,
|
|
2331
|
-
) {
|
|
2332
|
-
constructor(client) {
|
|
2333
|
-
super('alerts', AlertQuery, client);
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
async create(req) {
|
|
2337
|
-
const request = new AlertUpdateRequest(req);
|
|
2338
|
-
const alert = await this._create(request.toCleanObject());
|
|
2339
|
-
return alert;
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
async update(alertId, req) {
|
|
2343
|
-
const request = new AlertUpdateRequest(req);
|
|
2344
|
-
const alert = await this._update(alertId, request.toCleanObject());
|
|
2345
|
-
return alert;
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
|
|
2349
|
-
class ApiKeyResource extends mix(Resource).with(
|
|
2350
|
-
Creatable,
|
|
2351
|
-
Deactivable,
|
|
2352
|
-
Queryable,
|
|
2353
|
-
Retrievable,
|
|
2354
|
-
Updateable,
|
|
2355
|
-
) {
|
|
2356
|
-
constructor(client) {
|
|
2357
|
-
super('api_keys', ApiKeyQuery, client);
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
async create() {
|
|
2361
|
-
const apiKey = await this._create();
|
|
2362
|
-
return apiKey;
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
async deactivate(apiKeyId, minutes = 0) {
|
|
2366
|
-
const apiKey = await this._deactivate(apiKeyId, { minutes });
|
|
2367
|
-
return apiKey;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
async update(apiKeyId, metadata, userId) {
|
|
2371
|
-
const request = new ApiKeyUpdateRequest(userId, metadata);
|
|
2372
|
-
const apiKey = await this._update(apiKeyId, request.toCleanObject());
|
|
2373
|
-
return apiKey;
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
class ArpcResource extends mix(Resource).with(Creatable) {
|
|
2378
|
-
constructor(client) {
|
|
2379
|
-
super('arpc', Object, client);
|
|
2380
|
-
}
|
|
2381
|
-
|
|
2382
|
-
async create({
|
|
2383
|
-
number,
|
|
2384
|
-
arqc,
|
|
2385
|
-
arpcMethod,
|
|
2386
|
-
transactionData,
|
|
2387
|
-
responseCode,
|
|
2388
|
-
transactionCounter,
|
|
2389
|
-
panSequence,
|
|
2390
|
-
uniqueNumber,
|
|
2391
|
-
trackDataMethod,
|
|
2392
|
-
}) {
|
|
2393
|
-
const request = new ArpcRequest({
|
|
2394
|
-
number,
|
|
2395
|
-
arqc,
|
|
2396
|
-
arpcMethod,
|
|
2397
|
-
transactionData,
|
|
2398
|
-
responseCode,
|
|
2399
|
-
transactionCounter,
|
|
2400
|
-
panSequence,
|
|
2401
|
-
uniqueNumber,
|
|
2402
|
-
trackDataMethod,
|
|
2403
|
-
});
|
|
2404
|
-
const arpc = await this._create(request.toObject());
|
|
2405
|
-
return arpc;
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
2410
|
-
constructor(client) {
|
|
2411
|
-
super('balance_entries', BalanceEntryQuery, client);
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
async relatedTransaction(relatedTransactionUri) {
|
|
2415
|
-
const resource = getResource(relatedTransactionUri);
|
|
2416
|
-
if (resource == null) return null;
|
|
2417
|
-
|
|
2418
|
-
const response = await this.client.get({
|
|
2419
|
-
endpoint: relatedTransactionUri,
|
|
2420
|
-
});
|
|
2421
|
-
return getModelFromPath(`${resource}`, response);
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
async fundingInstrument(fundingInstrumentUri) {
|
|
2425
|
-
const resource = getResource(fundingInstrumentUri);
|
|
2426
|
-
if (resource == null) return null;
|
|
2427
|
-
|
|
2428
|
-
const response = await this.client.get({
|
|
2429
|
-
endpoint: fundingInstrumentUri,
|
|
2430
|
-
});
|
|
2431
|
-
return getModelFromPath(`${resource}`, response);
|
|
2432
|
-
}
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
2436
|
-
constructor(client) {
|
|
2437
|
-
super('bill_payments', BillPaymentQuery, client);
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
async serviceProvider(providerUri) {
|
|
2441
|
-
const resource = getResource(providerUri);
|
|
2442
|
-
if (resource == null) return null;
|
|
2443
|
-
|
|
2444
|
-
const response = await this.client.get({ endpoint: providerUri });
|
|
2445
|
-
return getModelFromPath(`${resource}`, response);
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
class BridegAccountResource extends mix(Resource).with(
|
|
2450
|
-
Queryable,
|
|
2451
|
-
Updateable,
|
|
2452
|
-
Retrievable,
|
|
2453
|
-
) {
|
|
2454
|
-
constructor(client) {
|
|
2455
|
-
super('bridge/accounts', BridgeAccountQuery, client);
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
async update({ userId = 'me', ...req }) {
|
|
2459
|
-
const request = new UserUpdateRequest(req);
|
|
2460
|
-
const account = await this._update(userId, request.toCleanObject());
|
|
2461
|
-
return account;
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
class BridgeBankAccountResource extends mix(Resource).with(
|
|
2466
|
-
Queryable,
|
|
2467
|
-
Retrievable,
|
|
2468
|
-
) {
|
|
2469
|
-
constructor(client) {
|
|
2470
|
-
super('bridge/bank_accounts', BridgeBankAccountQuery, client);
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
|
|
2474
|
-
class BridgeClabeResource extends mix(Resource).with(Queryable) {
|
|
2475
|
-
constructor(client) {
|
|
2476
|
-
super('bridge/clabes', BridgeQuery, client);
|
|
2477
|
-
}
|
|
1103
|
+
class CardResource extends Creatable(Deactivable(Queryable(Retrievable(Updateable(Resource))))) {
|
|
1104
|
+
constructor(client) {
|
|
1105
|
+
super(client, 'cards', Card.fromObject);
|
|
1106
|
+
}
|
|
1107
|
+
async create(userId, issuer, fundingType) {
|
|
1108
|
+
return this._create(CardRequest.toCleanObject({ userId, issuer, fundingType }));
|
|
1109
|
+
}
|
|
1110
|
+
async deactivate(cardId) {
|
|
1111
|
+
return this._deactivate(cardId, {});
|
|
1112
|
+
}
|
|
1113
|
+
async update(cardId, status, pinBlock) {
|
|
1114
|
+
return this._update(cardId, CardUpdateRequest.toCleanObject({
|
|
1115
|
+
status,
|
|
1116
|
+
...(pinBlock !== undefined ? { pinBlock } : {}),
|
|
1117
|
+
}));
|
|
1118
|
+
}
|
|
2478
1119
|
}
|
|
1120
|
+
var CardResource$1 = CardResource;
|
|
2479
1121
|
|
|
2480
|
-
class
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
1122
|
+
class CardTransactionResource extends Queryable(Retrievable(Resource)) {
|
|
1123
|
+
constructor(client) {
|
|
1124
|
+
super(client, 'card_transactions', CardTransaction.fromObject);
|
|
1125
|
+
}
|
|
1126
|
+
async relatedCard(relatedCardUri) {
|
|
1127
|
+
if (!relatedCardUri)
|
|
1128
|
+
return null;
|
|
1129
|
+
const response = await this.client.get({ endpoint: relatedCardUri });
|
|
1130
|
+
return Card.fromObject(response);
|
|
1131
|
+
}
|
|
2487
1132
|
}
|
|
1133
|
+
var CardTransactionResource$1 = CardTransactionResource;
|
|
2488
1134
|
|
|
2489
|
-
class
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
const response = await this.client.get({ endpoint: cardUri });
|
|
2503
|
-
return Card.fromObject(response);
|
|
2504
|
-
}
|
|
1135
|
+
class CardValidationResource extends Creatable(Resource) {
|
|
1136
|
+
constructor(client) {
|
|
1137
|
+
super(client, 'card_validations', CardValidation.fromObject);
|
|
1138
|
+
}
|
|
1139
|
+
async create(req) {
|
|
1140
|
+
return this._create(CardValidationRequest.toCleanObject(req));
|
|
1141
|
+
}
|
|
1142
|
+
async card(cardUri) {
|
|
1143
|
+
if (!cardUri)
|
|
1144
|
+
return null;
|
|
1145
|
+
const response = await this.client.get({ endpoint: cardUri });
|
|
1146
|
+
return Card.fromObject(response);
|
|
1147
|
+
}
|
|
2505
1148
|
}
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
return card;
|
|
2533
|
-
}
|
|
1149
|
+
var CardValidationResource$1 = CardValidationResource;
|
|
1150
|
+
|
|
1151
|
+
const RELATED_TRANSACTION_FACTORIES = {
|
|
1152
|
+
bill_payments: BillPayment.fromObject,
|
|
1153
|
+
'bridge/transactions': BridgeTransaction.fromObject,
|
|
1154
|
+
card_transactions: CardTransaction.fromObject,
|
|
1155
|
+
deposits: Deposit.fromObject,
|
|
1156
|
+
savings: Saving.fromObject,
|
|
1157
|
+
transfers: Transfer.fromObject,
|
|
1158
|
+
wallet_transactions: WalletTransaction.fromObject,
|
|
1159
|
+
whatsapp_transfers: WhatsAppTransfer.fromObject,
|
|
1160
|
+
};
|
|
1161
|
+
class CommissionResource extends Queryable(Retrievable(Resource)) {
|
|
1162
|
+
constructor(client) {
|
|
1163
|
+
super(client, 'commissions', Commission.fromObject);
|
|
1164
|
+
}
|
|
1165
|
+
async relatedTransaction(relatedTransactionUri) {
|
|
1166
|
+
const path = getResourcePath(relatedTransactionUri);
|
|
1167
|
+
if (!path)
|
|
1168
|
+
return null;
|
|
1169
|
+
const factory = RELATED_TRANSACTION_FACTORIES[path];
|
|
1170
|
+
if (!factory)
|
|
1171
|
+
return null;
|
|
1172
|
+
const response = await this.client.get({ endpoint: relatedTransactionUri });
|
|
1173
|
+
return factory(response);
|
|
1174
|
+
}
|
|
2534
1175
|
}
|
|
1176
|
+
var CommissionResource$1 = CommissionResource;
|
|
2535
1177
|
|
|
2536
|
-
class
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
async relatedCard(relatedCardUri) {
|
|
2545
|
-
const resource = getResource(relatedCardUri);
|
|
2546
|
-
if (resource == null) return null;
|
|
2547
|
-
|
|
2548
|
-
const response = await this.client.get({
|
|
2549
|
-
endpoint: relatedCardUri,
|
|
2550
|
-
});
|
|
2551
|
-
return getModelFromPath(`${resource}`, response);
|
|
2552
|
-
}
|
|
1178
|
+
class DepositResource extends Queryable(Retrievable(Resource)) {
|
|
1179
|
+
constructor(client) {
|
|
1180
|
+
super(client, 'deposits', Deposit.fromObject);
|
|
1181
|
+
}
|
|
1182
|
+
async source(sourceUri) {
|
|
1183
|
+
const response = await this.client.get({ endpoint: sourceUri });
|
|
1184
|
+
return Account.fromObject(response);
|
|
1185
|
+
}
|
|
2553
1186
|
}
|
|
1187
|
+
var DepositResource$1 = DepositResource;
|
|
2554
1188
|
|
|
2555
|
-
class
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
icvv,
|
|
2566
|
-
number,
|
|
2567
|
-
pinBlock,
|
|
2568
|
-
pinAttemptsExceeded,
|
|
2569
|
-
}) {
|
|
2570
|
-
const request = new CardValidationRequest({
|
|
2571
|
-
cvv,
|
|
2572
|
-
cvv2,
|
|
2573
|
-
expMonth,
|
|
2574
|
-
expYear,
|
|
2575
|
-
icvv,
|
|
2576
|
-
number,
|
|
2577
|
-
pinBlock,
|
|
2578
|
-
pinAttemptsExceeded,
|
|
2579
|
-
});
|
|
2580
|
-
const validation = await this._create(request.toCleanObject());
|
|
2581
|
-
return validation;
|
|
2582
|
-
}
|
|
2583
|
-
|
|
2584
|
-
async card(cardUri) {
|
|
2585
|
-
if (!cardUri) return null;
|
|
2586
|
-
const response = await this.client.get({ endpoint: cardUri });
|
|
2587
|
-
return Card.fromObject(response);
|
|
2588
|
-
}
|
|
1189
|
+
class FileResource extends Downlodable(Uploadable(Resource)) {
|
|
1190
|
+
constructor(client) {
|
|
1191
|
+
super(client, 'files', File.fromObject);
|
|
1192
|
+
}
|
|
1193
|
+
async download(id, { responseType } = {}) {
|
|
1194
|
+
return this._download(id, FileFormat.Any, responseType);
|
|
1195
|
+
}
|
|
1196
|
+
async upload(request) {
|
|
1197
|
+
return this._upload(FileUploadRequest.toObject(request));
|
|
1198
|
+
}
|
|
2589
1199
|
}
|
|
1200
|
+
var FileResource$1 = FileResource;
|
|
2590
1201
|
|
|
2591
|
-
class
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
if (resource == null) return null;
|
|
2599
|
-
|
|
2600
|
-
const response = await this.client.get(relatedTransactionUri);
|
|
2601
|
-
return getModelFromPath(`${resource}`, response);
|
|
2602
|
-
}
|
|
1202
|
+
class FraudFundsTransferResource extends Creatable(Resource) {
|
|
1203
|
+
constructor(client) {
|
|
1204
|
+
super(client, 'support/transfer_fraud_funds', FraudFundsTransfer.fromObject);
|
|
1205
|
+
}
|
|
1206
|
+
async create(req) {
|
|
1207
|
+
return this._create(FraudFundsTransferRequest.toObject(req));
|
|
1208
|
+
}
|
|
2603
1209
|
}
|
|
1210
|
+
var FraudFundsTransferResource$1 = FraudFundsTransferResource;
|
|
2604
1211
|
|
|
2605
|
-
class
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
1212
|
+
class KYCValidationsResource extends Creatable(Deactivable(Queryable(Retrievable(Resource)))) {
|
|
1213
|
+
constructor(client, isBridge = false) {
|
|
1214
|
+
super(client, isBridge ? 'bridge/kyc_validations' : 'kyc_validations', KYCValidations.fromObject);
|
|
1215
|
+
this.isBridge = isBridge;
|
|
1216
|
+
}
|
|
1217
|
+
async create(userId = 'me', force = false) {
|
|
1218
|
+
return this._create(KYCValidationsRequest.toCleanObject({
|
|
1219
|
+
force,
|
|
1220
|
+
userId,
|
|
1221
|
+
isBridge: this.isBridge,
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
async deactivate(kycValidationId) {
|
|
1225
|
+
return this._deactivate(kycValidationId, {});
|
|
1226
|
+
}
|
|
2614
1227
|
}
|
|
1228
|
+
var KYCValidationsResource$1 = KYCValidationsResource;
|
|
2615
1229
|
|
|
2616
|
-
class
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
async upload(request) {
|
|
2627
|
-
const fileUpload = await this._upload(request);
|
|
2628
|
-
return fileUpload;
|
|
2629
|
-
}
|
|
1230
|
+
class LegalPersonResource extends Creatable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
1231
|
+
constructor(client) {
|
|
1232
|
+
super(client, 'legal_persons', LegalPerson.fromObject);
|
|
1233
|
+
}
|
|
1234
|
+
async create(req) {
|
|
1235
|
+
return this._create(LegalPersonRequest.toCleanObject(req));
|
|
1236
|
+
}
|
|
1237
|
+
async update(legalPersonId, req) {
|
|
1238
|
+
return this._update(legalPersonId, LegalPersonUpdateRequest.toCleanObject(req));
|
|
1239
|
+
}
|
|
2630
1240
|
}
|
|
1241
|
+
var LegalPersonResource$1 = LegalPersonResource;
|
|
2631
1242
|
|
|
2632
|
-
class
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
userId,
|
|
2640
|
-
amount,
|
|
2641
|
-
concepto,
|
|
2642
|
-
clabe,
|
|
2643
|
-
reason,
|
|
2644
|
-
bankCode,
|
|
2645
|
-
});
|
|
2646
|
-
const fraudFundsTransfer = await this._create(request.toObject());
|
|
2647
|
-
return fraudFundsTransfer;
|
|
2648
|
-
}
|
|
1243
|
+
class LoginTokenResource extends Creatable(Resource) {
|
|
1244
|
+
constructor(client) {
|
|
1245
|
+
super(client, 'login_tokens', LoginToken.fromObject);
|
|
1246
|
+
}
|
|
1247
|
+
async create() {
|
|
1248
|
+
return this._create({});
|
|
1249
|
+
}
|
|
2649
1250
|
}
|
|
1251
|
+
var LoginTokenResource$1 = LoginTokenResource;
|
|
2650
1252
|
|
|
2651
|
-
class
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
) {
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
});
|
|
2672
|
-
const kycValidation = await this._create(request.toCleanObject());
|
|
2673
|
-
return kycValidation;
|
|
2674
|
-
}
|
|
2675
|
-
|
|
2676
|
-
async deactivate(kycValidationId) {
|
|
2677
|
-
const response = await this._deactivate(kycValidationId);
|
|
2678
|
-
return response;
|
|
2679
|
-
}
|
|
1253
|
+
class OperatorLoginResource extends Creatable(Resource) {
|
|
1254
|
+
constructor(client) {
|
|
1255
|
+
super(client, 'operator-login', OperatorLogin.fromObject);
|
|
1256
|
+
this.sessionIdInHeaders = null;
|
|
1257
|
+
}
|
|
1258
|
+
async create(email, password) {
|
|
1259
|
+
const operatorLogin = await this._create(OperatorLoginRequest.toCleanObject({ email, password }));
|
|
1260
|
+
if (operatorLogin.sessionToken) {
|
|
1261
|
+
this.sessionIdInHeaders = this.client.addHeadersToRequest({
|
|
1262
|
+
'X-Cuenca-SessionId': operatorLogin.sessionToken,
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
return operatorLogin;
|
|
1266
|
+
}
|
|
1267
|
+
clearSessionHeader() {
|
|
1268
|
+
if (this.sessionIdInHeaders) {
|
|
1269
|
+
this.sessionIdInHeaders.eject();
|
|
1270
|
+
this.sessionIdInHeaders = null;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
2680
1273
|
}
|
|
1274
|
+
var OperatorLoginResource$1 = OperatorLoginResource;
|
|
2681
1275
|
|
|
2682
|
-
class
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
1276
|
+
class OperatorResource extends Creatable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
1277
|
+
constructor(client) {
|
|
1278
|
+
super(client, 'operators', Operator.fromObject);
|
|
1279
|
+
}
|
|
1280
|
+
async create(req) {
|
|
1281
|
+
return this._create(OperatorRequest.toCleanObject(req));
|
|
1282
|
+
}
|
|
1283
|
+
async update(operatorId, req) {
|
|
1284
|
+
return this._update(operatorId, OperatorUpdateRequest.toCleanObject(req));
|
|
1285
|
+
}
|
|
2691
1286
|
}
|
|
1287
|
+
var OperatorResource$1 = OperatorResource;
|
|
2692
1288
|
|
|
2693
|
-
class PartnerResource extends
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
)
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
async create(req) {
|
|
2704
|
-
const request = new PartnerUserRequest(req);
|
|
2705
|
-
const partner = await this._create(request.toCleanObject());
|
|
2706
|
-
return partner;
|
|
2707
|
-
}
|
|
2708
|
-
|
|
2709
|
-
async update(partnerId, req) {
|
|
2710
|
-
const request = new PartnerUserRequest(req);
|
|
2711
|
-
const partner = await this._update(partnerId, request.toCleanObject());
|
|
2712
|
-
return partner;
|
|
2713
|
-
}
|
|
1289
|
+
class PartnerResource extends Creatable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
1290
|
+
constructor(client) {
|
|
1291
|
+
super(client, 'partners', Partner.fromObject);
|
|
1292
|
+
}
|
|
1293
|
+
async create(req) {
|
|
1294
|
+
return this._create(PartnerUserRequest.toCleanObject(req));
|
|
1295
|
+
}
|
|
1296
|
+
async update(partnerId, req) {
|
|
1297
|
+
return this._update(partnerId, PartnerUserRequest.toCleanObject(req));
|
|
1298
|
+
}
|
|
2714
1299
|
}
|
|
1300
|
+
var PartnerResource$1 = PartnerResource;
|
|
2715
1301
|
|
|
2716
|
-
class PostalCodeResource extends
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
1302
|
+
class PostalCodeResource extends Queryable(Resource) {
|
|
1303
|
+
constructor(client) {
|
|
1304
|
+
super(client, 'postal_codes', PostalCode.fromObject);
|
|
1305
|
+
}
|
|
2720
1306
|
}
|
|
1307
|
+
var PostalCodeResource$1 = PostalCodeResource;
|
|
2721
1308
|
|
|
2722
1309
|
class ReportResource extends Resource {
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
try {
|
|
2734
|
-
headersInterceptor = this.client.addHeadersToRequest({
|
|
2735
|
-
Accept: 'text/xml',
|
|
2736
|
-
});
|
|
2737
|
-
configInterceptor = this.client.addConfigToRequest({
|
|
2738
|
-
responseType: 'arraybuffer',
|
|
2739
|
-
});
|
|
2740
|
-
|
|
2741
|
-
return await this.client.post({
|
|
2742
|
-
endpoint: `/${this.path}`,
|
|
2743
|
-
data: request.toCleanObject(),
|
|
2744
|
-
});
|
|
2745
|
-
} finally {
|
|
2746
|
-
if (headersInterceptor) headersInterceptor.eject();
|
|
2747
|
-
if (configInterceptor) configInterceptor.eject();
|
|
1310
|
+
constructor(client) {
|
|
1311
|
+
super(client, 'reports', (obj) => obj);
|
|
1312
|
+
}
|
|
1313
|
+
async generateXml({ committeeMeetingDate, }) {
|
|
1314
|
+
return this.client.post({
|
|
1315
|
+
endpoint: `/${this.path}`,
|
|
1316
|
+
data: ReportGenerateRequest.toCleanObject({ committeeMeetingDate }),
|
|
1317
|
+
headers: { Accept: 'text/xml' },
|
|
1318
|
+
responseType: 'arraybuffer',
|
|
1319
|
+
});
|
|
2748
1320
|
}
|
|
2749
|
-
}
|
|
2750
1321
|
}
|
|
1322
|
+
var ReportResource$1 = ReportResource;
|
|
2751
1323
|
|
|
2752
|
-
class SavingResource extends
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
const saving = await this._create(request.toObject());
|
|
2766
|
-
return saving;
|
|
2767
|
-
}
|
|
2768
|
-
|
|
2769
|
-
async deactivate(savingId) {
|
|
2770
|
-
const response = await this._deactivate(savingId);
|
|
2771
|
-
return response;
|
|
2772
|
-
}
|
|
2773
|
-
|
|
2774
|
-
async update(savingId, category, goalAmount, goalDate, name) {
|
|
2775
|
-
const request = new SavingRequest(category, goalAmount, goalDate, name);
|
|
2776
|
-
const saving = await this._update(savingId, request.toObject());
|
|
2777
|
-
return saving;
|
|
2778
|
-
}
|
|
1324
|
+
class SavingResource extends Creatable(Deactivable(Queryable(Retrievable(Updateable(Resource))))) {
|
|
1325
|
+
constructor(client) {
|
|
1326
|
+
super(client, 'savings', Saving.fromObject);
|
|
1327
|
+
}
|
|
1328
|
+
async create(category, goalAmount, goalDate, name) {
|
|
1329
|
+
return this._create(SavingRequest.toObject({ category, goalAmount, goalDate, name }));
|
|
1330
|
+
}
|
|
1331
|
+
async deactivate(savingId) {
|
|
1332
|
+
return this._deactivate(savingId, {});
|
|
1333
|
+
}
|
|
1334
|
+
async update(savingId, category, goalAmount, goalDate, name) {
|
|
1335
|
+
return this._update(savingId, SavingRequest.toObject({ category, goalAmount, goalDate, name }));
|
|
1336
|
+
}
|
|
2779
1337
|
}
|
|
1338
|
+
var SavingResource$1 = SavingResource;
|
|
2780
1339
|
|
|
2781
|
-
class ServiceProviderResource extends
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
constructor(client) {
|
|
2786
|
-
super('service_providers', QueryParams, client);
|
|
2787
|
-
}
|
|
1340
|
+
class ServiceProviderResource extends Retrievable(Queryable(Resource)) {
|
|
1341
|
+
constructor(client) {
|
|
1342
|
+
super(client, 'service_providers', ServiceProvider.fromObject);
|
|
1343
|
+
}
|
|
2788
1344
|
}
|
|
1345
|
+
var ServiceProviderResource$1 = ServiceProviderResource;
|
|
2789
1346
|
|
|
2790
|
-
class SessionResource extends
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
type,
|
|
2805
|
-
userId,
|
|
2806
|
-
isBridge: this.isBridge,
|
|
2807
|
-
});
|
|
2808
|
-
const session = await this._create(req.toCleanObject());
|
|
2809
|
-
return session;
|
|
2810
|
-
}
|
|
1347
|
+
class SessionResource extends Creatable(Queryable(Retrievable(Resource))) {
|
|
1348
|
+
constructor(client, isBridge = false) {
|
|
1349
|
+
super(client, isBridge ? 'bridge/sessions' : 'sessions', Session.fromObject);
|
|
1350
|
+
this.isBridge = isBridge;
|
|
1351
|
+
}
|
|
1352
|
+
async create(userId, type, successUrl, failureUrl) {
|
|
1353
|
+
return this._create(SessionRequest.toCleanObject({
|
|
1354
|
+
...(failureUrl !== undefined ? { failureUrl } : {}),
|
|
1355
|
+
...(successUrl !== undefined ? { successUrl } : {}),
|
|
1356
|
+
type,
|
|
1357
|
+
userId,
|
|
1358
|
+
isBridge: this.isBridge,
|
|
1359
|
+
}));
|
|
1360
|
+
}
|
|
2811
1361
|
}
|
|
1362
|
+
var SessionResource$1 = SessionResource;
|
|
2812
1363
|
|
|
2813
|
-
class StatementResource extends
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
const [pdf, xml] = await Promise.all([
|
|
2833
|
-
this.pdf(statement.id),
|
|
2834
|
-
this.xml(statement.id),
|
|
2835
|
-
]);
|
|
2836
|
-
return { statement, pdf, xml };
|
|
2837
|
-
}
|
|
1364
|
+
class StatementResource extends Downlodable(Queryable(Resource)) {
|
|
1365
|
+
constructor(client) {
|
|
1366
|
+
super(client, 'statements', Statement.fromObject);
|
|
1367
|
+
}
|
|
1368
|
+
async pdf(id) {
|
|
1369
|
+
return this._download(id, FileFormat.Pdf);
|
|
1370
|
+
}
|
|
1371
|
+
async xml(id) {
|
|
1372
|
+
return this._download(id, FileFormat.Xml);
|
|
1373
|
+
}
|
|
1374
|
+
async downloadFiles({ userId, year, month, }) {
|
|
1375
|
+
validateStatementQuery({ year, month });
|
|
1376
|
+
const statement = await this.one({ userId, year, month });
|
|
1377
|
+
const [pdf, xml] = await Promise.all([
|
|
1378
|
+
this.pdf(statement.id),
|
|
1379
|
+
this.xml(statement.id),
|
|
1380
|
+
]);
|
|
1381
|
+
return { statement, pdf, xml };
|
|
1382
|
+
}
|
|
2838
1383
|
}
|
|
1384
|
+
var StatementResource$1 = StatementResource;
|
|
2839
1385
|
|
|
2840
|
-
class TransferResource extends
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
endpoint: destinationUri,
|
|
2853
|
-
});
|
|
2854
|
-
return Account.fromObject(response);
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
async create({
|
|
2858
|
-
accountNumber,
|
|
2859
|
-
amount,
|
|
2860
|
-
descriptor,
|
|
2861
|
-
recipientName,
|
|
2862
|
-
idempotencyKey,
|
|
2863
|
-
}) {
|
|
2864
|
-
const key =
|
|
2865
|
-
idempotencyKey ||
|
|
2866
|
-
this.constructor._genIdempotencyKey(accountNumber, amount);
|
|
2867
|
-
const request = new TransferRequest(
|
|
2868
|
-
accountNumber,
|
|
2869
|
-
amount,
|
|
2870
|
-
descriptor,
|
|
2871
|
-
key,
|
|
2872
|
-
recipientName,
|
|
2873
|
-
);
|
|
2874
|
-
const transfer = await this._create(request.toCleanObject());
|
|
2875
|
-
return transfer;
|
|
2876
|
-
}
|
|
2877
|
-
|
|
2878
|
-
async update(transferId, req) {
|
|
2879
|
-
const request = new TransferUpdateRequest(req);
|
|
2880
|
-
const transfer = await this._update(transferId, request.toCleanObject());
|
|
2881
|
-
return transfer;
|
|
2882
|
-
}
|
|
2883
|
-
|
|
2884
|
-
async createMany(requests) {
|
|
2885
|
-
if (!requests || !Array.isArray(requests) || !requests.length) return {};
|
|
2886
|
-
const transfers = { submitted: [], errors: [] };
|
|
2887
|
-
|
|
2888
|
-
await Promise.all(
|
|
2889
|
-
requests.map(
|
|
2890
|
-
async ({
|
|
2891
|
-
accountNumber,
|
|
2892
|
-
amount,
|
|
2893
|
-
descriptor,
|
|
2894
|
-
idempotencyKey,
|
|
2895
|
-
recipientName,
|
|
2896
|
-
}) => {
|
|
2897
|
-
const actualRequest = new TransferRequest(
|
|
1386
|
+
class TransferResource extends Creatable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
1387
|
+
constructor(client) {
|
|
1388
|
+
super(client, 'transfers', Transfer.fromObject);
|
|
1389
|
+
}
|
|
1390
|
+
async destination(destinationUri) {
|
|
1391
|
+
const response = await this.client.get({ endpoint: destinationUri });
|
|
1392
|
+
return Account.fromObject(response);
|
|
1393
|
+
}
|
|
1394
|
+
async create({ accountNumber, amount, descriptor, recipientName, idempotencyKey, }) {
|
|
1395
|
+
const key = idempotencyKey ??
|
|
1396
|
+
TransferResource._genIdempotencyKey(accountNumber, amount);
|
|
1397
|
+
return this._create(TransferRequest.toCleanObject({
|
|
2898
1398
|
accountNumber,
|
|
2899
1399
|
amount,
|
|
2900
1400
|
descriptor,
|
|
2901
|
-
idempotencyKey
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
return;
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
1401
|
+
idempotencyKey: key,
|
|
1402
|
+
...(recipientName !== undefined ? { recipientName } : {}),
|
|
1403
|
+
}));
|
|
1404
|
+
}
|
|
1405
|
+
async update(transferId, req) {
|
|
1406
|
+
return this._update(transferId, TransferUpdateRequest.toCleanObject(req));
|
|
1407
|
+
}
|
|
1408
|
+
async createMany(requests) {
|
|
1409
|
+
if (!requests || !Array.isArray(requests) || requests.length === 0) {
|
|
1410
|
+
return {};
|
|
1411
|
+
}
|
|
1412
|
+
const transfers = { submitted: [], errors: [] };
|
|
1413
|
+
await Promise.all(requests.map(async (req) => {
|
|
1414
|
+
const actualRequest = {
|
|
1415
|
+
...req,
|
|
1416
|
+
idempotencyKey: req.idempotencyKey ??
|
|
1417
|
+
TransferResource._genIdempotencyKey(req.accountNumber, req.amount),
|
|
1418
|
+
};
|
|
1419
|
+
try {
|
|
1420
|
+
const transfer = await this._create(TransferRequest.toCleanObject(actualRequest));
|
|
1421
|
+
transfers.submitted.push(transfer);
|
|
1422
|
+
}
|
|
1423
|
+
catch (error) {
|
|
1424
|
+
transfers.errors.push({ actualRequest, error });
|
|
1425
|
+
}
|
|
1426
|
+
}));
|
|
1427
|
+
return transfers;
|
|
1428
|
+
}
|
|
1429
|
+
static _genIdempotencyKey(accountNumber, amount) {
|
|
1430
|
+
const isoDate = dateToUTC(Date.now()).toISOString();
|
|
1431
|
+
/* v8 ignore next */
|
|
1432
|
+
const date = isoDate.split('T')[0] ?? '';
|
|
1433
|
+
return `${date}:${accountNumber}:${amount}`;
|
|
1434
|
+
}
|
|
2924
1435
|
}
|
|
1436
|
+
var TransferResource$1 = TransferResource;
|
|
2925
1437
|
|
|
2926
|
-
class UserCredentialResource extends
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
const credential = await this._update(userId, request.toCleanObject());
|
|
2940
|
-
return credential;
|
|
2941
|
-
}
|
|
1438
|
+
class UserCredentialResource extends Creatable(Updateable(Resource)) {
|
|
1439
|
+
constructor(client) {
|
|
1440
|
+
super(client, 'user_credentials', UserCredential.fromObject);
|
|
1441
|
+
}
|
|
1442
|
+
async create(password) {
|
|
1443
|
+
return this._create(UserCredentialRequest.toObject({ password }));
|
|
1444
|
+
}
|
|
1445
|
+
async update({ isActive, password, userId = 'me', }) {
|
|
1446
|
+
return this._update(userId, UserCredentialUpdateRequest.toCleanObject({
|
|
1447
|
+
...(password !== undefined ? { password } : {}),
|
|
1448
|
+
...(isActive !== undefined ? { isActive } : {}),
|
|
1449
|
+
}));
|
|
1450
|
+
}
|
|
2942
1451
|
}
|
|
1452
|
+
var UserCredentialResource$1 = UserCredentialResource;
|
|
2943
1453
|
|
|
2944
|
-
class UserLoginResource extends
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
await this._deactivate(userId, {});
|
|
2965
|
-
|
|
2966
|
-
// Remove current login id from headers
|
|
2967
|
-
this.loginIdInHeaders && this.loginIdInHeaders.eject();
|
|
2968
|
-
|
|
2969
|
-
return true;
|
|
2970
|
-
}
|
|
1454
|
+
class UserLoginResource extends Creatable(Deactivable(Resource)) {
|
|
1455
|
+
constructor(client) {
|
|
1456
|
+
super(client, 'user_logins', UserLogin.fromObject);
|
|
1457
|
+
this.loginIdInHeaders = null;
|
|
1458
|
+
}
|
|
1459
|
+
async create(password, userId) {
|
|
1460
|
+
const userLogin = await this._create(UserLoginRequest.toObject({ password, userId }));
|
|
1461
|
+
if (!userLogin.success)
|
|
1462
|
+
throw new InvalidPassword();
|
|
1463
|
+
this.loginIdInHeaders = this.client.addHeadersToRequest({
|
|
1464
|
+
'X-Cuenca-LoginId': userLogin.id,
|
|
1465
|
+
});
|
|
1466
|
+
return userLogin;
|
|
1467
|
+
}
|
|
1468
|
+
async logOut(userId = 'me') {
|
|
1469
|
+
await this._deactivate(userId, {});
|
|
1470
|
+
if (this.loginIdInHeaders)
|
|
1471
|
+
this.loginIdInHeaders.eject();
|
|
1472
|
+
return true;
|
|
1473
|
+
}
|
|
2971
1474
|
}
|
|
1475
|
+
var UserLoginResource$1 = UserLoginResource;
|
|
2972
1476
|
|
|
2973
|
-
class
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
)
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
async update({ userId = 'me', ...req }) {
|
|
2984
|
-
const request = new UserUpdateRequest(req);
|
|
2985
|
-
const user = await this._update(userId, request.toCleanObject());
|
|
2986
|
-
return user;
|
|
2987
|
-
}
|
|
2988
|
-
|
|
2989
|
-
async deactivate(userId) {
|
|
2990
|
-
const response = await this._deactivate(userId);
|
|
2991
|
-
return response;
|
|
2992
|
-
}
|
|
1477
|
+
class UserResource extends Deactivable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
1478
|
+
constructor(client) {
|
|
1479
|
+
super(client, 'users', User.fromObject);
|
|
1480
|
+
}
|
|
1481
|
+
async update({ userId = 'me', ...req }) {
|
|
1482
|
+
return this._update(userId, UserUpdateRequest.toCleanObject(req));
|
|
1483
|
+
}
|
|
1484
|
+
async deactivate(userId) {
|
|
1485
|
+
return this._deactivate(userId, {});
|
|
1486
|
+
}
|
|
2993
1487
|
}
|
|
1488
|
+
var UserResource$1 = UserResource;
|
|
2994
1489
|
|
|
2995
|
-
class UserReportResource extends
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
)
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
async create({ committeeMeetingDate, userId }) {
|
|
3006
|
-
const request = new UserReportCreateRequest({
|
|
3007
|
-
committeeMeetingDate,
|
|
3008
|
-
userId,
|
|
3009
|
-
});
|
|
3010
|
-
return this._create(request.toCleanObject());
|
|
3011
|
-
}
|
|
3012
|
-
|
|
3013
|
-
async update(userReportId, req) {
|
|
3014
|
-
const request = new UserReportUpdateRequest(req);
|
|
3015
|
-
return this._update(userReportId, request.toCleanObject());
|
|
3016
|
-
}
|
|
1490
|
+
class UserReportResource extends Creatable(Queryable(Retrievable(Updateable(Resource)))) {
|
|
1491
|
+
constructor(client) {
|
|
1492
|
+
super(client, 'user_reports', UserReport.fromObject);
|
|
1493
|
+
}
|
|
1494
|
+
async create(req) {
|
|
1495
|
+
return this._create(UserReportCreateRequest.toCleanObject(req));
|
|
1496
|
+
}
|
|
1497
|
+
async update(userReportId, req) {
|
|
1498
|
+
return this._update(userReportId, UserReportUpdateRequest.toCleanObject(req));
|
|
1499
|
+
}
|
|
3017
1500
|
}
|
|
1501
|
+
var UserReportResource$1 = UserReportResource;
|
|
3018
1502
|
|
|
3019
|
-
class UsersTosAgreementsResource extends
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
1503
|
+
class UsersTosAgreementsResource extends Retrievable(Resource) {
|
|
1504
|
+
constructor(client) {
|
|
1505
|
+
super(client, 'users_tos_agreements', UserTosAgreement.fromObject);
|
|
1506
|
+
}
|
|
3023
1507
|
}
|
|
1508
|
+
var UsersTosAgreementsResource$1 = UsersTosAgreementsResource;
|
|
3024
1509
|
|
|
3025
|
-
class
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
async update({ code, id }) {
|
|
3037
|
-
const request = new VerificationAttemptRequest({ code });
|
|
3038
|
-
const verification = await this._update(id, request.toObject());
|
|
3039
|
-
return verification;
|
|
3040
|
-
}
|
|
1510
|
+
class VerificationResource extends Creatable(Updateable(Resource)) {
|
|
1511
|
+
constructor(client) {
|
|
1512
|
+
super(client, 'verifications', Verification.fromObject);
|
|
1513
|
+
}
|
|
1514
|
+
async create(req) {
|
|
1515
|
+
return this._create(VerificationRequest.toObject(req));
|
|
1516
|
+
}
|
|
1517
|
+
async update({ code, id, }) {
|
|
1518
|
+
return this._update(id, VerificationAttemptRequest.toObject({ code }));
|
|
1519
|
+
}
|
|
3041
1520
|
}
|
|
1521
|
+
var VerificationResource$1 = VerificationResource;
|
|
3042
1522
|
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
) {
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
)
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
return getModelFromPath(`${resource}`, response);
|
|
3068
|
-
}
|
|
1523
|
+
const WALLET_FACTORIES = {
|
|
1524
|
+
savings: Saving.fromObject,
|
|
1525
|
+
};
|
|
1526
|
+
class WalletTransactionsResource extends Creatable(Queryable(Retrievable(Resource))) {
|
|
1527
|
+
constructor(client) {
|
|
1528
|
+
super(client, 'wallet_transactions', WalletTransaction.fromObject);
|
|
1529
|
+
}
|
|
1530
|
+
async create(amount, transactionType, walletUri) {
|
|
1531
|
+
return this._create(WalletTransactionRequest.toObject({ amount, transactionType, walletUri }));
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* @deprecated Method name has a typo. Retained for API compatibility.
|
|
1535
|
+
* A properly-named alias (`relatedWallet`) will be introduced in v2. See cuenca-js#59.
|
|
1536
|
+
*/
|
|
1537
|
+
async realtedWallet(walletUri) {
|
|
1538
|
+
const path = getResourcePath(walletUri);
|
|
1539
|
+
if (!path)
|
|
1540
|
+
return null;
|
|
1541
|
+
const factory = WALLET_FACTORIES[path];
|
|
1542
|
+
if (!factory)
|
|
1543
|
+
return null;
|
|
1544
|
+
const response = await this.client.get({ endpoint: walletUri });
|
|
1545
|
+
return factory(response);
|
|
1546
|
+
}
|
|
3069
1547
|
}
|
|
1548
|
+
var WalletTransactionsResource$1 = WalletTransactionsResource;
|
|
3070
1549
|
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
1550
|
+
const ACCOUNT_FACTORIES = {
|
|
1551
|
+
accounts: Account.fromObject,
|
|
1552
|
+
'bridge/accounts': BridgeAccount.fromObject,
|
|
1553
|
+
};
|
|
1554
|
+
class WhatsAppTransferResource extends Queryable(Retrievable(Resource)) {
|
|
1555
|
+
constructor(client) {
|
|
1556
|
+
super(client, 'whatsapp_transfers', WhatsAppTransfer.fromObject);
|
|
1557
|
+
}
|
|
1558
|
+
async accountDestination(destinationUri) {
|
|
1559
|
+
const path = getResourcePath(destinationUri);
|
|
1560
|
+
if (!path)
|
|
1561
|
+
return null;
|
|
1562
|
+
const factory = ACCOUNT_FACTORIES[path];
|
|
1563
|
+
if (!factory)
|
|
1564
|
+
return null;
|
|
1565
|
+
const response = await this.client.get({ endpoint: destinationUri });
|
|
1566
|
+
return factory(response);
|
|
1567
|
+
}
|
|
3086
1568
|
}
|
|
1569
|
+
var WhatsAppTransferResource$1 = WhatsAppTransferResource;
|
|
3087
1570
|
|
|
3088
1571
|
class Cuenca {
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
1572
|
+
constructor({ apiKey, apiSecret, language = 'en', phase = Phase.Sandbox, } = {}) {
|
|
1573
|
+
// Client type comes from src/client/client.d.ts, a declaration for the
|
|
1574
|
+
// plain-JS class in src/client/client.js. Delete both when the client
|
|
1575
|
+
// migrates to TypeScript (see cuenca-js#66).
|
|
1576
|
+
this.client = new Client({
|
|
1577
|
+
apiKey,
|
|
1578
|
+
apiSecret,
|
|
1579
|
+
language,
|
|
1580
|
+
phase,
|
|
1581
|
+
});
|
|
1582
|
+
this.withClient(this.client);
|
|
1583
|
+
}
|
|
1584
|
+
withClient(client) {
|
|
1585
|
+
this.accounts = new AccountResource$1(client);
|
|
1586
|
+
this.alerts = new AlertResource$1(client);
|
|
1587
|
+
this.apiKeys = new ApiKeyResource$1(client);
|
|
1588
|
+
this.arpc = new ArpcResource$1(client);
|
|
1589
|
+
this.balanceEntries = new BalanceEntryResource$1(client);
|
|
1590
|
+
this.billPayments = new BillPaymentResource$1(client);
|
|
1591
|
+
this.bridgeAccounts = new BridgeAccountResource$1(client);
|
|
1592
|
+
this.bridgeBankAccounts = new BridgeBankAccountResource$1(client);
|
|
1593
|
+
this.bridgeClabes = new BridgeClabeResource$1(client);
|
|
1594
|
+
this.bridgeKycValidations = new KYCValidationsResource$1(client, true);
|
|
1595
|
+
this.bridgeSessions = new SessionResource$1(client, true);
|
|
1596
|
+
this.bridgeTransactions = new BridgeTransactionResource$1(client);
|
|
1597
|
+
this.cardActivations = new CardActivationResource$1(client);
|
|
1598
|
+
this.cards = new CardResource$1(client);
|
|
1599
|
+
this.cardTransactions = new CardTransactionResource$1(client);
|
|
1600
|
+
this.cardValidations = new CardValidationResource$1(client);
|
|
1601
|
+
this.commissions = new CommissionResource$1(client);
|
|
1602
|
+
this.deposits = new DepositResource$1(client);
|
|
1603
|
+
this.files = new FileResource$1(client);
|
|
1604
|
+
this.fraudFundsTransfers = new FraudFundsTransferResource$1(client);
|
|
1605
|
+
this.kycValidations = new KYCValidationsResource$1(client);
|
|
1606
|
+
this.legalPersons = new LegalPersonResource$1(client);
|
|
1607
|
+
this.loginTokens = new LoginTokenResource$1(client);
|
|
1608
|
+
this.operatorLogins = new OperatorLoginResource$1(client);
|
|
1609
|
+
this.operators = new OperatorResource$1(client);
|
|
1610
|
+
this.partners = new PartnerResource$1(client);
|
|
1611
|
+
this.postalCodes = new PostalCodeResource$1(client);
|
|
1612
|
+
this.reports = new ReportResource$1(client);
|
|
1613
|
+
this.savings = new SavingResource$1(client);
|
|
1614
|
+
this.serviceProviders = new ServiceProviderResource$1(client);
|
|
1615
|
+
this.sessions = new SessionResource$1(client);
|
|
1616
|
+
this.statements = new StatementResource$1(client);
|
|
1617
|
+
this.transfers = new TransferResource$1(client);
|
|
1618
|
+
this.userCredentials = new UserCredentialResource$1(client);
|
|
1619
|
+
this.userLogins = new UserLoginResource$1(client);
|
|
1620
|
+
this.users = new UserResource$1(client);
|
|
1621
|
+
this.userReports = new UserReportResource$1(client);
|
|
1622
|
+
this.usersTosAgreements = new UsersTosAgreementsResource$1(client);
|
|
1623
|
+
this.verifications = new VerificationResource$1(client);
|
|
1624
|
+
this.walletTransactions = new WalletTransactionsResource$1(client);
|
|
1625
|
+
this.whatsAppTransfers = new WhatsAppTransferResource$1(client);
|
|
1626
|
+
}
|
|
3138
1627
|
}
|
|
3139
1628
|
|
|
3140
1629
|
export { Cuenca };
|