small case
This commit is contained in:
@@ -77,7 +77,7 @@ class _PortfolioState extends State<Portfolio> {
|
||||
GatewayEnvironment.PRODUCTION,
|
||||
'traderscircuit',
|
||||
false,
|
||||
[myBrokerAccounts[selectedIndex.value].brokerName!],
|
||||
["upstox"],
|
||||
);
|
||||
fetchHoldingsImportTxnId(myBrokerAccounts
|
||||
.elementAt(selectedIndex.value)
|
||||
@@ -405,6 +405,13 @@ class _PortfolioState extends State<Portfolio> {
|
||||
text25W600("My Portfolio"),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ScgatewayFlutterPlugin
|
||||
.setConfigEnvironment(
|
||||
GatewayEnvironment.PRODUCTION,
|
||||
'traderscircuit',
|
||||
false,
|
||||
[],
|
||||
);
|
||||
fetchAuthToken().then((fetchedAuthToken) {
|
||||
debugPrint(
|
||||
"fetchedAuthToken $fetchedAuthToken");
|
||||
|
||||
@@ -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<String> 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<Map<String, dynamic>> fetchHoldings(String authToken) async {
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Future<String> 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")));
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user