import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
import moment from 'moment';
import * as Model from './index';
import { Users } from './user.schema';
// const types= [null, 'USER', 'ADMIN','SELLER']
const device_types = [null, 'IOS', 'ANDROID', 'WEB'];
import { Workspace } from './workspace.model';
import { Agents } from './agent.schema';

export enum call_type {
  CALL = 'CALL',
  CHAT = 'CHAT',
  VOICE_CHAT = 'VOICE_CHAT'
}

@Schema()
export class Calls extends Document {

  @Prop({ type: Types.ObjectId, ref: Workspace.name, default: null })
  workspace_id: Types.ObjectId

  @Prop({ type: Types.ObjectId, ref: Agents.name, default: null })
  agent_id: Types.ObjectId

  @Prop({ type: String, enum: call_type, default: 'CALL' })
  type: string = null;

  @Prop({ type: String, default: null })
  call_id: string = null;

  @Prop({ type: String, default: null })
  voice_chat_id: string = null;

  @Prop({ type: String, default: null })
  stream_id: string = null;

  @Prop({ type: String, default: null })
  call_duration: string;

  @Prop({ type: Number, default: null })
  chat_duration: number;

  @Prop({ type: String, default: 'complete' })
  chat_status: string;

  @Prop({ type: String, default: 'ACTIVE' })
  status: string;

  @Prop({ type: String, default: null })
  last_message: string;

  @Prop({ type: String, default: null })
  summary: string;

  @Prop({ type: String, default: null })
  phone_no: string;

  @Prop({ type: String, default: null })
  country_code: string;

  @Prop({ type: String, default: null })
  email: string;

  @Prop({ type: String, default: null })
  name: string;

  @Prop({ type: String, default: null })
  emotion: string;

  @Prop({ type: Object, default: null })
  extracted_data: object;

  @Prop({ default: moment().utc().valueOf() })
  updated_at: number = moment().utc().valueOf();

  @Prop({ default: moment().utc().valueOf() })
  created_at: number = moment().utc().valueOf();
}

export const CallSchema = SchemaFactory.createForClass(Calls);
