package ervu_dashboard.security.model.jwt;

import java.util.Set;

import ervu_dashboard.security.model.role.ErvuRoleAuthority;

public record UserSession(
    String name,
    String realm,
    Set<ErvuRoleAuthority> roles,
    String recruitmentId // aka domainId
) {

  public static UserSessionBuilder builder() {
    return new UserSessionBuilder();
  }

  public static final class UserSessionBuilder {
    private String name;
    private String realm;
    private Set<ErvuRoleAuthority> roles;
    private String recruitmentId;

    private UserSessionBuilder() {
    }

    public static UserSessionBuilder aJwtClaims() {
      return new UserSessionBuilder();
    }

    public UserSessionBuilder withName(String name) {
      this.name = name;
      return this;
    }

    public UserSessionBuilder withRealm(String realm) {
      this.realm = realm;
      return this;
    }

    public UserSessionBuilder withRoles(Set<ErvuRoleAuthority> roles) {
      this.roles = roles;
      return this;
    }

    public UserSessionBuilder withRecruitmentId(String recruitmentId) {
      this.recruitmentId = recruitmentId;
      return this;
    }

    public UserSession build() {
      return new UserSession(name, realm, roles, recruitmentId);
    }
  }
}
