"use strict;" var request = require('superagent'); var AlphaApi = require("./alpha_api"); var DefaultApi = require("./default_api"); // Class constructor for the ApiClient // // The 'url' should indicate // // Options properties: // // - `timeout`: Defaults to 0. If nonzero, we'll set a client side timeout, in ms. // // Properties defined during initialization; // // - `basePath`, defaults to '/api/VERSION'. function ApiClient(url, options) { this.url = url; this.basePath = '/api'; this.timeout = 0; Object.defineProperties(this, { "apiKey": { enumerable: true, writable: true } }); } // Public method // // Creates a handle to the default (stable) set of methods. ApiClient.prototype.createDefaultApi = function() { return new DefaultApi(this); }; // Public method // // Creates a handle to the alpha (unstable) set of methods. ApiClient.prototype.createAlphaApi = function() { return new AlphaApi(this); }; // Undocumented method ApiClient.prototype.createUrl = function createUrl(path, pathParams) { var url = this.url + this.basePath + path; if (pathParams) { Object.keys(pathParams).forEach(function(key) { url = url.replace("{" + key + "}", encodeURIComponent(pathParams[key])); }); } return url; }; // Undocumented method ApiClient.prototype.executeMethod = function executeNoBody(method, path, pathParams, query, body, callback) { var req = request(method, this.createUrl(path, pathParams)); if (this.apiKey) { req.set('Authorization', this.apiKey); } if (query) { var q = {}; Object.keys(query).forEach(function(key) { if (query[key]) { q[key] = query[key]; } }); req.query(q); } req.accept('application/json'); if (0 < this.timeout) { req.timeout(this.timeout); } if (body) { req.send(body); } req.end(callback); }; module.exports = ApiClient;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 19597 | swellard | Refactor REST path | ||
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/lib/api_client.js | |||||
#6 | 19125 | tjuricek | JavaScript Client SDK commands tests with fix for passing around array query parameter arguments. | ||
#5 | 19122 | tjuricek | JavaScript Client SDK change-related tests. | ||
#4 | 19095 | tjuricek |
JS Client SDK branch spec CRUD test Added URL component encoding on path parameters. |
||
#3 | 19067 | tjuricek |
Add handling to deal with IllegalArgumentException as general "400" level errors from users. The different client APIs just need to have their respective techniques provide the error status. |
||
#2 | 19065 | tjuricek |
Revised Javascript Client SDK documentation to meet the new API, with fixes. Added a couple of basic tests, and added archival of the different testng XML output. The main major fix is to handle array output better. |
||
#1 | 19053 | tjuricek |
Rebuild JavaScript Client SDK. The JavaScript client now is a "typed" approach that tends to be similar in approach to the other clients, based on the swagger definition for the platform version. Importantly, client SDK tests are individual scripts (that run under node) that are actually controlled via TestNG. This approach now lets us use a consistent test reporting format so we can at least collect reports from each of the jobs. The documentation is still in progress, that I want to validate as the tests are generated. |