package ru.micord.ervu.account_applications.security.model;

import java.util.Set;

import ru.micord.ervu.account_applications.security.model.role.ErvuPermissionAuthority;

public record UserSession(
    String userId,
    String name,
    String realm,
    Set<ErvuPermissionAuthority> permissions,
    String domainId
) {

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

  public static final class UserSessionBuilder {
    private String userId;
    private String name;
    private String realm;
    private Set<ErvuPermissionAuthority> permissions;
    private String domainId;

    private UserSessionBuilder() {
    }

    public UserSessionBuilder withUserId(String userId) {
      this.userId = userId;
      return this;
    }

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

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

    public UserSessionBuilder withPermissions(Set<ErvuPermissionAuthority> permissions) {
      this.permissions = permissions;
      return this;
    }

    public UserSessionBuilder withDomainId(String domainId) {
      this.domainId = domainId;
      return this;
    }

    public UserSession build() {
      return new UserSession(userId, name, realm, permissions, domainId);
    }
  }
}
