@gitchrisqueen/tdameritrade-api-js-client
Version:
TD Ameritrade API integration for node.js
89 lines (77 loc) • 2.59 kB
JavaScript
/**
* TD Ameritrade API - OAuth2
* This is replication of the TD Ameritrade API.
*
* OpenAPI spec version: 0.1.4
*
*
* 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.
*
*/
import ApiClient from "../ApiClient";
import EASObject from '../model/EASObject';
import ErrorObject from '../model/ErrorObject';
/**
* Authentication service.
* @module api/AuthenticationApi
* @version 0.1.4
*/
export default class AuthenticationApi {
/**
* Constructs a new AuthenticationApi.
* @alias module:api/AuthenticationApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}
/**
* Post Access Token
* The token endpoint returns an access token along with an optional refresh token.
* @param {Object} opts Optional parameters
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/EASObject} and HTTP response
*/
oauth2TokenPOSTWithHttpInfo(opts) {
opts = opts || {};
let postBody = null;
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
'grant_type': opts['grant_type'],
'refresh_token': opts['refresh_token'],
'access_type': opts['access_type'],
'code': opts['code'],
'client_id': opts['client_id'],
'redirect_uri': opts['redirect_uri']
};
let authNames = [];
let contentTypes = ['application/x-www-form-urlencoded'];
let accepts = ['application/json'];
let returnType = EASObject;
return this.apiClient.callApi(
'/oauth2/token', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Post Access Token
* The token endpoint returns an access token along with an optional refresh token.
* @param {Object} opts Optional parameters
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/EASObject}
*/
oauth2TokenPOST(opts) {
return this.oauth2TokenPOSTWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
}