package de.jottyfan.camporganizer.module.registration.model;

import java.io.Serializable;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

import com.nimbusds.jose.shaded.gson.Gson;

/**
 * 
 * @author jotty
 *
 */
public class AlreadyKnownPersonBean implements Serializable {
	private static final long serialVersionUID = 1L;

	private String option;
	private RegistrationBean source;

	public String getJson() {
		Map<String, String> map = new HashMap<>();
		map.put("forename", source.getForename());
		map.put("surname", source.getSurname());
		map.put("street", source.getStreet());
		map.put("zip", source.getZip());
		map.put("city", source.getCity());
		map.put("phone", source.getPhone());
		map.put("email", source.getEmail());
		map.put("sex", source.getSex() == null ? null : source.getSex().getLiteral());
		map.put("birthDate",
				source.getBirthDate() == null ? null : source.getBirthDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
		return new Gson().toJson(map);
	}

	public String getOption() {
		return option;
	}

	public void setOption(String json) {
		this.option = json;
	}

	public RegistrationBean getSource() {
		return source;
	}

	public void setSource(RegistrationBean source) {
		this.source = source;
	}
}
