package com.thebluealliance.androidclient.datafeed.deserializers;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.thebluealliance.androidclient.models.Match;

import java.lang.reflect.Type;


public class MatchDeserializer implements JsonDeserializer<Match>{

	@Override
	public Match deserialize(final JsonElement json, Type typeOf, JsonDeserializationContext context) throws JsonParseException {
		final JsonObject object = json.getAsJsonObject();
		final Match match = new Match();
		
		match.setKey(object.get("key").getAsString());
		match.setTypeFromShort(object.get("comp_level").getAsString());
		match.setMatchNumber(object.get("match_number").getAsInt());
		match.setSetNumber(object.get("set_number").getAsInt());
		match.setAlliances(object.get("alliances").getAsJsonObject());
		/* NOT YET EXPOSED TO THE API, uncomment below when it is
		 * match.setTime(object.get("time").getAsString());
		 * match.setVideos(object.get("videos").getAsJsonObject);
		 */
		match.setTime("");
		match.setVideos(new JsonObject());
		match.setLastUpdated(System.currentTimeMillis());
		
		return null;
	}

}

@@ -959,70 +959,77 @@
 ;%0A%09%09
-/* NOT YET EXPOSED TO THE API, uncomment below when it is%0A%09%09 *
+match.setTimeString(object.get(%22time_string%22).getAsString());%0A       
  mat
@@ -1055,36 +1055,34 @@
 et(%22time%22).getAs
-Stri
+Lo
 ng());%0A%09%09 * matc
@@ -1078,11 +1078,8 @@
 ;%0A%09%09
- * 
 matc
@@ -1130,35 +1130,10 @@
 ject
+(
 )
-;%0A%09%09 */%0A%09%09match.setTime(%22%22
 );%0A%09

update match deserializer for match times in API