diff --git a/lib/view/MainScreen/Portfolio/PortfolioEmpty.dart b/lib/view/MainScreen/Portfolio/PortfolioEmpty.dart index 7682da3..1dc569a 100644 --- a/lib/view/MainScreen/Portfolio/PortfolioEmpty.dart +++ b/lib/view/MainScreen/Portfolio/PortfolioEmpty.dart @@ -77,7 +77,7 @@ class _PortfolioState extends State { GatewayEnvironment.PRODUCTION, 'traderscircuit', false, - [myBrokerAccounts[selectedIndex.value].brokerName!], + ["upstox"], ); fetchHoldingsImportTxnId(myBrokerAccounts .elementAt(selectedIndex.value) @@ -405,6 +405,13 @@ class _PortfolioState extends State { text25W600("My Portfolio"), GestureDetector( onTap: () { + ScgatewayFlutterPlugin + .setConfigEnvironment( + GatewayEnvironment.PRODUCTION, + 'traderscircuit', + false, + [], + ); fetchAuthToken().then((fetchedAuthToken) { debugPrint( "fetchedAuthToken $fetchedAuthToken"); diff --git a/lib/view_model/SmallCaseApi/smallcase_api_methods.dart b/lib/view_model/SmallCaseApi/smallcase_api_methods.dart index e4b44c9..b943ae7 100644 --- a/lib/view_model/SmallCaseApi/smallcase_api_methods.dart +++ b/lib/view_model/SmallCaseApi/smallcase_api_methods.dart @@ -1,10 +1,7 @@ -import 'dart:convert'; import 'dart:developer'; import 'package:dio/dio.dart'; -import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; -import 'package:scgateway_flutter_plugin/scgateway_flutter_plugin.dart'; import '../../Utils/api_urls.dart'; import '../../Utils/base_manager.dart'; @@ -130,6 +127,7 @@ Future fetchHoldingsImportTxnId(String authToken) async { if (responseData['status'] == "success" && !responseData.toString().contains( "{status: error, status_code: 500, message: Something went wrong.}")) { + log("Transaction id --> ${response.data['data']["data"]['transactionId']}"); return response.data['data']["data"] ['transactionId']; // jsonDecode(response.body) } else { @@ -156,46 +154,3 @@ Future> fetchHoldings(String authToken) async { } return {}; } - -Future fetchStocksOrderTxnId(String authToken, String body) async { - var response = await http.post(Uri.parse( - '${ApiUrls.base}api/create_post_transaction_stock_order?body=$body&auth_token=$authToken')); - var txnId = jsonDecode(response.body)['data']['transactionId']; - return txnId; -} - -enum TradeType { - BUY, - SELL, -} - -void loginNTrade(String ticker, int quantity, TradeType tradeType) { - fetchAuthToken().then((fetchedAuthToken) { - // debugPrint("fetchedAuthToken $fetchedAuthToken"); - fetchBrokerConnectTxnId(authToken: fetchedAuthToken).then( - (txnId) => ScgatewayFlutterPlugin.initGateway(fetchedAuthToken).then( - (value) => ScgatewayFlutterPlugin.triggerGatewayTransaction( - txnId, - ).then( - (loginRes) { - if (loginRes != null) { - var data = jsonDecode(loginRes)['data']; - if (data != null) { - String authToken = jsonDecode(data)['smallcaseAuthToken']; - String brokerName = jsonDecode(data)['broker']; - String txnId = jsonDecode(data)['transactionId']; - String body = - '{"intent":"TRANSACTION","orderConfig":{"type":"SECURITIES","securities":[{"ticker":"$ticker","quantity":"$quantity","type":"${tradeType.name}"},{"ticker":"RELIANCE","quantity":1,"type":"BUY"}]}}'; - fetchStocksOrderTxnId(authToken, body).then( - (stocksOrderTxnId) => ScgatewayFlutterPlugin - .triggerGatewayTransaction(stocksOrderTxnId) - .then( - (value) => debugPrint("Stocks Order res $value"))); - } - } - }, - ), - ), - ); - }); -}