pay_models.dart 4.46 KB
import 'package:json_annotation/json_annotation.dart';

part 'pay_models.g.dart';

@JsonSerializable()
class PayProductListResponse {
  const PayProductListResponse({this.productList});

  @JsonKey(name: 'product_list')
  final List<PayProduct>? productList;

  factory PayProductListResponse.fromJson(Map<String, dynamic> json) =>
      _$PayProductListResponseFromJson(json);
  Map<String, dynamic> toJson() => _$PayProductListResponseToJson(this);
}

@JsonSerializable()
class PayProduct {
  const PayProduct({
    this.id,
    this.name,
    this.profile,
    this.content,
    this.price,
    this.servePeriod,
    this.discountPrice,
    this.discountStartTime,
    this.discountEndTime,
  });

  final int? id;
  final String? name;
  final String? profile;
  final PayProductContent? content;
  final int? price;
  @JsonKey(name: 'serve_period')
  final int? servePeriod;
  @JsonKey(name: 'discount_price')
  final int? discountPrice;
  @JsonKey(name: 'discount_start_time')
  final int? discountStartTime;
  @JsonKey(name: 'discount_end_time')
  final int? discountEndTime;

  factory PayProduct.fromJson(Map<String, dynamic> json) =>
      _$PayProductFromJson(json);
  Map<String, dynamic> toJson() => _$PayProductToJson(this);
}

@JsonSerializable()
class PayProductContent {
  const PayProductContent({
    this.type,
    this.vipDays,
    this.label,
    this.description,
    this.isForever,
    this.share,
  });

  final int? type;
  @JsonKey(name: 'vip_days')
  final int? vipDays;
  final String? label;
  final String? description;
  @JsonKey(name: 'is_forever')
  final int? isForever;
  final int? share;

  factory PayProductContent.fromJson(Map<String, dynamic> json) =>
      _$PayProductContentFromJson(json);
  Map<String, dynamic> toJson() => _$PayProductContentToJson(this);
}

@JsonSerializable()
class CreatePayOrderRequest {
  const CreatePayOrderRequest({
    required this.productId,
    this.productChannel = 1,
    this.paymentChannel = 2,
  });

  @JsonKey(name: 'product_id')
  final int productId;
  @JsonKey(name: 'product_channel')
  final int productChannel;
  @JsonKey(name: 'payment_channel')
  final int paymentChannel;

  factory CreatePayOrderRequest.fromJson(Map<String, dynamic> json) =>
      _$CreatePayOrderRequestFromJson(json);
  Map<String, dynamic> toJson() => _$CreatePayOrderRequestToJson(this);
}

@JsonSerializable()
class CreatePayOrderResponse {
  const CreatePayOrderResponse({this.prepayData});

  @JsonKey(name: 'prepay_data')
  final String? prepayData;

  factory CreatePayOrderResponse.fromJson(Map<String, dynamic> json) =>
      _$CreatePayOrderResponseFromJson(json);
  Map<String, dynamic> toJson() => _$CreatePayOrderResponseToJson(this);
}

@JsonSerializable()
class SubscriptionProductListResponse {
  const SubscriptionProductListResponse({this.productList});

  @JsonKey(name: 'subscription_list')
  final List<SubscriptionProduct>? productList;

  factory SubscriptionProductListResponse.fromJson(
    Map<String, dynamic> json,
  ) =>
      _$SubscriptionProductListResponseFromJson(json);
  Map<String, dynamic> toJson() =>
      _$SubscriptionProductListResponseToJson(this);
}

@JsonSerializable()
class SubscriptionProduct {
  const SubscriptionProduct({
    this.agreementNo,
    this.startTime,
    this.endTime,
    this.nextPayPrice,
    this.productInfo,
  });

  @JsonKey(name: 'agreement_no')
  final String? agreementNo;
  @JsonKey(name: 'last_execute_timestamp')
  final int? startTime;
  @JsonKey(name: 'next_execute_timestamp')
  final int? endTime;
  @JsonKey(name: 'single_amount')
  final int? nextPayPrice;
  @JsonKey(name: 'product_info')
  final SubscriptionProductInfo? productInfo;

  factory SubscriptionProduct.fromJson(Map<String, dynamic> json) =>
      _$SubscriptionProductFromJson(json);
  Map<String, dynamic> toJson() => _$SubscriptionProductToJson(this);
}

@JsonSerializable()
class SubscriptionProductInfo {
  const SubscriptionProductInfo({this.name});

  final String? name;

  factory SubscriptionProductInfo.fromJson(Map<String, dynamic> json) =>
      _$SubscriptionProductInfoFromJson(json);
  Map<String, dynamic> toJson() => _$SubscriptionProductInfoToJson(this);
}

@JsonSerializable()
class SubscriptionCancelRequest {
  const SubscriptionCancelRequest({required this.agreementNo});

  @JsonKey(name: 'agreement_no')
  final String agreementNo;

  factory SubscriptionCancelRequest.fromJson(Map<String, dynamic> json) =>
      _$SubscriptionCancelRequestFromJson(json);
  Map<String, dynamic> toJson() => _$SubscriptionCancelRequestToJson(this);
}