import { FleioId, IBaseFleioObjectModel } from '../../base-model/base-fleio-object.model';
import { IClientModel } from '../../client-user/model/client.model';
import { IConfigOptionModel } from './config-option.model';
import { IPricingPlanModel } from '../../openstack/model/pricing-plan.model';
import { IServiceHostingAccountModel } from '@fleio-api/billing/services/model/service-hosting-account.model';
import { IServiceActionModel } from '@fleio-api/billing/model/service-action.model';
import { IYesNoDialogFlag } from '@shared/ui-api/interfaces/yes-no-dialog-flag';
import { ICurrencyModel } from '@fleio-api/billing/model/currency.model';

export enum PriceOverrideModel {
  Default = 'none',
  DiscountValue = 'discount-value',
  OverrideValue = 'override-value',
  DiscountPercentage = 'discount-percentage',
  FreeService = 'free-service',

}

export interface IServiceResources {
  can_renew_early: boolean;
  product_type?: string;
  plugin_name?: string;
  service_id?: FleioId;
  service_resources: any;
  disabled_features: string[];
}

export interface IServiceModel extends IBaseFleioObjectModel {
  suspend_flags: IYesNoDialogFlag[];
  renew_enabled?: boolean;
  pricing_plan: IPricingPlanModel;
  client: IClientModel;
  cycle: any;  // IProductCycleModel | FleioId
  currency: ICurrencyModel;
  product: any;  // IProductModel | FleioId
  order: number;
  billing_type: string;
  configurable_options: IConfigOptionModel[];
  internal_id: string;
  external_billing_id: string;
  display_name: string;
  override_value: string;
  status: string;
  task: string;
  notes: string;
  override_suspend_until: Date;
  suspend_reason: string;
  suspend_type: string;
  created_at: Date;
  activated_at: Date;
  updated_at: Date;
  suspended_at: Date;
  terminated_at: Date;
  auto_terminate_date: Date;
  auto_terminate_reason: string;
  current_service_cycle_end: Date;
  paid_until: Date;
  paid_until_display: string;
  next_invoice_date: Date;
  next_invoice_date_display: string;
  plugin_data: string;
  domain_name: string;
  cancellation_request: object;
  last_service_cycle_state: string;
  current_price: number;
  status_display?: string;
  hosting_account: IServiceHostingAccountModel;
  resources?: IServiceResources;
  actions: { [name: string]: IServiceActionModel };

  price_override: boolean;
  price_override_display: string;
  price_override_model: PriceOverrideModel;
  price_override_type: string;
  discount_value: number;
  discount_percent: number;
  price_override_tiers: { from: number; to: number; price: number }[];
  downgrade_order?: FleioId;
  is_free?: boolean;
}
