import { Entity } from '@domain/Entity';

type UserActivityProps = {
  userId?: string;
  action?: string;
  endpoint?: string;
  method?: string;
  ipAddress?: string;
  userAgent?: string;
  status?: number;
  entityId?: string;
  metadata?: Record<string, any>;
  htmlContent?: string | null;
  createdAt: Date;
};

export class UserActivity extends Entity<UserActivityProps> {
  get userId() {
    return this.props.userId;
  }

  get action() {
    return this.props.action;
  }

  get endpoint() {
    return this.props.endpoint;
  }

  get method() {
    return this.props.method;
  }

  get ipAddress() {
    return this.props.ipAddress;
  }

  get userAgent() {
    return this.props.userAgent;
  }

  get status() {
    return this.props.status;
  }

  get entityId() {
    return this.props.entityId;
  }

  get metadata() {
    return this.props.metadata;
  }

  get htmlContent() {
    return this.props.htmlContent;
  }

  get createdAt() {
    return this.props.createdAt;
  }

  set userId(userId: string) {
    this.props.userId = userId;
  }

  set action(action: string) {
    this.props.action = action;
  }

  set endpoint(endpoint: string) {
    this.props.endpoint = endpoint;
  }

  set method(method: string) {
    this.props.method = method;
  }

  set ipAddress(ipAddress: string) {
    this.props.ipAddress = ipAddress;
  }

  set userAgent(userAgent: string) {
    this.props.userAgent = userAgent;
  }

  set status(status: number) {
    this.props.status = status;
  }

  set entityId(entityId: string) {
    this.props.entityId = entityId;
  }

  set metadata(metadata: Record<string, any>) {
    this.props.metadata = metadata;
  }

  set htmlContent(htmlContent: string | null | undefined) {
    this.props.htmlContent = htmlContent ?? null;
  }

  set createdAt(createdAt: Date) {
    this.props.createdAt = createdAt;
  }

  public static create(props: UserActivityProps, id?: string) {
    return new UserActivity(props, id);
  }
}
