Closed sakibguy closed 1 year ago
SendData
Parser/Modelimport 'data_source.dart';
class SendData {
bool? success;
SendDataSource? dataSource;
SendData({this.success, this.dataSource});
factory SendData.fromJson(Map<String, dynamic> json) => SendData(
success: json['success'] as bool?,
dataSource: json['dataSource'] == null
? null
: SendDataSource.fromJson(
json['dataSource'] as Map<String, dynamic>),
);
Map<String, dynamic> toJson() => {
'success': success,
'dataSource': dataSource?.toJson(),
};
}
SendDataSource
Parser/Modelimport 'package:myalice/models/responseModels/sendChats/data.dart';
import 'admin_info.dart';
class SendDataSource {
dynamic id;
String? type;
String? source;
String? platformType;
int? platformId;
int? customerId;
int? projectId;
Data? data;
String? conversationId;
int? timestamp;
int? adminId;
AdminInfo? adminInfo;
dynamic success;
String? pusherKey;
SendDataSource({
this.id,
this.type,
this.source,
this.platformType,
this.platformId,
this.customerId,
this.projectId,
this.data,
this.conversationId,
this.timestamp,
this.adminId,
this.adminInfo,
this.success,
this.pusherKey,
});
factory SendDataSource.fromJson(Map<String, dynamic> json) => SendDataSource(
id: json['_id'],
type: json['type'] as String?,
source: json['source'] as String?,
platformType: json['platform_type'] as String?,
platformId: json['platform_id'] as int?,
customerId: json['customer_id'] as int?,
projectId: json['project_id'] as int?,
data: json['data'] == null
? null
: Data.fromJson(json['data'] as Map<String, dynamic>),
conversationId: json['conversation_id'] as String?,
timestamp: json['timestamp'] as int?,
adminId: json['admin_id'] as int?,
adminInfo: json['admin_info'] == null
? null
: AdminInfo.fromJson(json['admin_info'] as Map<String, dynamic>),
success: json['success'],
pusherKey: json['pusher_key'] as String?,
);
Map<String, dynamic> toJson() => {
'_id': id,
'type': type,
'source': source,
'platform_type': platformType,
'platform_id': platformId,
'customer_id': customerId,
'project_id': projectId,
'data': data?.toJson(),
'conversation_id': conversationId,
'timestamp': timestamp,
'admin_id': adminId,
'admin_info': adminInfo?.toJson(),
'success': success,
'pusher_key': pusherKey,
};
}
As _id: null might lead parse failed to SendDataSource. But couldn't be as defined dynamic (null value acceptable too) dynamic id;
{success: true, dataSource: {_id: null, type: message, source: admin, platform_type: facebook_messenger, platform_id: 1361, customer_id: 1043, project_id: 375, data: {type: text, data: {text: b3}}, conversation_id: m_iUuuVitsngrL4oRDvz7V3k6MoMJwaz_uVqGmpI3rBU_Pe_4zwKGNL4mH2LKJM1S_OLTSzBvNu-k5Y9w47sdu2g, timestamp: 1671283144708, admin_id: 256, admin_info: {id: 256, email: masuma+1@myalice.ai, avatar: https://s3-ap-southeast-1.amazonaws.com/stage-alice-v3/misc/7f2bdade109811ecabd40242c0a82005.jpeg, full_name: Masuma Imu}, success: null, pusher_key: 98d0990d74984ab2be8a047f62cd43c9}}
I/flutter (14212): [---ok---] sendConvText(): 1
{success: true, dataSource: {_id: null, type: message, source: admin, platform_type: facebook_messenger, platform_id: 1361, customer_id: 1043, project_id: 375, data: {type: text, data: {sub_type: null, urls: null, text: b6}}, conversation_id: m_iUuuVitsngrL4oRDvz7V3k6MoMJwaz_uVqGmpI3rBU_Pe_4zwKGNL4mH2LKJM1S_OLTSzBvNu-k5Y9w47sdu2g, timestamp: 1671286813177, admin_id: 256, admin_info: {id: 256, email: masuma+1@myalice.ai, avatar: https://s3-ap-southeast-1.amazonaws.com/stage-alice-v3/misc/7f2bdade109811ecabd40242c0a82005.jpeg, full_name: Masuma Imu}, success: null, pusher_key: ade1f14b049d4809be431544d45f7e83}}
Ignore now because https://github.com/sakibguy/worked-issues/issues/111#issuecomment-1356781365
PROB
I/flutter (14212): [---ok---] sendChats: 2 {success: true, dataSource: {_id: null, type: message, source: admin, platform_type: facebook_messenger, platform_id: 1361, customer_id: 1043, project_id: 375, data: {type: text, data: {text: b3}}, conversation_id: m_iUuuVitsngrL4oRDvz7V3k6MoMJwaz_uVqGmpI3rBU_Pe_4zwKGNL4mH2LKJM1S_OLTSzBvNu-k5Y9w47sdu2g, timestamp: 1671283144708, admin_id: 256, admin_info: {id: 256, email: masuma+1@myalice.ai, avatar: https://s3-ap-southeast-1.amazonaws.com/stage-alice-v3/misc/7f2bdade109811ecabd40242c0a82005.jpeg, full_name: Masuma Imu}, success: null, pusher_key: 98d0990d74984ab2be8a047f62cd43c9}}
SNaP