forge-oss
Version:
Asynchronous Javascript/Node.js library for the Autodesk Forge OSS API.
108 lines (101 loc) • 3.85 kB
JavaScript
/*
* The MIT License (MIT)
*
* Copyright (c) 2016
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['request'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('request'));
} else {
// Browser globals (root is window)
if (!root.ForgeOss) {
root.ForgeOss = {};
}
root.ForgeOss.ApiClient = factory(root.request);
}
}(this, function(request) {
'use strict';
/**
* @module ApiClient
*/
/**
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
* application to use this class directly - the *Api and model classes provide the public API for the service. The
* contents of this file should be regarded as internal but are documented for completeness.
* @alias module:ApiClient
* @class
*/
var exports = function() {
/**
* The authentication methods to be included for all API calls.
* @type {Array.<String>}
*/
this.authentications = {
'oauth2_access_code': { token_type: 'Bearer', expires_in: 82000 },
'oauth2_application': { token_type: 'Bearer', expires_in: 82000 }
};
};
exports.prototype.applyToAuthObjects = function applyToAuthObjects (oauth2_access_code, oauth2_application, authNames) {
var _this = this;
authNames.forEach(function (authName) {
var auth = _this.authentications[authName];
if (auth.accessToken) {
auth.access_token = auth.accessToken;
if (authName === 'oauth2_access_code')
oauth2_access_code.setCredentials(auth);
else if (authName === 'oauth2_application')
oauth2_application.setCredentials(auth);
}
});
};
exports.prototype.getAuthObject = function getAuthObject (oauth2_access_code, oauth2_application, authNames) {
var _this = this;
for (var i = 0; i < authNames.length; i++) {
var auth = _this.authentications[authNames[i]];
if (auth.accessToken) {
auth.access_token = auth.accessToken;
if (authNames[i] === 'oauth2_access_code') {
oauth2_access_code.setCredentials(auth);
return (oauth2_access_code);
} else if (authNames[i] === 'oauth2_application') {
oauth2_application.setCredentials(auth);
return (oauth2_application);
}
}
}
return (null);
};
/**
* The default API client implementation.
* @type {module:ApiClient}
*/
exports.instance = new exports();
return exports;
}));