UNPKG

@gitchrisqueen/tdameritrade-api-js-client

Version:
352 lines (303 loc) 12.7 kB
/* * 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.SavedOrdersApi = factory(root.GitChrisQueen_TDA_JS.ApiClient, root.GitChrisQueen_TDA_JS.EASObject, root.GitChrisQueen_TDA_JS.OrderGet); } }(this, function(ApiClient, EASObject, OrderGet) { 'use strict'; /** * SavedOrders service. * @module api/SavedOrdersApi * @version 0.1.4 */ /** * Constructs a new SavedOrdersApi. * @alias module:api/SavedOrdersApi * @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 Saved Orders by Path * Saved orders for a specific account. * @param {Number} accountId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response */ this.accountsAccountIdSavedordersGETWithHttpInfo = function(accountId) { 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 accountsAccountIdSavedordersGET"); } var pathParams = { 'accountId': accountId }; 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}/savedorders', 'GET', pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get Saved Orders by Path * Saved orders for a specific account. * @param {Number} accountId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet} */ this.accountsAccountIdSavedordersGET = function(accountId) { return this.accountsAccountIdSavedordersGETWithHttpInfo(accountId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Create Saved Orders * Save 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.accountsAccountIdSavedordersPOSTWithHttpInfo = 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 accountsAccountIdSavedordersPOST"); } 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( '/accounts/{accountId}/savedorders', 'POST', pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Create Saved Orders * Save 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.accountsAccountIdSavedordersPOST = function(accountId, opts) { return this.accountsAccountIdSavedordersPOSTWithHttpInfo(accountId, opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete Saved Orders * Delete a specific saved order for a specific account. * @param {Number} accountId * @param {Number} savedOrderId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/EASObject} and HTTP response */ this.accountsAccountIdSavedordersSavedOrderIdDELETEWithHttpInfo = function(accountId, savedOrderId) { 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 accountsAccountIdSavedordersSavedOrderIdDELETE"); } // verify the required parameter 'savedOrderId' is set if (savedOrderId === undefined || savedOrderId === null) { throw new Error("Missing the required parameter 'savedOrderId' when calling accountsAccountIdSavedordersSavedOrderIdDELETE"); } var pathParams = { 'accountId': accountId, 'savedOrderId': savedOrderId }; 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}/savedorders/{savedOrderId}', 'DELETE', pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete Saved Orders * Delete a specific saved order for a specific account. * @param {Number} accountId * @param {Number} savedOrderId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/EASObject} */ this.accountsAccountIdSavedordersSavedOrderIdDELETE = function(accountId, savedOrderId) { return this.accountsAccountIdSavedordersSavedOrderIdDELETEWithHttpInfo(accountId, savedOrderId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Get Saved Orders * Specific saved order by its ID, for a specific account. * @param {Number} accountId * @param {Number} savedOrderId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/OrderGet} and HTTP response */ this.accountsAccountIdSavedordersSavedOrderIdGETWithHttpInfo = function(accountId, savedOrderId) { 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 accountsAccountIdSavedordersSavedOrderIdGET"); } // verify the required parameter 'savedOrderId' is set if (savedOrderId === undefined || savedOrderId === null) { throw new Error("Missing the required parameter 'savedOrderId' when calling accountsAccountIdSavedordersSavedOrderIdGET"); } var pathParams = { 'accountId': accountId, 'savedOrderId': savedOrderId }; 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}/savedorders/{savedOrderId}', 'GET', pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get Saved Orders * Specific saved order by its ID, for a specific account. * @param {Number} accountId * @param {Number} savedOrderId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/OrderGet} */ this.accountsAccountIdSavedordersSavedOrderIdGET = function(accountId, savedOrderId) { return this.accountsAccountIdSavedordersSavedOrderIdGETWithHttpInfo(accountId, savedOrderId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Replace Saved Orders * Replace an existing saved order for an account. The existing saved order will be replaced by the new order. see our Place Order Samples Guide - Click here. * @param {Number} accountId * @param {Number} savedOrderId * @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.accountsAccountIdSavedordersSavedOrderIdPUTWithHttpInfo = function(accountId, savedOrderId, 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 accountsAccountIdSavedordersSavedOrderIdPUT"); } // verify the required parameter 'savedOrderId' is set if (savedOrderId === undefined || savedOrderId === null) { throw new Error("Missing the required parameter 'savedOrderId' when calling accountsAccountIdSavedordersSavedOrderIdPUT"); } var pathParams = { 'accountId': accountId, 'savedOrderId': savedOrderId }; 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( '/accounts/{accountId}/savedorders/{savedOrderId}', 'PUT', pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Replace Saved Orders * Replace an existing saved order for an account. The existing saved order will be replaced by the new order. see our Place Order Samples Guide - Click here. * @param {Number} accountId * @param {Number} savedOrderId * @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.accountsAccountIdSavedordersSavedOrderIdPUT = function(accountId, savedOrderId, opts) { return this.accountsAccountIdSavedordersSavedOrderIdPUTWithHttpInfo(accountId, savedOrderId, opts) .then(function(response_and_data) { return response_and_data.data; }); } }; return exports; }));