package in.gov.digilocker.uidai.web.controller;

import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HomeController {
	
	@GetMapping(value="/", produces=MediaType.APPLICATION_JSON_VALUE)
	public String home() {
		try {
			JSONObject jsonObject= new JSONObject();
			jsonObject.put("code", -1);
			jsonObject.put("status", false);
			jsonObject.put("response", "Get method not allowed here.");
			jsonObject.put("date", new Date());
			return jsonObject.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return "home";
	}
	
	@GetMapping(value="/api", produces=MediaType.APPLICATION_JSON_VALUE)
	public String apiHome() {
		try {
			JSONObject jsonObject= new JSONObject();
			jsonObject.put("code", -1);
			jsonObject.put("status", false);
			jsonObject.put("response", "Get method not allowed here.");
			jsonObject.put("date", new Date());
			return jsonObject.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return "home";
	}
}