package in.gov.digilocker.uidai.services.xmlresponse;

import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name = "Resp")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "status", "err", "kycRes", "code", "ret", "ts", "ttl", "txn" })
public class KycFailedResponse {
	
	@XmlAttribute(name= "status")private String status;
	@XmlAttribute(name= "err")private String err;
	@XmlElement(name= "kycRes")private String kycRes;
	@XmlAttribute(name= "code")private String code;
	@XmlAttribute(name= "ret")private String ret; 
	@XmlAttribute(name= "ts")private String ts;
	@XmlAttribute(name= "ttl")private String ttl;
	@XmlAttribute(name= "txn")private String txn;
	
	private String xmlResp;

	public KycFailedResponse() {
		this.status = "";
		this.err = "";
		this.kycRes = "";
		this.code = "";
		this.ret = "";
		this.ts = "";
		this.ttl = "";
		this.txn = "";
		this.xmlResp= "";
	}

	public KycFailedResponse(String status, String err, String kycRes, String code, String ret, String ts, String ttl,  String txn, UidDataResponse uidData, String xmlResp) {
		this.status = status;
		this.err = err;
		this.kycRes = kycRes;
		this.code = code;
		this.ret = ret;
		this.ts = ts;
		this.ttl = ttl;
		this.txn = txn;
		this.xmlResp= xmlResp;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getErr() {
		return this.err;
	}

	public void setErr(String err) {
		this.err = err;
	}

	public String getKycRes() {
		return this.kycRes;
	}

	public void setKycRes(String kycRes) {
		this.kycRes = kycRes;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getRet() {
		return this.ret;
	}

	public void setRet(String ret) {
		this.ret = ret;
	}

	public String getTs() {
		return this.ts;
	}

	public void setTs(String ts) {
		this.ts = ts;
	}

	public String getTtl() {
		return this.ttl;
	}

	public void setTtl(String ttl) {
		this.ttl = ttl;
	}

	public String getTxn() {
		return this.txn;
	}

	public void setTxn(String txn) {
		this.txn = txn;
	}

	public String getXmlResp() {
		return xmlResp;
	}

	public void setXmlResp(String xmlResp) {
		this.xmlResp = xmlResp;
	}

	public static KycFailedResponse buildXMLToKycResponse(String respXML) throws JAXBException {
		JAXBContext context = JAXBContext.newInstance(new Class[] { KycFailedResponse.class });
		Unmarshaller um = context.createUnmarshaller();
		StringReader reader = new StringReader(respXML);
		KycFailedResponse kycFailedResponse= new KycFailedResponse();
		kycFailedResponse = (KycFailedResponse) um.unmarshal(reader);
		return kycFailedResponse;
	}
}
