Comparing version 2.0.8 to 2.0.9
@@ -17,2 +17,7 @@ const cadujs = require('../src/client') | ||
test('when try connectKycProxy without config', () => { | ||
expect(() => cadujs.connectKycProxy()) | ||
.toThrow() | ||
}) | ||
test("when try connect without 'clientApplicationKey'", () => { | ||
@@ -64,2 +69,13 @@ expect(() => cadujs.connect({ | ||
}) | ||
test('when try connectKycProxy with correct values', () => { | ||
const client = cadujs.connectKycProxy({ | ||
environment: 'sandbox', | ||
clientApplicationKey: '1234-1234-1234', | ||
secret: '1234', | ||
userIdentifier: 'test@pagar.me', | ||
}) | ||
expect(client).toBeInstanceOf(Object) | ||
}) | ||
}) |
@@ -75,13 +75,16 @@ module.exports = | ||
economicActivitiesRoutes = _require4.economicActivitiesRoutes, | ||
analysisRoutes = _require4.analysisRoutes; | ||
analysisRoutes = _require4.analysisRoutes, | ||
kycProxyAnalysisRoutes = _require4.kycProxyAnalysisRoutes; | ||
var adapters = __webpack_require__(21); | ||
var adapters = __webpack_require__(22); | ||
var _require5 = __webpack_require__(26), | ||
var _require5 = __webpack_require__(27), | ||
validateConfig = _require5.validateConfig; | ||
configs.Promise = __webpack_require__(28); | ||
configs.Promise = __webpack_require__(29); | ||
var chooseHost = ifElse(equals('live'), always('https://api-cadu.stone.com.br'), always('https://api-sandbox-cadu.stone.com.br')); | ||
var chooseHostKycProxy = ifElse(equals('live'), always('https://kyc-proxy.risco.pagar.me'), always('https://kyc-proxy.stg.risco.pagar.me')); | ||
var connect = function connect() { | ||
@@ -122,3 +125,30 @@ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var connectKycProxy = function connectKycProxy() { | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
validateConfig(config); | ||
var environment = config.environment, | ||
secret = config.secret, | ||
clientApplicationKey = config.clientApplicationKey, | ||
userIdentifier = config.userIdentifier; | ||
var library = mappersmith({ | ||
middlewares: [encodeJson, headerAuth({ | ||
secret: secret, | ||
clientApplicationKey: clientApplicationKey, | ||
userIdentifier: userIdentifier | ||
})], | ||
host: chooseHostKycProxy(environment), | ||
resources: { | ||
Analysis: kycProxyAnalysisRoutes | ||
} | ||
}); | ||
return assoc('adapters', adapters, library); | ||
}; | ||
module.exports = { | ||
connectKycProxy: connectKycProxy, | ||
connect: connect, | ||
@@ -261,2 +291,3 @@ adapters: adapters | ||
var analysisRoutes = __webpack_require__(20); | ||
var kycProxyAnalysisRoutes = __webpack_require__(21); | ||
@@ -273,3 +304,4 @@ module.exports = { | ||
economicActivitiesRoutes: economicActivitiesRoutes, | ||
analysisRoutes: analysisRoutes | ||
analysisRoutes: analysisRoutes, | ||
kycProxyAnalysisRoutes: kycProxyAnalysisRoutes | ||
}; | ||
@@ -603,2 +635,22 @@ | ||
/* 21 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
var riskAPI = '/risk/v1/members'; | ||
module.exports = { | ||
byId: { | ||
method: 'get', | ||
path: riskAPI + '/{memberKey}/analyses/{analysisKey}' | ||
}, | ||
create: { | ||
method: 'post', | ||
path: riskAPI + '/{memberKey}/analyses' | ||
} | ||
}; | ||
/***/ }, | ||
/* 22 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -608,6 +660,6 @@ | ||
var pagarmeRecipientAdapter = __webpack_require__(22); | ||
var pagarmeBankAccountAdapter = __webpack_require__(23); | ||
var pagarmeAddressAdapter = __webpack_require__(24); | ||
var pagarmeRiskAnalysisAdapter = __webpack_require__(25); | ||
var pagarmeRecipientAdapter = __webpack_require__(23); | ||
var pagarmeBankAccountAdapter = __webpack_require__(24); | ||
var pagarmeAddressAdapter = __webpack_require__(25); | ||
var pagarmeRiskAnalysisAdapter = __webpack_require__(26); | ||
@@ -624,3 +676,3 @@ module.exports = { | ||
/***/ }, | ||
/* 22 */ | ||
/* 23 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -631,4 +683,4 @@ | ||
var moment = __webpack_require__(8); | ||
var bankAccountAdapter = __webpack_require__(23); | ||
var addressAdapter = __webpack_require__(24); | ||
var bankAccountAdapter = __webpack_require__(24); | ||
var addressAdapter = __webpack_require__(25); | ||
@@ -745,3 +797,3 @@ var _require = __webpack_require__(9), | ||
/***/ }, | ||
/* 23 */ | ||
/* 24 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -774,3 +826,3 @@ | ||
/***/ }, | ||
/* 24 */ | ||
/* 25 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -821,3 +873,3 @@ | ||
/***/ }, | ||
/* 25 */ | ||
/* 26 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -827,3 +879,3 @@ | ||
var recipientAdapter = __webpack_require__(22); | ||
var recipientAdapter = __webpack_require__(23); | ||
@@ -871,3 +923,3 @@ var _require = __webpack_require__(9), | ||
/***/ }, | ||
/* 26 */ | ||
/* 27 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -881,3 +933,3 @@ | ||
var Joi = __webpack_require__(27); | ||
var Joi = __webpack_require__(28); | ||
@@ -904,3 +956,3 @@ var configSchema = Joi.object().keys({ | ||
/***/ }, | ||
/* 27 */ | ||
/* 28 */ | ||
/***/ function(module, exports) { | ||
@@ -911,3 +963,3 @@ | ||
/***/ }, | ||
/* 28 */ | ||
/* 29 */ | ||
/***/ function(module, exports) { | ||
@@ -914,0 +966,0 @@ |
{ | ||
"name": "cadu", | ||
"version": "2.0.8", | ||
"version": "2.0.9", | ||
"description": "A JavaScript library to interface with CADU", | ||
@@ -5,0 +5,0 @@ "main": "src/client.js", |
@@ -23,3 +23,5 @@ const { default: mappersmith, configs } = require('mappersmith') | ||
analysisRoutes, | ||
kycProxyAnalysisRoutes, | ||
} = require('./routes') | ||
const adapters = require('./adapters') | ||
@@ -39,2 +41,8 @@ | ||
const chooseHostKycProxy = ifElse( | ||
equals('live'), | ||
always('https://kyc-proxy.risco.pagar.me'), | ||
always('https://kyc-proxy.stg.risco.pagar.me') | ||
) | ||
const connect = (config = {}) => { | ||
@@ -77,5 +85,34 @@ validateConfig(config) | ||
const connectKycProxy = (config = {}) => { | ||
validateConfig(config) | ||
const { | ||
environment, | ||
secret, | ||
clientApplicationKey, | ||
userIdentifier, | ||
} = config | ||
const library = mappersmith({ | ||
middlewares: [ | ||
encodeJson, | ||
headerAuth({ | ||
secret, | ||
clientApplicationKey, | ||
userIdentifier, | ||
}), | ||
], | ||
host: chooseHostKycProxy(environment), | ||
resources: { | ||
Analysis: kycProxyAnalysisRoutes, | ||
}, | ||
}) | ||
return assoc('adapters', adapters, library) | ||
} | ||
module.exports = { | ||
connectKycProxy, | ||
connect, | ||
adapters, | ||
} |
@@ -11,2 +11,3 @@ const memberRoutes = require('./member') | ||
const analysisRoutes = require('./risk/analysis') | ||
const kycProxyAnalysisRoutes = require('./kyc-proxy/analysis') | ||
@@ -24,2 +25,3 @@ module.exports = { | ||
analysisRoutes, | ||
kycProxyAnalysisRoutes, | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124783
34
2486