Skip to content

Commit 3729f1f

Browse files
Merge pull request #302 from waqas-younas-deriv/bring_latest_api_playground_changes_in_flutter_deriv_api
waqas/apply_latest_deriv_api_playground_changes
2 parents 280b7ef + 0244d08 commit 3729f1f

File tree

439 files changed

+11553
-5276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

439 files changed

+11553
-5276
lines changed

lib/api/response/account_closure_response_result.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ abstract class AccountClosureResponseModel {
1919
class AccountClosureResponse extends AccountClosureResponseModel {
2020
/// Initializes Account closure response class.
2121
const AccountClosureResponse({
22-
bool? accountClosure,
23-
}) : super(
24-
accountClosure: accountClosure,
25-
);
22+
super.accountClosure,
23+
});
2624

2725
/// Creates an instance from JSON.
2826
factory AccountClosureResponse.fromJson(
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import
2+
3+
import 'package:equatable/equatable.dart';
4+
5+
import 'package:flutter_deriv_api/helpers/helpers.dart';
6+
7+
/// Account list response model class.
8+
abstract class AccountListResponseModel {
9+
/// Initializes Account list response model class .
10+
const AccountListResponseModel({
11+
this.accountList,
12+
});
13+
14+
/// List of accounts for current user. This is also available from the `authroize` call.
15+
final List<AccountListItem>? accountList;
16+
}
17+
18+
/// Account list response class.
19+
class AccountListResponse extends AccountListResponseModel {
20+
/// Initializes Account list response class.
21+
const AccountListResponse({
22+
super.accountList,
23+
});
24+
25+
/// Creates an instance from JSON.
26+
factory AccountListResponse.fromJson(
27+
dynamic accountListJson,
28+
) =>
29+
AccountListResponse(
30+
accountList: accountListJson == null
31+
? null
32+
: List<AccountListItem>.from(
33+
accountListJson?.map(
34+
(dynamic item) => AccountListItem.fromJson(item),
35+
),
36+
),
37+
);
38+
39+
/// Converts an instance to JSON.
40+
Map<String, dynamic> toJson() {
41+
final Map<String, dynamic> resultMap = <String, dynamic>{};
42+
43+
if (accountList != null) {
44+
resultMap['account_list'] = accountList!
45+
.map<dynamic>(
46+
(AccountListItem item) => item.toJson(),
47+
)
48+
.toList();
49+
}
50+
51+
return resultMap;
52+
}
53+
54+
/// Creates a copy of instance with given parameters.
55+
AccountListResponse copyWith({
56+
List<AccountListItem>? accountList,
57+
}) =>
58+
AccountListResponse(
59+
accountList: accountList ?? this.accountList,
60+
);
61+
}
62+
63+
/// AccountCategoryEnum mapper.
64+
final Map<String, AccountCategoryEnum> accountCategoryEnumMapper =
65+
<String, AccountCategoryEnum>{
66+
"trading": AccountCategoryEnum.trading,
67+
"wallet": AccountCategoryEnum.wallet,
68+
};
69+
70+
/// AccountCategory Enum.
71+
enum AccountCategoryEnum {
72+
/// trading.
73+
trading,
74+
75+
/// wallet.
76+
wallet,
77+
}
78+
79+
/// PlatformEnum mapper.
80+
final Map<String, PlatformEnum> platformEnumMapper = <String, PlatformEnum>{
81+
"ctrader": PlatformEnum.ctrader,
82+
"derivez": PlatformEnum.derivez,
83+
"dtrade": PlatformEnum.dtrade,
84+
"dwallet": PlatformEnum.dwallet,
85+
"dxtrade": PlatformEnum.dxtrade,
86+
"mt5": PlatformEnum.mt5,
87+
};
88+
89+
/// Platform Enum.
90+
enum PlatformEnum {
91+
/// ctrader.
92+
ctrader,
93+
94+
/// derivez.
95+
derivez,
96+
97+
/// dtrade.
98+
dtrade,
99+
100+
/// dwallet.
101+
dwallet,
102+
103+
/// dxtrade.
104+
dxtrade,
105+
106+
/// mt5.
107+
mt5,
108+
}
109+
/// Account list item model class.
110+
abstract class AccountListItemModel {
111+
/// Initializes Account list item model class .
112+
const AccountListItemModel({
113+
required this.loginid,
114+
required this.linkedTo,
115+
required this.landingCompanyName,
116+
required this.isVirtual,
117+
required this.isDisabled,
118+
required this.currency,
119+
required this.createdAt,
120+
required this.accountType,
121+
required this.accountCategory,
122+
this.broker,
123+
});
124+
125+
/// The account ID of specified account.
126+
final String loginid;
127+
128+
/// Details of the list of Trading accounts linked to the Wallet account.
129+
final List<LinkedToItem> linkedTo;
130+
131+
/// Landing company shortcode the account belongs to.
132+
final String landingCompanyName;
133+
134+
/// Boolean value: `true` or `false`, indicating whether the account is a virtual-money account.
135+
final bool isVirtual;
136+
137+
/// Boolean value: `true` or `false`, indicating whether the account is marked as disabled or not.
138+
final bool isDisabled;
139+
140+
/// Currency of specified account.
141+
final String currency;
142+
143+
/// Creation time of the account as epoch.
144+
final DateTime createdAt;
145+
146+
/// Account type.
147+
final String accountType;
148+
149+
/// Account category.
150+
final AccountCategoryEnum accountCategory;
151+
152+
/// 2 letter broker code.
153+
final String? broker;
154+
}
155+
156+
/// Account list item class.
157+
class AccountListItem extends AccountListItemModel {
158+
/// Initializes Account list item class.
159+
const AccountListItem({
160+
required super.accountCategory,
161+
required super.accountType,
162+
required super.createdAt,
163+
required super.currency,
164+
required super.isDisabled,
165+
required super.isVirtual,
166+
required super.landingCompanyName,
167+
required super.linkedTo,
168+
required super.loginid,
169+
super.broker,
170+
});
171+
172+
/// Creates an instance from JSON.
173+
factory AccountListItem.fromJson(Map<String, dynamic> json) =>
174+
AccountListItem(
175+
accountCategory: accountCategoryEnumMapper[json['account_category']]!,
176+
accountType: json['account_type'],
177+
createdAt: getDateTime(json['created_at'])!,
178+
currency: json['currency'],
179+
isDisabled: getBool(json['is_disabled'])!,
180+
isVirtual: getBool(json['is_virtual'])!,
181+
landingCompanyName: json['landing_company_name'],
182+
linkedTo: List<LinkedToItem>.from(
183+
json['linked_to'].map(
184+
(dynamic item) => LinkedToItem.fromJson(item),
185+
),
186+
),
187+
loginid: json['loginid'],
188+
broker: json['broker'],
189+
);
190+
191+
/// Converts an instance to JSON.
192+
Map<String, dynamic> toJson() {
193+
final Map<String, dynamic> resultMap = <String, dynamic>{};
194+
195+
resultMap['account_category'] = accountCategoryEnumMapper.entries
196+
.firstWhere((MapEntry<String, AccountCategoryEnum> entry) =>
197+
entry.value == accountCategory)
198+
.key;
199+
resultMap['account_type'] = accountType;
200+
resultMap['created_at'] = getSecondsSinceEpochDateTime(createdAt);
201+
resultMap['currency'] = currency;
202+
resultMap['is_disabled'] = isDisabled;
203+
resultMap['is_virtual'] = isVirtual;
204+
resultMap['landing_company_name'] = landingCompanyName;
205+
resultMap['linked_to'] = linkedTo
206+
.map<dynamic>(
207+
(LinkedToItem item) => item.toJson(),
208+
)
209+
.toList();
210+
211+
resultMap['loginid'] = loginid;
212+
resultMap['broker'] = broker;
213+
214+
return resultMap;
215+
}
216+
217+
/// Creates a copy of instance with given parameters.
218+
AccountListItem copyWith({
219+
AccountCategoryEnum? accountCategory,
220+
String? accountType,
221+
DateTime? createdAt,
222+
String? currency,
223+
bool? isDisabled,
224+
bool? isVirtual,
225+
String? landingCompanyName,
226+
List<LinkedToItem>? linkedTo,
227+
String? loginid,
228+
String? broker,
229+
}) =>
230+
AccountListItem(
231+
accountCategory: accountCategory ?? this.accountCategory,
232+
accountType: accountType ?? this.accountType,
233+
createdAt: createdAt ?? this.createdAt,
234+
currency: currency ?? this.currency,
235+
isDisabled: isDisabled ?? this.isDisabled,
236+
isVirtual: isVirtual ?? this.isVirtual,
237+
landingCompanyName: landingCompanyName ?? this.landingCompanyName,
238+
linkedTo: linkedTo ?? this.linkedTo,
239+
loginid: loginid ?? this.loginid,
240+
broker: broker ?? this.broker,
241+
);
242+
}
243+
/// Linked to item model class.
244+
abstract class LinkedToItemModel {
245+
/// Initializes Linked to item model class .
246+
const LinkedToItemModel({
247+
this.loginid,
248+
this.platform,
249+
});
250+
251+
/// Account ID.
252+
final String? loginid;
253+
254+
/// Account platform name.
255+
final PlatformEnum? platform;
256+
}
257+
258+
/// Linked to item class.
259+
class LinkedToItem extends LinkedToItemModel {
260+
/// Initializes Linked to item class.
261+
const LinkedToItem({
262+
super.loginid,
263+
super.platform,
264+
});
265+
266+
/// Creates an instance from JSON.
267+
factory LinkedToItem.fromJson(Map<String, dynamic> json) => LinkedToItem(
268+
loginid: json['loginid'],
269+
platform: json['platform'] == null
270+
? null
271+
: platformEnumMapper[json['platform']],
272+
);
273+
274+
/// Converts an instance to JSON.
275+
Map<String, dynamic> toJson() {
276+
final Map<String, dynamic> resultMap = <String, dynamic>{};
277+
278+
resultMap['loginid'] = loginid;
279+
resultMap['platform'] = platformEnumMapper.entries
280+
.firstWhere(
281+
(MapEntry<String, PlatformEnum> entry) => entry.value == platform)
282+
.key;
283+
284+
return resultMap;
285+
}
286+
287+
/// Creates a copy of instance with given parameters.
288+
LinkedToItem copyWith({
289+
String? loginid,
290+
PlatformEnum? platform,
291+
}) =>
292+
LinkedToItem(
293+
loginid: loginid ?? this.loginid,
294+
platform: platform ?? this.platform,
295+
);
296+
}

lib/api/response/account_security_response_result.dart

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ abstract class AccountSecurityResponseModel {
1919
class AccountSecurityResponse extends AccountSecurityResponseModel {
2020
/// Initializes Account security response class.
2121
const AccountSecurityResponse({
22-
AccountSecurity? accountSecurity,
23-
}) : super(
24-
accountSecurity: accountSecurity,
25-
);
22+
super.accountSecurity,
23+
});
2624

2725
/// Creates an instance from JSON.
2826
factory AccountSecurityResponse.fromJson(
@@ -68,10 +66,8 @@ abstract class AccountSecurityModel {
6866
class AccountSecurity extends AccountSecurityModel {
6967
/// Initializes Account security class.
7068
const AccountSecurity({
71-
Totp? totp,
72-
}) : super(
73-
totp: totp,
74-
);
69+
super.totp,
70+
});
7571

7672
/// Creates an instance from JSON.
7773
factory AccountSecurity.fromJson(Map<String, dynamic> json) =>
@@ -117,12 +113,9 @@ abstract class TotpModel {
117113
class Totp extends TotpModel {
118114
/// Initializes Totp class.
119115
const Totp({
120-
bool? isEnabled,
121-
String? secretKey,
122-
}) : super(
123-
isEnabled: isEnabled,
124-
secretKey: secretKey,
125-
);
116+
super.isEnabled,
117+
super.secretKey,
118+
});
126119

127120
/// Creates an instance from JSON.
128121
factory Totp.fromJson(Map<String, dynamic> json) => Totp(

lib/api/response/account_statistics_response_result.dart

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ abstract class AccountStatisticsResponseModel {
1919
class AccountStatisticsResponse extends AccountStatisticsResponseModel {
2020
/// Initializes Account statistics response class.
2121
const AccountStatisticsResponse({
22-
AccountStatistics? accountStatistics,
23-
}) : super(
24-
accountStatistics: accountStatistics,
25-
);
22+
super.accountStatistics,
23+
});
2624

2725
/// Creates an instance from JSON.
2826
factory AccountStatisticsResponse.fromJson(
@@ -76,14 +74,10 @@ abstract class AccountStatisticsModel {
7674
class AccountStatistics extends AccountStatisticsModel {
7775
/// Initializes Account statistics class.
7876
const AccountStatistics({
79-
String? currency,
80-
double? totalDeposits,
81-
double? totalWithdrawals,
82-
}) : super(
83-
currency: currency,
84-
totalDeposits: totalDeposits,
85-
totalWithdrawals: totalWithdrawals,
86-
);
77+
super.currency,
78+
super.totalDeposits,
79+
super.totalWithdrawals,
80+
});
8781

8882
/// Creates an instance from JSON.
8983
factory AccountStatistics.fromJson(Map<String, dynamic> json) =>

0 commit comments

Comments
 (0)