import Joi from 'joi';
import { DimensionUnit } from '../../models';
import { DimensionUnitSchema } from '../../models/units/dimension-unit-schema';

/** @description Dimensions specific to a package rate class */
export interface PackageRatingGroupDimensions {
  /** @description Unit of the dimensions */
  Unit: DimensionUnit;
  /** @description Length of the package */
  Length?: number;
  /** @description Width of the package */
  Width?: number;
  /** @description Height of the package */
  Height?: number;
  /** @description Girth of the package as defined by the carrier */
  Girth?: number;
  /** @description No two sides exceed this amount */
  NoTwoSides?: number;
  /** @description Length plus girth should not exceed this amount */
  LengthPlusGirth?: number;
  /** @description Volume of the package */
  Volume?: number;
}

export const PackageRatingGroupDimensionsSchema = Joi.object({
  Unit: DimensionUnitSchema.required(),
  Length: Joi.number().min(0).optional(),
  Width: Joi.number().min(0).optional(),
  Height: Joi.number().min(0).optional(),
  NoTwoSides: Joi.number().min(0).optional(),
  LengthPlusGirth: Joi.number().min(0).optional(),
  Girth: Joi.number().min(0).optional(),
  Volume: Joi.number().min(0).optional(),
});
