package com.growthbeat.analytics;

import java.util.List;

import com.growthbeat.Context;
import com.growthbeat.analytics.model.Event;

public class GrowthAnalytics {

	private final String BASE_URL = "https://api.analytics.growthbeat.com";
	private Context context = new Context();

	public GrowthAnalytics() {
		super();
		context.getGrowthbeatHttpClient().setBaseUrl(BASE_URL);
	}

	public GrowthAnalytics(String credentialId) {
		this();
		context.setCredentialId(credentialId);
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	public Event findById(String id) {
		return Event.findById(id, context);
	}

	public List<Event> findByApplicationId(String applicationId) {
		return Event.findByApplicationId(applicationId, context);
	}

	public Event create(String parentEventId, String applicationId, String name, String description) {
		return Event.create(parentEventId, applicationId, name, description, context);
	}

	public Event update(String eventId, String description) {
		return Event.update(eventId, description, context);
	}

	public void delete(String eventId) {
		Event.delete(eventId, context);
	}

}

@@ -127,16 +127,59 @@
 l.Event;
+%0Aimport com.growthbeat.analytics.model.Tag;
 %0A%0Apublic
@@ -663,24 +663,29 @@
 c Event find
+Event
 ById(String 
@@ -752,24 +752,29 @@
 %3CEvent%3E find
+Event
 ByApplicatio
@@ -885,16 +885,21 @@
 t create
+Event
 (String 
@@ -1075,16 +1075,21 @@
 t update
+Event
 (String 
@@ -1196,16 +1196,21 @@
 d delete
+Event
 (String 
@@ -1258,10 +1258,579 @@
 t);%0A%09%7D%0A%0A
+%09public Tag findTagById(String id) %7B%0A%09%09return Tag.findById(id, context);%0A%09%7D%0A%0A%09public List%3CTag%3E findTagByApplicationId(String applicationId) %7B%0A%09%09return Tag.findByApplicationId(applicationId, context);%0A%09%7D%0A%0A%09public Tag createTag(String parentTagId, String applicationId, String name, String description) %7B%0A%09%09return Tag.create(parentTagId, applicationId, name, description, context);%0A%09%7D%0A%0A%09public Tag updateTag(String tagId, String description) %7B%0A%09%09return Tag.update(tagId, description, context);%0A%09%7D%0A%0A%09public void deleteTag(String tagId) %7B%0A%09%09Tag.delete(tagId, context);%0A%09%7D%0A%0A
 %7D%0A

Add Tag function.