package com.google.sps.agents;
 
// Imports the Google Cloud client library
import com.google.cloud.dialogflow.v2.QueryInput;
import com.google.cloud.dialogflow.v2.QueryResult;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import com.google.sps.data.Output;
import com.google.sps.agents.Agent;
import com.google.sps.utils.TimeUtils;
import java.io.IOException;
import java.util.Date;
import java.util.Map;

/**
 * Reminders Agent
 */
public class Reminders implements Agent {
    private String intentName = null;
    private String recurrence = null;
    private Date date = null;
    private String name = "";
    private String fulfillment = "";
    private String display = null;
    
    public Reminders(String intentName, Map<String, Value> parameters) {
        this.intentName = intentName;
        try {
            setParameters(parameters);
        } catch (Exception e) {
            fulfillment = null;
        }
    }

    @Override 
    public void setParameters(Map<String, Value> parameters) {
        if (intentName.equals("snooze")) {
			Struct durationStruct = parameters.get("date-time").getStructValue();
			Map<String, Value> durationMap = durationStruct.getFieldsMap();
			Date start = TimeUtils.stringToDate(durationMap.get("startDateTime").getStringValue());
			Date end = TimeUtils.stringToDate(durationMap.get("endDateTime").getStringValue());
			int diffSec = (int)((end.getTime() - start.getTime()) / 1000);
			String timeDisplay = TimeUtils.timeToString(diffSec);
			if (timeDisplay == null) {
				fulfillment = "Sorry, unable to set a timer for less than 1 second or more than 1 day. Please try adding a reminder instead.";
			} else {
				fulfillment = "Starting a timer for " + timeDisplay + " now.";
				display = TimeUtils.makeClockDisplay(diffSec);
			}
		 } else {
			fulfillment = "Sorry, the reminders feature is not supported yet.";
			//TODO: if we ever get access to storing user info or calendars...
		 }
	}
	
	@Override
	public String getOutput() {
	    return fulfillment;
	}

	@Override
	public String getDisplay() {
		return display;
	}

	@Override
	public String getRedirect() {
		return null;
    }
}

@@ -1071,19 +1071,28 @@
 ze%22)) %7B%0A
-%09%09%09
+            
 Struct d
@@ -1153,19 +1153,28 @@
 alue();%0A
-%09%09%09
+            
 Map%3CStri
@@ -1226,26 +1226,28 @@
 eldsMap();%0A%09
-%09%09
+    
 Date start =
@@ -1323,18 +1323,20 @@
 ue());%0A%09
-%09%09
+    
 Date end
@@ -1412,18 +1412,20 @@
 ue());%0A%09
-%09%09
+    
 int diff
@@ -1480,18 +1480,20 @@
 1000);%0A%09
-%09%09
+    
 String t
@@ -1538,19 +1538,28 @@
 ffSec);%0A
-%09%09%09
+            
 if (time
@@ -1574,27 +1574,32 @@
 == null) %7B%0A%09
-%09%09%09
+        
 fulfillment 
@@ -1714,18 +1714,20 @@
 ead.%22;%0A%09
-%09%09
+    
 %7D else %7B
@@ -1727,18 +1727,16 @@
  else %7B%0A
-%09%09
 %09%09fulfil
@@ -1792,18 +1792,16 @@
  now.%22;%0A
-%09%09
 %09%09displa
@@ -1845,16 +1845,23 @@
 c);%0A
-%09%09%09
+            
 %7D%0A%09
-%09 
 %7D el
@@ -1866,18 +1866,20 @@
 else %7B%0A%09
-%09%09
+    
 fulfillm
@@ -1939,18 +1939,20 @@
 yet.%22;%0A%09
-%09%09
+    
 //TODO: 
@@ -2015,18 +2015,22 @@
 ..%0A%09
-%09 %7D%0A%09%7D%0A%09%0A%09
+%7D%0A    %7D%0A%09%0A    
 @Ove
@@ -2027,33 +2027,36 @@
 %09%0A    @Override%0A
-%09
+    
 public String ge
@@ -2068,20 +2068,16 @@
 ut() %7B%0A%09
-    
 return f
@@ -2088,21 +2088,27 @@
 llment;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Overrid
@@ -2101,33 +2101,36 @@
 %0A%0A    @Override%0A
-%09
+    
 public String ge
@@ -2138,26 +2138,32 @@
 Display() %7B%0A
-%09%09
+        
 return displ
@@ -2170,13 +2170,19 @@
 ay;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Ove
@@ -2187,17 +2187,20 @@
 verride%0A
-%09
+    
 public S
@@ -2221,17 +2221,16 @@
 ect() %7B%0A
-%09
 %09return 

Update Reminders.java