Skip to content

Commit 280b7ef

Browse files
Merge pull request #300 from naif-deriv/get_limits_update
Naif/add new `get_limits` models.
2 parents c9d1f69 + 98454be commit 280b7ef

File tree

3 files changed

+248
-17
lines changed

3 files changed

+248
-17
lines changed

lib/api/response/get_limits_response_result.dart

+231
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ abstract class GetLimitsModel {
8686
this.dailyTransfers,
8787
this.dailyTurnover,
8888
this.lifetimeLimit,
89+
this.lifetimeTransfers,
8990
this.marketSpecific,
9091
this.numOfDays,
9192
this.numOfDaysLimit,
@@ -113,6 +114,9 @@ abstract class GetLimitsModel {
113114
/// Lifetime withdrawal limit
114115
final double? lifetimeLimit;
115116

117+
/// Lifetime transfer limits. Only present when applicable to the current accout.
118+
final LifetimeTransfers? lifetimeTransfers;
119+
116120
/// Contains limitation information for each market.
117121
final Map<String, List<MarketSpecificPropertyItem>>? marketSpecific;
118122

@@ -153,6 +157,7 @@ class GetLimits extends GetLimitsModel {
153157
super.dailyTransfers,
154158
super.dailyTurnover,
155159
super.lifetimeLimit,
160+
super.lifetimeTransfers,
156161
super.marketSpecific,
157162
super.numOfDays,
158163
super.numOfDaysLimit,
@@ -173,6 +178,9 @@ class GetLimits extends GetLimitsModel {
173178
dailyTransfers: json['daily_transfers'],
174179
dailyTurnover: getDouble(json['daily_turnover']),
175180
lifetimeLimit: getDouble(json['lifetime_limit']),
181+
lifetimeTransfers: json['lifetime_transfers'] == null
182+
? null
183+
: LifetimeTransfers.fromJson(json['lifetime_transfers']),
176184
marketSpecific: json['market_specific'] == null
177185
? null
178186
: Map<String, List<MarketSpecificPropertyItem>>.fromEntries(json[
@@ -214,6 +222,9 @@ class GetLimits extends GetLimitsModel {
214222
resultMap['daily_transfers'] = dailyTransfers;
215223
resultMap['daily_turnover'] = dailyTurnover;
216224
resultMap['lifetime_limit'] = lifetimeLimit;
225+
if (lifetimeTransfers != null) {
226+
resultMap['lifetime_transfers'] = lifetimeTransfers!.toJson();
227+
}
217228
resultMap['market_specific'] = marketSpecific;
218229
resultMap['num_of_days'] = numOfDays;
219230
resultMap['num_of_days_limit'] = numOfDaysLimit;
@@ -239,6 +250,7 @@ class GetLimits extends GetLimitsModel {
239250
Map<String, dynamic>? dailyTransfers,
240251
double? dailyTurnover,
241252
double? lifetimeLimit,
253+
LifetimeTransfers? lifetimeTransfers,
242254
Map<String, List<MarketSpecificPropertyItem>>? marketSpecific,
243255
int? numOfDays,
244256
double? numOfDaysLimit,
@@ -257,6 +269,7 @@ class GetLimits extends GetLimitsModel {
257269
dailyTransfers: dailyTransfers ?? this.dailyTransfers,
258270
dailyTurnover: dailyTurnover ?? this.dailyTurnover,
259271
lifetimeLimit: lifetimeLimit ?? this.lifetimeLimit,
272+
lifetimeTransfers: lifetimeTransfers ?? this.lifetimeTransfers,
260273
marketSpecific: marketSpecific ?? this.marketSpecific,
261274
numOfDays: numOfDays ?? this.numOfDays,
262275
numOfDaysLimit: numOfDaysLimit ?? this.numOfDaysLimit,
@@ -272,6 +285,224 @@ class GetLimits extends GetLimitsModel {
272285
this.withdrawalSinceInceptionMonetary,
273286
);
274287
}
288+
/// Lifetime transfers model class.
289+
abstract class LifetimeTransfersModel {
290+
/// Initializes Lifetime transfers model class .
291+
const LifetimeTransfersModel({
292+
this.cryptoToCrypto,
293+
this.cryptoToFiat,
294+
this.fiatToCrypto,
295+
});
296+
297+
/// Lifetime transfer limit for crypto to crypto currencies.
298+
final CryptoToCrypto? cryptoToCrypto;
299+
300+
/// Lifetime transfer limit for crypto to fiat currencies.
301+
final CryptoToFiat? cryptoToFiat;
302+
303+
/// Lifetime transfer limit for fiat to crypto currencies.
304+
final FiatToCrypto? fiatToCrypto;
305+
}
306+
307+
/// Lifetime transfers class.
308+
class LifetimeTransfers extends LifetimeTransfersModel {
309+
/// Initializes Lifetime transfers class.
310+
const LifetimeTransfers({
311+
super.cryptoToCrypto,
312+
super.cryptoToFiat,
313+
super.fiatToCrypto,
314+
});
315+
316+
/// Creates an instance from JSON.
317+
factory LifetimeTransfers.fromJson(Map<String, dynamic> json) =>
318+
LifetimeTransfers(
319+
cryptoToCrypto: json['crypto_to_crypto'] == null
320+
? null
321+
: CryptoToCrypto.fromJson(json['crypto_to_crypto']),
322+
cryptoToFiat: json['crypto_to_fiat'] == null
323+
? null
324+
: CryptoToFiat.fromJson(json['crypto_to_fiat']),
325+
fiatToCrypto: json['fiat_to_crypto'] == null
326+
? null
327+
: FiatToCrypto.fromJson(json['fiat_to_crypto']),
328+
);
329+
330+
/// Converts an instance to JSON.
331+
Map<String, dynamic> toJson() {
332+
final Map<String, dynamic> resultMap = <String, dynamic>{};
333+
334+
if (cryptoToCrypto != null) {
335+
resultMap['crypto_to_crypto'] = cryptoToCrypto!.toJson();
336+
}
337+
if (cryptoToFiat != null) {
338+
resultMap['crypto_to_fiat'] = cryptoToFiat!.toJson();
339+
}
340+
if (fiatToCrypto != null) {
341+
resultMap['fiat_to_crypto'] = fiatToCrypto!.toJson();
342+
}
343+
344+
return resultMap;
345+
}
346+
347+
/// Creates a copy of instance with given parameters.
348+
LifetimeTransfers copyWith({
349+
CryptoToCrypto? cryptoToCrypto,
350+
CryptoToFiat? cryptoToFiat,
351+
FiatToCrypto? fiatToCrypto,
352+
}) =>
353+
LifetimeTransfers(
354+
cryptoToCrypto: cryptoToCrypto ?? this.cryptoToCrypto,
355+
cryptoToFiat: cryptoToFiat ?? this.cryptoToFiat,
356+
fiatToCrypto: fiatToCrypto ?? this.fiatToCrypto,
357+
);
358+
}
359+
/// Crypto to crypto model class.
360+
abstract class CryptoToCryptoModel {
361+
/// Initializes Crypto to crypto model class .
362+
const CryptoToCryptoModel({
363+
this.allowed,
364+
this.available,
365+
});
366+
367+
/// Total limit in client's currency.
368+
final double? allowed;
369+
370+
/// Remaining limit in client's currency.
371+
final double? available;
372+
}
373+
374+
/// Crypto to crypto class.
375+
class CryptoToCrypto extends CryptoToCryptoModel {
376+
/// Initializes Crypto to crypto class.
377+
const CryptoToCrypto({
378+
super.allowed,
379+
super.available,
380+
});
381+
382+
/// Creates an instance from JSON.
383+
factory CryptoToCrypto.fromJson(Map<String, dynamic> json) => CryptoToCrypto(
384+
allowed: getDouble(json['allowed']),
385+
available: getDouble(json['available']),
386+
);
387+
388+
/// Converts an instance to JSON.
389+
Map<String, dynamic> toJson() {
390+
final Map<String, dynamic> resultMap = <String, dynamic>{};
391+
392+
resultMap['allowed'] = allowed;
393+
resultMap['available'] = available;
394+
395+
return resultMap;
396+
}
397+
398+
/// Creates a copy of instance with given parameters.
399+
CryptoToCrypto copyWith({
400+
double? allowed,
401+
double? available,
402+
}) =>
403+
CryptoToCrypto(
404+
allowed: allowed ?? this.allowed,
405+
available: available ?? this.available,
406+
);
407+
}
408+
/// Crypto to fiat model class.
409+
abstract class CryptoToFiatModel {
410+
/// Initializes Crypto to fiat model class .
411+
const CryptoToFiatModel({
412+
this.allowed,
413+
this.available,
414+
});
415+
416+
/// Total limit in client's currency.
417+
final double? allowed;
418+
419+
/// Remaining limit in client's currency.
420+
final double? available;
421+
}
422+
423+
/// Crypto to fiat class.
424+
class CryptoToFiat extends CryptoToFiatModel {
425+
/// Initializes Crypto to fiat class.
426+
const CryptoToFiat({
427+
super.allowed,
428+
super.available,
429+
});
430+
431+
/// Creates an instance from JSON.
432+
factory CryptoToFiat.fromJson(Map<String, dynamic> json) => CryptoToFiat(
433+
allowed: getDouble(json['allowed']),
434+
available: getDouble(json['available']),
435+
);
436+
437+
/// Converts an instance to JSON.
438+
Map<String, dynamic> toJson() {
439+
final Map<String, dynamic> resultMap = <String, dynamic>{};
440+
441+
resultMap['allowed'] = allowed;
442+
resultMap['available'] = available;
443+
444+
return resultMap;
445+
}
446+
447+
/// Creates a copy of instance with given parameters.
448+
CryptoToFiat copyWith({
449+
double? allowed,
450+
double? available,
451+
}) =>
452+
CryptoToFiat(
453+
allowed: allowed ?? this.allowed,
454+
available: available ?? this.available,
455+
);
456+
}
457+
/// Fiat to crypto model class.
458+
abstract class FiatToCryptoModel {
459+
/// Initializes Fiat to crypto model class .
460+
const FiatToCryptoModel({
461+
this.allowed,
462+
this.available,
463+
});
464+
465+
/// Total limit in client's currency.
466+
final double? allowed;
467+
468+
/// Remaining limit in client's currency.
469+
final double? available;
470+
}
471+
472+
/// Fiat to crypto class.
473+
class FiatToCrypto extends FiatToCryptoModel {
474+
/// Initializes Fiat to crypto class.
475+
const FiatToCrypto({
476+
super.allowed,
477+
super.available,
478+
});
479+
480+
/// Creates an instance from JSON.
481+
factory FiatToCrypto.fromJson(Map<String, dynamic> json) => FiatToCrypto(
482+
allowed: getDouble(json['allowed']),
483+
available: getDouble(json['available']),
484+
);
485+
486+
/// Converts an instance to JSON.
487+
Map<String, dynamic> toJson() {
488+
final Map<String, dynamic> resultMap = <String, dynamic>{};
489+
490+
resultMap['allowed'] = allowed;
491+
resultMap['available'] = available;
492+
493+
return resultMap;
494+
}
495+
496+
/// Creates a copy of instance with given parameters.
497+
FiatToCrypto copyWith({
498+
double? allowed,
499+
double? available,
500+
}) =>
501+
FiatToCrypto(
502+
allowed: allowed ?? this.allowed,
503+
available: available ?? this.available,
504+
);
505+
}
275506
/// Market specific property item model class.
276507
abstract class MarketSpecificPropertyItemModel {
277508
/// Initializes Market specific property item model class .

lib/basic_api/generated/get_limits_receive.dart

+5-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,11 @@ class GetLimitsReceive extends Response {
99
/// Initialize GetLimitsReceive.
1010
const GetLimitsReceive({
1111
this.getLimits,
12-
Map<String, dynamic>? echoReq,
13-
Map<String, dynamic>? error,
14-
String? msgType,
15-
int? reqId,
16-
}) : super(
17-
echoReq: echoReq,
18-
error: error,
19-
msgType: msgType,
20-
reqId: reqId,
21-
);
12+
super.echoReq,
13+
super.error,
14+
super.msgType,
15+
super.reqId,
16+
});
2217

2318
/// Creates an instance from JSON.
2419
factory GetLimitsReceive.fromJson(Map<String, dynamic> json) =>

lib/basic_api/generated/get_limits_send.dart

+12-7
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@ class GetLimitsRequest extends Request {
99
/// Initialize GetLimitsRequest.
1010
const GetLimitsRequest({
1111
this.getLimits = true,
12-
Map<String, dynamic>? passthrough,
13-
int? reqId,
14-
}) : super(
15-
msgType: 'get_limits',
16-
passthrough: passthrough,
17-
reqId: reqId,
18-
);
12+
this.loginid,
13+
super.msgType = 'get_limits',
14+
super.passthrough,
15+
super.reqId,
16+
});
1917

2018
/// Creates an instance from JSON.
2119
factory GetLimitsRequest.fromJson(Map<String, dynamic> json) =>
2220
GetLimitsRequest(
2321
getLimits: json['get_limits'] == null ? null : json['get_limits'] == 1,
22+
loginid: json['loginid'] as String?,
2423
passthrough: json['passthrough'] as Map<String, dynamic>?,
2524
reqId: json['req_id'] as int?,
2625
);
2726

2827
/// Must be `true`
2928
final bool? getLimits;
3029

30+
/// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id.
31+
final String? loginid;
32+
3133
/// Converts this instance to JSON
3234
@override
3335
Map<String, dynamic> toJson() => <String, dynamic>{
@@ -36,6 +38,7 @@ class GetLimitsRequest extends Request {
3638
: getLimits!
3739
? 1
3840
: 0,
41+
'loginid': loginid,
3942
'passthrough': passthrough,
4043
'req_id': reqId,
4144
};
@@ -44,11 +47,13 @@ class GetLimitsRequest extends Request {
4447
@override
4548
GetLimitsRequest copyWith({
4649
bool? getLimits,
50+
String? loginid,
4751
Map<String, dynamic>? passthrough,
4852
int? reqId,
4953
}) =>
5054
GetLimitsRequest(
5155
getLimits: getLimits ?? this.getLimits,
56+
loginid: loginid ?? this.loginid,
5257
passthrough: passthrough ?? this.passthrough,
5358
reqId: reqId ?? this.reqId,
5459
);

0 commit comments

Comments
 (0)