|
2 | 2 | (function(root, factory) {
|
3 | 3 | if (typeof define === 'function' && define.amd) {
|
4 | 4 | // AMD. Register as an anonymous module.
|
5 |
| - define(['superagent', 'superagent-proxy', 'querystring'], factory); |
| 5 | + define(['superagent', 'superagent-proxy', 'querystring', 'Authentication/MerchantConfig', 'Authentication/Logger', 'Authentication/Constants', 'Authentication/Authorization', 'Authentication/PayloadDigest'], factory); |
6 | 6 | } else if (typeof module === 'object' && module.exports) {
|
7 | 7 | // CommonJS-like environments that support module.exports, like Node.
|
8 |
| - module.exports = factory(require('superagent'), require('superagent-proxy'), require('querystring')); |
| 8 | + module.exports = factory(require('superagent'), require('superagent-proxy'), require('querystring'), require('./authentication/core/MerchantConfig'), require('./authentication/logging/Logger'), require('./authentication/util/Constants'), require('./authentication/core/Authorization'), require('./authentication/payloadDigest/DigestGenerator')); |
9 | 9 | } else {
|
10 | 10 | // Browser globals (root is window)
|
11 | 11 | if (!root.{{moduleName}}) {
|
12 | 12 | root.{{moduleName}} = {};
|
13 | 13 | }
|
14 |
| - root.{{moduleName}}.ApiClient = factory(root.superagent, root.superagent_proxy, root.querystring); |
| 14 | + root.{{moduleName}}.ApiClient = factory(root.superagent, root.superagent_proxy, root.querystring, root.Authentication.MerchantConfig, root.Authentication.Logger, root.Authentication.Constants, root.Authentication.Authorization, root.Authentication.PayloadDigest); |
15 | 15 | }
|
16 |
| -}(this, function(superagent, superagent_proxy, querystring) { |
| 16 | +}(this, function(superagent, superagent_proxy, querystring, MerchantConfig, Logger, Constants, Authorization, PayloadDigest) { |
17 | 17 | 'use strict';
|
18 | 18 |
|
19 | 19 | {{#emitJSDoc}} /**
|
|
354 | 354 |
|
355 | 355 | // Code added by Infosys dev team
|
356 | 356 |
|
357 |
| - var AuthenticationSDK = require('cybersource-rest-auth'); |
358 | 357 | /**
|
359 | 358 | * This method will set the merchantConfig object global
|
360 | 359 | *
|
361 | 360 | * @param {Configuration} configObject merchantConfiguration properties.
|
362 | 361 | */
|
363 | 362 | exports.prototype.setConfiguration = function (configObject) {
|
364 | 363 |
|
365 |
| - this.merchantConfig = new AuthenticationSDK.MerchantConfig(configObject); |
366 |
| - this.constants = AuthenticationSDK.Constants; |
| 364 | + this.merchantConfig = new MerchantConfig(configObject); |
| 365 | + this.constants = Constants; |
367 | 366 | this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost();
|
368 |
| - this.logger = AuthenticationSDK.Logger.getLogger(this.merchantConfig, 'ApiClient'); |
| 367 | + this.logger = Logger.getLogger(this.merchantConfig, 'ApiClient'); |
369 | 368 | }
|
370 | 369 |
|
371 | 370 | /**
|
|
384 | 383 | this.logger.info('Authentication Type : ' + this.merchantConfig.getAuthenticationType());
|
385 | 384 | this.logger.info(this.constants.REQUEST_TYPE + ' : ' + httpMethod.toUpperCase());
|
386 | 385 |
|
387 |
| - var token = AuthenticationSDK.Authorization.getToken(this.merchantConfig, this.logger); |
| 386 | + var token = Authorization.getToken(this.merchantConfig, this.logger); |
388 | 387 |
|
389 | 388 | var clientId = getClientId();
|
390 | 389 |
|
|
405 | 404 | if (httpMethod.toLowerCase() === this.constants.POST
|
406 | 405 | || httpMethod.toLowerCase() === this.constants.PATCH
|
407 | 406 | || httpMethod.toLowerCase() === this.constants.PUT) {
|
408 |
| - var digest = AuthenticationSDK.PayloadDigest.generateDigest(this.merchantConfig, this.logger); |
| 407 | + var digest = PayloadDigest.generateDigest(this.merchantConfig, this.logger); |
409 | 408 | digest = this.constants.SIGNATURE_ALGORITHAM + digest;
|
410 | 409 | this.logger.info(this.constants.DIGEST + " : " + digest);
|
411 | 410 | headerParams['digest'] = digest;
|
|
0 commit comments