/// <summary> /// Get all accounts for a specific user /// </summary> /// <returns></returns> public IEnumerable <AnalyticsAccountRequest> GetAccounts() { if (string.IsNullOrEmpty(_token)) { throw new Exception("No token found. Did you forget to login?"); } var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/accounts/default"); var parser = new AnalyticsXmlParser(); return(parser.Parse(data, new AnalyticsAccountApiMap())); }
/// <summary> /// Get dashboard summary for a given profile /// </summary> /// <returns></returns> public DashboardRequest GetDashboard(string start, string end) { if (string.IsNullOrEmpty(_token)) { throw new Exception("No token found. Did you forget to login?"); } if (_profile == null) { throw new Exception("No profile set. Use .Profile() to set."); } var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/data?ids=ga%3A" + _profile.Value + "&metrics=ga%3Avisits,ga%3Apageviews,ga%3Abounces,ga%3Aentrances,ga%3AtimeOnSite,ga%3AnewVisits&start-date=" + start + "&end-date=" + end + "&max-results=50"); var parser = new AnalyticsXmlParser(); return(parser.Parse(data, new DashboardApiMap()).First()); }