ClimateOrderCreateOptions.fromJson constructor

ClimateOrderCreateOptions.fromJson(
  1. Object? json
)

Implementation

factory ClimateOrderCreateOptions.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return ClimateOrderCreateOptions(
    amount: map['amount'] == null ? null : (map['amount'] as num).toInt(),
    beneficiary: map['beneficiary'] == null
        ? null
        : ClimateRemovalsBeneficiary.fromJson(map['beneficiary']),
    currency: map['currency'] == null ? null : (map['currency'] as String),
    expand: map['expand'] == null
        ? null
        : (map['expand'] as List<Object?>)
            .map((el) => (el as String))
            .toList(),
    metadata: map['metadata'] == null
        ? null
        : (map['metadata'] as Map).cast<String, Object?>().map((
              key,
              value,
            ) =>
                MapEntry(
                  key,
                  (value as String),
                )),
    metricTons:
        map['metric_tons'] == null ? null : (map['metric_tons'] as String),
    product: (map['product'] as String),
  );
}