package webchurch.push.util;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import webchurch.push.model.PushDTO;
import javapns.notification.Payload;

public class CustomPayLoad extends Payload{
	private JSONObject payload = new JSONObject();
	public CustomPayLoad(PushDTO pushDTO, String sound, int badge) throws JSONException {
		put(PushName.TITLE, pushDTO.getTitle(), this.payload, false);
		put(PushName.MSG_APPLE, pushDTO.getMsg(), this.payload, false);
		put(PushName.LINK, pushDTO.getLink(), this.payload, false);
		put("badge", badge, this.payload, false);
		put("sound", sound, this.payload, false);
	}

	public CustomPayLoad addCDictionarys(String name, String value)
			throws JSONException {
		logger.debug("Adding custom Dictionary [" + name + "] = [" + value
				+ "]");
		put(name, value, this.payload, false);
		return this;
	}

	public CustomPayLoad addCDictionarys(String name, int value)
			throws JSONException {
		logger.debug("Adding custom Dictionary [" + name + "] = [" + value
				+ "]");
		put(name, Integer.valueOf(value), this.payload, false);
		return this;
	}

	public CustomPayLoad addCDictionary(String name, List values)
			throws JSONException {
		logger.debug("Adding custom Dictionary [" + name + "] = (list)");
		put(name, values, this.payload, false);
		return this;
	}
	
	
}
