AnchorTransaction.fromJson constructor
AnchorTransaction.fromJson(
- Map<String, dynamic> json
)
Implementation
factory AnchorTransaction.fromJson(Map<String, dynamic> json) {
Map<String, dynamic>? instructionsJson =
json['instructions'] == null ? null : json['instructions'];
Map<String, DepositInstruction>? instructions;
if (instructionsJson != null) {
instructions = {};
instructionsJson.forEach((key, value) {
instructions![key] = DepositInstruction.fromJson(value);
});
}
Map<String, dynamic>? fieldsDynamic = json['required_info_updates'] == null
? null
: json['required_info_updates'];
// sometimes the fields are surrounded by another object 'transaction'
if (fieldsDynamic != null &&
fieldsDynamic.length == 1 &&
fieldsDynamic['transaction'] != null) {
fieldsDynamic = fieldsDynamic['transaction'];
}
Map<String, AnchorField>? infoUpFields;
if (fieldsDynamic != null) {
infoUpFields = {};
fieldsDynamic.forEach((key, value) {
infoUpFields![key] = AnchorField.fromJson(value);
});
}
return AnchorTransaction(
id: json['id'],
kind: json['kind'],
status: json['status'],
statusEta: convertInt(json['status_eta']),
moreInfoUrl: json['more_info_url'],
amountIn: json['amount_in'],
amountInAsset: json['amount_in_asset'],
amountOut: json['amount_out'],
amountOutAsset: json['amount_out_asset'],
amountFee: json['amount_fee'],
amountFeeAsset: json['amount_fee_asset'],
feeDetails: json['fee_details'] == null
? null
: FeeDetails.fromJson(json['fee_details']),
quoteId: json['quote_id'],
from: json['from'],
to: json['to'],
externalExtra: json['external_extra'],
externalExtraText: json['external_extra_text'],
depositMemo: json['deposit_memo'],
depositMemoType: json['deposit_memo_type'],
withdrawAnchorAccount: json['withdraw_anchor_account'],
withdrawMemo: json['withdraw_memo'],
withdrawMemoType: json['withdraw_memo_type'],
startedAt: json['started_at'],
updatedAt: json['updated_at'],
completedAt: json['completed_at'],
stellarTransactionId: json['stellar_transaction_id'],
externalTransactionId: json['external_transaction_id'],
message: json['message'],
refunded: json['refunded'],
refunds: json['refunds'] == null
? null
: TransactionRefunds.fromJson(json['refunds']),
requiredInfoMessage: json['required_info_message'],
requiredInfoUpdates: infoUpFields,
instructions: instructions,
claimableBalanceId: json['claimable_balance_id']);
}