<?php

namespace App\Interfaces;

use App\Models\StatusAkun;
use App\Models\UserRole;

class UserRequest
{
  public ?int $id = null;
  public string $nama;
  public string $username;
  public string $password;
  public string $email;
  public string $noTelepon;
  public UserRole $role;
  public ?int $divisiId = null;
  public ?string $namaDivisi = null;
  public StatusAkun $statusAkun;
  public ?string $spesialisasi = null;

  public static function create(
    string $nama,
    string $username,
    string $password,
    string $email,
    string $noTelepon,
    UserRole $role,
    ?int $divisiId,
    StatusAkun $statusAkun,
    ?string $spesialisasi
  ): self {

    $request = new self();

    $request->nama = $nama;
    $request->username = $username;
    $request->password = $password;
    $request->email = $email;
    $request->noTelepon = $noTelepon;
    $request->role = $role;
    $request->divisiId = $divisiId;
    $request->statusAkun = $statusAkun;
    $request->spesialisasi = $spesialisasi;

    return $request;
  }

  public static function update(
    int $id,
    string $nama,
    string $username,
    string $email,
    string $noTelepon,
    UserRole $role,
    ?int $divisiId,
    StatusAkun $statusAkun,
    ?string $spesialisasi
  ): self {

    $request = new self();

    $request->id = $id;
    $request->nama = $nama;
    $request->username = $username;
    $request->email = $email;
    $request->noTelepon = $noTelepon;
    $request->role = $role;
    $request->divisiId = $divisiId;
    $request->statusAkun = $statusAkun;
    $request->spesialisasi = $spesialisasi;

    return $request;
  }

  // ===== Getter =====

  public function getNama(): string
  {
    return $this->nama;
  }

  public function getUsername(): string
  {
    return $this->username;
  }

  public function getPassword(): string
  {
    return $this->password;
  }

  public function getEmail(): string
  {
    return $this->email;
  }

  public function getNoTelepon(): string
  {
    return $this->noTelepon;
  }

  public function getRole(): UserRole
  {
    return $this->role;
  }

  public function getDivisiId(): ?int
  {
    return $this->divisiId ?? null;
  }

  public function getStatusAkun(): StatusAkun
  {
    return $this->statusAkun;
  }

  public function getNamaDivisi(): ?string
  {
    return $this->namaDivisi ?? null;
  }

  public function getId(): ?int
  {
    return $this->id;
  }

  public function getSpesialisasi(): ?string
  {
    return $this->spesialisasi ?? null;
  }

  // ===== Setter =====
  public function hashPassword(): void
  {
    $this->password = password_hash($this->password, PASSWORD_DEFAULT);
  }
}
