Merge pull request #68 from WDI-Ideas/product

websocket
This commit is contained in:
Raj
2024-06-05 19:58:55 +05:30
committed by GitHub
8 changed files with 518 additions and 278 deletions

View File

@@ -10,14 +10,14 @@ class HomeModel {
status = json['status'];
statusCode = json['status_code'];
message = json['message'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['status'] = status;
data['status_code'] = statusCode;
data['message'] = message;
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
data['status_code'] = this.statusCode;
data['message'] = this.message;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
@@ -33,210 +33,95 @@ class Data {
List<Products>? products;
ContentByteVideo? contentByteVideo;
bool? isUpstoxTokenRefreshed;
String? upstoxAccessToken;
String? upstoxClientId;
String? upstoxSecretKey;
Data(
{this.exploreTheUnseenActiveCalls,
this.exploreTheUnseenExitedCalls,
this.indexLiveData,
this.userData,
this.products,
this.contentByteVideo,
this.isUpstoxTokenRefreshed,
this.indexLiveData});
this.upstoxAccessToken,
this.upstoxClientId,
this.upstoxSecretKey});
Data.fromJson(Map<String, dynamic> json) {
if (json['explore_the_unseen_active_calls'] != null) {
exploreTheUnseenActiveCalls = <ExploreTheUnseenActiveCalls>[];
json['explore_the_unseen_active_calls'].forEach((v) {
exploreTheUnseenActiveCalls!
.add(ExploreTheUnseenActiveCalls.fromJson(v));
.add(new ExploreTheUnseenActiveCalls.fromJson(v));
});
}
if (json['explore_the_unseen_exited_calls'] != null) {
exploreTheUnseenExitedCalls = <ExploreTheUnseenExitedCalls>[];
json['explore_the_unseen_exited_calls'].forEach((v) {
exploreTheUnseenExitedCalls!
.add(ExploreTheUnseenExitedCalls.fromJson(v));
.add(new ExploreTheUnseenExitedCalls.fromJson(v));
});
}
indexLiveData = json['index_live_data'] != null
? IndexLiveData.fromJson(json['index_live_data'])
? new IndexLiveData.fromJson(json['index_live_data'])
: null;
userData = json['user_data'] != null
? new UserData.fromJson(json['user_data'])
: null;
userData =
json['user_data'] != null ? UserData.fromJson(json['user_data']) : null;
if (json['products'] != null) {
products = <Products>[];
json['products'].forEach((v) {
products!.add(Products.fromJson(v));
products!.add(new Products.fromJson(v));
});
}
contentByteVideo = json['content_byte_video'] != null
? ContentByteVideo.fromJson(json['content_byte_video'])
? new ContentByteVideo.fromJson(json['content_byte_video'])
: null;
isUpstoxTokenRefreshed = json['isUpstoxTokenRefreshed'];
upstoxAccessToken = json['upstoxAccessToken'];
upstoxClientId = json['upstox_client_id'];
upstoxSecretKey = json['upstox_secret_key'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (exploreTheUnseenActiveCalls != null) {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.exploreTheUnseenActiveCalls != null) {
data['explore_the_unseen_active_calls'] =
exploreTheUnseenActiveCalls!.map((v) => v.toJson()).toList();
this.exploreTheUnseenActiveCalls!.map((v) => v.toJson()).toList();
}
if (exploreTheUnseenExitedCalls != null) {
if (this.exploreTheUnseenExitedCalls != null) {
data['explore_the_unseen_exited_calls'] =
exploreTheUnseenExitedCalls!.map((v) => v.toJson()).toList();
this.exploreTheUnseenExitedCalls!.map((v) => v.toJson()).toList();
}
if (indexLiveData != null) {
data['index_live_data'] = indexLiveData!.toJson();
if (this.indexLiveData != null) {
data['index_live_data'] = this.indexLiveData!.toJson();
}
if (userData != null) {
data['user_data'] = userData!.toJson();
if (this.userData != null) {
data['user_data'] = this.userData!.toJson();
}
if (products != null) {
data['products'] = products!.map((v) => v.toJson()).toList();
if (this.products != null) {
data['products'] = this.products!.map((v) => v.toJson()).toList();
}
if (contentByteVideo != null) {
data['content_byte_video'] = contentByteVideo!.toJson();
if (this.contentByteVideo != null) {
data['content_byte_video'] = this.contentByteVideo!.toJson();
}
data['isUpstoxTokenRefreshed'] = isUpstoxTokenRefreshed;
return data;
}
}
class IndexLiveData {
String? status;
Data1? data;
IndexLiveData({this.status, this.data});
IndexLiveData.fromJson(Map<String, dynamic> json) {
status = json['status'];
data = json['data'] != null ? Data1.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['status'] = status;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class Data1 {
NSEINDEXNiftyBank? nSEINDEXNiftyBank;
NSEINDEXNiftyBank? nSEINDEXNifty50;
Data1({this.nSEINDEXNiftyBank, this.nSEINDEXNifty50});
Data1.fromJson(Map<String, dynamic> json) {
nSEINDEXNiftyBank = json['NSE_INDEX:Nifty Bank'] != null
? NSEINDEXNiftyBank.fromJson(json['NSE_INDEX:Nifty Bank'])
: null;
nSEINDEXNifty50 = json['NSE_INDEX:Nifty 50'] != null
? NSEINDEXNiftyBank.fromJson(json['NSE_INDEX:Nifty 50'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (nSEINDEXNiftyBank != null) {
data['NSE_INDEX:Nifty Bank'] = nSEINDEXNiftyBank!.toJson();
}
if (nSEINDEXNifty50 != null) {
data['NSE_INDEX:Nifty 50'] = nSEINDEXNifty50!.toJson();
}
return data;
}
}
class NSEINDEXNiftyBank {
Ohlc? ohlc;
String? timestamp;
String? instrumentToken;
String? symbol;
double? lastPrice;
double? netChange;
String? lastTradeTime;
NSEINDEXNiftyBank({
this.ohlc,
this.timestamp,
this.instrumentToken,
this.symbol,
this.lastPrice,
this.netChange,
this.lastTradeTime,
});
NSEINDEXNiftyBank.fromJson(Map<String, dynamic> json) {
ohlc = json['ohlc'] != null ? Ohlc.fromJson(json['ohlc']) : null;
timestamp = json['timestamp'];
instrumentToken = json['instrument_token'];
symbol = json['symbol'];
lastPrice = json['last_price'];
netChange = json['net_change'];
lastTradeTime = json['last_trade_time'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (ohlc != null) {
data['ohlc'] = ohlc!.toJson();
}
data['timestamp'] = timestamp;
data['instrument_token'] = instrumentToken;
data['symbol'] = symbol;
data['last_price'] = lastPrice;
data['net_change'] = netChange;
data['last_trade_time'] = lastTradeTime;
return data;
}
}
class Ohlc {
double? open;
double? high;
double? low;
double? close;
Ohlc({this.open, this.high, this.low, this.close});
Ohlc.fromJson(Map<String, dynamic> json) {
open = json['open'].toDouble();
high = json['high'].toDouble();
low = json['low'].toDouble();
close = json['close'].toDouble();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['open'] = open;
data['high'] = high;
data['low'] = low;
data['close'] = close;
data['isUpstoxTokenRefreshed'] = this.isUpstoxTokenRefreshed;
data['upstoxAccessToken'] = this.upstoxAccessToken;
data['upstox_client_id'] = this.upstoxClientId;
data['upstox_secret_key'] = this.upstoxSecretKey;
return data;
}
}
class ExploreTheUnseenActiveCalls {
int? id;
int? manageProductXid;
int? productTypeXid;
int? recommendationActionsXid;
String? stockName;
String? instrumentKey;
String? stockImage;
String? qty;
String? duration;
String? currentPrice;
String? buyPrice;
@@ -245,17 +130,17 @@ class ExploreTheUnseenActiveCalls {
int? isSendRecommendationNow;
String? scheduleDateTime;
String? createdAt;
ProductData? productData;
String? docs;
ProductTypeData? productTypeData;
ActionData? actionData;
ExploreTheUnseenActiveCalls(
{this.id,
this.manageProductXid,
this.productTypeXid,
this.recommendationActionsXid,
this.stockName,
this.instrumentKey,
this.stockImage,
this.qty,
this.duration,
this.currentPrice,
this.buyPrice,
@@ -264,17 +149,17 @@ class ExploreTheUnseenActiveCalls {
this.isSendRecommendationNow,
this.scheduleDateTime,
this.createdAt,
this.productData,
this.docs,
this.productTypeData,
this.actionData});
ExploreTheUnseenActiveCalls.fromJson(Map<String, dynamic> json) {
id = json['id'];
manageProductXid = json['manage_product_xid'];
productTypeXid = json['product_type_xid'];
recommendationActionsXid = json['recommendation_actions_xid'];
stockName = json['stock_name'];
instrumentKey = json['instrument_key'];
stockImage = json['stock_image'];
qty = json['qty'];
duration = json['duration'];
currentPrice = json['current_price'];
buyPrice = json['buy_price'];
@@ -283,36 +168,37 @@ class ExploreTheUnseenActiveCalls {
isSendRecommendationNow = json['is_send_recommendation_now'];
scheduleDateTime = json['schedule_date_time'];
createdAt = json['created_at'];
productData = json['product_data'] != null
? ProductData.fromJson(json['product_data'])
docs = json['docs'];
productTypeData = json['product_type_data'] != null
? new ProductTypeData.fromJson(json['product_type_data'])
: null;
actionData = json['action_data'] != null
? ActionData.fromJson(json['action_data'])
? new ActionData.fromJson(json['action_data'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['manage_product_xid'] = manageProductXid;
data['recommendation_actions_xid'] = recommendationActionsXid;
data['stock_name'] = stockName;
data['instrument_key'] = instrumentKey;
data['stock_image'] = stockImage;
data['qty'] = qty;
data['duration'] = duration;
data['current_price'] = currentPrice;
data['buy_price'] = buyPrice;
data['target_price'] = targetPrice;
data['stop_loss'] = stopLoss;
data['is_send_recommendation_now'] = isSendRecommendationNow;
data['schedule_date_time'] = scheduleDateTime;
data['created_at'] = createdAt;
if (productData != null) {
data['product_data'] = productData!.toJson();
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['product_type_xid'] = this.productTypeXid;
data['recommendation_actions_xid'] = this.recommendationActionsXid;
data['stock_name'] = this.stockName;
data['instrument_key'] = this.instrumentKey;
data['stock_image'] = this.stockImage;
data['duration'] = this.duration;
data['current_price'] = this.currentPrice;
data['buy_price'] = this.buyPrice;
data['target_price'] = this.targetPrice;
data['stop_loss'] = this.stopLoss;
data['is_send_recommendation_now'] = this.isSendRecommendationNow;
data['schedule_date_time'] = this.scheduleDateTime;
data['created_at'] = this.createdAt;
data['docs'] = this.docs;
if (this.productTypeData != null) {
data['product_type_data'] = this.productTypeData!.toJson();
}
if (actionData != null) {
data['action_data'] = actionData!.toJson();
if (this.actionData != null) {
data['action_data'] = this.actionData!.toJson();
}
return data;
}
@@ -320,12 +206,11 @@ class ExploreTheUnseenActiveCalls {
class ExploreTheUnseenExitedCalls {
int? id;
int? manageProductXid;
int? productTypeXid;
int? recommendationActionsXid;
String? stockName;
String? instrumentKey;
String? stockImage;
String? qty;
String? duration;
String? currentPrice;
String? buyPrice;
@@ -334,17 +219,17 @@ class ExploreTheUnseenExitedCalls {
int? isSendRecommendationNow;
String? scheduleDateTime;
String? createdAt;
ProductData? productData;
String? docs;
ProductTypeData? productTypeData;
ActionData? actionData;
ExploreTheUnseenExitedCalls(
{this.id,
this.manageProductXid,
this.productTypeXid,
this.recommendationActionsXid,
this.stockName,
this.instrumentKey,
this.stockImage,
this.qty,
this.duration,
this.currentPrice,
this.buyPrice,
@@ -353,17 +238,17 @@ class ExploreTheUnseenExitedCalls {
this.isSendRecommendationNow,
this.scheduleDateTime,
this.createdAt,
this.productData,
this.docs,
this.productTypeData,
this.actionData});
ExploreTheUnseenExitedCalls.fromJson(Map<String, dynamic> json) {
id = json['id'];
manageProductXid = json['manage_product_xid'];
productTypeXid = json['product_type_xid'];
recommendationActionsXid = json['recommendation_actions_xid'];
stockName = json['stock_name'];
instrumentKey = json['instrument_key'];
stockImage = json['stock_image'];
qty = json['qty'];
duration = json['duration'];
currentPrice = json['current_price'];
buyPrice = json['buy_price'];
@@ -372,62 +257,63 @@ class ExploreTheUnseenExitedCalls {
isSendRecommendationNow = json['is_send_recommendation_now'];
scheduleDateTime = json['schedule_date_time'];
createdAt = json['created_at'];
productData = json['product_data'] != null
? ProductData.fromJson(json['product_data'])
docs = json['docs'];
productTypeData = json['product_type_data'] != null
? new ProductTypeData.fromJson(json['product_type_data'])
: null;
actionData = json['action_data'] != null
? ActionData.fromJson(json['action_data'])
? new ActionData.fromJson(json['action_data'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['manage_product_xid'] = manageProductXid;
data['recommendation_actions_xid'] = recommendationActionsXid;
data['stock_name'] = stockName;
data['instrument_key'] = instrumentKey;
data['stock_image'] = stockImage;
data['qty'] = qty;
data['duration'] = duration;
data['current_price'] = currentPrice;
data['buy_price'] = buyPrice;
data['target_price'] = targetPrice;
data['stop_loss'] = stopLoss;
data['is_send_recommendation_now'] = isSendRecommendationNow;
data['schedule_date_time'] = scheduleDateTime;
data['created_at'] = createdAt;
if (productData != null) {
data['product_data'] = productData!.toJson();
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['product_type_xid'] = this.productTypeXid;
data['recommendation_actions_xid'] = this.recommendationActionsXid;
data['stock_name'] = this.stockName;
data['instrument_key'] = this.instrumentKey;
data['stock_image'] = this.stockImage;
data['duration'] = this.duration;
data['current_price'] = this.currentPrice;
data['buy_price'] = this.buyPrice;
data['target_price'] = this.targetPrice;
data['stop_loss'] = this.stopLoss;
data['is_send_recommendation_now'] = this.isSendRecommendationNow;
data['schedule_date_time'] = this.scheduleDateTime;
data['created_at'] = this.createdAt;
data['docs'] = this.docs;
if (this.productTypeData != null) {
data['product_type_data'] = this.productTypeData!.toJson();
}
if (actionData != null) {
data['action_data'] = actionData!.toJson();
if (this.actionData != null) {
data['action_data'] = this.actionData!.toJson();
}
return data;
}
}
class ProductData {
class ProductTypeData {
int? id;
String? productName;
int? isActive;
String? title;
String? isActive;
String? createdAt;
ProductData({this.id, this.productName, this.isActive, this.createdAt});
ProductTypeData({this.id, this.title, this.isActive, this.createdAt});
ProductData.fromJson(Map<String, dynamic> json) {
ProductTypeData.fromJson(Map<String, dynamic> json) {
id = json['id'];
productName = json['product_name'];
title = json['title'];
isActive = json['is_active'];
createdAt = json['created_at'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['product_name'] = productName;
data['is_active'] = isActive;
data['created_at'] = createdAt;
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['title'] = this.title;
data['is_active'] = this.isActive;
data['created_at'] = this.createdAt;
return data;
}
}
@@ -448,11 +334,248 @@ class ActionData {
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['is_active'] = isActive;
data['created_at'] = createdAt;
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['is_active'] = this.isActive;
data['created_at'] = this.createdAt;
return data;
}
}
class IndexLiveData {
String? status;
Data1? data;
IndexLiveData({this.status, this.data});
IndexLiveData.fromJson(Map<String, dynamic> json) {
status = json['status'];
data = json['data'] != null ? new Data1.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class Data1 {
NSEINDEXNiftyBank? nSEINDEXNiftyBank;
NSEINDEXNifty50? nSEINDEXNifty50;
Data1({this.nSEINDEXNiftyBank, this.nSEINDEXNifty50});
Data1.fromJson(Map<String, dynamic> json) {
nSEINDEXNiftyBank = json['NSE_INDEX:Nifty Bank'] != null
? new NSEINDEXNiftyBank.fromJson(json['NSE_INDEX:Nifty Bank'])
: null;
nSEINDEXNifty50 = json['NSE_INDEX:Nifty 50'] != null
? new NSEINDEXNifty50.fromJson(json['NSE_INDEX:Nifty 50'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.nSEINDEXNiftyBank != null) {
data['NSE_INDEX:Nifty Bank'] = this.nSEINDEXNiftyBank!.toJson();
}
if (this.nSEINDEXNifty50 != null) {
data['NSE_INDEX:Nifty 50'] = this.nSEINDEXNifty50!.toJson();
}
return data;
}
}
class NSEINDEXNiftyBank {
Ohlc? ohlc;
String? timestamp;
String? instrumentToken;
String? symbol;
double? lastPrice;
String? volume;
String? averagePrice;
Null? oi;
int? netChange;
String? totalBuyQuantity;
String? totalSellQuantity;
String? lowerCircuitLimit;
String? upperCircuitLimit;
String? lastTradeTime;
String? oiDayHigh;
String? oiDayLow;
NSEINDEXNiftyBank(
{this.ohlc,
this.timestamp,
this.instrumentToken,
this.symbol,
this.lastPrice,
this.volume,
this.averagePrice,
this.oi,
this.netChange,
this.totalBuyQuantity,
this.totalSellQuantity,
this.lowerCircuitLimit,
this.upperCircuitLimit,
this.lastTradeTime,
this.oiDayHigh,
this.oiDayLow});
NSEINDEXNiftyBank.fromJson(Map<String, dynamic> json) {
ohlc = json['ohlc'] != null ? new Ohlc.fromJson(json['ohlc']) : null;
timestamp = json['timestamp'];
instrumentToken = json['instrument_token'];
symbol = json['symbol'];
lastPrice = json['last_price'];
volume = json['volume'];
averagePrice = json['average_price'];
oi = json['oi'];
netChange = json['net_change'];
totalBuyQuantity = json['total_buy_quantity'];
totalSellQuantity = json['total_sell_quantity'];
lowerCircuitLimit = json['lower_circuit_limit'];
upperCircuitLimit = json['upper_circuit_limit'];
lastTradeTime = json['last_trade_time'];
oiDayHigh = json['oi_day_high'];
oiDayLow = json['oi_day_low'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.ohlc != null) {
data['ohlc'] = this.ohlc!.toJson();
}
data['timestamp'] = this.timestamp;
data['instrument_token'] = this.instrumentToken;
data['symbol'] = this.symbol;
data['last_price'] = this.lastPrice;
data['volume'] = this.volume;
data['average_price'] = this.averagePrice;
data['oi'] = this.oi;
data['net_change'] = this.netChange;
data['total_buy_quantity'] = this.totalBuyQuantity;
data['total_sell_quantity'] = this.totalSellQuantity;
data['lower_circuit_limit'] = this.lowerCircuitLimit;
data['upper_circuit_limit'] = this.upperCircuitLimit;
data['last_trade_time'] = this.lastTradeTime;
data['oi_day_high'] = this.oiDayHigh;
data['oi_day_low'] = this.oiDayLow;
return data;
}
}
class Ohlc {
double? open;
double? high;
double? low;
double? close;
Ohlc({this.open, this.high, this.low, this.close});
Ohlc.fromJson(Map<String, dynamic> json) {
open = json['open'];
high = json['high'];
low = json['low'];
close = json['close'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['open'] = this.open;
data['high'] = this.high;
data['low'] = this.low;
data['close'] = this.close;
return data;
}
}
class NSEINDEXNifty50 {
Ohlc? ohlc;
String? timestamp;
String? instrumentToken;
String? symbol;
double? lastPrice;
Null? volume;
Null? averagePrice;
Null? oi;
double? netChange;
String? totalBuyQuantity;
String? totalSellQuantity;
String? lowerCircuitLimit;
String? upperCircuitLimit;
String? lastTradeTime;
String? oiDayHigh;
String? oiDayLow;
NSEINDEXNifty50(
{this.ohlc,
this.timestamp,
this.instrumentToken,
this.symbol,
this.lastPrice,
this.volume,
this.averagePrice,
this.oi,
this.netChange,
this.totalBuyQuantity,
this.totalSellQuantity,
this.lowerCircuitLimit,
this.upperCircuitLimit,
this.lastTradeTime,
this.oiDayHigh,
this.oiDayLow});
NSEINDEXNifty50.fromJson(Map<String, dynamic> json) {
ohlc = json['ohlc'] != null ? new Ohlc.fromJson(json['ohlc']) : null;
timestamp = json['timestamp'];
instrumentToken = json['instrument_token'];
symbol = json['symbol'];
lastPrice = json['last_price'];
volume = json['volume'];
averagePrice = json['average_price'];
oi = json['oi'];
netChange = json['net_change'];
totalBuyQuantity = json['total_buy_quantity'];
totalSellQuantity = json['total_sell_quantity'];
lowerCircuitLimit = json['lower_circuit_limit'];
upperCircuitLimit = json['upper_circuit_limit'];
lastTradeTime = json['last_trade_time'];
oiDayHigh = json['oi_day_high'];
oiDayLow = json['oi_day_low'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.ohlc != null) {
data['ohlc'] = this.ohlc!.toJson();
}
data['timestamp'] = this.timestamp;
data['instrument_token'] = this.instrumentToken;
data['symbol'] = this.symbol;
data['last_price'] = this.lastPrice;
data['volume'] = this.volume;
data['average_price'] = this.averagePrice;
data['oi'] = this.oi;
data['net_change'] = this.netChange;
data['total_buy_quantity'] = this.totalBuyQuantity;
data['total_sell_quantity'] = this.totalSellQuantity;
data['lower_circuit_limit'] = this.lowerCircuitLimit;
data['upper_circuit_limit'] = this.upperCircuitLimit;
data['last_trade_time'] = this.lastTradeTime;
data['oi_day_high'] = this.oiDayHigh;
data['oi_day_low'] = this.oiDayLow;
return data;
}
}
@@ -486,14 +609,14 @@ class UserData {
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['first_name'] = firstName;
data['last_name'] = lastName;
data['user_name'] = userName;
data['profile_photo'] = profilePhoto;
data['is_active'] = isActive;
data['created_at'] = createdAt;
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['first_name'] = this.firstName;
data['last_name'] = this.lastName;
data['user_name'] = this.userName;
data['profile_photo'] = this.profilePhoto;
data['is_active'] = this.isActive;
data['created_at'] = this.createdAt;
return data;
}
}
@@ -512,10 +635,10 @@ class Products {
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['title'] = title;
data['created_at'] = createdAt;
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['title'] = this.title;
data['created_at'] = this.createdAt;
return data;
}
}
@@ -561,18 +684,18 @@ class ContentByteVideo {
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['content_type'] = contentType;
data['title'] = title;
data['description'] = description;
data['tags'] = tags;
data['file'] = file;
data['category_id'] = categoryId;
data['image'] = image;
data['is_active'] = isActive;
data['created_at'] = createdAt;
data['link'] = link;
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['content_type'] = this.contentType;
data['title'] = this.title;
data['description'] = this.description;
data['tags'] = this.tags;
data['file'] = this.file;
data['category_id'] = this.categoryId;
data['image'] = this.image;
data['is_active'] = this.isActive;
data['created_at'] = this.createdAt;
data['link'] = this.link;
return data;
}
}

View File

@@ -8,6 +8,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:traderscircuit/Utils/Common/CommonBottomNavigation.dart';
import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart';
import 'package:traderscircuit/Utils/Common/sized_box.dart';
@@ -53,8 +54,12 @@ class _HomeScreenState extends State<HomeScreen> {
GetProfile().GetProfileAPI().then((value) {
userName.value = ProfileObj!.data!.userName ?? "User";
});
HomeApi().getHomeData().then((value) {
HomeApi().getHomeData().then((value) async {
homeModel = HomeModel.fromJson(value.data);
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString(
'upstocksAccessToken', homeModel.data!.upstoxAccessToken!);
await prefs.setString('upstocksApiKey', homeModel.data!.upstoxSecretKey!);
productsController.isUpstoxTokenNotExpired.value =
homeModel.data!.isUpstoxTokenRefreshed!;
isApiCalling.value = false;
@@ -602,7 +607,7 @@ Widget cardcallWidget(
required String action}) {
return Container(
width: 398,
height: 251,
height: 261,
decoration: ShapeDecoration(
color: const Color(0x232C79ED),
shape: RoundedRectangleBorder(
@@ -687,7 +692,7 @@ Widget cardcallWidget(
Get.to(const ExploreUnseen());
},
child: Container(
height: 52,
height: 50,
width: 150,
decoration: ShapeDecoration(
color: const Color(0xFF0093FF),

View File

@@ -272,7 +272,8 @@ class _ShortTradeState extends State<ShortTrade> {
.data!.activeCalls![index].stockImage!,
text: callRecommendationsModel
.data!.activeCalls![index].stockName!,
amount: '₹ 196.50 - ₹ 197',
amount:
'${callRecommendationsModel.data!.activeCalls![index].buyPrice}',
targetamount:
'${callRecommendationsModel.data!.activeCalls![index].targetPrice}',
stoploss:
@@ -282,7 +283,7 @@ class _ShortTradeState extends State<ShortTrade> {
action: callRecommendationsModel
.data!.activeCalls![index].actionData!.name!,
)
: Text("Please Subscribe to Swing traxde")
: Text("Please Subscribe to Swing trade")
: productsController.selectedIndex.value == 1
? ProfileObj!.data!.subscriptionData!.productData!
.productName! ==
@@ -916,7 +917,7 @@ class _ShortTradeState extends State<ShortTrade> {
child: Container(
padding: const EdgeInsets.all(15),
width: 398,
height: 285,
height: 300,
decoration: ShapeDecoration(
color: const Color(0x232C79ED),
shape: RoundedRectangleBorder(
@@ -944,10 +945,13 @@ class _ShortTradeState extends State<ShortTrade> {
color: Colors.white.withOpacity(0.30000001192092896),
),
const Gap(10),
text16W700(text),
SizedBox(
width: 150,
child: text16W700(text),
),
const Spacer(),
Container(
width: 62.w,
width: 60.w,
height: 25.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.r),
@@ -965,10 +969,10 @@ class _ShortTradeState extends State<ShortTrade> {
: const Color(0Xff1B1B1B),
)),
),
const Gap(15),
const Gap(10),
],
),
const Gap(30),
const Gap(20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -980,13 +984,13 @@ class _ShortTradeState extends State<ShortTrade> {
text12W400_979797('Entry Price'),
],
),
const Gap(10),
const Gap(8),
Container(
width: 2,
height: 35,
color: Colors.white.withOpacity(0.30000001192092896),
),
const Gap(10),
const Gap(8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -1004,7 +1008,7 @@ class _ShortTradeState extends State<ShortTrade> {
// const Gap(10),
],
),
const Gap(10),
const Gap(8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -1013,7 +1017,7 @@ class _ShortTradeState extends State<ShortTrade> {
text12W400_979797('Stop Loss'),
],
),
const Gap(30),
const Gap(25),
Container(
width: 398,
height: 52,

View File

@@ -6,11 +6,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart' hide FormData;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:traderscircuit/Utils/text.dart';
import 'package:traderscircuit/Utils/utils.dart';
import 'package:traderscircuit/controller/products_controller.dart';
import 'package:traderscircuit/model/StockDetailsModel/stock_details_model.dart';
import 'package:traderscircuit/resources/routes/route_name.dart';
import 'package:traderscircuit/view/MainScreen/stockDetails/upstock_websocket.dart';
import 'package:traderscircuit/view_model/StockDetailsApi/stock_details_api.dart';
import '../../../Utils/Common/CommonAppBar.dart';
@@ -29,8 +30,10 @@ class _StockDetailsScreenState extends State<StockDetailsScreen> {
String instrumentName = Get.arguments["instrument_name"];
String percentageDifference = "";
String netChange = "";
// late IO.Socket socket;
ProductsController productsController = Get.put(ProductsController());
UpstoxWebSocket? upstoxWebSocket;
@override
void initState() {
@@ -96,6 +99,8 @@ class _StockDetailsScreenState extends State<StockDetailsScreen> {
isLoading.value = false;
});
// initializeWebSocket();
} else {
isLoading.value = false;
}
@@ -109,6 +114,24 @@ class _StockDetailsScreenState extends State<StockDetailsScreen> {
percentageDifference = percentageChange.toStringAsFixed(2);
}
Future<void> initializeWebSocket() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String? upstocksAccessToken = prefs.getString('upstocksAccessToken');
String? upstocksApiKey = prefs.getString('upstocksApiKey');
final apiKey = upstocksApiKey;
final accessToken = upstocksAccessToken;
upstoxWebSocket = UpstoxWebSocket(
apiKey: apiKey!,
accessToken: accessToken!,
instrument: instrumentName,
);
upstoxWebSocket?.connect();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -234,7 +257,6 @@ class _StockDetailsScreenState extends State<StockDetailsScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16W700(
stockDetailsModel!.data!.stockData!.symbol!),
const Gap(14),
@@ -371,7 +393,6 @@ class _StockDetailsScreenState extends State<StockDetailsScreen> {
return const FlLine(
color: Color(
0xff37434d,
),
strokeWidth: 1,
);

View File

@@ -0,0 +1,44 @@
import 'dart:convert';
import 'package:web_socket_channel/web_socket_channel.dart';
class UpstoxWebSocket {
final String apiKey;
final String accessToken;
final String instrument;
WebSocketChannel? _channel;
UpstoxWebSocket({
required this.apiKey,
required this.accessToken,
required this.instrument,
});
void connect() {
final url =
'wss://api.upstox.com/live/v1/feed?apiKey=$apiKey&accessToken=$accessToken';
_channel = WebSocketChannel.connect(Uri.parse(url));
_channel?.sink.add(json.encode({
"guid": "someguid",
"method": "subscribe",
"data": {
"mode": "full",
"instrumentKeys": instrument,
}
}));
_channel?.stream.listen((data) {
print('Received: $data');
// Handle incoming data
}, onError: (error) {
print('Error: $error');
}, onDone: () {
print('WebSocket closed');
});
}
void disconnect() {
_channel?.sink.close();
}
}

View File

@@ -69,6 +69,7 @@ class _VerifyOTPState extends State<VerifyOTP> {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString(
'accessToken', resp.data["data"]["access-token"]);
isProfileUpdated == 0
? Get.toNamed(RouteName.adddetails)

View File

@@ -357,10 +357,10 @@ packages:
dependency: transitive
description:
name: firebase_core_web
sha256: c8e1d59385eee98de63c92f961d2a7062c5d9a65e7f45bdc7f1b0b205aab2492
sha256: "22fcb352744908224fc7be3caae254836099786acfe5df6e9fe901e9c2575a41"
url: "https://pub.dev"
source: hosted
version: "2.11.5"
version: "2.17.1"
firebase_crashlytics:
dependency: "direct main"
description:
@@ -808,6 +808,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.10"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
lottie:
dependency: "direct main"
description:
@@ -1141,6 +1149,22 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
socket_io_client:
dependency: "direct main"
description:
name: socket_io_client
sha256: ede469f3e4c55e8528b4e023bdedbc20832e8811ab9b61679d1ba3ed5f01f23b
url: "https://pub.dev"
source: hosted
version: "2.0.3+1"
socket_io_common:
dependency: transitive
description:
name: socket_io_common
sha256: "2ab92f8ff3ebbd4b353bf4a98bee45cc157e3255464b2f90f66e09c4472047eb"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
source_span:
dependency: transitive
description:
@@ -1498,10 +1522,26 @@ packages:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "0.5.1"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
url: "https://pub.dev"
source: hosted
version: "0.1.5"
web_socket_channel:
dependency: "direct main"
description:
name: web_socket_channel
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
url: "https://pub.dev"
source: hosted
version: "3.0.0"
win32:
dependency: transitive
description:
@@ -1527,5 +1567,5 @@ packages:
source: hosted
version: "6.3.0"
sdks:
dart: ">=3.2.0 <4.0.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.16.0"

View File

@@ -61,6 +61,8 @@ dependencies:
syncfusion_flutter_charts: ^21.2.4
flutter_inappwebview: ^6.0.0
flutter_branch_sdk: ^7.1.0
socket_io_client: ^2.0.3+1
web_socket_channel: ^3.0.0
dev_dependencies: