304 lines
5.8 KiB
TypeScript
304 lines
5.8 KiB
TypeScript
import { ApiProperty } from '@midwayjs/swagger';
|
|
import { Rule, RuleType } from '@midwayjs/validate';
|
|
|
|
// 定义包装类型的联合类型
|
|
export type PackagingType =
|
|
// | PackagingPallet
|
|
PackagingPackage;
|
|
// | PackagingCourierPak
|
|
// | PackagingEnvelope;
|
|
|
|
// 定义包装类型的枚举,用于 API 文档描述
|
|
export enum PackagingTypeEnum {
|
|
Pallet = 'pallet',
|
|
Package = 'package',
|
|
CourierPak = 'courier-pak',
|
|
Envelope = 'envelope',
|
|
}
|
|
|
|
export class Address {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
address_line_1: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
city: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
region: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
country: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
postal_code: string;
|
|
}
|
|
|
|
export class PhoneNumber {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
number: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
extension: string;
|
|
}
|
|
|
|
export class Location {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
name: string;
|
|
|
|
@ApiProperty({ type: Address })
|
|
@Rule(RuleType.object<Address>())
|
|
address: Address;
|
|
|
|
@ApiProperty({ type: PhoneNumber })
|
|
@Rule(RuleType.object<PhoneNumber>())
|
|
phone_number: PhoneNumber;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.array<string>())
|
|
email_addresses: string[];
|
|
|
|
contact_name?: string;
|
|
}
|
|
|
|
export class Time {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
hour: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
minute: string;
|
|
}
|
|
|
|
export enum SignatureRequirementEnum {
|
|
NOTREQUIRED = 'not-required',
|
|
REQUIRED = 'required',
|
|
ADULTREQUIRED = 'adult-required',
|
|
}
|
|
|
|
export class Destination extends Location {
|
|
@ApiProperty({ type: Time })
|
|
@Rule(RuleType.object<Time>())
|
|
ready_at: Time;
|
|
|
|
@ApiProperty({ type: Time })
|
|
@Rule(RuleType.object<Time>())
|
|
ready_until: Time;
|
|
|
|
@ApiProperty({ type: SignatureRequirementEnum })
|
|
@Rule(RuleType.string().valid(...Object.values(SignatureRequirementEnum)))
|
|
SignatureRequirementEnum: SignatureRequirementEnum;
|
|
}
|
|
|
|
export class Date {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
year: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
month: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
day: string;
|
|
}
|
|
|
|
export enum UnitEnum {
|
|
KG = 'kg',
|
|
LB = 'lb',
|
|
G = 'g',
|
|
OZ = 'oz',
|
|
}
|
|
|
|
export class Cubid {
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
w: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
h: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
l: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
unit: string;
|
|
}
|
|
|
|
export class Weight {
|
|
@ApiProperty({ enum: UnitEnum })
|
|
@Rule(RuleType.string().valid(...Object.values(UnitEnum)))
|
|
unit: UnitEnum;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
value: number;
|
|
}
|
|
|
|
export class Measurements {
|
|
@ApiProperty({ type: Cubid })
|
|
cuboid: Cubid;
|
|
|
|
@ApiProperty({ type: Cubid })
|
|
weight: Weight;
|
|
}
|
|
|
|
export class Pallets {
|
|
@ApiProperty({ type: Measurements })
|
|
@Rule(RuleType.object<Measurements>())
|
|
measurements: Measurements;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
description: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
freight_class: string;
|
|
}
|
|
|
|
export class PackagingPallet {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
pallet_type: string;
|
|
|
|
@ApiProperty({ type: Pallets })
|
|
@Rule(RuleType.object<Pallets>())
|
|
pallets: Pallets;
|
|
}
|
|
|
|
export class Package {
|
|
@ApiProperty({ type: Measurements })
|
|
@Rule(RuleType.object<Measurements>())
|
|
measurements: Measurements;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
description: string;
|
|
}
|
|
|
|
export class PackagingPackage {
|
|
@ApiProperty({ type: Package, isArray: true })
|
|
@Rule(RuleType.array<Package>())
|
|
packages: Package[];
|
|
}
|
|
|
|
export class PackagingCourierPak {
|
|
@ApiProperty({ type: Package, isArray: true })
|
|
@Rule(RuleType.array<Package>())
|
|
courier_paks: Package[];
|
|
}
|
|
|
|
export class PackagingEnvelope {
|
|
// 添加必要的属性和装饰器
|
|
@ApiProperty()
|
|
@Rule(RuleType.boolean())
|
|
includes_return_label?: boolean;
|
|
}
|
|
|
|
// export enum InsuranceTypeEnum {
|
|
// INTERNAL = 'internal',
|
|
// CARRIER = 'carrier',
|
|
// }
|
|
// export class Insurance {
|
|
// @ApiProperty({ enum: InsuranceTypeEnum })
|
|
// @Rule(RuleType.string().valid(...Object.values(InsuranceTypeEnum)))
|
|
// type: InsuranceTypeEnum;
|
|
// }
|
|
|
|
export class ShippingDetailsDTO {
|
|
@ApiProperty({ type: Location })
|
|
@Rule(RuleType.object<Location>())
|
|
origin: Location;
|
|
|
|
@ApiProperty({ type: Destination })
|
|
@Rule(RuleType.object<Destination>())
|
|
destination: Destination;
|
|
|
|
@ApiProperty({ type: Date })
|
|
@Rule(RuleType.object<Date>())
|
|
expected_ship_date: Date;
|
|
|
|
@ApiProperty({ enum: PackagingTypeEnum })
|
|
@Rule(RuleType.string().valid(...Object.values(PackagingTypeEnum)))
|
|
packaging_type: PackagingTypeEnum;
|
|
|
|
@ApiProperty({
|
|
type: () => [
|
|
// PackagingPallet,
|
|
PackagingPackage,
|
|
// PackagingCourierPak,
|
|
// PackagingEnvelope,
|
|
],
|
|
})
|
|
@Rule(RuleType.object<PackagingType>())
|
|
packaging_properties: PackagingType;
|
|
|
|
// @ApiProperty({ type: Insurance })
|
|
// @Rule(RuleType.object<Insurance>())
|
|
// insurance?: Insurance;
|
|
|
|
@ApiProperty()
|
|
reference_codes: string[];
|
|
}
|
|
|
|
export class Money {
|
|
@ApiProperty()
|
|
currency: string;
|
|
|
|
@ApiProperty()
|
|
value: string;
|
|
}
|
|
|
|
export class Surcharges {
|
|
@ApiProperty()
|
|
type: string;
|
|
|
|
@ApiProperty({ type: Money })
|
|
amount: Money;
|
|
}
|
|
|
|
export class RateDTO {
|
|
@ApiProperty()
|
|
carrier_name: string;
|
|
|
|
@ApiProperty()
|
|
service_name: string;
|
|
|
|
@ApiProperty()
|
|
service_id: string;
|
|
|
|
@ApiProperty({ type: Date })
|
|
valid_until: Date;
|
|
|
|
@ApiProperty({ type: Money })
|
|
total: Money;
|
|
|
|
@ApiProperty({ type: Money })
|
|
base: Money;
|
|
|
|
@ApiProperty({ type: Surcharges, isArray: true })
|
|
surcharges: Surcharges[];
|
|
|
|
@ApiProperty({ type: Money, isArray: true })
|
|
taxes: Money[];
|
|
|
|
@ApiProperty()
|
|
transit_time_days: number;
|
|
|
|
@ApiProperty()
|
|
transit_time_not_available: boolean;
|
|
}
|