feat: integrate enakgame and voucher
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
This commit is contained in:
@@ -100,7 +100,6 @@ abstract class CustomerOrderPaymentDto with _$CustomerOrderPaymentDto {
|
||||
@JsonKey(name: 'method_type') String? methodType,
|
||||
@JsonKey(name: 'amount') int? amount,
|
||||
@JsonKey(name: 'refund_amount') int? refundAmount,
|
||||
@JsonKey(name: 'points_used') int? pointsUsed,
|
||||
}) = _CustomerOrderPaymentDto;
|
||||
|
||||
factory CustomerOrderPaymentDto.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -114,7 +113,6 @@ abstract class CustomerOrderPaymentDto with _$CustomerOrderPaymentDto {
|
||||
methodType: methodType ?? '',
|
||||
amount: amount ?? 0,
|
||||
refundAmount: refundAmount ?? 0,
|
||||
pointsUsed: pointsUsed,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ abstract class OutletDto with _$OutletDto {
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'address') String? address,
|
||||
@JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment,
|
||||
@JsonKey(name: 'earns_points') bool? earnsPoints,
|
||||
@JsonKey(name: 'earns_coins') bool? earnsCoins,
|
||||
}) = _OutletDto;
|
||||
@@ -20,7 +19,6 @@ abstract class OutletDto with _$OutletDto {
|
||||
id: id ?? '',
|
||||
name: name ?? '',
|
||||
address: (address?.trim().isEmpty ?? true) ? null : address!.trim(),
|
||||
acceptsPointPayment: acceptsPointPayment ?? false,
|
||||
earnsPoints: earnsPoints ?? false,
|
||||
earnsCoins: earnsCoins ?? false,
|
||||
);
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
part of '../wallet_dtos.dart';
|
||||
|
||||
@freezed
|
||||
abstract class PaymentCodeDto with _$PaymentCodeDto {
|
||||
const factory PaymentCodeDto({
|
||||
@JsonKey(name: 'code') String? code,
|
||||
@JsonKey(name: 'qr_payload') String? qrPayload,
|
||||
@JsonKey(name: 'expires_at') String? expiresAt,
|
||||
}) = _PaymentCodeDto;
|
||||
|
||||
factory PaymentCodeDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentCodeDtoFromJson(json);
|
||||
|
||||
const PaymentCodeDto._();
|
||||
|
||||
PaymentCode toDomain() => PaymentCode(
|
||||
code: code ?? '',
|
||||
qrPayload: qrPayload ?? '',
|
||||
// Kode berlaku 2 menit; dipakai hanya bila server tidak mengirim expires_at.
|
||||
expiresAt:
|
||||
_parseDateTime(expiresAt) ??
|
||||
DateTime.now().add(const Duration(minutes: 2)),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
part of '../wallet_dtos.dart';
|
||||
|
||||
/// `terms` belum dibaca: bentuknya masih disepakati dengan tim backoffice,
|
||||
/// sementara itu yang ditampilkan `description` saja (§9.1).
|
||||
@freezed
|
||||
abstract class VoucherDto with _$VoucherDto {
|
||||
const factory VoucherDto({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'description') String? description,
|
||||
@JsonKey(name: 'image_url') String? imageUrl,
|
||||
@JsonKey(name: 'voucher_type') String? voucherType,
|
||||
@JsonKey(name: 'face_value') int? faceValue,
|
||||
@JsonKey(name: 'point_cost') int? pointCost,
|
||||
@JsonKey(name: 'max_per_customer') int? maxPerCustomer,
|
||||
@JsonKey(name: 'valid_until') String? validUntil,
|
||||
@JsonKey(name: 'available') int? available,
|
||||
}) = _VoucherDto;
|
||||
|
||||
factory VoucherDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$VoucherDtoFromJson(json);
|
||||
|
||||
const VoucherDto._();
|
||||
|
||||
Voucher toDomain() => Voucher(
|
||||
id: id ?? '',
|
||||
name: name ?? '',
|
||||
description: (description?.trim().isEmpty ?? true) ? null : description,
|
||||
imageUrl: (imageUrl?.isEmpty ?? true) ? null : imageUrl,
|
||||
type: VoucherType.fromApi(voucherType),
|
||||
faceValue: faceValue ?? 0,
|
||||
pointCost: pointCost ?? 0,
|
||||
maxPerCustomer: maxPerCustomer,
|
||||
validUntil: _parseDateTime(validUntil),
|
||||
available: available,
|
||||
);
|
||||
}
|
||||
|
||||
/// Item "Voucher saya" dan response tukar voucher; [pointBalance] dan
|
||||
/// [replayed] hanya ada di response tukar.
|
||||
@freezed
|
||||
abstract class VoucherRedemptionDto with _$VoucherRedemptionDto {
|
||||
const factory VoucherRedemptionDto({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'voucher_id') String? voucherId,
|
||||
@JsonKey(name: 'voucher_name') String? voucherName,
|
||||
@JsonKey(name: 'voucher_image_url') String? voucherImageUrl,
|
||||
@JsonKey(name: 'voucher_type') String? voucherType,
|
||||
@JsonKey(name: 'status') String? status,
|
||||
@JsonKey(name: 'face_value') int? faceValue,
|
||||
@JsonKey(name: 'point_cost') int? pointCost,
|
||||
@JsonKey(name: 'code') String? code,
|
||||
@JsonKey(name: 'code_expires_at') String? codeExpiresAt,
|
||||
@JsonKey(name: 'completed_at') String? completedAt,
|
||||
@JsonKey(name: 'created_at') String? createdAt,
|
||||
@JsonKey(name: 'point_balance') int? pointBalance,
|
||||
@JsonKey(name: 'replayed') bool? replayed,
|
||||
}) = _VoucherRedemptionDto;
|
||||
|
||||
factory VoucherRedemptionDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$VoucherRedemptionDtoFromJson(json);
|
||||
|
||||
const VoucherRedemptionDto._();
|
||||
|
||||
VoucherRedemption toDomain() => VoucherRedemption(
|
||||
id: id ?? '',
|
||||
voucherId: voucherId ?? '',
|
||||
voucherName: voucherName ?? '',
|
||||
voucherImageUrl: (voucherImageUrl?.isEmpty ?? true)
|
||||
? null
|
||||
: voucherImageUrl,
|
||||
voucherType: VoucherType.fromApi(voucherType),
|
||||
status: VoucherRedemptionStatus.fromApi(status),
|
||||
faceValue: faceValue ?? 0,
|
||||
pointCost: pointCost ?? 0,
|
||||
code: (code?.isEmpty ?? true) ? null : code,
|
||||
codeExpiresAt: _parseDateTime(codeExpiresAt),
|
||||
completedAt: _parseDateTime(completedAt),
|
||||
createdAt: _parseDateTime(createdAt),
|
||||
);
|
||||
|
||||
VoucherRedeemResult toRedeemResult() => VoucherRedeemResult(
|
||||
redemption: toDomain(),
|
||||
pointBalance: pointBalance ?? 0,
|
||||
replayed: replayed ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
class VoucherRedemptionPageDto {
|
||||
final List<VoucherRedemptionDto> items;
|
||||
final WalletPaginationDto pagination;
|
||||
|
||||
const VoucherRedemptionPageDto({
|
||||
required this.items,
|
||||
required this.pagination,
|
||||
});
|
||||
|
||||
VoucherRedemptionPage toDomain() => VoucherRedemptionPage(
|
||||
items: items.map((e) => e.toDomain()).toList(),
|
||||
page: pagination.page ?? 1,
|
||||
totalPages: pagination.totalPages ?? 1,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user