ProductUpdateOptions.fromJson constructor

ProductUpdateOptions.fromJson(
  1. Object? json
)

Implementation

factory ProductUpdateOptions.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return ProductUpdateOptions(
    active: map['active'] == null ? null : (map['active'] as bool),
    defaultPrice: map['default_price'] == null
        ? null
        : (map['default_price'] as String),
    description:
        map['description'] == null ? null : (map['description'] as String),
    expand: map['expand'] == null
        ? null
        : (map['expand'] as List<Object?>)
            .map((el) => (el as String))
            .toList(),
    features: map['features'] == null
        ? null
        : (map['features'] as List<Object?>)
            .map((el) => ProductFeaturesItem.fromJson(el))
            .toList(),
    images: map['images'] == null
        ? null
        : (map['images'] 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),
                )),
    name: map['name'] == null ? null : (map['name'] as String),
    packageDimensions: map['package_dimensions'] == null
        ? null
        : PackageDimensions.fromJson(map['package_dimensions']),
    shippable: map['shippable'] == null ? null : (map['shippable'] as bool),
    statementDescriptor: map['statement_descriptor'] == null
        ? null
        : (map['statement_descriptor'] as String),
    taxCode: map['tax_code'] == null ? null : (map['tax_code'] as String),
    unitLabel:
        map['unit_label'] == null ? null : (map['unit_label'] as String),
    url: map['url'] == null ? null : (map['url'] as String),
  );
}