Files
parsshop-back/src/modules/checkout/dto/checkout-summary-response.dto.ts

262 lines
4.8 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
class CheckoutProductDto {
@ApiProperty()
id: string;
@ApiProperty()
title: string;
@ApiProperty({ nullable: true })
slug: string | null;
@ApiProperty({ nullable: true })
technicalCode: string | null;
@ApiProperty({ nullable: true })
brand: string | null;
@ApiProperty({ nullable: true })
brandslug: string | null;
@ApiProperty()
stock: number;
@ApiProperty({ nullable: true })
mainImageUrl: string | null;
}
class CheckoutCartItemDto {
@ApiProperty()
id: string;
@ApiProperty()
quantity: number;
@ApiProperty()
baseUnitPrice: number;
@ApiProperty()
unitPrice: number;
@ApiProperty()
baseLineTotal: number;
@ApiProperty()
discountAmount: number;
@ApiProperty()
lineTotal: number;
@ApiProperty()
currency_unit: string;
@ApiProperty()
currency_label: string;
@ApiProperty({ type: CheckoutProductDto })
product: CheckoutProductDto;
}
class CheckoutAddressDto {
@ApiProperty()
id: string;
@ApiProperty()
title: string;
@ApiProperty()
recipientName: string;
@ApiProperty()
phone: string;
@ApiProperty()
province: string;
@ApiProperty()
city: string;
@ApiProperty({ nullable: true })
postalCode: string | null;
@ApiProperty()
addressLine: string;
@ApiProperty({ nullable: true })
plaque: string | null;
@ApiProperty({ nullable: true })
unit: string | null;
@ApiProperty()
isDefault: boolean;
}
class CheckoutEstimatedDeliveryDto {
@ApiProperty()
minDays: number;
@ApiProperty()
maxDays: number;
}
class CheckoutShippingMethodDto {
@ApiProperty()
id: string;
@ApiProperty()
code: string;
@ApiProperty()
title: string;
@ApiProperty({ nullable: true })
description: string | null;
@ApiProperty()
feeAmount: number;
@ApiProperty({ nullable: true })
currency_unit: string | null;
@ApiProperty({ type: CheckoutEstimatedDeliveryDto })
estimatedDelivery: CheckoutEstimatedDeliveryDto;
}
class CheckoutPaymentMethodBankAccountDto {
@ApiProperty({ nullable: true })
bankName: string | null;
@ApiProperty({ nullable: true })
accountHolderName: string | null;
@ApiProperty({ nullable: true })
accountNumber: string | null;
@ApiProperty({ nullable: true })
cardNumber: string | null;
@ApiProperty({ nullable: true })
shebaNumber: string | null;
}
class CheckoutPaymentMethodDto {
@ApiProperty()
id: string;
@ApiProperty()
code: string;
@ApiProperty()
type: string;
@ApiProperty()
title: string;
@ApiProperty({ nullable: true })
description: string | null;
@ApiProperty({ nullable: true })
instructions: string | null;
@ApiProperty()
isSandboxEnabled: boolean;
@ApiProperty()
displayOrder: number;
@ApiPropertyOptional({ type: CheckoutPaymentMethodBankAccountDto, nullable: true })
bankAccount?: CheckoutPaymentMethodBankAccountDto | null;
}
class CheckoutPricingDto {
@ApiProperty()
subtotal: number;
@ApiProperty()
levelDiscount: number;
@ApiProperty()
payableSubtotal: number;
@ApiProperty()
shipping: number;
@ApiProperty()
tax: number;
@ApiProperty()
total: number;
@ApiProperty()
taxPercent: number;
@ApiProperty({ nullable: true })
currency_unit: string | null;
@ApiProperty({ nullable: true })
currency_label: string | null;
}
class CheckoutNotesDto {
@ApiProperty()
orderWillNotBeCreated: boolean;
@ApiProperty()
requiresAddressSelection: boolean;
}
class CheckoutCartDto {
@ApiProperty()
id: string;
@ApiProperty()
itemsCount: number;
@ApiProperty({ type: [CheckoutCartItemDto] })
items: CheckoutCartItemDto[];
}
class CheckoutShippingSectionDto {
@ApiProperty({ type: CheckoutShippingMethodDto, nullable: true })
selectedMethod: CheckoutShippingMethodDto | null;
@ApiProperty({ type: [CheckoutShippingMethodDto] })
methods: CheckoutShippingMethodDto[];
}
class CheckoutPaymentSectionDto {
@ApiProperty({ type: CheckoutPaymentMethodDto, nullable: true })
selectedMethod: CheckoutPaymentMethodDto | null;
@ApiProperty({ type: [CheckoutPaymentMethodDto] })
methods: CheckoutPaymentMethodDto[];
}
export class CheckoutSummaryResponseDto {
@ApiProperty()
reviewReady: boolean;
@ApiProperty({ type: CheckoutCartDto })
cart: CheckoutCartDto;
@ApiProperty({ type: CheckoutAddressDto, nullable: true })
address: CheckoutAddressDto | null;
@ApiProperty({ type: [CheckoutAddressDto] })
availableAddresses: CheckoutAddressDto[];
@ApiProperty({ type: CheckoutShippingSectionDto })
shipping: CheckoutShippingSectionDto;
@ApiProperty({ type: CheckoutPaymentSectionDto })
payment: CheckoutPaymentSectionDto;
@ApiProperty({ type: CheckoutPricingDto })
pricing: CheckoutPricingDto;
@ApiProperty({ type: CheckoutNotesDto })
notes: CheckoutNotesDto;
}