risk profile api
This commit is contained in:
@@ -30,8 +30,33 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!-- Don't delete the meta-data below.
|
|
||||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
<!-- SMALL CASE API-->
|
||||||
|
<activity android:name="com.smallcase.gateway.screens.transaction.activity.TransactionProcessActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data
|
||||||
|
android:host="pi-advisors"
|
||||||
|
android:scheme="scgateway"
|
||||||
|
/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="com.smallcase.gateway.screens.common.RedirectActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data
|
||||||
|
android:host="pi-advisors"
|
||||||
|
android:scheme="scgatewayredirect"
|
||||||
|
/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class MainController extends GetxController {
|
|||||||
var currentTab = [
|
var currentTab = [
|
||||||
const HomeScreen(),
|
const HomeScreen(),
|
||||||
const ShortTrade(),
|
const ShortTrade(),
|
||||||
const Holdings(),
|
const Portfolio(),
|
||||||
].obs;
|
].obs;
|
||||||
|
|
||||||
void updateTab(int index) {
|
void updateTab(int index) {
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
class ApiUrls {
|
class ApiUrls {
|
||||||
|
// PIE BASE URL FOR SMALL CASE --> NEED TO BE UPDATED
|
||||||
|
|
||||||
|
static const String pieBase = "https://app.piadvisors.in/";
|
||||||
|
|
||||||
//Base URL
|
//Base URL
|
||||||
static const base = "http://192.168.50.117/Trader_circuit/api/";
|
static const base = "http://192.168.50.117/Trader_circuit/api/";
|
||||||
|
|
||||||
@@ -13,4 +17,9 @@ class ApiUrls {
|
|||||||
|
|
||||||
//FAQ API
|
//FAQ API
|
||||||
static String faqApi = "${base}getFaq";
|
static String faqApi = "${base}getFaq";
|
||||||
|
|
||||||
|
//RISK PROFILE API
|
||||||
|
static String getRiskProfileQuestionAnswerApi = "${base}riskProfileQueAns";
|
||||||
|
static String addRiskProfileQuestionAnswerApi =
|
||||||
|
"${base}getRiskProfileQuestionAnswerApi";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class NetworkApiServices extends BaseApiServices {
|
|||||||
Dio dio = Dio();
|
Dio dio = Dio();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ResponseData> getApi(String url) async {
|
Future<ResponseData> getApi(String url, {bool isAuth = false}) async {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print("api url is >>> $url");
|
print("api url is >>> $url");
|
||||||
}
|
}
|
||||||
@@ -22,14 +22,10 @@ class NetworkApiServices extends BaseApiServices {
|
|||||||
String? token = prefs.getString('token').toString();
|
String? token = prefs.getString('token').toString();
|
||||||
log(token);
|
log(token);
|
||||||
try {
|
try {
|
||||||
response = await dio.get(
|
response = await dio.get(url,
|
||||||
url,
|
options: Options(headers: {
|
||||||
// options: Options(headers: {
|
isAuth ? 'authorization' : "Bearer $token": "",
|
||||||
// 'authorization': "Bearer $token",
|
}));
|
||||||
|
|
||||||
// // "device-id": deviceId
|
|
||||||
// })
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return ResponseData<dynamic>(
|
return ResponseData<dynamic>(
|
||||||
@@ -58,7 +54,7 @@ class NetworkApiServices extends BaseApiServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ResponseData> postApi(data, String url) async {
|
Future<ResponseData> postApi(data, String url, {bool isAuth = false}) async {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print("data >>> $data");
|
print("data >>> $data");
|
||||||
print("api url is >>> $url");
|
print("api url is >>> $url");
|
||||||
@@ -70,17 +66,9 @@ class NetworkApiServices extends BaseApiServices {
|
|||||||
try {
|
try {
|
||||||
response = await dio.post(url,
|
response = await dio.post(url,
|
||||||
data: data,
|
data: data,
|
||||||
options: (token == null || token == "")
|
options: Options(headers: {
|
||||||
? Options(
|
isAuth ? 'authorization' : "Bearer $token": "",
|
||||||
headers: {
|
}));
|
||||||
"Authorization":
|
|
||||||
"Basic KzIkcVBiSlIzNncmaGUoalMmV0R6ZkpqdEVoSlVLVXA6dCRCZHEmSnQmc3Y0eUdqY0VVcTg5aEVZZHVSalhIMnU=",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: Options(headers: {
|
|
||||||
"Authorization": "Bearer $token",
|
|
||||||
//'access-token': token,
|
|
||||||
}));
|
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
if (e is DioException) {
|
if (e is DioException) {
|
||||||
log(e.response.toString());
|
log(e.response.toString());
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:traderscircuit/firebase_options.dart';
|
import 'package:traderscircuit/firebase_options.dart';
|
||||||
|
import 'package:scgateway_flutter_plugin/scgateway_flutter_plugin.dart';
|
||||||
import 'package:traderscircuit/resources/routes/route_name.dart';
|
import 'package:traderscircuit/resources/routes/route_name.dart';
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:traderscircuit/resources/routes/routes.dart';
|
import 'package:traderscircuit/resources/routes/routes.dart';
|
||||||
@@ -28,6 +29,14 @@ Future<void> main() async {
|
|||||||
// GlobalVariables globalVariables = GlobalVariables();
|
// GlobalVariables globalVariables = GlobalVariables();
|
||||||
//token = prefs.getString('token');
|
//token = prefs.getString('token');
|
||||||
// OnBoard = prefs.getBool("OnBoard");
|
// OnBoard = prefs.getBool("OnBoard");
|
||||||
|
|
||||||
|
//smallcase
|
||||||
|
ScgatewayFlutterPlugin.setConfigEnvironment(
|
||||||
|
GatewayEnvironment.PRODUCTION,
|
||||||
|
'pi-advisors',
|
||||||
|
false,
|
||||||
|
[],
|
||||||
|
);
|
||||||
SystemChrome.setPreferredOrientations([
|
SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
]).then((value) => runApp(const MyApp()));
|
]).then((value) => runApp(const MyApp()));
|
||||||
|
|||||||
34
lib/model/SmallCaseModel/broker_account_model.dart
Normal file
34
lib/model/SmallCaseModel/broker_account_model.dart
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
class BrokerAccountModel {
|
||||||
|
final String? id;
|
||||||
|
final String? userId;
|
||||||
|
final String? brokerName;
|
||||||
|
final String? authToken;
|
||||||
|
final String? txnId;
|
||||||
|
|
||||||
|
const BrokerAccountModel({
|
||||||
|
required this.id,
|
||||||
|
required this.userId,
|
||||||
|
required this.brokerName,
|
||||||
|
required this.authToken,
|
||||||
|
required this.txnId,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BrokerAccountModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BrokerAccountModel(
|
||||||
|
id: json['id'].toString(),
|
||||||
|
userId: json['user_id'].toString(),
|
||||||
|
brokerName: json['broker_name'] as String?,
|
||||||
|
authToken: json['auth_token'] as String?,
|
||||||
|
txnId: json['transaction_id'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['user_id'] = userId;
|
||||||
|
data['broker_name'] = brokerName;
|
||||||
|
data['auth_token'] = authToken;
|
||||||
|
data['transaction_id'] = txnId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,23 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:async/async.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:lottie/lottie.dart';
|
import 'package:lottie/lottie.dart';
|
||||||
|
import 'package:scgateway_flutter_plugin/scgateway_flutter_plugin.dart';
|
||||||
import 'package:traderscircuit/Utils/Common/CommonBottomNavigation.dart';
|
import 'package:traderscircuit/Utils/Common/CommonBottomNavigation.dart';
|
||||||
import 'package:traderscircuit/Utils/Common/commonBotton.dart';
|
import 'package:traderscircuit/Utils/Common/commonBotton.dart';
|
||||||
import 'package:traderscircuit/Utils/text.dart';
|
import 'package:traderscircuit/Utils/text.dart';
|
||||||
import 'package:traderscircuit/view/MainScreen/MainScreen.dart';
|
import 'package:traderscircuit/view/MainScreen/MainScreen.dart';
|
||||||
|
import 'package:traderscircuit/view/MainScreen/Portfolio/Holdings.dart';
|
||||||
import 'package:traderscircuit/view/Sidemenu/Sidemenu.dart';
|
import 'package:traderscircuit/view/Sidemenu/Sidemenu.dart';
|
||||||
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
|
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
|
||||||
|
|
||||||
|
import '../../../model/SmallCaseModel/broker_account_model.dart';
|
||||||
|
import '../../../view_model/SmallCaseApi/smallcase_api_methods.dart';
|
||||||
|
|
||||||
class Portfolio extends StatefulWidget {
|
class Portfolio extends StatefulWidget {
|
||||||
const Portfolio({super.key});
|
const Portfolio({super.key});
|
||||||
|
|
||||||
@@ -20,13 +29,238 @@ class _PortfolioState extends State<Portfolio> {
|
|||||||
GlobalKey<ScaffoldState> _scaffoldKey1 = GlobalKey<ScaffoldState>();
|
GlobalKey<ScaffoldState> _scaffoldKey1 = GlobalKey<ScaffoldState>();
|
||||||
List<String> containerTexts = ["Swing Trade", "Multibagger", "Options"];
|
List<String> containerTexts = ["Swing Trade", "Multibagger", "Options"];
|
||||||
final selectedIndex = 0.obs;
|
final selectedIndex = 0.obs;
|
||||||
|
|
||||||
|
FutureGroup fetchUserIdAndBrokerAccounts = FutureGroup();
|
||||||
|
List<BrokerAccountModel> myBrokerAccounts = [];
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// fetchUserIdAndBrokerAccounts.add(getUserId()); // TODO Need to add userid here
|
||||||
|
fetchUserIdAndBrokerAccounts.add(fetchBrokerAccounts());
|
||||||
|
fetchUserIdAndBrokerAccounts.close();
|
||||||
|
// fetchUserIdAndBrokerAccounts.future.then((value) {
|
||||||
|
// int userId = value[0];
|
||||||
|
// List<BrokerAccountModel> brokerAccounts = value[1];
|
||||||
|
// try {
|
||||||
|
// myBrokerAccounts.addAll(brokerAccounts
|
||||||
|
// .where((element) => element.userId == userId.toString()));
|
||||||
|
// } catch (e) {}
|
||||||
|
// debugPrint("myBrokerAccounts.length ${myBrokerAccounts.length}");
|
||||||
|
// debugPrint("BrokerAccounts.length ${brokerAccounts.length}");
|
||||||
|
// if (myBrokerAccounts.isEmpty) {
|
||||||
|
// setState(() {
|
||||||
|
// body = Center(
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// children: [
|
||||||
|
// const Text("You need to add broker account"),
|
||||||
|
// const Text("to fetch holdings"),
|
||||||
|
// const SizedBox(height: 6),
|
||||||
|
// OutlinedButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// //Get.off(Broker());
|
||||||
|
// Get.to(() => Broker());
|
||||||
|
// },
|
||||||
|
// child: const Text("Brokerage Account"),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ));
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// setBodyToBrokers();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
// void setBodyToBrokers() {
|
||||||
|
// setState(() {
|
||||||
|
// body = Padding(
|
||||||
|
// padding: const EdgeInsets.only(top: 28, left: 28, right: 28),
|
||||||
|
// child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
|
// const Text("Please select your broker account"),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Expanded(
|
||||||
|
// child: ListView.builder(
|
||||||
|
// itemCount: myBrokerAccounts.length,
|
||||||
|
// itemBuilder: (context, index) {
|
||||||
|
// return OutlinedButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// setState(() {
|
||||||
|
// body = const Center(child: CircularProgressIndicator());
|
||||||
|
// });
|
||||||
|
// fetchHoldingsImportTxnId(
|
||||||
|
// myBrokerAccounts.elementAt(index).authToken!)
|
||||||
|
// .then((txnIdResponse) {
|
||||||
|
// if (txnIdResponse.statusCode == 200) {
|
||||||
|
// debugPrint('SESSION STARTED');
|
||||||
|
// debugPrint(
|
||||||
|
// 'AUTH TOKEN: ${myBrokerAccounts.elementAt(index).authToken!}');
|
||||||
|
// fetchHoldingsImportTxnId(
|
||||||
|
// myBrokerAccounts.elementAt(index).authToken!)
|
||||||
|
// .then((txnRes) {
|
||||||
|
// String txnId =
|
||||||
|
// jsonDecode(txnRes.body)['data']['transactionId'];
|
||||||
|
// debugPrint('TXN ID $txnId');
|
||||||
|
// ScgatewayFlutterPlugin.triggerGatewayTransaction(
|
||||||
|
// txnId)
|
||||||
|
// .then(
|
||||||
|
// (txnRes) {
|
||||||
|
// debugPrint('TXN RES $txnRes');
|
||||||
|
// if (txnRes != null) {
|
||||||
|
// fetchHoldings(
|
||||||
|
// //holdingsAuthToken
|
||||||
|
// myBrokerAccounts
|
||||||
|
// .elementAt(index)
|
||||||
|
// .authToken!)
|
||||||
|
// .then(
|
||||||
|
// (holdings) {
|
||||||
|
// setState(() {
|
||||||
|
// // body = netWorthPage(holdings);
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// debugPrint('SESSION EXPIRED');
|
||||||
|
// onTxnTimeout();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// child: Text(myBrokerAccounts.elementAt(index).brokerName!),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ]),
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void onTxnTimeout() {
|
||||||
|
// bool showDialogContent = true;
|
||||||
|
// bool replaceDialogContentWithLoader = false;
|
||||||
|
// showDialog(
|
||||||
|
// barrierDismissible: false,
|
||||||
|
// context: context,
|
||||||
|
// builder: (context) => AlertDialog(content: StatefulBuilder(
|
||||||
|
// builder: (context, setDialogState) {
|
||||||
|
// return Column(
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// children: [
|
||||||
|
// Visibility(
|
||||||
|
// visible: showDialogContent,
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// const Text("Transaction Timeout",
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// fontSize: 18,
|
||||||
|
// )),
|
||||||
|
// const SizedBox(height: 18),
|
||||||
|
// const Text("You need to login again to continue"),
|
||||||
|
// const SizedBox(height: 18),
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// OutlinedButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// setBodyToBrokers();
|
||||||
|
// Get.back();
|
||||||
|
// },
|
||||||
|
// child: const Text("Cancel"),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(width: 12),
|
||||||
|
// ElevatedButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// setDialogState(() {
|
||||||
|
// showDialogContent = false;
|
||||||
|
// replaceDialogContentWithLoader = true;
|
||||||
|
// });
|
||||||
|
// //login again
|
||||||
|
// 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'];
|
||||||
|
// getUserId().then((userId) {
|
||||||
|
// postBrokerAccount(
|
||||||
|
// userId: userId!
|
||||||
|
// .toString(),
|
||||||
|
// brokerName:
|
||||||
|
// brokerName,
|
||||||
|
// authToken: authToken,
|
||||||
|
// txnId: txnId)
|
||||||
|
// .then((isPosted) {
|
||||||
|
// if (isPosted) {
|
||||||
|
// // Get.back();
|
||||||
|
// // setBodyToBrokers();
|
||||||
|
// Get.off(Holdings());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// child: const Text("Login Again"),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Visibility(
|
||||||
|
// visible: replaceDialogContentWithLoader,
|
||||||
|
// child: const Padding(
|
||||||
|
// padding: EdgeInsets.symmetric(vertical: 28.0),
|
||||||
|
// child: Center(
|
||||||
|
// child: CircularProgressIndicator(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// )));
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey1,
|
key: _scaffoldKey1,
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
drawerEnableOpenDragGesture: false,
|
drawerEnableOpenDragGesture: false,
|
||||||
drawer: Container(child: SideMenu()),
|
drawer: Container(child: const SideMenu()),
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
scrolledUnderElevation: 0.0,
|
scrolledUnderElevation: 0.0,
|
||||||
@@ -49,12 +283,13 @@ class _PortfolioState extends State<Portfolio> {
|
|||||||
),
|
),
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
CommonBlurLeft(),
|
const CommonBlurLeft(),
|
||||||
CommonBlurRight(),
|
const CommonBlurRight(),
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@@ -75,15 +310,73 @@ class _PortfolioState extends State<Portfolio> {
|
|||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Spacer(),
|
const Spacer(),
|
||||||
LottieBuilder.asset(
|
LottieBuilder.asset(
|
||||||
"assets/images/empty.json",
|
"assets/images/empty.json",
|
||||||
width: 200.w,
|
width: 200.w,
|
||||||
height: 200.h,
|
height: 200.h,
|
||||||
),
|
),
|
||||||
Spacer(),
|
const Spacer(),
|
||||||
CommonBtn(text: "Add"),
|
CommonBtn(
|
||||||
Spacer(),
|
text: "Add",
|
||||||
|
onTap: () {
|
||||||
|
// replaceAddAccountBtnWithLoader();
|
||||||
|
// Timer.periodic(Duration(seconds: 8), (timer) {
|
||||||
|
// // replaceLoaderWithAddAccountBtn();
|
||||||
|
// timer.cancel();
|
||||||
|
// });
|
||||||
|
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'];
|
||||||
|
// getUserId().then((userId) {
|
||||||
|
postBrokerAccount(
|
||||||
|
userId: "12",
|
||||||
|
brokerName: brokerName,
|
||||||
|
authToken: authToken,
|
||||||
|
txnId: txnId)
|
||||||
|
.then((isPosted) {
|
||||||
|
// replaceLoaderWithAddAccountBtn();
|
||||||
|
// Navigator.pushReplacement(
|
||||||
|
// context,
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (context) =>
|
||||||
|
// Broker()));
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.clearSnackBars();
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'New broker account is added')));
|
||||||
|
});
|
||||||
|
// });
|
||||||
|
// replaceLoaderWithAddAccountBtn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
const Spacer(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
46
lib/view_model/RiskProfileApi/risk_profile_api.dart
Normal file
46
lib/view_model/RiskProfileApi/risk_profile_api.dart
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
import '../../Utils/api_urls.dart';
|
||||||
|
import '../../Utils/base_manager.dart';
|
||||||
|
import '../../data/network/network_api_services.dart';
|
||||||
|
|
||||||
|
class RiskProfileApi {
|
||||||
|
Future<ResponseData<dynamic>> getRiskProfileData() async {
|
||||||
|
final response = await NetworkApiServices()
|
||||||
|
.getApi(ApiUrls.getRiskProfileQuestionAnswerApi, isAuth: true);
|
||||||
|
log(response.data.toString());
|
||||||
|
if (response.status == ResponseStatus.SUCCESS) {
|
||||||
|
Map<String, dynamic> responseData =
|
||||||
|
Map<String, dynamic>.from(response.data);
|
||||||
|
if (responseData['status'] == "success") {
|
||||||
|
return response;
|
||||||
|
} else {
|
||||||
|
return ResponseData<dynamic>(
|
||||||
|
responseData['message'], ResponseStatus.FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ResponseData<dynamic>> addRiskProfileData(FormData data) async {
|
||||||
|
final response = await NetworkApiServices().postApi(
|
||||||
|
data,
|
||||||
|
ApiUrls.addRiskProfileQuestionAnswerApi,
|
||||||
|
isAuth: true,
|
||||||
|
);
|
||||||
|
log(response.data.toString());
|
||||||
|
if (response.status == ResponseStatus.SUCCESS) {
|
||||||
|
Map<String, dynamic> responseData =
|
||||||
|
Map<String, dynamic>.from(response.data);
|
||||||
|
if (responseData['status'] == "success") {
|
||||||
|
return response;
|
||||||
|
} else {
|
||||||
|
return ResponseData<dynamic>(
|
||||||
|
responseData['message'], ResponseStatus.FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
137
lib/view_model/SmallCaseApi/smallcase_api_methods.dart
Normal file
137
lib/view_model/SmallCaseApi/smallcase_api_methods.dart
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
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 '../../model/SmallCaseModel/broker_account_model.dart';
|
||||||
|
|
||||||
|
// void openDashboardPage(BuildContext context) {
|
||||||
|
// Navigator.pushReplacement(
|
||||||
|
// context, MaterialPageRoute(builder: ((context) => PortfolioMainUI())));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void openEquityPage(BuildContext context, Map<String, dynamic> holdings) {
|
||||||
|
// Navigator.push(
|
||||||
|
// context,
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: ((context) => Equityinner(holdings: holdings))));
|
||||||
|
// }
|
||||||
|
|
||||||
|
//broker account table
|
||||||
|
//fetch broker accounts
|
||||||
|
Future<List<BrokerAccountModel>> fetchBrokerAccounts() async {
|
||||||
|
final response = await http.Client()
|
||||||
|
.get(Uri.parse('${ApiUrls.pieBase}api/get_broker_account_data'));
|
||||||
|
final parsed = jsonDecode(response.body);
|
||||||
|
return parsed
|
||||||
|
.map<BrokerAccountModel>((json) => BrokerAccountModel.fromJson(json))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete broker account
|
||||||
|
Future<bool> deleteBrokerAccount(int id) async {
|
||||||
|
final response = await http.Client()
|
||||||
|
.get(Uri.parse('${ApiUrls.pieBase}api/delete_brokerage_account/$id'));
|
||||||
|
if (response.statusCode == 200) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//post broker account
|
||||||
|
Future<bool> postBrokerAccount({
|
||||||
|
required String userId,
|
||||||
|
required String brokerName,
|
||||||
|
required String authToken,
|
||||||
|
required String txnId,
|
||||||
|
}) async {
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse('${ApiUrls.pieBase}api/add_broker_account'),
|
||||||
|
body: <String, String>{
|
||||||
|
"user_id": userId,
|
||||||
|
"broker_name": brokerName,
|
||||||
|
"auth_token": authToken,
|
||||||
|
"transaction_id": txnId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> fetchAuthToken() async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(
|
||||||
|
'${ApiUrls.pieBase}api/get_small_case_auth_token/',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return jsonDecode(response.body)['data'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> fetchBrokerConnectTxnId({required String authToken}) async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(
|
||||||
|
'${ApiUrls.pieBase}api/get_small_case_broker_connect_transaction/$authToken',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return jsonDecode(response.body)['data']['transactionId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<http.Response> fetchHoldingsImportTxnId(String authToken) async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(
|
||||||
|
'${ApiUrls.pieBase}api/get_small_case_holding_import_transaction_id/$authToken',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> fetchHoldings(String authToken) async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(
|
||||||
|
'${ApiUrls.pieBase}api/fetch_small_case_holding/$authToken',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return jsonDecode(response.body)['data'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> fetchStocksOrderTxnId(String authToken, String body) async {
|
||||||
|
var response = await http.post(Uri.parse(
|
||||||
|
'${ApiUrls.pieBase}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")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
99
pubspec.lock
99
pubspec.lock
@@ -26,7 +26,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.4.2"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
||||||
@@ -286,7 +286,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_branch_sdk:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_branch_sdk
|
||||||
|
sha256: "3850097e5c70d89db235fb160e92eac5928f4206ab167b0d83c7e4e50b1357f8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.1.0"
|
||||||
flutter_cache_manager:
|
flutter_cache_manager:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -295,7 +302,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.3.1"
|
version: "3.3.1"
|
||||||
|
flutter_isolate:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_isolate
|
||||||
|
sha256: "8ab879634322a012feb096153cf759caa118d81300189d1730455f3718bca24b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.5-pre"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@@ -570,7 +584,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.0"
|
version: "0.5.0"
|
||||||
|
|
||||||
octo_image:
|
octo_image:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -587,23 +600,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.5.3"
|
version: "3.5.3"
|
||||||
package_info_plus:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: package_info_plus
|
|
||||||
sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.2.0"
|
|
||||||
package_info_plus_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: package_info_plus_platform_interface
|
|
||||||
sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.1"
|
|
||||||
|
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -724,7 +720,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.2"
|
version: "6.1.2"
|
||||||
|
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -733,7 +728,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.27.7"
|
version: "0.27.7"
|
||||||
|
scgateway_flutter_plugin:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: scgateway_flutter_plugin
|
||||||
|
sha256: c52831292d73b7004af314f7e34ea4c510110da3e7d1cc274a745b3524e6a724
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.1"
|
||||||
|
share_plus:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus
|
||||||
|
sha256: b1f15232d41e9701ab2f04181f21610c36c83a12ae426b79b4bd011c567934b1
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.3.4"
|
||||||
|
share_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_platform_interface
|
||||||
|
sha256: "251eb156a8b5fa9ce033747d73535bf53911071f8d3b6f4f0b578505ce0d4496"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.4.0"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -883,17 +901,46 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "1.3.2"
|
||||||
|
url_launcher_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_linux
|
||||||
|
sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.1"
|
||||||
|
url_launcher_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_platform_interface
|
||||||
|
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.2"
|
||||||
|
url_launcher_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_web
|
||||||
|
sha256: "7fd2f55fe86cea2897b963e864dc01a7eb0719ecc65fcef4c1cc3d686d718bb2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
|
url_launcher_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: url_launcher_windows
|
||||||
|
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.1"
|
||||||
uuid:
|
uuid:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: uuid
|
name: uuid
|
||||||
|
|
||||||
sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f"
|
sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2.2"
|
version: "4.2.2"
|
||||||
|
|
||||||
vector_graphics:
|
vector_graphics:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ dependencies:
|
|||||||
firebase_core:
|
firebase_core:
|
||||||
dio: ^5.1.2
|
dio: ^5.1.2
|
||||||
expansion_tile_group: ^1.2.4
|
expansion_tile_group: ^1.2.4
|
||||||
|
scgateway_flutter_plugin: ^2.3.1
|
||||||
|
async: ^2.4.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@@ -63,4 +65,4 @@ flutter:
|
|||||||
|
|
||||||
- family: hiragino
|
- family: hiragino
|
||||||
fonts:
|
fonts:
|
||||||
- asset: assets/fonts/hiragino/Hiragino Sans GB W6.TTF
|
- asset: assets/fonts/hiragino/Hiragino Sans GB W6.TTF
|
||||||
|
|||||||
Reference in New Issue
Block a user