package com.growthbeat.analytics;

import java.util.List;

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

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 findEventById(String id) {
		return Event.findById(id, context);
	}

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

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

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

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

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

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

	public Tag createTag(String parentTagId, String applicationId, String name, String description) {
		return Tag.create(parentTagId, applicationId, name, description, context);
	}

	public Tag updateTag(String tagId, String description) {
		return Tag.update(tagId, description, context);
	}

	public void deleteTag(String tagId) {
		Tag.delete(tagId, context);
	}

}

@@ -128,16 +128,62 @@
 .Event;%0A
+import com.growthbeat.analytics.model.Metric;%0A
 import c
@@ -217,16 +217,16 @@
 el.Tag;%0A
-
 %0Apublic 
@@ -807,16 +807,17 @@
 indEvent
+s
 ByApplic
@@ -1407,16 +1407,17 @@
  findTag
+s
 ByApplic
@@ -1841,16 +1841,16 @@
 agId) %7B%0A
-
 %09%09Tag.de
@@ -1875,10 +1875,693 @@
 t);%0A%09%7D%0A%0A
+%09// TODO Semgnet API%0A%0A%09public Metric findMetricById(String id) %7B%0A%09%09return Metric.findById(id, context);%0A%09%7D%0A%0A%09public List%3CMetric%3E findMetricsByParentMetricId(String parentMetricId, Integer depth) %7B%0A%09%09return Metric.findByParentMetricId(parentMetricId, depth, context);%0A%09%7D%0A%0A%09public Metric createMetric(String parentMetricId, String name, String description, String query) %7B%0A%09%09return Metric.create(parentMetricId, name, description, query, context);%0A%09%7D%0A%0A%09public Metric updateMetric(String metricId, String description, String query) %7B%0A%09%09return Metric.update(metricId, description, query, context);%0A%09%7D%0A%0A%09public void deleteMetric(String metricId) %7B%0A%09%09Metric.delete(metricId, context);%0A%09%7D%0A%0A
 %7D%0A

Add Metric function.