public void Live_Push_Geckometer() { // Arrange var widgetKey = GECKOMETER_WIDGETKEY; // replace this value with your own var obj = new GeckoMeterChart() { Item = 0.9m, Format = "percent", Min = new DataItem() { Text = "Min", Value = 0.0m }, Max = new DataItem() { Text = "Max", Value = 1.0m } }; var push = new PushPayload <GeckoMeterChart>() { ApiKey = _apiKey, Data = obj }; var client = new GeckoConnect(); // Act Assert.AreNotEqual("<api key here>", _apiKey); Assert.AreNotEqual("<widget key here>", widgetKey); var result = client.Push <GeckoMeterChart>(push, widgetKey); // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Success); Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message)); }
public HttpResponseMessage GeckoMeter([FromUri] string format = "JSON", [FromUri] string type = "1") { try { if (!User.Identity.IsAuthenticated) { return(this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception("API key not specified."))); } if (Guid.Parse(ConfigurationManager.AppSettings["GeckoAPIkey"]).ToString() != User.Identity.Name) { return(this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception(string.Format("Unknown API key, should be '{0}'.", ConfigurationManager.AppSettings["GeckoAPIkey"])))); } //if (int.Parse(type) != 1) { return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(string.Format("Type parameter '{0}' is wrong.", type))); } // You would modify what gets returned here to make it meaningful var retVal = new GeckoMeterChart() { Item = 23, Min = new DataItem() { Value = 10, Text = "Min visitors" }, Max = new DataItem() { Value = 30, Text = "Max visitors" } }; return(this.Request.CreateResponse <GeckoMeterChart>(HttpStatusCode.OK, retVal)); } catch (Exception ex) { return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public void Live_Push_Geckometer() { // Arrange var widgetKey = "<widget key here>"; // replace this value with your own var obj = new GeckoMeterChart() { Item = 0.9m, Format = "percent", Min = new DataItem() { Text = "Min", Value = 0.0m }, Max = new DataItem() { Text = "Max", Value = 1.0m } }; var push = new PushPayload<GeckoMeterChart>() { ApiKey = this.apiKey, Data = obj }; var client = new GeckoConnect(); // Act Assert.AreNotEqual("<api key here>", this.apiKey); Assert.AreNotEqual("<widget key here>", widgetKey); var result = client.Push<GeckoMeterChart>(push, widgetKey); // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Success); Assert.IsTrue(string.IsNullOrWhiteSpace(result.Message)); }
public HttpResponseMessage GeckoMeter([FromUri]string format = "JSON", [FromUri]string type = "1") { try { if (!User.Identity.IsAuthenticated) { return this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception("API key not specified.")); } if (Guid.Parse(ConfigurationManager.AppSettings["GeckoAPIkey"]).ToString() != User.Identity.Name) { return this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception(string.Format("Unknown API key, should be '{0}'.", ConfigurationManager.AppSettings["GeckoAPIkey"]))); } //if (int.Parse(type) != 1) { return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(string.Format("Type parameter '{0}' is wrong.", type))); } // You would modify what gets returned here to make it meaningful var retVal = new GeckoMeterChart() { Item = 23, Min = new DataItem() { Value = 10, Text = "Min visitors" }, Max = new DataItem() { Value = 30, Text = "Max visitors" } }; return this.Request.CreateResponse<GeckoMeterChart>(HttpStatusCode.OK, retVal); } catch (Exception ex) { return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex); } }