mangopay4-nodejs-sdk 1.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.js.yml +32 -0
- package/.github/workflows/npm-publish.yml +26 -0
- package/.jshintrc +16 -0
- package/CHANGELOG.md +946 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/docs/BankAccounts.md +35 -0
- package/docs/BankingAliases.md +108 -0
- package/docs/CardPreAuthorizations.md +55 -0
- package/docs/CardRegistrations.md +55 -0
- package/docs/Cards.md +82 -0
- package/docs/Clients.md +142 -0
- package/docs/DisputeDocuments.md +53 -0
- package/docs/Disputes.md +292 -0
- package/docs/Events.md +23 -0
- package/docs/Hooks.md +68 -0
- package/docs/Idempotency.md +11 -0
- package/docs/KycDocuments.md +52 -0
- package/docs/Mandates.md +125 -0
- package/docs/OptionsHelper.md +32 -0
- package/docs/PayIns.md +72 -0
- package/docs/PayOuts.md +55 -0
- package/docs/README.md +131 -0
- package/docs/Refunds.md +25 -0
- package/docs/Reports.md +63 -0
- package/docs/Repudiations.md +25 -0
- package/docs/Responses.md +33 -0
- package/docs/Transfers.md +72 -0
- package/docs/UboDeclarations.md +70 -0
- package/docs/Users.md +322 -0
- package/docs/Wallets.md +70 -0
- package/docs/templates/class.mustache +11 -0
- package/docs/templates/file.mustache +53 -0
- package/docs/templates/function.mustache +33 -0
- package/docs/templates/index.mustache +26 -0
- package/docs/templates/overview.mustache +1 -0
- package/examples/createUsers.js +112 -0
- package/examples/createWallet.js +28 -0
- package/examples/failedRequest.js +20 -0
- package/examples/getBankAccounts.js +29 -0
- package/examples/getUserEmoney.js +16 -0
- package/examples/getUsers.js +32 -0
- package/examples/readResponseHeaders.js +42 -0
- package/index.js +1 -0
- package/lib/Model.js +58 -0
- package/lib/api.js +467 -0
- package/lib/apiMethods.js +270 -0
- package/lib/config.js +57 -0
- package/lib/log.js +9 -0
- package/lib/mangopay.js +8 -0
- package/lib/models/Address.js +32 -0
- package/lib/models/BankAccount.js +45 -0
- package/lib/models/BankAccountDetails.js +7 -0
- package/lib/models/BankAccountDetailsCA.js +12 -0
- package/lib/models/BankAccountDetailsGB.js +10 -0
- package/lib/models/BankAccountDetailsIBAN.js +10 -0
- package/lib/models/BankAccountDetailsOTHER.js +16 -0
- package/lib/models/BankAccountDetailsUS.js +14 -0
- package/lib/models/BankAccountType.js +8 -0
- package/lib/models/BankingAlias.js +37 -0
- package/lib/models/BankingAliasIBAN.js +27 -0
- package/lib/models/Billing.js +14 -0
- package/lib/models/BinData.js +16 -0
- package/lib/models/Birthplace.js +10 -0
- package/lib/models/BrowserInfo.js +15 -0
- package/lib/models/Card.js +19 -0
- package/lib/models/CardInfo.js +32 -0
- package/lib/models/CardPreAuthorization.js +144 -0
- package/lib/models/CardRegistration.js +29 -0
- package/lib/models/CardValidation.js +19 -0
- package/lib/models/CategorizeUserLegal.js +15 -0
- package/lib/models/CategorizeUserNatural.js +18 -0
- package/lib/models/Check.js +13 -0
- package/lib/models/CheckData.js +8 -0
- package/lib/models/Client.js +62 -0
- package/lib/models/ClientWallet.js +28 -0
- package/lib/models/Conversion.js +19 -0
- package/lib/models/ConversionRate.js +10 -0
- package/lib/models/CountryAuthorization.js +12 -0
- package/lib/models/DebitedBankAccount.js +15 -0
- package/lib/models/DeclaredUbo.js +29 -0
- package/lib/models/DeclaredUboStatus.js +17 -0
- package/lib/models/Deposit.js +29 -0
- package/lib/models/Dispute.js +46 -0
- package/lib/models/DisputeDocument.js +10 -0
- package/lib/models/DisputeDocumentPage.js +12 -0
- package/lib/models/DisputeReason.js +11 -0
- package/lib/models/Document.js +12 -0
- package/lib/models/DocumentPageConsult.js +17 -0
- package/lib/models/EMoney.js +30 -0
- package/lib/models/EntityBase.js +70 -0
- package/lib/models/Hook.js +19 -0
- package/lib/models/IdempotencyResponse.js +11 -0
- package/lib/models/IdentityVerification.js +12 -0
- package/lib/models/KycDocument.js +11 -0
- package/lib/models/KycDocumentStatus.js +7 -0
- package/lib/models/KycDocumentType.js +7 -0
- package/lib/models/KycPage.js +12 -0
- package/lib/models/LegalPersonType.js +7 -0
- package/lib/models/LegalRepresentative.js +16 -0
- package/lib/models/Mandate.js +69 -0
- package/lib/models/MandateStatus.js +7 -0
- package/lib/models/Money.js +16 -0
- package/lib/models/PayByBankSupportedBank.js +7 -0
- package/lib/models/PayIn.js +36 -0
- package/lib/models/PayInExecutionDetails.js +7 -0
- package/lib/models/PayInExecutionDetailsBankingAlias.js +19 -0
- package/lib/models/PayInExecutionDetailsDirect.js +29 -0
- package/lib/models/PayInExecutionDetailsWeb.js +40 -0
- package/lib/models/PayInExecutionType.js +5 -0
- package/lib/models/PayInIntent.js +20 -0
- package/lib/models/PayInIntentSplit.js +14 -0
- package/lib/models/PayInIntentSplits.js +7 -0
- package/lib/models/PayInPaymentDetails.js +7 -0
- package/lib/models/PayInPaymentDetailsApplePay.js +19 -0
- package/lib/models/PayInPaymentDetailsBancontact.js +13 -0
- package/lib/models/PayInPaymentDetailsBankWire.js +23 -0
- package/lib/models/PayInPaymentDetailsBankingAlias.js +18 -0
- package/lib/models/PayInPaymentDetailsBizum.js +23 -0
- package/lib/models/PayInPaymentDetailsBlik.js +17 -0
- package/lib/models/PayInPaymentDetailsCard.js +10 -0
- package/lib/models/PayInPaymentDetailsCardDirect.js +14 -0
- package/lib/models/PayInPaymentDetailsCardWeb.js +28 -0
- package/lib/models/PayInPaymentDetailsDirectDebitDirect.js +22 -0
- package/lib/models/PayInPaymentDetailsDirectDebitWeb.js +13 -0
- package/lib/models/PayInPaymentDetailsGiropay.js +15 -0
- package/lib/models/PayInPaymentDetailsGooglePay.js +35 -0
- package/lib/models/PayInPaymentDetailsIdeal.js +25 -0
- package/lib/models/PayInPaymentDetailsKlarna.js +36 -0
- package/lib/models/PayInPaymentDetailsMbway.js +20 -0
- package/lib/models/PayInPaymentDetailsMultibanco.js +14 -0
- package/lib/models/PayInPaymentDetailsPayByBank.js +71 -0
- package/lib/models/PayInPaymentDetailsPayPal.js +63 -0
- package/lib/models/PayInPaymentDetailsPayconiq.js +23 -0
- package/lib/models/PayInPaymentDetailsPreAuthorized.js +10 -0
- package/lib/models/PayInPaymentDetailsSatispay.js +19 -0
- package/lib/models/PayInPaymentDetailsSwish.js +35 -0
- package/lib/models/PayInPaymentDetailsTwint.js +15 -0
- package/lib/models/PayInPaymentType.js +21 -0
- package/lib/models/PayInRecurringRegistration.js +64 -0
- package/lib/models/PayInTemplateURLOptions.js +10 -0
- package/lib/models/PayOut.js +24 -0
- package/lib/models/PayOutPaymentDetails.js +7 -0
- package/lib/models/PayOutPaymentDetailsBankWire.js +32 -0
- package/lib/models/PayOutPaymentType.js +3 -0
- package/lib/models/PaymentData.js +20 -0
- package/lib/models/PaymentMethodMetadata.js +38 -0
- package/lib/models/PayoutMethods.js +7 -0
- package/lib/models/PendingUserAction.js +16 -0
- package/lib/models/PersonType.js +5 -0
- package/lib/models/PlatformCategorization.js +16 -0
- package/lib/models/PlatformType.js +10 -0
- package/lib/models/Quote.js +11 -0
- package/lib/models/Recipient.js +20 -0
- package/lib/models/RecipientSchema.js +17 -0
- package/lib/models/RecurringPayIn.js +10 -0
- package/lib/models/RecurringPayInCIT.js +32 -0
- package/lib/models/RecurringPayInCurrentState.js +24 -0
- package/lib/models/RecurringPayInMIT.js +27 -0
- package/lib/models/RecurringPayInPut.js +24 -0
- package/lib/models/Refund.js +26 -0
- package/lib/models/RefundReasonDetails.js +10 -0
- package/lib/models/Report.js +54 -0
- package/lib/models/ReportFilter.js +52 -0
- package/lib/models/ReportFilterV2.js +11 -0
- package/lib/models/ReportV2.js +28 -0
- package/lib/models/Repudiation.js +51 -0
- package/lib/models/SecurityInfo.js +12 -0
- package/lib/models/Settlement.js +16 -0
- package/lib/models/SettlementTransfer.js +37 -0
- package/lib/models/Shipping.js +14 -0
- package/lib/models/ShippingAddress.js +25 -0
- package/lib/models/ShippingPreference.js +5 -0
- package/lib/models/Transaction.js +50 -0
- package/lib/models/Transfer.js +13 -0
- package/lib/models/Ubo.js +19 -0
- package/lib/models/UboDeclaration.js +42 -0
- package/lib/models/UboDeclarationRefusedReasonType.js +23 -0
- package/lib/models/UboDeclarationStatus.js +26 -0
- package/lib/models/UboRefusedReasonType.js +14 -0
- package/lib/models/User.js +66 -0
- package/lib/models/UserCategory.js +5 -0
- package/lib/models/UserConsent.js +7 -0
- package/lib/models/UserDataFormatValidation.js +7 -0
- package/lib/models/UserEnrollmentResult.js +7 -0
- package/lib/models/UserLegal.js +65 -0
- package/lib/models/UserLegalOwner.js +66 -0
- package/lib/models/UserLegalPayer.js +66 -0
- package/lib/models/UserLegalSca.js +57 -0
- package/lib/models/UserNatural.js +51 -0
- package/lib/models/UserNaturalCapacity.js +13 -0
- package/lib/models/UserNaturalOwner.js +55 -0
- package/lib/models/UserNaturalPayer.js +55 -0
- package/lib/models/UserNaturalPut.js +49 -0
- package/lib/models/UserNaturalSca.js +56 -0
- package/lib/models/VirtualAccount.js +22 -0
- package/lib/models/Wallet.js +32 -0
- package/lib/models/index.js +102 -0
- package/lib/service.js +14 -0
- package/lib/services/BankAccounts.js +31 -0
- package/lib/services/BankingAliases.js +137 -0
- package/lib/services/CardPreAuthorizations.js +75 -0
- package/lib/services/CardRegistrations.js +64 -0
- package/lib/services/Cards.js +168 -0
- package/lib/services/Clients.js +196 -0
- package/lib/services/Conversions.js +155 -0
- package/lib/services/Deposits.js +109 -0
- package/lib/services/DisputeDocuments.js +65 -0
- package/lib/services/Disputes.js +409 -0
- package/lib/services/Events.js +24 -0
- package/lib/services/Hooks.js +81 -0
- package/lib/services/Idempotency.js +17 -0
- package/lib/services/IdentityVerifications.js +48 -0
- package/lib/services/KycDocuments.js +66 -0
- package/lib/services/Mandates.js +161 -0
- package/lib/services/OptionsHelper.js +20 -0
- package/lib/services/PayIns.js +690 -0
- package/lib/services/PayOuts.js +110 -0
- package/lib/services/Recipients.js +117 -0
- package/lib/services/Refunds.js +29 -0
- package/lib/services/Regulatory.js +29 -0
- package/lib/services/Reports.js +61 -0
- package/lib/services/ReportsV2.js +55 -0
- package/lib/services/Repudiations.js +33 -0
- package/lib/services/Responses.js +23 -0
- package/lib/services/Settlements.js +74 -0
- package/lib/services/Transfers.js +87 -0
- package/lib/services/UboDeclarations.js +135 -0
- package/lib/services/Users.js +831 -0
- package/lib/services/VirtualAccounts.js +99 -0
- package/lib/services/Wallets.js +85 -0
- package/lib/services/index.js +34 -0
- package/lib/utils.js +36 -0
- package/package.json +40 -0
- package/test/TestKycPageFile.png +0 -0
- package/test/helpers.js +1431 -0
- package/test/main.js +10 -0
- package/test/mocha.opts +3 -0
- package/test/services/BankAccounts.js +46 -0
- package/test/services/BankingAliases.js +89 -0
- package/test/services/CardPreAuthorizations.js +70 -0
- package/test/services/CardRegistrations.js +239 -0
- package/test/services/Cards.js +54 -0
- package/test/services/Clients.js +235 -0
- package/test/services/Conversions.js +308 -0
- package/test/services/Deposits.js +148 -0
- package/test/services/Disputes.js +542 -0
- package/test/services/EMoney.js +54 -0
- package/test/services/Events.js +143 -0
- package/test/services/Hooks.js +109 -0
- package/test/services/Idempotency.js +46 -0
- package/test/services/IdentityVerifications.js +68 -0
- package/test/services/KycDocuments.js +73 -0
- package/test/services/Mandates.js +256 -0
- package/test/services/PayIns.js +2553 -0
- package/test/services/PayOuts.js +106 -0
- package/test/services/RateLimit.js +48 -0
- package/test/services/Recipients.js +234 -0
- package/test/services/Refunds.js +123 -0
- package/test/services/Regulatory.js +45 -0
- package/test/services/Reports.js +114 -0
- package/test/services/ReportsV2.js +306 -0
- package/test/services/Repudiations.js +22 -0
- package/test/services/Settlements.js +58 -0
- package/test/services/Tokens.js +55 -0
- package/test/services/Transfers.js +137 -0
- package/test/services/UboDeclarations.js +135 -0
- package/test/services/Users.js +1303 -0
- package/test/services/VirtualAccounts.js +105 -0
- package/test/services/Wallets.js +132 -0
- package/test/settlement_sample.csv +8 -0
- package/typings/base.d.ts +308 -0
- package/typings/enums.d.ts +204 -0
- package/typings/index.d.ts +885 -0
- package/typings/index.test-d.ts +1535 -0
- package/typings/models/address.d.ts +70 -0
- package/typings/models/bankAccount.d.ts +235 -0
- package/typings/models/bankingAlias.d.ts +97 -0
- package/typings/models/billing.d.ts +42 -0
- package/typings/models/birthplace.d.ts +9 -0
- package/typings/models/card.d.ts +119 -0
- package/typings/models/cardPreauthorization.d.ts +157 -0
- package/typings/models/cardRegistration.d.ts +83 -0
- package/typings/models/cardValidation.d.ts +125 -0
- package/typings/models/client.d.ts +208 -0
- package/typings/models/conversion.d.ts +225 -0
- package/typings/models/conversionRate.d.ts +29 -0
- package/typings/models/countryAuthorization.d.ts +16 -0
- package/typings/models/deposit.d.ts +104 -0
- package/typings/models/dispute.d.ts +116 -0
- package/typings/models/disputeDocument.d.ts +119 -0
- package/typings/models/entityBase.d.ts +9 -0
- package/typings/models/event.d.ts +142 -0
- package/typings/models/hook.d.ts +39 -0
- package/typings/models/idempotency.d.ts +36 -0
- package/typings/models/identityVerification.d.ts +98 -0
- package/typings/models/kycDocument.d.ts +114 -0
- package/typings/models/mandate.d.ts +93 -0
- package/typings/models/money.d.ts +45 -0
- package/typings/models/payIn.d.ts +3742 -0
- package/typings/models/payOut.d.ts +144 -0
- package/typings/models/recipient.d.ts +242 -0
- package/typings/models/refund.d.ts +92 -0
- package/typings/models/report.d.ts +234 -0
- package/typings/models/reportV2.d.ts +145 -0
- package/typings/models/repudiation.d.ts +26 -0
- package/typings/models/securityInfo.d.ts +12 -0
- package/typings/models/settlement.d.ts +50 -0
- package/typings/models/settlementTransfer.d.ts +37 -0
- package/typings/models/shipping.d.ts +37 -0
- package/typings/models/shippingAddress.d.ts +15 -0
- package/typings/models/transaction.d.ts +85 -0
- package/typings/models/transfer.d.ts +119 -0
- package/typings/models/uboDeclaration.d.ts +100 -0
- package/typings/models/user.d.ts +1001 -0
- package/typings/models/virtualAccount.d.ts +182 -0
- package/typings/models/wallet.d.ts +46 -0
- package/typings/models.d.ts +74 -0
- package/typings/services/BankAccounts.d.ts +12 -0
- package/typings/services/BankingAliases.d.ts +51 -0
- package/typings/services/CardPreauthorizations.d.ts +44 -0
- package/typings/services/CardRegistrations.d.ts +43 -0
- package/typings/services/Cards.d.ts +80 -0
- package/typings/services/Clients.d.ts +77 -0
- package/typings/services/Conversions.d.ts +23 -0
- package/typings/services/Deposits.d.ts +20 -0
- package/typings/services/DisputeDocuments.d.ts +27 -0
- package/typings/services/Disputes.d.ts +169 -0
- package/typings/services/Events.d.ts +11 -0
- package/typings/services/Hooks.d.ts +33 -0
- package/typings/services/Idempotency.d.ts +7 -0
- package/typings/services/IdentityVerifications.d.ts +29 -0
- package/typings/services/KycDocuments.d.ts +38 -0
- package/typings/services/Mandates.d.ts +59 -0
- package/typings/services/OptionsHelper.d.ts +11 -0
- package/typings/services/PayIns.d.ts +319 -0
- package/typings/services/PayOuts.d.ts +34 -0
- package/typings/services/Recipients.d.ts +55 -0
- package/typings/services/Refunds.d.ts +12 -0
- package/typings/services/Regulatory.d.ts +17 -0
- package/typings/services/Reports.d.ts +26 -0
- package/typings/services/ReportsV2.d.ts +26 -0
- package/typings/services/Repudiations.d.ts +12 -0
- package/typings/services/Responses.d.ts +10 -0
- package/typings/services/Settlements.d.ts +28 -0
- package/typings/services/Transfers.d.ts +38 -0
- package/typings/services/UboDeclarations.d.ts +81 -0
- package/typings/services/Users.d.ts +308 -0
- package/typings/services/VirtualAccounts.d.ts +42 -0
- package/typings/services/Wallets.d.ts +36 -0
- package/typings/tsconfig.json +20 -0
- package/typings/tslint.json +11 -0
- package/typings/types.d.ts +652 -0
|
@@ -0,0 +1,831 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Users
|
|
3
|
+
* @desc [MangoPay Users API Reference](https://docs.mangopay.com/endpoints/v2.01/users)
|
|
4
|
+
*/
|
|
5
|
+
var _ = require('underscore');
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var Promise = require('promise');
|
|
8
|
+
var Service = require('../service');
|
|
9
|
+
|
|
10
|
+
var UserNatural = require('../models/UserNatural');
|
|
11
|
+
var UserNaturalSca = require('../models/UserNaturalSca');
|
|
12
|
+
var UserLegal = require('../models/UserLegal');
|
|
13
|
+
var UserLegalSca = require('../models/UserLegalSca');
|
|
14
|
+
var PersonType = require('../models/PersonType');
|
|
15
|
+
var BankAccountDetailsCA = require('../models/BankAccountDetailsCA');
|
|
16
|
+
var BankAccountDetailsGB = require('../models/BankAccountDetailsGB');
|
|
17
|
+
var BankAccountDetailsIBAN = require('../models/BankAccountDetailsIBAN');
|
|
18
|
+
var BankAccountDetailsOTHER = require('../models/BankAccountDetailsOTHER');
|
|
19
|
+
var BankAccountDetailsUS = require('../models/BankAccountDetailsUS');
|
|
20
|
+
var BankAccount = require('../models/BankAccount');
|
|
21
|
+
var Wallet = require('../models/Wallet');
|
|
22
|
+
var Transaction = require('../models/Transaction');
|
|
23
|
+
var Card = require('../models/Card');
|
|
24
|
+
var KycDocument = require('../models/KycDocument');
|
|
25
|
+
var KycPage = require('../models/KycPage');
|
|
26
|
+
var EMoney = require('../models/EMoney');
|
|
27
|
+
var UboDeclaration = require('../models/UboDeclaration');
|
|
28
|
+
var PreAuthorization = require('../models/CardPreAuthorization');
|
|
29
|
+
var UserNaturalPut = require('../models/UserNaturalPut');
|
|
30
|
+
var CategorizeUserNatural = require('../models/CategorizeUserNatural');
|
|
31
|
+
var CategorizeUserLegal = require('../models/CategorizeUserLegal');
|
|
32
|
+
var UserEnrollmentResult = require('../models/UserEnrollmentResult');
|
|
33
|
+
var UserDataFormatValidation = require('../models/UserDataFormatValidation');
|
|
34
|
+
var UserConsent = require('../models/UserConsent');
|
|
35
|
+
|
|
36
|
+
var Users = Service.extend({
|
|
37
|
+
/**
|
|
38
|
+
* Create a new user
|
|
39
|
+
* @param {Object} user Can be a UserNatural, UserLegal, UserNaturalSca, UserLegalSca or a hash of user properties.
|
|
40
|
+
* @return {Object} Promise of the request
|
|
41
|
+
*/
|
|
42
|
+
create: function(user, callback, options) {
|
|
43
|
+
var userCreateDetails = this._getUserApiAndClass(user);
|
|
44
|
+
|
|
45
|
+
// user.NaturalSca and user.LegalSca are needed for SCA when using TS, but should not be sent to the API
|
|
46
|
+
delete user.NaturalSca;
|
|
47
|
+
delete user.LegalSca;
|
|
48
|
+
|
|
49
|
+
options = this._api._getOptions(callback,
|
|
50
|
+
options,
|
|
51
|
+
{
|
|
52
|
+
data: user,
|
|
53
|
+
dataClass: userCreateDetails.userClass
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return this._api.method(userCreateDetails.createApiMethod, callback, options);
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get all users
|
|
61
|
+
* @return {Object} Request promise
|
|
62
|
+
*/
|
|
63
|
+
getAll: function(callback, options) {
|
|
64
|
+
return this._api.method('users_all', callback, options);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get natural or legal user by ID
|
|
69
|
+
* @param {number} userId User identifier
|
|
70
|
+
* @param {Function} callback Callback function
|
|
71
|
+
* @param {Object} options Request options
|
|
72
|
+
* @return {Object} Request promise
|
|
73
|
+
*/
|
|
74
|
+
get: function(userId, callback, options) {
|
|
75
|
+
options = this._api._getOptions(callback,
|
|
76
|
+
options,
|
|
77
|
+
{
|
|
78
|
+
path: {
|
|
79
|
+
id: userId
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return this._api.method('users_get', callback, options);
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get natural or legal SCA user by ID
|
|
88
|
+
* @param {number} userId User identifier
|
|
89
|
+
* @param {Function} callback Callback function
|
|
90
|
+
* @param {Object} options Request options
|
|
91
|
+
* @return {Object} Request promise
|
|
92
|
+
*/
|
|
93
|
+
getSca: function(userId, callback, options) {
|
|
94
|
+
options = this._api._getOptions(callback,
|
|
95
|
+
options,
|
|
96
|
+
{
|
|
97
|
+
path: {
|
|
98
|
+
id: userId
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return this._api.method('users_get_sca', callback, options);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get natural user by ID
|
|
107
|
+
* @param {number} userId User identifier
|
|
108
|
+
* @param {Function} callback Callback function Callback function
|
|
109
|
+
* @param {Object} options Request options
|
|
110
|
+
* @return {Object} Request promise
|
|
111
|
+
*/
|
|
112
|
+
getNatural: function(userId, callback, options) {
|
|
113
|
+
options = this._api._getOptions(callback, options);
|
|
114
|
+
options = _.extend({},
|
|
115
|
+
options,
|
|
116
|
+
{
|
|
117
|
+
path: {
|
|
118
|
+
id: userId
|
|
119
|
+
},
|
|
120
|
+
dataClass: UserNatural
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return this._api.method('users_getnaturals', callback, options);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get natural SCA user by ID
|
|
128
|
+
* @param {number} userId User identifier
|
|
129
|
+
* @param {Function} callback Callback function Callback function
|
|
130
|
+
* @param {Object} options Request options
|
|
131
|
+
* @return {Object} Request promise
|
|
132
|
+
*/
|
|
133
|
+
getNaturalSca: function(userId, callback, options) {
|
|
134
|
+
options = this._api._getOptions(callback, options);
|
|
135
|
+
options = _.extend({},
|
|
136
|
+
options,
|
|
137
|
+
{
|
|
138
|
+
path: {
|
|
139
|
+
id: userId
|
|
140
|
+
},
|
|
141
|
+
dataClass: UserNaturalSca
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return this._api.method('users_getnaturals_sca', callback, options);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get legal user by ID
|
|
149
|
+
* @param {number} userId User identifier
|
|
150
|
+
* @param {Function} callback Callback function Callback function
|
|
151
|
+
* @param {Object} options Request options
|
|
152
|
+
* @return {Object} Request promise
|
|
153
|
+
*/
|
|
154
|
+
getLegal: function(userId, callback, options) {
|
|
155
|
+
options = this._api._getOptions(callback, options);
|
|
156
|
+
options = _.extend({},
|
|
157
|
+
options,
|
|
158
|
+
{
|
|
159
|
+
path: {
|
|
160
|
+
id: userId
|
|
161
|
+
},
|
|
162
|
+
dataClass: UserLegal
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return this._api.method('users_getlegals', callback, options);
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Get legal SCA user by ID
|
|
170
|
+
* @param {number} userId User identifier
|
|
171
|
+
* @param {Function} callback Callback function Callback function
|
|
172
|
+
* @param {Object} options Request options
|
|
173
|
+
* @return {Object} Request promise
|
|
174
|
+
*/
|
|
175
|
+
getLegalSca: function(userId, callback, options) {
|
|
176
|
+
options = this._api._getOptions(callback, options);
|
|
177
|
+
options = _.extend({},
|
|
178
|
+
options,
|
|
179
|
+
{
|
|
180
|
+
path: {
|
|
181
|
+
id: userId
|
|
182
|
+
},
|
|
183
|
+
dataClass: UserLegalSca
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
return this._api.method('users_getlegals_sca', callback, options);
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Save user
|
|
191
|
+
* @param {Object} user User object to be saved
|
|
192
|
+
* @param {function} callback
|
|
193
|
+
* @param {Object} options
|
|
194
|
+
* @return {Object} Request promise
|
|
195
|
+
*/
|
|
196
|
+
updateNatural: function(userPut, user, callback, options) {
|
|
197
|
+
if (!user.Id) this._api.errorHandler('Cannot update user, the Id is missing');
|
|
198
|
+
options = this._api._getOptions(callback,
|
|
199
|
+
options,
|
|
200
|
+
{
|
|
201
|
+
data: userPut,
|
|
202
|
+
path: {
|
|
203
|
+
id: user.Id
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
var userSaveDetails = this._getUserApiAndClass(userPut);
|
|
208
|
+
options.dataClass = userSaveDetails.userPutClass;
|
|
209
|
+
|
|
210
|
+
return this._api.method(userSaveDetails.saveApiMethod, callback, options);
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Save user
|
|
215
|
+
* @param {Object} user User object to be saved
|
|
216
|
+
* @param {function} callback
|
|
217
|
+
* @param {Object} options
|
|
218
|
+
* @return {Object} Request promise
|
|
219
|
+
*/
|
|
220
|
+
update: function(user, callback, options) {
|
|
221
|
+
if (!user.Id) this._api.errorHandler('Cannot update user, the Id is missing');
|
|
222
|
+
options = this._api._getOptions(callback,
|
|
223
|
+
options,
|
|
224
|
+
{
|
|
225
|
+
data: user,
|
|
226
|
+
path: {
|
|
227
|
+
id: user.Id
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
var userSaveDetails = this._getUserApiAndClass(user);
|
|
232
|
+
options.dataClass = userSaveDetails.userClass;
|
|
233
|
+
|
|
234
|
+
return this._api.method(userSaveDetails.saveApiMethod, callback, options);
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Save SCA user
|
|
239
|
+
* @param {Object} user User object to be saved
|
|
240
|
+
* @param {function} callback
|
|
241
|
+
* @param {Object} options
|
|
242
|
+
* @return {Object} Request promise
|
|
243
|
+
*/
|
|
244
|
+
updateSca: function(user, callback, options) {
|
|
245
|
+
if (!user.Id) this._api.errorHandler('Cannot update user, the Id is missing');
|
|
246
|
+
options = this._api._getOptions(callback,
|
|
247
|
+
options,
|
|
248
|
+
{
|
|
249
|
+
data: user,
|
|
250
|
+
path: {
|
|
251
|
+
id: user.Id
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
var userSaveDetails = this._getUserApiAndClass(user);
|
|
256
|
+
options.dataClass = userSaveDetails.userClass;
|
|
257
|
+
|
|
258
|
+
return this._api.method(userSaveDetails.saveApiMethod, callback, options);
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Create bank account for user
|
|
263
|
+
* @param {number} userId User identifier
|
|
264
|
+
* @param {Object} bankAccount Bank account object
|
|
265
|
+
* @param {function} callback
|
|
266
|
+
* @param {Object} options
|
|
267
|
+
* @return {Object} Request promise
|
|
268
|
+
*/
|
|
269
|
+
createBankAccount: function(userId, bankAccount, callback, options) {
|
|
270
|
+
options = this._api._getOptions(callback,
|
|
271
|
+
options,
|
|
272
|
+
{
|
|
273
|
+
path: {
|
|
274
|
+
id: userId
|
|
275
|
+
},
|
|
276
|
+
data: bankAccount,
|
|
277
|
+
dataClass: BankAccount
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
var createBankAccountApiMethod = 'users_createbankaccounts_' + this._getBankAccountType(bankAccount);
|
|
282
|
+
} catch (err) {
|
|
283
|
+
if (callback) callback(null, null, err);
|
|
284
|
+
return Promise.reject(err);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return this._api.method(createBankAccountApiMethod, callback, options);
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Deactivate a bank account
|
|
292
|
+
* @param userId
|
|
293
|
+
* @param bankAccountId
|
|
294
|
+
* @param callback
|
|
295
|
+
* @param options
|
|
296
|
+
* @returns {*}
|
|
297
|
+
*/
|
|
298
|
+
deactivateBankAccount: function(userId, bankAccountId, callback, options) {
|
|
299
|
+
options = this._api._getOptions(callback,
|
|
300
|
+
options,
|
|
301
|
+
{
|
|
302
|
+
path: {
|
|
303
|
+
id: userId,
|
|
304
|
+
bankAccountId: bankAccountId
|
|
305
|
+
},
|
|
306
|
+
data: { Active: false },
|
|
307
|
+
dataClass: BankAccount
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
return this._api.method('users_deactivate_bankaccount', callback, options);
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Get all bank accounts for user
|
|
315
|
+
* @param {number} userId User identifier
|
|
316
|
+
* @param {function} callback
|
|
317
|
+
* @param {Object} options
|
|
318
|
+
* @return {Object} Request promise
|
|
319
|
+
*/
|
|
320
|
+
getBankAccounts: function(userId, callback, options) {
|
|
321
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
322
|
+
Object.assign(options, { parameters: { ...options } });
|
|
323
|
+
options = this._api._getOptions(callback,
|
|
324
|
+
options,
|
|
325
|
+
{
|
|
326
|
+
path: {
|
|
327
|
+
id: userId
|
|
328
|
+
},
|
|
329
|
+
dataClass: BankAccount
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
return this._api.method('users_allbankaccount', callback, options);
|
|
333
|
+
},
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Get bank account for user
|
|
337
|
+
* @param {number} userId User identifier
|
|
338
|
+
* @param {number} bankAccountId Bank account id
|
|
339
|
+
* @param {function} callback
|
|
340
|
+
* @param {Object} options
|
|
341
|
+
* @return {Object} Request promise
|
|
342
|
+
*/
|
|
343
|
+
getBankAccount: function(userId, bankAccountId, callback, options) {
|
|
344
|
+
options = this._api._getOptions(callback,
|
|
345
|
+
options,
|
|
346
|
+
{
|
|
347
|
+
path: {
|
|
348
|
+
id: userId,
|
|
349
|
+
bankAccountId: bankAccountId
|
|
350
|
+
},
|
|
351
|
+
dataClass: BankAccount
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
return this._api.method('users_getbankaccount', callback, options);
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Get all wallets accounts for user
|
|
359
|
+
* @param {number} userId User identifier
|
|
360
|
+
* @param {function} callback
|
|
361
|
+
* @param {Object} options
|
|
362
|
+
* @return {Object} Request promise
|
|
363
|
+
*/
|
|
364
|
+
getWallets: function(userId, callback, options) {
|
|
365
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
366
|
+
Object.assign(options, { parameters: { ...options } });
|
|
367
|
+
options = this._api._getOptions(callback,
|
|
368
|
+
options,
|
|
369
|
+
{
|
|
370
|
+
path: {
|
|
371
|
+
id: userId
|
|
372
|
+
},
|
|
373
|
+
dataClass: Wallet
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
return this._api.method('users_allwallets', callback, options);
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Get all transactions for user
|
|
381
|
+
* @param {number} userId User identifier
|
|
382
|
+
* @param {function} callback
|
|
383
|
+
* @param {Object} options
|
|
384
|
+
* @return {Object} Request promise
|
|
385
|
+
*/
|
|
386
|
+
getTransactions: function(userId, callback, options) {
|
|
387
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
388
|
+
Object.assign(options, { parameters: { ...options } });
|
|
389
|
+
options = this._api._getOptions(callback,
|
|
390
|
+
options,
|
|
391
|
+
{
|
|
392
|
+
path: {
|
|
393
|
+
id: userId
|
|
394
|
+
},
|
|
395
|
+
dataClass: Transaction
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
return this._api.method('users_alltransactions', callback, options);
|
|
399
|
+
},
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Get all cards for user
|
|
403
|
+
* @param {number} userId User identifier
|
|
404
|
+
* @param {function} callback
|
|
405
|
+
* @param {Object} options
|
|
406
|
+
* @return {Object} Request promise
|
|
407
|
+
*/
|
|
408
|
+
getCards: function(userId, callback, options) {
|
|
409
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
410
|
+
Object.assign(options, { parameters: { ...options } });
|
|
411
|
+
options = this._api._getOptions(callback,
|
|
412
|
+
options,
|
|
413
|
+
{
|
|
414
|
+
path: {
|
|
415
|
+
id: userId
|
|
416
|
+
},
|
|
417
|
+
dataClass: Card
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
return this._api.method('users_allcards', callback, options);
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Create new KYC document
|
|
425
|
+
* @param {number} userId User identifier
|
|
426
|
+
* @param {Object} kycDocument
|
|
427
|
+
* @param {function} callback
|
|
428
|
+
* @param {Object} options
|
|
429
|
+
* @return {Object} Request promise
|
|
430
|
+
*/
|
|
431
|
+
createKycDocument: function(userId, kycDocument, callback, options) {
|
|
432
|
+
options = this._api._getOptions(callback,
|
|
433
|
+
options,
|
|
434
|
+
{
|
|
435
|
+
path: {
|
|
436
|
+
id: userId
|
|
437
|
+
},
|
|
438
|
+
data: kycDocument,
|
|
439
|
+
dataClass: KycDocument
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
return this._api.method('kyc_documents_create', callback, options);
|
|
443
|
+
},
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Get all KYC documents for user
|
|
447
|
+
* @param {number} userId
|
|
448
|
+
* @param {function} callback
|
|
449
|
+
* @param {object} options
|
|
450
|
+
* @return {Object} Request promise
|
|
451
|
+
*/
|
|
452
|
+
getKycDocuments: function(userId, callback, options) {
|
|
453
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
454
|
+
Object.assign(options, { parameters: { ...options } });
|
|
455
|
+
options = this._api._getOptions(callback,
|
|
456
|
+
options,
|
|
457
|
+
{
|
|
458
|
+
path: {
|
|
459
|
+
id: userId
|
|
460
|
+
},
|
|
461
|
+
dataClass: KycDocument
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
return this._api.method('users_allkycdocuments', callback, options);
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Get KYC document
|
|
469
|
+
* @param {number} userId
|
|
470
|
+
* @param {number} kycDocumentId
|
|
471
|
+
* @param {function} callback
|
|
472
|
+
* @param {object} options
|
|
473
|
+
* @return {Object} Request promise
|
|
474
|
+
*/
|
|
475
|
+
getKycDocument: function(userId, kycDocumentId, callback, options) {
|
|
476
|
+
options = this._api._getOptions(callback,
|
|
477
|
+
options,
|
|
478
|
+
{
|
|
479
|
+
path: {
|
|
480
|
+
id: userId,
|
|
481
|
+
documentId: kycDocumentId
|
|
482
|
+
},
|
|
483
|
+
dataClass: KycDocument
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
return this._api.method('kyc_documents_get', callback, options);
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Save KYC document
|
|
491
|
+
* @param {number} userId
|
|
492
|
+
* @param {Object} kycDocument
|
|
493
|
+
* @param {function} callback
|
|
494
|
+
* @param {object} options
|
|
495
|
+
* @return {Object} Request promise
|
|
496
|
+
*/
|
|
497
|
+
updateKycDocument: function(userId, kycDocument, callback, options) {
|
|
498
|
+
options = this._api._getOptions(callback,
|
|
499
|
+
options,
|
|
500
|
+
{
|
|
501
|
+
path: {
|
|
502
|
+
id: userId,
|
|
503
|
+
documentId: kycDocument.Id
|
|
504
|
+
},
|
|
505
|
+
data: kycDocument,
|
|
506
|
+
dataClass: KycDocument
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
return this._api.method('kyc_documents_save', callback, options);
|
|
510
|
+
},
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Create page for KYC document
|
|
514
|
+
* @param {number} userId
|
|
515
|
+
* @param {number} kycDocumentId
|
|
516
|
+
* @param {Object} kycPage
|
|
517
|
+
* @param {function} callback
|
|
518
|
+
* @param {Object} options
|
|
519
|
+
* @return {Object} Request promise
|
|
520
|
+
*/
|
|
521
|
+
createKycPage: function(userId, kycDocumentId, kycPage, callback, options) {
|
|
522
|
+
options = this._api._getOptions(callback,
|
|
523
|
+
options,
|
|
524
|
+
{
|
|
525
|
+
path: {
|
|
526
|
+
id: userId,
|
|
527
|
+
documentId: kycDocumentId
|
|
528
|
+
},
|
|
529
|
+
data: kycPage
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
return this._api.method('kyc_page_create', callback, options);
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Create page for KYC document
|
|
537
|
+
* @param {number} userId
|
|
538
|
+
* @param {number} kycDocumentId
|
|
539
|
+
* @param {string} file File path
|
|
540
|
+
* @param {function} callback
|
|
541
|
+
* @param {Object} options
|
|
542
|
+
* @return {Object} Request promise
|
|
543
|
+
*/
|
|
544
|
+
createKycPageFromFile: function(userId, kycDocumentId, file, callback, options) {
|
|
545
|
+
if (!file) {
|
|
546
|
+
this._api.errorHandler('File path cannot be empty');
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
try {
|
|
551
|
+
fs.statSync(file);
|
|
552
|
+
} catch (e) {
|
|
553
|
+
this._api.errorHandler('File does not exist');
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
var kycPage = new KycPage({
|
|
558
|
+
File: Buffer.from(fs.readFileSync(file)).toString('base64')
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
if (!kycPage.File) this._api.errorHandler('Content of the file cannot be empty');
|
|
562
|
+
return this.createKycPage(userId, kycDocumentId, kycPage, callback, options);
|
|
563
|
+
},
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Get users's EMoney
|
|
567
|
+
* @param {number} userId User identifier
|
|
568
|
+
* @param {year} year The year for which we want to get the emoney
|
|
569
|
+
* @param {month} month The month for which we want to get the emoney. Can be null
|
|
570
|
+
* @param {function} callback
|
|
571
|
+
* @param {Object} options
|
|
572
|
+
* @return {Object} Request promise
|
|
573
|
+
*/
|
|
574
|
+
getEMoney: function(userId, year, month = null, callback, options) {
|
|
575
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
576
|
+
Object.assign(options, { parameters: { ...options } });
|
|
577
|
+
options = this._api._getOptions(callback,
|
|
578
|
+
options,
|
|
579
|
+
{
|
|
580
|
+
path: {
|
|
581
|
+
id: userId,
|
|
582
|
+
year: year,
|
|
583
|
+
month: month
|
|
584
|
+
},
|
|
585
|
+
dataClass: EMoney
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
let api_method = (month === null ? 'users_getemoney_year' : 'users_getemoney_month');
|
|
589
|
+
|
|
590
|
+
return this._api.method(api_method, callback, options);
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
getPreAuthorizations: function(userId, callback, options) {
|
|
594
|
+
if (options && !options.hasOwnProperty('parameters'))
|
|
595
|
+
Object.assign(options, { parameters: { ...options } });
|
|
596
|
+
options = this._api._getOptions(callback,
|
|
597
|
+
options,
|
|
598
|
+
{
|
|
599
|
+
path: {
|
|
600
|
+
id: userId
|
|
601
|
+
},
|
|
602
|
+
dataClass: PreAuthorization
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
return this._api.method('preauthorizations_get_for_user', callback, options);
|
|
606
|
+
},
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Gets the details for a user instance of hash of properties
|
|
610
|
+
* @param {Object|UserNatural|UserLegal|UserNaturalSca|UserLegalSca} user
|
|
611
|
+
*/
|
|
612
|
+
_getUserApiAndClass: function(user) {
|
|
613
|
+
// user.NaturalSca & user.LegalSca are needed when using TS
|
|
614
|
+
if (user instanceof UserNaturalSca || user.NaturalSca === true) {
|
|
615
|
+
return {
|
|
616
|
+
createApiMethod: 'users_createnaturals_sca',
|
|
617
|
+
saveApiMethod: 'users_savenaturals_sca',
|
|
618
|
+
deleteApiMethod: 'users_close_natural',
|
|
619
|
+
userClass: UserNaturalSca
|
|
620
|
+
};
|
|
621
|
+
} else if (user instanceof UserLegalSca || user.LegalSca === true) {
|
|
622
|
+
return {
|
|
623
|
+
createApiMethod: 'users_createlegals_sca',
|
|
624
|
+
saveApiMethod: 'users_savelegals_sca',
|
|
625
|
+
deleteApiMethod: 'users_close_legal',
|
|
626
|
+
userClass: UserLegalSca
|
|
627
|
+
};
|
|
628
|
+
} else if (user instanceof UserNatural || user.PersonType === PersonType.Natural) {
|
|
629
|
+
return {
|
|
630
|
+
createApiMethod: 'users_createnaturals',
|
|
631
|
+
saveApiMethod: 'users_savenaturals',
|
|
632
|
+
deleteApiMethod: 'users_close_natural',
|
|
633
|
+
userClass: UserNatural,
|
|
634
|
+
userPutClass: UserNaturalPut
|
|
635
|
+
};
|
|
636
|
+
} else if (user instanceof UserLegal || user.PersonType === PersonType.Legal) {
|
|
637
|
+
return {
|
|
638
|
+
createApiMethod: 'users_createlegals',
|
|
639
|
+
saveApiMethod: 'users_savelegals',
|
|
640
|
+
deleteApiMethod: 'users_close_legal',
|
|
641
|
+
userClass: UserLegal
|
|
642
|
+
};
|
|
643
|
+
} else {
|
|
644
|
+
this._api.errorHandler('Invalid user data');
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Based on the bank account type, we return the key necessary for getting the request method
|
|
650
|
+
* @param {Object} bankAccount
|
|
651
|
+
* @return {string}
|
|
652
|
+
* @private
|
|
653
|
+
*/
|
|
654
|
+
_getBankAccountType: function(bankAccount) {
|
|
655
|
+
if (bankAccount.Type) {
|
|
656
|
+
return bankAccount.Type.toLowerCase();
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (bankAccount.Details instanceof BankAccountDetailsCA) return 'ca';
|
|
660
|
+
if (bankAccount.Details instanceof BankAccountDetailsGB) return 'gb';
|
|
661
|
+
if (bankAccount.Details instanceof BankAccountDetailsIBAN) return 'iban';
|
|
662
|
+
if (bankAccount.Details instanceof BankAccountDetailsOTHER) return 'other';
|
|
663
|
+
if (bankAccount.Details instanceof BankAccountDetailsUS) return 'us';
|
|
664
|
+
|
|
665
|
+
throw new Error('Unspecified BankAccount type');
|
|
666
|
+
},
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Get user block status
|
|
670
|
+
* @param {number} userId User identifier
|
|
671
|
+
* @param {Function} callback Callback function
|
|
672
|
+
* @param {Object} options Request options
|
|
673
|
+
* @return {Object} Request promise
|
|
674
|
+
*/
|
|
675
|
+
getBlockStatus: function(userId, callback, options) {
|
|
676
|
+
options = this._api._getOptions(callback,
|
|
677
|
+
options,
|
|
678
|
+
{
|
|
679
|
+
path: {
|
|
680
|
+
id: userId
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
return this._api.method('users_block_status', callback, options);
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Get user regulatory
|
|
689
|
+
* @param {number} userId User identifier
|
|
690
|
+
* @param {Function} callback Callback function
|
|
691
|
+
* @param {Object} options Request options
|
|
692
|
+
* @return {Object} Request promise
|
|
693
|
+
*/
|
|
694
|
+
getRegulatory: function(userId, callback, options) {
|
|
695
|
+
options = this._api._getOptions(callback,
|
|
696
|
+
options,
|
|
697
|
+
{
|
|
698
|
+
path: {
|
|
699
|
+
id: userId
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
return this._api.method('users_regulatory', callback, options);
|
|
704
|
+
},
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* This endpoint allows you to transition a user whose UserCategory is PAYER into an OWNER
|
|
708
|
+
* by providing the required information and redirecting them on the PendingUserAction.RedirectUrl
|
|
709
|
+
* response value to complete SCA enrollment.
|
|
710
|
+
*
|
|
711
|
+
* For Natural Users, optionally, you can update the Email and provide or update the PhoneNumber
|
|
712
|
+
* and PhoneNumberCountry before SCA redirection.
|
|
713
|
+
*
|
|
714
|
+
* For Legal Users, optionally, you can update the LegalRepresentative.Email and provide or update
|
|
715
|
+
* the LegalRepresentative.PhoneNumber and LegalRepresentative.PhoneNumberCountry before SCA redirection.
|
|
716
|
+
*
|
|
717
|
+
* @param {CategorizeUserNatural|CategorizeUserLegal} user
|
|
718
|
+
* @return {UserNaturalSca|UserLegalSca} Promise of the request
|
|
719
|
+
*/
|
|
720
|
+
categorize: function(user, callback, options) {
|
|
721
|
+
var apiMethod;
|
|
722
|
+
var dataClass;
|
|
723
|
+
|
|
724
|
+
if (user instanceof CategorizeUserNatural || user.NaturalSca === true) {
|
|
725
|
+
apiMethod = 'users_categorizenaturals_sca';
|
|
726
|
+
dataClass = UserNaturalSca;
|
|
727
|
+
} else if (user instanceof CategorizeUserLegal || user.LegalSca === true) {
|
|
728
|
+
apiMethod = 'users_categorizelegals_sca';
|
|
729
|
+
dataClass = UserLegalSca;
|
|
730
|
+
} else {
|
|
731
|
+
this._api.errorHandler('Invalid user data');
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// user.NaturalSca and user.LegalSca are needed for SCA when using TS, but should not be sent to the API
|
|
735
|
+
delete user.NaturalSca;
|
|
736
|
+
delete user.LegalSca;
|
|
737
|
+
|
|
738
|
+
options = this._api._getOptions(callback,
|
|
739
|
+
options,
|
|
740
|
+
{
|
|
741
|
+
data: user,
|
|
742
|
+
dataClass: dataClass,
|
|
743
|
+
path: {
|
|
744
|
+
id: user.Id
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
return this._api.method(apiMethod, callback, options);
|
|
749
|
+
},
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* If UserCategory is OWNER, this endpoint allows you to enroll a user in SCA.
|
|
753
|
+
* Your platform needs to retrieve the returned PendingUserAction.RedirectUrl,
|
|
754
|
+
* add an encoded returnUrl query parameter for them to be returned to after the SCA session, and redirect the user.
|
|
755
|
+
*
|
|
756
|
+
* @param {string} userId The user identifier
|
|
757
|
+
* @return {UserEnrollmentResult}
|
|
758
|
+
*/
|
|
759
|
+
enroll: function(userId, callback, options) {
|
|
760
|
+
options = this._api._getOptions(callback,
|
|
761
|
+
options,
|
|
762
|
+
{
|
|
763
|
+
dataClass: UserEnrollmentResult,
|
|
764
|
+
path: {
|
|
765
|
+
id: userId
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
return this._api.method('users_enroll_sca', callback, options);
|
|
770
|
+
},
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Manage user consent
|
|
774
|
+
*
|
|
775
|
+
* @param {string} userId The user identifier
|
|
776
|
+
* @return {UserConsent}
|
|
777
|
+
*/
|
|
778
|
+
manageConsent: function(userId, callback, options) {
|
|
779
|
+
options = this._api._getOptions(callback,
|
|
780
|
+
options,
|
|
781
|
+
{
|
|
782
|
+
dataClass: UserConsent,
|
|
783
|
+
path: {
|
|
784
|
+
id: userId
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
return this._api.method('users_manage_consent', callback, options);
|
|
789
|
+
},
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Close a user (change status to CLOSED). The resource remains available for historical purposes.
|
|
793
|
+
* @param {Object} user User object to be closed
|
|
794
|
+
* @param {function} callback
|
|
795
|
+
* @param {Object} options
|
|
796
|
+
* @return {Object} Request promise
|
|
797
|
+
*/
|
|
798
|
+
close: function(user, callback, options) {
|
|
799
|
+
if (!user.Id) this._api.errorHandler('Cannot close user, the Id is missing');
|
|
800
|
+
options = this._api._getOptions(callback,
|
|
801
|
+
options,
|
|
802
|
+
{
|
|
803
|
+
path: {
|
|
804
|
+
id: user.Id
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
var userApiAndClass = this._getUserApiAndClass(user);
|
|
809
|
+
return this._api.method(userApiAndClass.deleteApiMethod, callback, options);
|
|
810
|
+
},
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Validate the format of user data
|
|
814
|
+
* @param {Object} dataValidation
|
|
815
|
+
* @param {function} callback
|
|
816
|
+
* @param {Object} options
|
|
817
|
+
* @return {Object} Request promise
|
|
818
|
+
*/
|
|
819
|
+
validateDataFormat: function (dataValidation, callback, options) {
|
|
820
|
+
options = this._api._getOptions(callback,
|
|
821
|
+
options,
|
|
822
|
+
{
|
|
823
|
+
data: dataValidation,
|
|
824
|
+
dataClass: UserDataFormatValidation
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
return this._api.method('users_validate_data_format', callback, options);
|
|
828
|
+
},
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
module.exports = Users;
|