import 'package:json_annotation/json_annotation.dart';

part 'goods_bean.g.dart';

@JsonSerializable()
class GoodsBean {
  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'sort')
  int? sort;

  @JsonKey(name: 'name')
  String name;

  @JsonKey(name: 'level')
  int level;

  @JsonKey(name: 'description')
  String? description;

  @JsonKey(name: 'originalAmount')
  int originalAmount;

  @JsonKey(name: 'amount')
  int amount;

  @JsonKey(name: 'subscriptionMillis')
  int subscriptionMillis;

  @JsonKey(name: 'popular')
  bool popular;

  @JsonKey(name: 'newcomer')
  bool newcomer;

  @JsonKey(name: 'tag')
  String? tag;

  @JsonKey(name: 'appleGoodsId')
  String? appleGoodsId;

  GoodsBean(
      this.id,
      this.name,
      this.level,
      this.originalAmount,
      this.amount,
      this.subscriptionMillis,
      this.popular,
      this.newcomer,
      this.tag,
      this.appleGoodsId);

  factory GoodsBean.fromJson(Map<String, dynamic> json) =>
      _$GoodsBeanFromJson(json);

  GoodsBean copyWith() {
    return GoodsBean(
      id,
      name,
      level,
      originalAmount,
      amount,
      subscriptionMillis,
      popular,
      newcomer,
      tag,
      appleGoodsId,
    );
  }
}
