snaptrade-typescript-sdk 6.4.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- ef1bca40-b1e0-4bee-a0fc-3ad6bf8353b5
1
+ 4174766a-a000-448d-907d-7b028d62bca9
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## snaptrade-typescript-sdk@6.4.0
1
+ ## snaptrade-typescript-sdk@7.0.0
2
2
  Connect brokerage accounts to your app for live positions and trading
3
3
 
4
4
 
@@ -37,14 +37,14 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
37
37
  * @summary Get transaction history for a user
38
38
  * @param {string} userId
39
39
  * @param {string} userSecret
40
- * @param {string} [startDate]
41
- * @param {string} [endDate]
40
+ * @param {string | Date} [startDate]
41
+ * @param {string | Date} [endDate]
42
42
  * @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
43
43
  * @param {string} [brokerageAuthorizations] Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations
44
44
  * @param {*} [options] Override http request option.
45
45
  * @throws {RequiredError}
46
46
  */
47
- getActivities: async (userId: string, userSecret: string, startDate?: string, endDate?: string, accounts?: string, brokerageAuthorizations?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
47
+ getActivities: async (userId: string, userSecret: string, startDate?: string | Date, endDate?: string | Date, accounts?: string, brokerageAuthorizations?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
48
48
  // verify required parameter 'userId' is not null or undefined
49
49
  assertParamExists('getActivities', 'userId', userId)
50
50
  // verify required parameter 'userSecret' is not null or undefined
@@ -68,11 +68,15 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
68
68
  // authentication PartnerTimestamp required
69
69
  await setApiKeyToObject({object: localVarQueryParameter, keyParamName: "timestamp", configuration})
70
70
  if (startDate !== undefined) {
71
- localVarQueryParameter['startDate'] = startDate;
71
+ localVarQueryParameter['startDate'] = (startDate as any instanceof Date) ?
72
+ (startDate as any).toISOString().substr(0,10) :
73
+ startDate;
72
74
  }
73
75
 
74
76
  if (endDate !== undefined) {
75
- localVarQueryParameter['endDate'] = endDate;
77
+ localVarQueryParameter['endDate'] = (endDate as any instanceof Date) ?
78
+ (endDate as any).toISOString().substr(0,10) :
79
+ endDate;
76
80
  }
77
81
 
78
82
  if (accounts !== undefined) {
@@ -111,8 +115,8 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
111
115
  /**
112
116
  * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
113
117
  * @summary Get performance information for a specific timeframe
114
- * @param {string} startDate
115
- * @param {string} endDate
118
+ * @param {string | Date} startDate
119
+ * @param {string | Date} endDate
116
120
  * @param {string} userId
117
121
  * @param {string} userSecret
118
122
  * @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
@@ -121,7 +125,7 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
121
125
  * @param {*} [options] Override http request option.
122
126
  * @throws {RequiredError}
123
127
  */
124
- getReportingCustomRange: async (startDate: string, endDate: string, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
128
+ getReportingCustomRange: async (startDate: string | Date, endDate: string | Date, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
125
129
  // verify required parameter 'startDate' is not null or undefined
126
130
  assertParamExists('getReportingCustomRange', 'startDate', startDate)
127
131
  // verify required parameter 'endDate' is not null or undefined
@@ -149,11 +153,15 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
149
153
  // authentication PartnerTimestamp required
150
154
  await setApiKeyToObject({object: localVarQueryParameter, keyParamName: "timestamp", configuration})
151
155
  if (startDate !== undefined) {
152
- localVarQueryParameter['startDate'] = startDate;
156
+ localVarQueryParameter['startDate'] = (startDate as any instanceof Date) ?
157
+ (startDate as any).toISOString().substr(0,10) :
158
+ startDate;
153
159
  }
154
160
 
155
161
  if (endDate !== undefined) {
156
- localVarQueryParameter['endDate'] = endDate;
162
+ localVarQueryParameter['endDate'] = (endDate as any instanceof Date) ?
163
+ (endDate as any).toISOString().substr(0,10) :
164
+ endDate;
157
165
  }
158
166
 
159
167
  if (accounts !== undefined) {
@@ -281,17 +289,17 @@ export type TransactionsAndReportingApiGetActivitiesRequest = {
281
289
 
282
290
  /**
283
291
  *
284
- * @type {string}
292
+ * @type {string | Date}
285
293
  * @memberof TransactionsAndReportingApiGetActivities
286
294
  */
287
- readonly startDate?: string
295
+ readonly startDate?: string | Date
288
296
 
289
297
  /**
290
298
  *
291
- * @type {string}
299
+ * @type {string | Date}
292
300
  * @memberof TransactionsAndReportingApiGetActivities
293
301
  */
294
- readonly endDate?: string
302
+ readonly endDate?: string | Date
295
303
 
296
304
  /**
297
305
  * Optional comma seperated list of account IDs used to filter the request on specific accounts
@@ -318,17 +326,17 @@ export type TransactionsAndReportingApiGetReportingCustomRangeRequest = {
318
326
 
319
327
  /**
320
328
  *
321
- * @type {string}
329
+ * @type {string | Date}
322
330
  * @memberof TransactionsAndReportingApiGetReportingCustomRange
323
331
  */
324
- readonly startDate: string
332
+ readonly startDate: string | Date
325
333
 
326
334
  /**
327
335
  *
328
- * @type {string}
336
+ * @type {string | Date}
329
337
  * @memberof TransactionsAndReportingApiGetReportingCustomRange
330
338
  */
331
- readonly endDate: string
339
+ readonly endDate: string | Date
332
340
 
333
341
  /**
334
342
  *
package/configuration.ts CHANGED
@@ -110,7 +110,7 @@ export class Configuration {
110
110
  this.accessToken = param.accessToken;
111
111
  this.basePath = param.basePath;
112
112
  this.baseOptions = param.baseOptions ?? {};
113
- this.userAgent = param.userAgent === undefined ? "Konfig/6.4.0/typescript" : param.userAgent;
113
+ this.userAgent = param.userAgent === undefined ? "Konfig/7.0.0/typescript" : param.userAgent;
114
114
  this.formDataCtor = param.formDataCtor;
115
115
  }
116
116
 
@@ -25,19 +25,19 @@ export declare const TransactionsAndReportingApiAxiosParamCreator: (configuratio
25
25
  * @summary Get transaction history for a user
26
26
  * @param {string} userId
27
27
  * @param {string} userSecret
28
- * @param {string} [startDate]
29
- * @param {string} [endDate]
28
+ * @param {string | Date} [startDate]
29
+ * @param {string | Date} [endDate]
30
30
  * @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
31
31
  * @param {string} [brokerageAuthorizations] Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations
32
32
  * @param {*} [options] Override http request option.
33
33
  * @throws {RequiredError}
34
34
  */
35
- getActivities: (userId: string, userSecret: string, startDate?: string, endDate?: string, accounts?: string, brokerageAuthorizations?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
35
+ getActivities: (userId: string, userSecret: string, startDate?: string | Date, endDate?: string | Date, accounts?: string, brokerageAuthorizations?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
36
36
  /**
37
37
  * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
38
38
  * @summary Get performance information for a specific timeframe
39
- * @param {string} startDate
40
- * @param {string} endDate
39
+ * @param {string | Date} startDate
40
+ * @param {string | Date} endDate
41
41
  * @param {string} userId
42
42
  * @param {string} userSecret
43
43
  * @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
@@ -46,7 +46,7 @@ export declare const TransactionsAndReportingApiAxiosParamCreator: (configuratio
46
46
  * @param {*} [options] Override http request option.
47
47
  * @throws {RequiredError}
48
48
  */
49
- getReportingCustomRange: (startDate: string, endDate: string, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
49
+ getReportingCustomRange: (startDate: string | Date, endDate: string | Date, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
50
50
  };
51
51
  /**
52
52
  * TransactionsAndReportingApi - functional programming interface
@@ -112,16 +112,16 @@ export type TransactionsAndReportingApiGetActivitiesRequest = {
112
112
  readonly userSecret: string;
113
113
  /**
114
114
  *
115
- * @type {string}
115
+ * @type {string | Date}
116
116
  * @memberof TransactionsAndReportingApiGetActivities
117
117
  */
118
- readonly startDate?: string;
118
+ readonly startDate?: string | Date;
119
119
  /**
120
120
  *
121
- * @type {string}
121
+ * @type {string | Date}
122
122
  * @memberof TransactionsAndReportingApiGetActivities
123
123
  */
124
- readonly endDate?: string;
124
+ readonly endDate?: string | Date;
125
125
  /**
126
126
  * Optional comma seperated list of account IDs used to filter the request on specific accounts
127
127
  * @type {string}
@@ -143,16 +143,16 @@ export type TransactionsAndReportingApiGetActivitiesRequest = {
143
143
  export type TransactionsAndReportingApiGetReportingCustomRangeRequest = {
144
144
  /**
145
145
  *
146
- * @type {string}
146
+ * @type {string | Date}
147
147
  * @memberof TransactionsAndReportingApiGetReportingCustomRange
148
148
  */
149
- readonly startDate: string;
149
+ readonly startDate: string | Date;
150
150
  /**
151
151
  *
152
- * @type {string}
152
+ * @type {string | Date}
153
153
  * @memberof TransactionsAndReportingApiGetReportingCustomRange
154
154
  */
155
- readonly endDate: string;
155
+ readonly endDate: string | Date;
156
156
  /**
157
157
  *
158
158
  * @type {string}
@@ -96,8 +96,8 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
96
96
  * @summary Get transaction history for a user
97
97
  * @param {string} userId
98
98
  * @param {string} userSecret
99
- * @param {string} [startDate]
100
- * @param {string} [endDate]
99
+ * @param {string | Date} [startDate]
100
+ * @param {string | Date} [endDate]
101
101
  * @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
102
102
  * @param {string} [brokerageAuthorizations] Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations
103
103
  * @param {*} [options] Override http request option.
@@ -142,10 +142,14 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
142
142
  // authentication PartnerTimestamp required
143
143
  _a.sent();
144
144
  if (startDate !== undefined) {
145
- localVarQueryParameter['startDate'] = startDate;
145
+ localVarQueryParameter['startDate'] = (startDate instanceof Date) ?
146
+ startDate.toISOString().substr(0, 10) :
147
+ startDate;
146
148
  }
147
149
  if (endDate !== undefined) {
148
- localVarQueryParameter['endDate'] = endDate;
150
+ localVarQueryParameter['endDate'] = (endDate instanceof Date) ?
151
+ endDate.toISOString().substr(0, 10) :
152
+ endDate;
149
153
  }
150
154
  if (accounts !== undefined) {
151
155
  localVarQueryParameter['accounts'] = accounts;
@@ -179,8 +183,8 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
179
183
  /**
180
184
  * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
181
185
  * @summary Get performance information for a specific timeframe
182
- * @param {string} startDate
183
- * @param {string} endDate
186
+ * @param {string | Date} startDate
187
+ * @param {string | Date} endDate
184
188
  * @param {string} userId
185
189
  * @param {string} userSecret
186
190
  * @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
@@ -232,10 +236,14 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
232
236
  // authentication PartnerTimestamp required
233
237
  _a.sent();
234
238
  if (startDate !== undefined) {
235
- localVarQueryParameter['startDate'] = startDate;
239
+ localVarQueryParameter['startDate'] = (startDate instanceof Date) ?
240
+ startDate.toISOString().substr(0, 10) :
241
+ startDate;
236
242
  }
237
243
  if (endDate !== undefined) {
238
- localVarQueryParameter['endDate'] = endDate;
244
+ localVarQueryParameter['endDate'] = (endDate instanceof Date) ?
245
+ endDate.toISOString().substr(0, 10) :
246
+ endDate;
239
247
  }
240
248
  if (accounts !== undefined) {
241
249
  localVarQueryParameter['accounts'] = accounts;
@@ -34,7 +34,7 @@ var Configuration = /** @class */ (function () {
34
34
  this.accessToken = param.accessToken;
35
35
  this.basePath = param.basePath;
36
36
  this.baseOptions = (_a = param.baseOptions) !== null && _a !== void 0 ? _a : {};
37
- this.userAgent = param.userAgent === undefined ? "Konfig/6.4.0/typescript" : param.userAgent;
37
+ this.userAgent = param.userAgent === undefined ? "Konfig/7.0.0/typescript" : param.userAgent;
38
38
  this.formDataCtor = param.formDataCtor;
39
39
  }
40
40
  /**
@@ -9,7 +9,6 @@
9
9
  * https://konfigthis.com
10
10
  * Do not edit the class manually.
11
11
  */
12
- import { BrokerageAuthorization } from './brokerage-authorization';
13
12
  /**
14
13
  * SnapTradeUser Investment Account
15
14
  * @export
@@ -25,10 +24,10 @@ export interface SnapTradeHoldingsAccount {
25
24
  'id'?: string;
26
25
  /**
27
26
  *
28
- * @type {BrokerageAuthorization}
27
+ * @type {string}
29
28
  * @memberof SnapTradeHoldingsAccount
30
29
  */
31
- 'brokerage_authorization'?: BrokerageAuthorization;
30
+ 'brokerage_authorization'?: string;
32
31
  /**
33
32
  *
34
33
  * @type {string}
@@ -48,8 +48,8 @@ Name | Type | Description | Notes
48
48
  ------------- | ------------- | ------------- | -------------
49
49
  **userId** | [**string**] | | defaults to undefined
50
50
  **userSecret** | [**string**] | | defaults to undefined
51
- **startDate** | [**string**] | | (optional) defaults to undefined
52
- **endDate** | [**string**] | | (optional) defaults to undefined
51
+ **startDate** | [**string | Date**] | | (optional) defaults to undefined
52
+ **endDate** | [**string | Date**] | | (optional) defaults to undefined
53
53
  **accounts** | [**string**] | Optional comma seperated list of account IDs used to filter the request on specific accounts | (optional) defaults to undefined
54
54
  **brokerageAuthorizations** | [**string**] | Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations | (optional) defaults to undefined
55
55
 
@@ -111,8 +111,8 @@ console.log(getReportingCustomRangeResponse)
111
111
 
112
112
  Name | Type | Description | Notes
113
113
  ------------- | ------------- | ------------- | -------------
114
- **startDate** | [**string**] | | defaults to undefined
115
- **endDate** | [**string**] | | defaults to undefined
114
+ **startDate** | [**string | Date**] | | defaults to undefined
115
+ **endDate** | [**string | Date**] | | defaults to undefined
116
116
  **userId** | [**string**] | | defaults to undefined
117
117
  **userSecret** | [**string**] | | defaults to undefined
118
118
  **accounts** | [**string**] | Optional comma seperated list of account IDs used to filter the request on specific accounts | (optional) defaults to undefined
package/index.test.ts CHANGED
@@ -88,6 +88,66 @@ it("getUserAccountBalance", async () => {
88
88
  console.log(response.data);
89
89
  });
90
90
 
91
+ it("getActivities", async () => {
92
+ const snaptrade = new Snaptrade({
93
+ consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
94
+ clientId: process.env.SNAPTRADE_CLIENT_ID,
95
+ });
96
+ const userId = process.env.SNAPTRADE_TEST_USER_ID;
97
+ const userSecret = process.env.SNAPTRADE_TEST_USER_SECRET;
98
+ let activities = await snaptrade.transactionsAndReporting.getActivities({
99
+ userId,
100
+ userSecret,
101
+ });
102
+ console.log(activities.data);
103
+ expect(activities).not.toBeNull();
104
+ // create two variables "startDate" and "endDate" that are strings representing 1 year ago and today in yyyy-mm-dd format using today's date
105
+ const startDate = "2020-01-01";
106
+ const endDate = "2020-12-31";
107
+ activities = await snaptrade.transactionsAndReporting.getActivities({
108
+ userId,
109
+ userSecret,
110
+ startDate,
111
+ endDate,
112
+ });
113
+ console.log(activities.data);
114
+ expect(activities).not.toBeNull();
115
+ // create two variables "startDate" and "endDate" that are Date instances representing 1 year ago and today
116
+ const endDate2 = new Date();
117
+ // create variable startDate2 which is 1 year before endDate2
118
+ const startDate2 = new Date(endDate2);
119
+ startDate2.setFullYear(startDate2.getFullYear() - 1);
120
+ activities = await snaptrade.transactionsAndReporting.getActivities({
121
+ userId,
122
+ userSecret,
123
+ startDate: startDate2,
124
+ endDate: endDate2,
125
+ });
126
+ console.log(activities.data);
127
+ expect(activities).not.toBeNull();
128
+ });
129
+
130
+ it("getUserHoldings", async () => {
131
+ const snaptrade = new Snaptrade({
132
+ consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
133
+ clientId: process.env.SNAPTRADE_CLIENT_ID,
134
+ });
135
+ const userId = process.env.SNAPTRADE_TEST_USER_ID;
136
+ const userSecret = process.env.SNAPTRADE_TEST_USER_SECRET;
137
+ const accounts = await snaptrade.accountInformation.listUserAccounts({
138
+ userId,
139
+ userSecret,
140
+ });
141
+ const holdings = await snaptrade.accountInformation.getUserHoldings({
142
+ userId,
143
+ userSecret,
144
+ accountId: accounts.data[0].id,
145
+ });
146
+ // assert holdings is not null with jest
147
+ expect(holdings).not.toBeNull();
148
+ console.log(holdings.data);
149
+ });
150
+
91
151
  it.skip("getOptionsChain", async () => {
92
152
  const snaptrade = new Snaptrade({
93
153
  consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
@@ -12,9 +12,6 @@
12
12
  * Do not edit the class manually.
13
13
  */
14
14
 
15
- // May contain unused imports in some cases
16
- // @ts-ignore
17
- import { BrokerageAuthorization } from './brokerage-authorization';
18
15
 
19
16
  /**
20
17
  * SnapTradeUser Investment Account
@@ -32,10 +29,10 @@ export interface SnapTradeHoldingsAccount {
32
29
  'id'?: string;
33
30
  /**
34
31
  *
35
- * @type {BrokerageAuthorization}
32
+ * @type {string}
36
33
  * @memberof SnapTradeHoldingsAccount
37
34
  */
38
- 'brokerage_authorization'?: BrokerageAuthorization;
35
+ 'brokerage_authorization'?: string;
39
36
  /**
40
37
  *
41
38
  * @type {string}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snaptrade-typescript-sdk",
3
- "version": "6.4.0",
3
+ "version": "7.0.0",
4
4
  "description": "Client for SnapTrade",
5
5
  "author": "Konfig",
6
6
  "repository": {