package sg.ncl.service.user.web;

import sg.ncl.service.user.data.jpa.UserEntity;
import sg.ncl.service.user.domain.LoginActivity;
import sg.ncl.service.user.domain.User;
import sg.ncl.service.user.domain.UserStatus;

import java.time.ZonedDateTime;
import java.util.List;

/**
 * @author Christopher Zhong
 */
public class UserInfo implements User {

    private final String id;
    private final UserDetailsInfo userDetails;
    private final Boolean emailVerified;
    private final UserStatus status;
    private final ZonedDateTime applicationDate;
    private final ZonedDateTime processedDate;
    private final List<? extends LoginActivity> loginActivities;
    private final List<String> teamIds;

    public UserInfo(final String id, final UserDetailsInfo userDetails, final Boolean emailVerified, final UserStatus status, final ZonedDateTime applicationDate, final ZonedDateTime processedDate, final List<? extends LoginActivity> loginActivities, final List<String> teamIds) {
        this.id = id;
        this.userDetails = userDetails;
        this.emailVerified = emailVerified;
        this.status = status;
        this.applicationDate = applicationDate;
        this.processedDate = processedDate;
        this.loginActivities = loginActivities;
        this.teamIds = teamIds;
    }

    public UserInfo(final UserEntity userEntity) {
        this(userEntity.getId(),
                new UserDetailsInfo(userEntity.getUserDetails()),
                userEntity.isEmailVerified(),
                userEntity.getStatus(),
                userEntity.getApplicationDate(),
                userEntity.getProcessedDate(),
                userEntity.getLoginActivities(),
                userEntity.getTeamIds()
        );
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public UserDetailsInfo getUserDetails() {
        return userDetails;
    }

    @Override
    public boolean isEmailVerified() {
        return emailVerified;
    }

    @Override
    public UserStatus getStatus() {
        return status;
    }

    @Override
    public ZonedDateTime getApplicationDate() {
        return applicationDate;
    }

    @Override
    public ZonedDateTime getProcessedDate() {
        return processedDate;
    }

    @Override
    public List<? extends LoginActivity> getLoginActivities() {
        return loginActivities;
    }

    @Override
    public List<String> getTeamIds() {
        return teamIds;
    }

}

@@ -27,16 +27,123 @@
 r.web;%0A%0A
+import com.fasterxml.jackson.annotation.JsonCreator;%0Aimport com.fasterxml.jackson.annotation.JsonProperty;%0A
 import s
@@ -816,40 +816,106 @@
     
-public UserInfo(final String id,
+@JsonCreator%0A    public UserInfo(@JsonProperty(%22id%22) final String id, @JsonProperty(%22userDetails%22)
  fin
@@ -945,16 +945,47 @@
 Details,
+ @JsonProperty(%22emailVerified%22)
  final B
@@ -1005,16 +1005,40 @@
 erified,
+ @JsonProperty(%22status%22)
  final U
@@ -1054,16 +1054,49 @@
  status,
+ @JsonProperty(%22applicationDate%22)
  final Z
@@ -1120,24 +1120,55 @@
 icationDate,
+ @JsonProperty(%22processedDate%22)
  final Zoned
@@ -1190,16 +1190,49 @@
 sedDate,
+ @JsonProperty(%22loginActivities%22)
  final L
@@ -1276,16 +1276,41 @@
 ivities,
+ @JsonProperty(%22teamIds%22)
  final L

add @JsonCreator and @JsonProperty to UserInfo