package com.growthbeat.model;

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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.growthbeat.Context;
import com.growthbeat.constants.Constants;

public class Consumption extends Model {

	private int count;
	private Date created;
	private Account account;
	private Resource resource;
	private Action action;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Constants.ISO_8601_DATETIME_FORMAT)
	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public Resource getResource() {
		return resource;
	}

	public void setResource(Resource resource) {
		this.resource = resource;
	}

	public Action getAction() {
		return action;
	}

	public void setAction(Action action) {
		this.action = action;
	}

	public static Consumption create(String accountId, String resourceId, String actionId, int count, Context context) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("accountId", accountId);
		params.put("resourceId", resourceId);
		params.put("actionId", actionId);
		params.put("count", count);
		return post(context, "1/consumptions", params, Consumption.class);
	}

}

@@ -73,16 +73,39 @@
 ashMap;%0A
+import java.util.List;%0A
 import j
@@ -171,16 +171,70 @@
 Format;%0A
+import com.fasterxml.jackson.core.type.TypeReference;%0A
 import c
@@ -298,16 +298,55 @@
 nstants;
+%0Aimport com.growthbeat.utils.JsonUtils;
 %0A%0Apublic
@@ -1596,10 +1596,336 @@
 s);%0A%09%7D%0A%0A
+%09public static List%3CConsumption%3E create(List%3CMap%3CString, String%3E%3E consumptions, Context context) %7B%0A%09%09Map%3CString, Object%3E params = new HashMap%3CString, Object%3E();%0A%09%09params.put(%22consumptions%22, JsonUtils.serialize(consumptions));%0A%09%09return post(context, %221/consumptions%22, params, new TypeReference%3CList%3CConsumption%3E%3E() %7B%0A%09%09%7D);%0A%09%7D%0A%0A
 %7D%0A

add list consumption