package io.featureflow.client;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by oliver on 23/05/2016.
 */
public class FeatureFlowContext{

    String key;
    Map<String, ? extends JsonElement> values = new HashMap<>();

    public FeatureFlowContext(String key) {
        this.key = key;
    }

    public static Builder keyedContext(String key){
        return new Builder(key);
    }
    public static Builder context(){
        return new Builder();
    }

    public static class Builder{
        private String key;
        private Map<String, JsonElement> values = new HashMap<>();

        public Builder() {}
        public Builder(String key) {
            this.key = key;
        }

        public Builder withValue(String key, JsonElement value){
            this.values.put(key, value);
            return this;
        }
        public Builder withValue(String key, String value){
            JsonPrimitive jsonValue = new JsonPrimitive(value);
            this.values.put(key, jsonValue);
            return this;
        }
        public Builder withValue(String key, DateTime value){
            JsonPrimitive jsonValue = new JsonPrimitive(toIso(value));
            this.values.put(key, jsonValue);
            return this;
        }
        public Builder withValue(String key, Number value){
            JsonPrimitive jsonValue = new JsonPrimitive(value);
            this.values.put(key, jsonValue);
            return this;
        }
        public FeatureFlowContext build(){
            if(key==null)key = "anonymous";
            FeatureFlowContext context = new FeatureFlowContext(key);
            context.values = values;
            return context;
        }

        protected static String toIso(DateTime date) {
            DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
            String str = fmt.print(date);
            return str;
        }
    }
}

package io.featureflow.client;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by oliver on 23/05/2016.
 */
public class FeatureFlowContext{

    String key;
    Map<String, ? extends JsonElement> values = new HashMap<>();

    public FeatureFlowContext(String key) {
        this.key = key;
    }

    public static Builder keyedContext(String key){
        return new Builder(key);
    }
    public static Builder context(){
        return new Builder();
    }

    public Map<String,? extends JsonElement> getValues() {
        return values;
    }

    public static class Builder{
        private String key;
        private Map<String, JsonElement> values = new HashMap<>();

        public Builder() {}
        public Builder(String key) {
            this.key = key;
        }

        public Builder withValue(String key, JsonElement value){
            this.values.put(key, value);
            return this;
        }
        public Builder withValue(String key, String value){
            JsonPrimitive jsonValue = new JsonPrimitive(value);
            this.values.put(key, jsonValue);
            return this;
        }
        public Builder withValue(String key, DateTime value){
            JsonPrimitive jsonValue = new JsonPrimitive(toIso(value));
            this.values.put(key, jsonValue);
            return this;
        }
        public Builder withValue(String key, Number value){
            JsonPrimitive jsonValue = new JsonPrimitive(value);
            this.values.put(key, jsonValue);
            return this;
        }
        public FeatureFlowContext build(){
            if(key==null)key = "anonymous";
            FeatureFlowContext context = new FeatureFlowContext(key);
            context.values = values;
            return context;
        }

        protected static String toIso(DateTime date) {
            DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
            String str = fmt.print(date);
            return str;
        }
        protected static DateTime fromIso(String isoDate) {
            DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
            DateTime dt = fmt.parseDateTime(isoDate);
            return dt;
        }
    }
}

Convert and save context values as targets and lookups, added get targets and target search lookup endpoints