@gitchrisqueen/tdameritrade-api-js-client
Version:
TD Ameritrade API integration for node.js
316 lines (274 loc) • 10.3 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 OrderGet from '../model/OrderGet';
/**
* Orders service.
* @module api/OrdersApi
* @version 0.1.4
*/
export default class OrdersApi {
/**
* 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.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}
/**
* Get Orders by Path
* Orders for a specific account.
* @param {Object} opts Optional parameters
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
accountsAccountIdOrdersGETWithHttpInfo(accountId, opts) {
opts = opts || {};
let postBody = null;
let pathParams = {
'accountId': accountId
};
let queryParams = {
'maxResults': opts['maxResults'],
'fromEnteredTime': opts['fromEnteredTime'],
'toEnteredTime': opts['toEnteredTime'],
'status': opts['status']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = OrderGet;
return this.apiClient.callApi(
'/accounts/{accountId}/orders', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Get Orders by Path
* Orders for a specific account.
* @param {Object} opts Optional parameters
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
accountsAccountIdOrdersGET(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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/EASObject} and HTTP response
*/
accountsAccountIdOrdersOrderIdDELETEWithHttpInfo(accountId, orderId) {
let postBody = null;
let pathParams = {
'accountId': accountId,
'orderId': orderId
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = EASObject;
return this.apiClient.callApi(
'/accounts/{accountId}/orders/{orderId}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Cancel Order
* Cancel a specific order for a spcific account
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/EASObject}
*/
accountsAccountIdOrdersOrderIdDELETE(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.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
accountsAccountIdOrdersOrderIdGETWithHttpInfo(accountId, orderId) {
let postBody = null;
let pathParams = {
'accountId': accountId,
'orderId': orderId
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = OrderGet;
return this.apiClient.callApi(
'/accounts/{accountId}/orders/{orderId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Get Order
* Get a specific order for a specific account.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
accountsAccountIdOrdersOrderIdGET(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.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
accountsAccountIdOrdersOrderIdPUTWithHttpInfo(accountId, orderId) {
let postBody = null;
let pathParams = {
'accountId': accountId,
'orderId': orderId
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = OrderGet;
return this.apiClient.callApi(
'/accounts/{accountId}/orders/{orderId}', 'PUT',
pathParams, queryParams, 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.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
accountsAccountIdOrdersOrderIdPUT(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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
ordersGETWithHttpInfo(opts) {
opts = opts || {};
let postBody = null;
let pathParams = {
};
let queryParams = {
'accountId': opts['accountId'],
'maxResults': opts['maxResults'],
'fromEnteredTime': opts['fromEnteredTime'],
'toEnteredTime': opts['toEnteredTime'],
'status': opts['status']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = OrderGet;
return this.apiClient.callApi(
'/orders', 'GET',
pathParams, queryParams, 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
ordersGET(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 {Object} opts Optional parameters
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response
*/
ordersPOSTWithHttpInfo(accountId, opts) {
opts = opts || {};
let postBody = opts['body'];
let pathParams = {
'accountId': accountId
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/Json'];
let accepts = ['application/json'];
let returnType = OrderGet;
return this.apiClient.callApi(
'/orders', 'POST',
pathParams, queryParams, 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 {Object} opts Optional parameters
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet}
*/
ordersPOST(accountId, opts) {
return this.ordersPOSTWithHttpInfo(accountId, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
}