@gitchrisqueen/tdameritrade-api-js-client
Version:
TD Ameritrade API integration for node.js
425 lines (369 loc) • 14.9 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
*
* Swagger Codegen version: 2.4.14
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient', 'model/EASObject', 'model/OrderGet'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('../model/EASObject'), require('../model/OrderGet'));
} else {
// Browser globals (root is window)
if (!root.GitChrisQueen_TDA_JS) {
root.GitChrisQueen_TDA_JS = {};
}
root.GitChrisQueen_TDA_JS.OrdersApi = factory(root.GitChrisQueen_TDA_JS.ApiClient, root.GitChrisQueen_TDA_JS.EASObject, root.GitChrisQueen_TDA_JS.OrderGet);
}
}(this, function(ApiClient, EASObject, OrderGet) {
'use strict';
/**
* Orders service.
* @module api/OrdersApi
* @version 0.1.4
*/
/**
* Constructs a new OrdersApi.
* @alias module:api/OrdersApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
var exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Get Orders by Path
* Orders for a specific account.
* @param {Number} accountId
* @param {Object} opts Optional parameters
* @param {Number} opts.maxResults
* @param {Date} opts.fromEnteredTime
* @param {Date} opts.toEnteredTime
* @param {module:model/String} opts.status
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
this.accountsAccountIdOrdersGETWithHttpInfo = function(accountId, opts) {
opts = opts || {};
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling accountsAccountIdOrdersGET");
}
var pathParams = {
'accountId': accountId
};
var queryParams = {
'maxResults': opts['maxResults'],
'fromEnteredTime': opts['fromEnteredTime'],
'toEnteredTime': opts['toEnteredTime'],
'status': opts['status'],
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = ['bearerAuth'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = OrderGet;
return this.apiClient.callApi(
'/accounts/{accountId}/orders', 'GET',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Get Orders by Path
* Orders for a specific account.
* @param {Number} accountId
* @param {Object} opts Optional parameters
* @param {Number} opts.maxResults
* @param {Date} opts.fromEnteredTime
* @param {Date} opts.toEnteredTime
* @param {module:model/String} opts.status
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
this.accountsAccountIdOrdersGET = function(accountId, opts) {
return this.accountsAccountIdOrdersGETWithHttpInfo(accountId, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Cancel Order
* Cancel a specific order for a spcific account
* @param {Number} accountId
* @param {Number} orderId
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/EASObject} and HTTP response
*/
this.accountsAccountIdOrdersOrderIdDELETEWithHttpInfo = function(accountId, orderId) {
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling accountsAccountIdOrdersOrderIdDELETE");
}
// verify the required parameter 'orderId' is set
if (orderId === undefined || orderId === null) {
throw new Error("Missing the required parameter 'orderId' when calling accountsAccountIdOrdersOrderIdDELETE");
}
var pathParams = {
'accountId': accountId,
'orderId': orderId
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = ['bearerAuth'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = EASObject;
return this.apiClient.callApi(
'/accounts/{accountId}/orders/{orderId}', 'DELETE',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Cancel Order
* Cancel a specific order for a spcific account
* @param {Number} accountId
* @param {Number} orderId
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/EASObject}
*/
this.accountsAccountIdOrdersOrderIdDELETE = function(accountId, orderId) {
return this.accountsAccountIdOrdersOrderIdDELETEWithHttpInfo(accountId, orderId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Get Order
* Get a specific order for a specific account.
* @param {Number} accountId
* @param {Number} orderId
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
this.accountsAccountIdOrdersOrderIdGETWithHttpInfo = function(accountId, orderId) {
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling accountsAccountIdOrdersOrderIdGET");
}
// verify the required parameter 'orderId' is set
if (orderId === undefined || orderId === null) {
throw new Error("Missing the required parameter 'orderId' when calling accountsAccountIdOrdersOrderIdGET");
}
var pathParams = {
'accountId': accountId,
'orderId': orderId
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = ['bearerAuth'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = OrderGet;
return this.apiClient.callApi(
'/accounts/{accountId}/orders/{orderId}', 'GET',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Get Order
* Get a specific order for a specific account.
* @param {Number} accountId
* @param {Number} orderId
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
this.accountsAccountIdOrdersOrderIdGET = function(accountId, orderId) {
return this.accountsAccountIdOrdersOrderIdGETWithHttpInfo(accountId, orderId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Replace Order
* Replace an existing order for an account. The existing order will be replaced by the new order. Once replaced, the old order will be canceled and a new order will be created. See our Place Order Samples Guide - https://developer.tdameritrade.com/content/place-order-samples.
* @param {Number} accountId
* @param {Number} orderId
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
this.accountsAccountIdOrdersOrderIdPUTWithHttpInfo = function(accountId, orderId) {
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling accountsAccountIdOrdersOrderIdPUT");
}
// verify the required parameter 'orderId' is set
if (orderId === undefined || orderId === null) {
throw new Error("Missing the required parameter 'orderId' when calling accountsAccountIdOrdersOrderIdPUT");
}
var pathParams = {
'accountId': accountId,
'orderId': orderId
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = ['bearerAuth'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = OrderGet;
return this.apiClient.callApi(
'/accounts/{accountId}/orders/{orderId}', 'PUT',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Replace Order
* Replace an existing order for an account. The existing order will be replaced by the new order. Once replaced, the old order will be canceled and a new order will be created. See our Place Order Samples Guide - https://developer.tdameritrade.com/content/place-order-samples.
* @param {Number} accountId
* @param {Number} orderId
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
this.accountsAccountIdOrdersOrderIdPUT = function(accountId, orderId) {
return this.accountsAccountIdOrdersOrderIdPUTWithHttpInfo(accountId, orderId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Get Orders By Query
* All orders for a specific account or, if account ID isn't specified, orders will be returned for all linked accounts.
* @param {Object} opts Optional parameters
* @param {Number} opts.accountId
* @param {Number} opts.maxResults
* @param {Date} opts.fromEnteredTime
* @param {Date} opts.toEnteredTime
* @param {module:model/String} opts.status
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
this.ordersGETWithHttpInfo = function(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'accountId': opts['accountId'],
'maxResults': opts['maxResults'],
'fromEnteredTime': opts['fromEnteredTime'],
'toEnteredTime': opts['toEnteredTime'],
'status': opts['status'],
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = ['bearerAuth'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = OrderGet;
return this.apiClient.callApi(
'/orders', 'GET',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Get Orders By Query
* All orders for a specific account or, if account ID isn't specified, orders will be returned for all linked accounts.
* @param {Object} opts Optional parameters
* @param {Number} opts.accountId
* @param {Number} opts.maxResults
* @param {Date} opts.fromEnteredTime
* @param {Date} opts.toEnteredTime
* @param {module:model/String} opts.status
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
this.ordersGET = function(opts) {
return this.ordersGETWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Place Order
* Place an order for a specific account. See our Place Order Samples Guide - https://developer.tdameritrade.com/content/place-order-samples.
* @param {Number} accountId
* @param {Object} opts Optional parameters
* @param {module:model/OrderGet} opts.body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
this.ordersPOSTWithHttpInfo = function(accountId, opts) {
opts = opts || {};
var postBody = opts['body'];
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling ordersPOST");
}
var pathParams = {
'accountId': accountId
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = ['bearerAuth'];
var contentTypes = ['application/Json'];
var accepts = ['application/json'];
var returnType = OrderGet;
return this.apiClient.callApi(
'/orders', 'POST',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Place Order
* Place an order for a specific account. See our Place Order Samples Guide - https://developer.tdameritrade.com/content/place-order-samples.
* @param {Number} accountId
* @param {Object} opts Optional parameters
* @param {module:model/OrderGet} opts.body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
this.ordersPOST = function(accountId, opts) {
return this.ordersPOSTWithHttpInfo(accountId, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
};
return exports;
}));