import { ValueObject } from '../../../../shared/domain/ValueObject';
import { Result, ok, err } from '../../../../shared/core/Result';
import { NotificationType as NotificationTypeEnum } from '@semble/types';

interface NotificationTypeProps {
  value: NotificationTypeEnum;
}

export class NotificationType extends ValueObject<NotificationTypeProps> {
  get value(): NotificationTypeEnum {
    return this.props.value;
  }

  private constructor(props: NotificationTypeProps) {
    super(props);
  }

  public static create(type: NotificationTypeEnum): Result<NotificationType> {
    if (!Object.values(NotificationTypeEnum).includes(type)) {
      return err(new Error(`Invalid notification type: ${type}`));
    }
    return ok(new NotificationType({ value: type }));
  }

  public static userAddedYourCard(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_ADDED_YOUR_CARD);
  }

  public static userAddedYourBskyPost(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_ADDED_YOUR_BSKY_POST);
  }

  public static userAddedYourCollection(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_ADDED_YOUR_COLLECTION);
  }

  public static userAddedToYourCollection(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_ADDED_TO_YOUR_COLLECTION);
  }

  public static userFollowedYou(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_FOLLOWED_YOU);
  }

  public static userFollowedYourCollection(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_FOLLOWED_YOUR_COLLECTION);
  }

  public static userConnectedYourUrl(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_CONNECTED_YOUR_URL);
  }

  public static userConnectedYourPost(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_CONNECTED_YOUR_POST);
  }

  public static userConnectedYourCollection(): Result<NotificationType> {
    return this.create(NotificationTypeEnum.USER_CONNECTED_YOUR_COLLECTION);
  }
}
