Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naif/add new get_limits models. #300

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 231 additions & 0 deletions lib/api/response/get_limits_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ abstract class GetLimitsModel {
this.dailyTransfers,
this.dailyTurnover,
this.lifetimeLimit,
this.lifetimeTransfers,
this.marketSpecific,
this.numOfDays,
this.numOfDaysLimit,
Expand Down Expand Up @@ -113,6 +114,9 @@ abstract class GetLimitsModel {
/// Lifetime withdrawal limit
final double? lifetimeLimit;

/// Lifetime transfer limits. Only present when applicable to the current accout.
final LifetimeTransfers? lifetimeTransfers;

/// Contains limitation information for each market.
final Map<String, List<MarketSpecificPropertyItem>>? marketSpecific;

Expand Down Expand Up @@ -153,6 +157,7 @@ class GetLimits extends GetLimitsModel {
super.dailyTransfers,
super.dailyTurnover,
super.lifetimeLimit,
super.lifetimeTransfers,
super.marketSpecific,
super.numOfDays,
super.numOfDaysLimit,
Expand All @@ -173,6 +178,9 @@ class GetLimits extends GetLimitsModel {
dailyTransfers: json['daily_transfers'],
dailyTurnover: getDouble(json['daily_turnover']),
lifetimeLimit: getDouble(json['lifetime_limit']),
lifetimeTransfers: json['lifetime_transfers'] == null
? null
: LifetimeTransfers.fromJson(json['lifetime_transfers']),
marketSpecific: json['market_specific'] == null
? null
: Map<String, List<MarketSpecificPropertyItem>>.fromEntries(json[
Expand Down Expand Up @@ -214,6 +222,9 @@ class GetLimits extends GetLimitsModel {
resultMap['daily_transfers'] = dailyTransfers;
resultMap['daily_turnover'] = dailyTurnover;
resultMap['lifetime_limit'] = lifetimeLimit;
if (lifetimeTransfers != null) {
resultMap['lifetime_transfers'] = lifetimeTransfers!.toJson();
}
resultMap['market_specific'] = marketSpecific;
resultMap['num_of_days'] = numOfDays;
resultMap['num_of_days_limit'] = numOfDaysLimit;
Expand All @@ -239,6 +250,7 @@ class GetLimits extends GetLimitsModel {
Map<String, dynamic>? dailyTransfers,
double? dailyTurnover,
double? lifetimeLimit,
LifetimeTransfers? lifetimeTransfers,
Map<String, List<MarketSpecificPropertyItem>>? marketSpecific,
int? numOfDays,
double? numOfDaysLimit,
Expand All @@ -257,6 +269,7 @@ class GetLimits extends GetLimitsModel {
dailyTransfers: dailyTransfers ?? this.dailyTransfers,
dailyTurnover: dailyTurnover ?? this.dailyTurnover,
lifetimeLimit: lifetimeLimit ?? this.lifetimeLimit,
lifetimeTransfers: lifetimeTransfers ?? this.lifetimeTransfers,
marketSpecific: marketSpecific ?? this.marketSpecific,
numOfDays: numOfDays ?? this.numOfDays,
numOfDaysLimit: numOfDaysLimit ?? this.numOfDaysLimit,
Expand All @@ -272,6 +285,224 @@ class GetLimits extends GetLimitsModel {
this.withdrawalSinceInceptionMonetary,
);
}
/// Lifetime transfers model class.
abstract class LifetimeTransfersModel {
/// Initializes Lifetime transfers model class .
const LifetimeTransfersModel({
this.cryptoToCrypto,
this.cryptoToFiat,
this.fiatToCrypto,
});

/// Lifetime transfer limit for crypto to crypto currencies.
final CryptoToCrypto? cryptoToCrypto;

/// Lifetime transfer limit for crypto to fiat currencies.
final CryptoToFiat? cryptoToFiat;

/// Lifetime transfer limit for fiat to crypto currencies.
final FiatToCrypto? fiatToCrypto;
}

/// Lifetime transfers class.
class LifetimeTransfers extends LifetimeTransfersModel {
/// Initializes Lifetime transfers class.
const LifetimeTransfers({
super.cryptoToCrypto,
super.cryptoToFiat,
super.fiatToCrypto,
});

/// Creates an instance from JSON.
factory LifetimeTransfers.fromJson(Map<String, dynamic> json) =>
LifetimeTransfers(
cryptoToCrypto: json['crypto_to_crypto'] == null
? null
: CryptoToCrypto.fromJson(json['crypto_to_crypto']),
cryptoToFiat: json['crypto_to_fiat'] == null
? null
: CryptoToFiat.fromJson(json['crypto_to_fiat']),
fiatToCrypto: json['fiat_to_crypto'] == null
? null
: FiatToCrypto.fromJson(json['fiat_to_crypto']),
);

/// Converts an instance to JSON.
Map<String, dynamic> toJson() {
final Map<String, dynamic> resultMap = <String, dynamic>{};

if (cryptoToCrypto != null) {
resultMap['crypto_to_crypto'] = cryptoToCrypto!.toJson();
}
if (cryptoToFiat != null) {
resultMap['crypto_to_fiat'] = cryptoToFiat!.toJson();
}
if (fiatToCrypto != null) {
resultMap['fiat_to_crypto'] = fiatToCrypto!.toJson();
}

return resultMap;
}

/// Creates a copy of instance with given parameters.
LifetimeTransfers copyWith({
CryptoToCrypto? cryptoToCrypto,
CryptoToFiat? cryptoToFiat,
FiatToCrypto? fiatToCrypto,
}) =>
LifetimeTransfers(
cryptoToCrypto: cryptoToCrypto ?? this.cryptoToCrypto,
cryptoToFiat: cryptoToFiat ?? this.cryptoToFiat,
fiatToCrypto: fiatToCrypto ?? this.fiatToCrypto,
);
}
/// Crypto to crypto model class.
abstract class CryptoToCryptoModel {
/// Initializes Crypto to crypto model class .
const CryptoToCryptoModel({
this.allowed,
this.available,
});

/// Total limit in client's currency.
final double? allowed;

/// Remaining limit in client's currency.
final double? available;
}

/// Crypto to crypto class.
class CryptoToCrypto extends CryptoToCryptoModel {
/// Initializes Crypto to crypto class.
const CryptoToCrypto({
super.allowed,
super.available,
});

/// Creates an instance from JSON.
factory CryptoToCrypto.fromJson(Map<String, dynamic> json) => CryptoToCrypto(
allowed: getDouble(json['allowed']),
available: getDouble(json['available']),
);

/// Converts an instance to JSON.
Map<String, dynamic> toJson() {
final Map<String, dynamic> resultMap = <String, dynamic>{};

resultMap['allowed'] = allowed;
resultMap['available'] = available;

return resultMap;
}

/// Creates a copy of instance with given parameters.
CryptoToCrypto copyWith({
double? allowed,
double? available,
}) =>
CryptoToCrypto(
allowed: allowed ?? this.allowed,
available: available ?? this.available,
);
}
/// Crypto to fiat model class.
abstract class CryptoToFiatModel {
/// Initializes Crypto to fiat model class .
const CryptoToFiatModel({
this.allowed,
this.available,
});

/// Total limit in client's currency.
final double? allowed;

/// Remaining limit in client's currency.
final double? available;
}

/// Crypto to fiat class.
class CryptoToFiat extends CryptoToFiatModel {
/// Initializes Crypto to fiat class.
const CryptoToFiat({
super.allowed,
super.available,
});

/// Creates an instance from JSON.
factory CryptoToFiat.fromJson(Map<String, dynamic> json) => CryptoToFiat(
allowed: getDouble(json['allowed']),
available: getDouble(json['available']),
);

/// Converts an instance to JSON.
Map<String, dynamic> toJson() {
final Map<String, dynamic> resultMap = <String, dynamic>{};

resultMap['allowed'] = allowed;
resultMap['available'] = available;

return resultMap;
}

/// Creates a copy of instance with given parameters.
CryptoToFiat copyWith({
double? allowed,
double? available,
}) =>
CryptoToFiat(
allowed: allowed ?? this.allowed,
available: available ?? this.available,
);
}
/// Fiat to crypto model class.
abstract class FiatToCryptoModel {
/// Initializes Fiat to crypto model class .
const FiatToCryptoModel({
this.allowed,
this.available,
});

/// Total limit in client's currency.
final double? allowed;

/// Remaining limit in client's currency.
final double? available;
}

/// Fiat to crypto class.
class FiatToCrypto extends FiatToCryptoModel {
/// Initializes Fiat to crypto class.
const FiatToCrypto({
super.allowed,
super.available,
});

/// Creates an instance from JSON.
factory FiatToCrypto.fromJson(Map<String, dynamic> json) => FiatToCrypto(
allowed: getDouble(json['allowed']),
available: getDouble(json['available']),
);

/// Converts an instance to JSON.
Map<String, dynamic> toJson() {
final Map<String, dynamic> resultMap = <String, dynamic>{};

resultMap['allowed'] = allowed;
resultMap['available'] = available;

return resultMap;
}

/// Creates a copy of instance with given parameters.
FiatToCrypto copyWith({
double? allowed,
double? available,
}) =>
FiatToCrypto(
allowed: allowed ?? this.allowed,
available: available ?? this.available,
);
}
/// Market specific property item model class.
abstract class MarketSpecificPropertyItemModel {
/// Initializes Market specific property item model class .
Expand Down
15 changes: 5 additions & 10 deletions lib/basic_api/generated/get_limits_receive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ class GetLimitsReceive extends Response {
/// Initialize GetLimitsReceive.
const GetLimitsReceive({
this.getLimits,
Map<String, dynamic>? echoReq,
Map<String, dynamic>? error,
String? msgType,
int? reqId,
}) : super(
echoReq: echoReq,
error: error,
msgType: msgType,
reqId: reqId,
);
super.echoReq,
super.error,
super.msgType,
super.reqId,
});

/// Creates an instance from JSON.
factory GetLimitsReceive.fromJson(Map<String, dynamic> json) =>
Expand Down
19 changes: 12 additions & 7 deletions lib/basic_api/generated/get_limits_send.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,27 @@ class GetLimitsRequest extends Request {
/// Initialize GetLimitsRequest.
const GetLimitsRequest({
this.getLimits = true,
Map<String, dynamic>? passthrough,
int? reqId,
}) : super(
msgType: 'get_limits',
passthrough: passthrough,
reqId: reqId,
);
this.loginid,
super.msgType = 'get_limits',
super.passthrough,
super.reqId,
});

/// Creates an instance from JSON.
factory GetLimitsRequest.fromJson(Map<String, dynamic> json) =>
GetLimitsRequest(
getLimits: json['get_limits'] == null ? null : json['get_limits'] == 1,
loginid: json['loginid'] as String?,
passthrough: json['passthrough'] as Map<String, dynamic>?,
reqId: json['req_id'] as int?,
);

/// Must be `true`
final bool? getLimits;

/// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id.
final String? loginid;

/// Converts this instance to JSON
@override
Map<String, dynamic> toJson() => <String, dynamic>{
Expand All @@ -36,6 +38,7 @@ class GetLimitsRequest extends Request {
: getLimits!
? 1
: 0,
'loginid': loginid,
'passthrough': passthrough,
'req_id': reqId,
};
Expand All @@ -44,11 +47,13 @@ class GetLimitsRequest extends Request {
@override
GetLimitsRequest copyWith({
bool? getLimits,
String? loginid,
Map<String, dynamic>? passthrough,
int? reqId,
}) =>
GetLimitsRequest(
getLimits: getLimits ?? this.getLimits,
loginid: loginid ?? this.loginid,
passthrough: passthrough ?? this.passthrough,
reqId: reqId ?? this.reqId,
);
Expand Down
Loading