firstock 1.0.1 → 1.0.4

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.
package/Readme.md CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  # The Firstock Developer API Nodejs client -
2
3
 
3
4
  To communicate with the Firstock Developer API using Nodejs, you can use the official Nodejs client library provided by Firstock.
@@ -283,3 +284,9 @@ Refer to the [Firstock Connect Documentation](https://connect.thefirstock.com/)
283
284
  ## Changelog
284
285
 
285
286
  Check release notes.
287
+
288
+
289
+
290
+
291
+
292
+
@@ -933,8 +933,8 @@ class Firstock extends AFirstock_1.default {
933
933
  callBack(err, null);
934
934
  }
935
935
  else if (jKey) {
936
- axiosInterceptor
937
- .post(`productConversion`, {
936
+ // Prepare the request payload
937
+ const requestPayload = {
938
938
  userId,
939
939
  jKey,
940
940
  exchange: params.exchange,
@@ -942,7 +942,13 @@ class Firstock extends AFirstock_1.default {
942
942
  quantity: params.quantity,
943
943
  product: params.product,
944
944
  previousProduct: params.previousProduct,
945
- })
945
+ };
946
+ // Add msgFlag to payload if provided
947
+ if (params.msgFlag) {
948
+ requestPayload.msgFlag = params.msgFlag;
949
+ }
950
+ axiosInterceptor
951
+ .post(`productConversion`, requestPayload)
946
952
  .then((response) => {
947
953
  const { data } = response;
948
954
  callBack(null, data);
@@ -1767,5 +1773,53 @@ class Firstock extends AFirstock_1.default {
1767
1773
  }
1768
1774
  });
1769
1775
  }
1776
+ /**
1777
+ * Retrieves holdings details for a user from the Firstock API.
1778
+ *
1779
+ * This method sends a request to the Firstock holdingsDetails endpoint using the provided
1780
+ * user ID and session token (jKey) retrieved from config.json. The response contains the user's holdings information.
1781
+ *
1782
+ * @param {Object} params - Holdings parameters.
1783
+ * @param {string} params.userId - Firstock user ID (e.g., SU2707).
1784
+ * @param {function} callBack - Callback with `(error, result)`:
1785
+ * - `error`: Error object if the request fails.
1786
+ * - `result`: Parsed response containing holdings information if successful.
1787
+ */
1788
+ getHoldingsDetails({ userId }, callBack) {
1789
+ (0, commonFunction_1.readData)((err, data) => {
1790
+ if (err) {
1791
+ const errorMessage = err instanceof Error ? err.message : err;
1792
+ callBack(new Error((0, commonFunction_1.errorMessageMapping)({ message: errorMessage })), null);
1793
+ }
1794
+ else if (data) {
1795
+ (0, commonFunction_1.checkifUserLoggedIn)({ userId, jsonData: data }, (err, jKey) => {
1796
+ if (err) {
1797
+ callBack(new Error(err), null);
1798
+ }
1799
+ else if (jKey) {
1800
+ axiosInterceptor
1801
+ .post("holdingsDetails", {
1802
+ userId,
1803
+ jKey
1804
+ })
1805
+ .then((response) => {
1806
+ const { data } = response;
1807
+ this.userId = userId;
1808
+ callBack(null, data);
1809
+ })
1810
+ .catch((error) => {
1811
+ callBack((0, commonFunction_1.handleError)(error), null);
1812
+ });
1813
+ }
1814
+ else {
1815
+ callBack(new Error("No jKey found for userId in config.json"), null);
1816
+ }
1817
+ });
1818
+ }
1819
+ else {
1820
+ callBack(new Error("No config data found"), null);
1821
+ }
1822
+ });
1823
+ }
1770
1824
  }
1771
1825
  exports.Firstock = Firstock;
package/dist/test.js CHANGED
@@ -6,14 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const index_1 = __importDefault(require("./index"));
7
7
  const firstock = new index_1.default();
8
8
  let orderNumber = "";
9
- const userDetails = {
10
- userId: "",
11
- password: "",
12
- TOTP: "",
13
- vendorCode: "",
14
- apiKey: "",
15
- };
16
- // Login and user Details start
9
+ // const userDetails = {
10
+ // userId: "NP2997",
11
+ // password: "Skanda@202",
12
+ // TOTP: "1997",
13
+ // vendorCode: "NP2997_API",
14
+ // apiKey: "65d837ab42a4b0000fbe05f37ee575fb",
15
+ // };
16
+ // const userDetails = {
17
+ // userId: "",
18
+ // password: "",
19
+ // TOTP: "",
20
+ // vendorCode: "",
21
+ // apiKey: "",
22
+ // };
23
+ // // Login and user Details start
17
24
  // firstock.login(
18
25
  // {
19
26
  // userId: userDetails.userId,
@@ -155,6 +162,21 @@ const userDetails = {
155
162
  // console.log("productConversion Result: ", result);
156
163
  // }
157
164
  // );
165
+ // firstock.productConversion(
166
+ // {
167
+ // userId: userDetails.userId,
168
+ // exchange: "NFO",
169
+ // tradingSymbol: "NIFTY",
170
+ // quantity: "250",
171
+ // product: "C",
172
+ // previousProduct: "I",
173
+ // msgFlag: "1" // Buy and Day
174
+ // },
175
+ // (err: Error | string | null, result: any) => {
176
+ // console.log("productConversion (Buy & Day) Error: ", err);
177
+ // console.log("productConversion (Buy & Day) Result: ", result);
178
+ // }
179
+ // );
158
180
  // Holdings
159
181
  // firstock.holdings(
160
182
  // { userId: userDetails.userId},//, product: "C"
@@ -335,6 +357,16 @@ const userDetails = {
335
357
  // console.log("brokerageCalculator Result: ", result)
336
358
  // }
337
359
  // )
360
+ // Get Holdings Details
361
+ // firstock.getHoldingsDetails(
362
+ // {
363
+ // userId: userDetails.userId
364
+ // },
365
+ // (err: Error | null, result: any) => {
366
+ // console.log("Error: ", err);
367
+ // console.log("Result: ", result);
368
+ // }
369
+ // );
338
370
  // Logout
339
371
  // firstock.logout(
340
372
  // { userId: userDetails.userId },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firstock",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Node js package for using firstock developer apis",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
package/config.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
-
3
- }