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;
    }
}
@@ -532,17 +532,18 @@
 null;%0A  
-%09
+  
 private 
@@ -784,16 +784,18 @@
 %7B%0A      
+  
 this.int
@@ -822,16 +822,18 @@
 ;%0A      
+  
 try %7B%0A  
@@ -838,16 +838,20 @@
         
+   
+ 
 setParam
@@ -875,16 +875,18 @@
 ;%0A      
+  
 %7D catch 
@@ -901,32 +901,36 @@
 on e) %7B%0A        
+   
+ 
 fulfillment = nu
@@ -935,24 +935,26 @@
 null;%0A      
+  
 %7D%0A    %7D%0A%0A%09@O
@@ -950,17 +950,20 @@
 %0A    %7D%0A%0A
-%09
+    
 @Overrid
@@ -965,17 +965,20 @@
 erride %0A
-%09
+    
 public v
@@ -1030,24 +1030,26 @@
 rs) %7B%0A      
+  
 if (intentNa
@@ -1071,24 +1071,19 @@
 ze%22)) %7B%0A
-        
+%09%09%09
 Struct d
@@ -1144,24 +1144,19 @@
 alue();%0A
-        
+%09%09%09
 Map%3CStri
@@ -1211,24 +1211,19 @@
 sMap();%0A
-        
+%09%09%09
 Date sta
@@ -1302,24 +1302,19 @@
 lue());%0A
-        
+%09%09%09
 Date end
@@ -1389,24 +1389,19 @@
 lue());%0A
-        
+%09%09%09
 int diff
@@ -1455,24 +1455,19 @@
  1000);%0A
-        
+%09%09%09
 String t
@@ -1512,24 +1512,19 @@
 ffSec);%0A
-        
+%09%09%09
 if (time
@@ -1542,26 +1542,20 @@
 null) %7B%0A
-          
+%09%09%09%09
 fulfillm
@@ -1673,24 +1673,19 @@
 tead.%22;%0A
-        
+%09%09%09
 %7D else %7B
@@ -1685,26 +1685,20 @@
  else %7B%0A
-          
+%09%09%09%09
 fulfillm
@@ -1752,26 +1752,20 @@
  now.%22;%0A
-          
+%09%09%09%09
 display 
@@ -1807,23 +1807,15 @@
 c);%0A
-        %7D%0A     
+%09%09%09%7D%0A%09%09
  %7D e
@@ -1820,24 +1820,19 @@
  else %7B%0A
-        
+%09%09%09
 fulfillm
@@ -1891,24 +1891,19 @@
  yet.%22;%0A
-        
+%09%09%09
 //TODO: 
@@ -1961,21 +1961,18 @@
 dars...%0A
-     
+%09%09
  %7D%0A%09%7D%0A%09%0A
@@ -2014,16 +2014,18 @@
 () %7B%0A%09  
+  
 return f
@@ -2167,8 +2167,9 @@
 %0A    %7D%0A%7D
+%0A

Update Reminders.java