fromJson static method
Returns a new BillingPaymentAttempt instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static BillingPaymentAttempt? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key),
'Required key "BillingPaymentAttempt[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "BillingPaymentAttempt[$key]" has a null value in JSON.');
});
return true;
}());
return BillingPaymentAttempt(
object: BillingPaymentAttemptObjectEnum.fromJson(json[r'object'])!,
id: mapValueOfType<String>(json, r'id')!,
paymentId: mapValueOfType<String>(json, r'payment_id')!,
instanceId: mapValueOfType<String>(json, r'instance_id')!,
chargeType: mapValueOfType<String>(json, r'charge_type')!,
payeeId: mapValueOfType<String>(json, r'payee_id')!,
payee: mapValueOfType<Object>(json, r'payee')!,
payerId: mapValueOfType<String>(json, r'payer_id')!,
payer: CommercePayerResponse.fromJson(json[r'payer'])!,
subscriptionItemId:
mapValueOfType<String>(json, r'subscription_item_id'),
subscriptionItem: mapValueOfType<Object>(json, r'subscription_item'),
amount: CommerceMoneyResponse.fromJson(json[r'amount'])!,
paymentMethodId: mapValueOfType<String>(json, r'payment_method_id')!,
paymentMethod:
CommercePaymentMethodResponse.fromJson(json[r'payment_method'])!,
statementId: mapValueOfType<String>(json, r'statement_id')!,
gatewayExternalId: mapValueOfType<String>(json, r'gateway_external_id'),
gatewayExternalUrl:
mapValueOfType<String>(json, r'gateway_external_url'),
status: BillingPaymentAttemptStatusEnum.fromJson(json[r'status'])!,
paidAt: mapValueOfType<int>(json, r'paid_at'),
failedAt: mapValueOfType<int>(json, r'failed_at'),
createdAt: mapValueOfType<int>(json, r'created_at')!,
updatedAt: mapValueOfType<int>(json, r'updated_at')!,
);
}
return null;
}