|
7 | 7 | * NOTE: This class is auto generated by the swagger code generator program. |
8 | 8 | * https://github.com/swagger-api/swagger-codegen.git |
9 | 9 | * |
10 | | - * Swagger Codegen version: 2.3.0 |
| 10 | + * Swagger Codegen version: 2.2.3 |
11 | 11 | * |
12 | 12 | * Do not edit the class manually. |
13 | 13 | * |
14 | 14 | */ |
15 | 15 |
|
16 | | -(function(root, factory) { |
| 16 | +(function (root, factory) { |
17 | 17 | if (typeof define === 'function' && define.amd) { |
18 | 18 | // AMD. Register as an anonymous module. |
19 | 19 | define(['superagent', 'querystring'], factory); |
|
27 | 27 | } |
28 | 28 | root.CyberSource.ApiClient = factory(root.superagent, root.querystring); |
29 | 29 | } |
30 | | -}(this, function(superagent, querystring) { |
| 30 | +}(this, function (superagent, querystring) { |
31 | 31 | 'use strict'; |
32 | 32 |
|
33 | 33 | /** |
|
42 | 42 | * @alias module:ApiClient |
43 | 43 | * @class |
44 | 44 | */ |
45 | | - var exports = function() { |
| 45 | + var exports = function () { |
46 | 46 | /** |
47 | 47 | * The base URL against which to resolve every API call's (relative) path. |
48 | 48 | * @type {String} |
49 | | - * @default https://apitest.cybersource.com |
| 49 | + * @default https://api.cybersource.com |
50 | 50 | */ |
51 | 51 | this.basePath = 'https://apitest.cybersource.com'.replace(/\/+$/, ''); |
52 | 52 |
|
|
93 | 93 | this.agent = new superagent.agent(); |
94 | 94 | } |
95 | 95 |
|
96 | | - /** |
97 | | - * The filepath where reports are downloaded |
98 | | - */ |
| 96 | + /** |
| 97 | + * The filepath where reports are downloaded |
| 98 | + */ |
99 | 99 | this.downloadFilePath = ''; |
100 | 100 | }; |
101 | 101 |
|
|
104 | 104 | * @param param The actual parameter. |
105 | 105 | * @returns {String} The string representation of <code>param</code>. |
106 | 106 | */ |
107 | | - exports.prototype.paramToString = function(param) { |
| 107 | + exports.prototype.paramToString = function (param) { |
108 | 108 | if (param == undefined || param == null) { |
109 | 109 | return ''; |
110 | 110 | } |
|
121 | 121 | * @param {Object} pathParams The parameter values to append. |
122 | 122 | * @returns {String} The encoded path with parameter values substituted. |
123 | 123 | */ |
124 | | - exports.prototype.buildUrl = function(path, pathParams) { |
| 124 | + exports.prototype.buildUrl = function (path, pathParams) { |
125 | 125 | if (!path.match(/^\//)) { |
126 | 126 | path = '/' + path; |
127 | 127 | } |
128 | 128 | var url = this.basePath + path; |
129 | 129 | var _this = this; |
130 | | - url = url.replace(/\{([\w-]+)\}/g, function(fullMatch, key) { |
| 130 | + url = url.replace(/\{([\w-]+)\}/g, function (fullMatch, key) { |
131 | 131 | var value; |
132 | 132 | if (pathParams.hasOwnProperty(key)) { |
133 | 133 | value = _this.paramToString(pathParams[key]); |
|
150 | 150 | * @param {String} contentType The MIME content type to check. |
151 | 151 | * @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>. |
152 | 152 | */ |
153 | | - exports.prototype.isJsonMime = function(contentType) { |
| 153 | + exports.prototype.isJsonMime = function (contentType) { |
154 | 154 | return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i)); |
155 | 155 | }; |
156 | 156 |
|
|
159 | 159 | * @param {Array.<String>} contentTypes |
160 | 160 | * @returns {String} The chosen content type, preferring JSON. |
161 | 161 | */ |
162 | | - exports.prototype.jsonPreferredMime = function(contentTypes) { |
| 162 | + exports.prototype.jsonPreferredMime = function (contentTypes) { |
163 | 163 | for (var i = 0; i < contentTypes.length; i++) { |
164 | 164 | if (this.isJsonMime(contentTypes[i])) { |
165 | 165 | return contentTypes[i]; |
|
173 | 173 | * @param param The parameter to check. |
174 | 174 | * @returns {Boolean} <code>true</code> if <code>param</code> represents a file. |
175 | 175 | */ |
176 | | - exports.prototype.isFileParam = function(param) { |
| 176 | + exports.prototype.isFileParam = function (param) { |
177 | 177 | // fs.ReadStream in Node.js and Electron (but not in runtime like browserify) |
178 | 178 | if (typeof require === 'function') { |
179 | 179 | var fs; |
180 | 180 | try { |
181 | 181 | fs = require('fs'); |
182 | | - } catch (err) {} |
| 182 | + } catch (err) { } |
183 | 183 | if (fs && fs.ReadStream && param instanceof fs.ReadStream) { |
184 | 184 | return true; |
185 | 185 | } |
|
209 | 209 | * @param {Object.<String, Object>} params The parameters as object properties. |
210 | 210 | * @returns {Object.<String, Object>} normalized parameters. |
211 | 211 | */ |
212 | | - exports.prototype.normalizeParams = function(params) { |
| 212 | + exports.prototype.normalizeParams = function (params) { |
213 | 213 | var newParams = {}; |
214 | 214 | for (var key in params) { |
215 | 215 | if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) { |
|
290 | 290 | * @param {Object} request The request object created by a <code>superagent()</code> call. |
291 | 291 | * @param {Array.<String>} authNames An array of authentication method names. |
292 | 292 | */ |
293 | | - exports.prototype.applyAuthToRequest = function(request, authNames) { |
| 293 | + exports.prototype.applyAuthToRequest = function (request, authNames) { |
294 | 294 | var _this = this; |
295 | | - authNames.forEach(function(authName) { |
| 295 | + authNames.forEach(function (authName) { |
296 | 296 | var auth = _this.authentications[authName]; |
297 | 297 | switch (auth.type) { |
298 | 298 | case 'basic': |
|
317 | 317 | break; |
318 | 318 | case 'oauth2': |
319 | 319 | if (auth.accessToken) { |
320 | | - request.set({'Authorization': 'Bearer ' + auth.accessToken}); |
| 320 | + request.set({ 'Authorization': 'Bearer ' + auth.accessToken }); |
321 | 321 | } |
322 | 322 | break; |
323 | 323 | default: |
|
348 | 348 | } |
349 | 349 | return exports.convertToType(data, returnType); |
350 | 350 | }; |
351 | | - |
352 | | - // Code added by Infosys dev team |
| 351 | + |
| 352 | + // Code added by Infosys dev team |
353 | 353 |
|
354 | 354 | var AuthenticationSDK = require('cybersource-rest-auth'); |
355 | 355 | /** |
|
361 | 361 |
|
362 | 362 | this.merchantConfig = new AuthenticationSDK.MerchantConfig(configObject); |
363 | 363 | this.constants = AuthenticationSDK.Constants; |
364 | | - this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost(); |
| 364 | + this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost(); |
365 | 365 | this.logger = AuthenticationSDK.Logger.getLogger(this.merchantConfig); |
366 | 366 | } |
367 | 367 |
|
|
416 | 416 |
|
417 | 417 | return headerParams; |
418 | 418 | } |
419 | | - |
| 419 | + |
420 | 420 | /** |
421 | 421 | * Callback function to receive the result of the operation. |
422 | 422 | * @callback module:ApiClient~callApiCallback |
|
443 | 443 | * @returns {Object} The SuperAgent request object. |
444 | 444 | */ |
445 | 445 | exports.prototype.callApi = function callApi(path, httpMethod, pathParams, |
446 | | - queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, |
447 | | - returnType, callback) { |
| 446 | + queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, |
| 447 | + returnType, callback) { |
448 | 448 |
|
449 | 449 | var _this = this; |
450 | 450 | var url = this.buildUrl(path, pathParams); |
|
455 | 455 |
|
456 | 456 | // set query parameters |
457 | 457 | if (httpMethod.toLowerCase() === this.constants.GET && this.cache === false) { |
458 | | - queryParams['_'] = new Date().getTime(); |
| 458 | + queryParams['_'] = new Date().getTime(); |
459 | 459 | } |
460 | 460 | request.query(this.normalizeParams(queryParams)); |
461 | 461 |
|
462 | | - /** |
| 462 | + /** |
463 | 463 | *added by infosys team, to generate requestTarget with pathParam |
464 | 464 | */ |
465 | 465 | var requestTarget = this.buildRequestTarget(path, pathParams, queryParams); |
|
469 | 469 | || httpMethod.toLowerCase() === this.constants.PUT) { |
470 | 470 | bodyParam = JSON.stringify(bodyParam, null, 0); |
471 | 471 | } |
472 | | - headerParams = this.callAuthenticationHeader(httpMethod, requestTarget, bodyParam, headerParams); |
473 | | - |
| 472 | + headerParams = this.callAuthenticationHeader(httpMethod, requestTarget, bodyParam, headerParams); |
| 473 | + |
474 | 474 | // set header parameters |
475 | 475 | request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); |
476 | 476 |
|
|
480 | 480 | var contentType = this.jsonPreferredMime(contentTypes); |
481 | 481 | if (contentType) { |
482 | 482 | // Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746) |
483 | | - if(contentType != 'multipart/form-data') { |
| 483 | + if (contentType != 'multipart/form-data') { |
484 | 484 | request.type(contentType); |
485 | 485 | } |
486 | 486 | } else if (!request.header['Content-Type']) { |
|
508 | 508 | var accept = this.jsonPreferredMime(accepts); |
509 | 509 | if (accept) { |
510 | 510 | request.accept(accept); |
511 | | - /* Code for downloading file from stream */ |
| 511 | + /* Code for downloading file from stream */ |
512 | 512 | if (accept === 'application/xml') { |
513 | 513 | var fs = require('fs'); |
514 | 514 | var stream = fs.createWriteStream(this.downloadFilePath); |
|
524 | 524 | } |
525 | 525 |
|
526 | 526 | // Attach previously saved cookies, if enabled |
527 | | - if (this.enableCookies){ |
| 527 | + if (this.enableCookies) { |
528 | 528 | if (typeof window === 'undefined') { |
529 | 529 | this.agent.attachCookies(request); |
530 | 530 | } |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 |
|
536 | | - |
537 | | - request.end(function(error, response) { |
| 536 | + request.end(function (error, response) { |
538 | 537 | if (callback) { |
539 | 538 | var data = null; |
540 | 539 | if (!error) { |
541 | 540 | try { |
542 | 541 | data = _this.deserialize(response, returnType); |
543 | | - if (_this.enableCookies && typeof window === 'undefined'){ |
| 542 | + if (_this.enableCookies && typeof window === 'undefined') { |
544 | 543 | _this.agent.saveCookies(response); |
545 | 544 | } |
546 | 545 | } catch (err) { |
|
592 | 591 | } |
593 | 592 | return requestTarget; |
594 | 593 | }; |
595 | | - |
| 594 | + |
596 | 595 | /** |
597 | 596 | * Parses an ISO-8601 string representation of a date value. |
598 | 597 | * @param {String} str The date value as a string. |
599 | 598 | * @returns {Date} The parsed date object. |
600 | 599 | */ |
601 | | - exports.parseDate = function(str) { |
| 600 | + exports.parseDate = function (str) { |
602 | 601 | return new Date(str.replace(/T/i, ' ')); |
603 | 602 | }; |
604 | 603 |
|
|
611 | 610 | * all properties on <code>data<code> will be converted to this type. |
612 | 611 | * @returns An instance of the specified type or null or undefined if data is null or undefined. |
613 | 612 | */ |
614 | | - exports.convertToType = function(data, type) { |
| 613 | + exports.convertToType = function (data, type) { |
615 | 614 | if (data === null || data === undefined) |
616 | 615 | return data |
617 | 616 |
|
|
627 | 626 | case 'Date': |
628 | 627 | return this.parseDate(String(data)); |
629 | 628 | case 'Blob': |
630 | | - return data; |
| 629 | + return data; |
631 | 630 | default: |
632 | 631 | if (type === Object) { |
633 | 632 | // generic object, return directly |
|
638 | 637 | } else if (Array.isArray(type)) { |
639 | 638 | // for array type like: ['String'] |
640 | 639 | var itemType = type[0]; |
641 | | - return data.map(function(item) { |
| 640 | + return data.map(function (item) { |
642 | 641 | return exports.convertToType(item, itemType); |
643 | 642 | }); |
644 | 643 | } else if (typeof type === 'object') { |
|
672 | 671 | * @param data {Object|Array} The REST data. |
673 | 672 | * @param obj {Object|Array} The target object or array. |
674 | 673 | */ |
675 | | - exports.constructFromObject = function(data, obj, itemType) { |
| 674 | + exports.constructFromObject = function (data, obj, itemType) { |
676 | 675 | if (Array.isArray(data)) { |
677 | 676 | for (var i = 0; i < data.length; i++) { |
678 | 677 | if (data.hasOwnProperty(i)) |
|
0 commit comments