예제 #1
0
        /// <summary>
        /// Create an API client.
        /// </summary>
        /// <param name="description">Short description for the key (i.e.: HipChat, Campfire, etc.)</param>
        /// <returns>Instance of GaugesNet.Entity.Client class.</returns>
        public Entity.Client CreateClient(string description)
        {
            if (string.IsNullOrEmpty(description))
            {
                throw new ArgumentNullException("description required.");
            }

            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("description", description);

            string response = new Curl().Post("https://secure.gaug.es/clients", _token, data);
            return JsonConvert.DeserializeObject<Entity.ApiClients>(response).Client;
        }
예제 #2
0
        /// <summary>
        /// Create a new gauge.
        /// </summary>
        /// <param name="title">The title of the gauge.</param>
        /// <param name="timezone">The time zone that should be used for all date/time operations.</param>
        /// <param name="allowedHosts">Comma or space separated list of domains to accept tracking data from.</param>
        /// <returns>Instance of GaugesNet.Entity.Gauge class.</returns>
        public Entity.Gauge CreateGauge(string title, string timezone, string allowedHosts)
        {
            if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException("title required."); }
            if (string.IsNullOrEmpty(timezone)) { throw new ArgumentNullException("timezone required."); }

            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("title", title);
            data.Add("tz", timezone);
            if (string.IsNullOrEmpty(allowedHosts)) { data.Add("allowed_hosts", allowedHosts); }

            string response = new Curl().Post("https://secure.gaug.es/gauges", _token, data);
            return JsonConvert.DeserializeObject<Entity.ApiGauges>(response).Gauge;
        }
예제 #3
0
        /// <summary>
        /// Update user's first name and/or last name.
        /// </summary>
        /// <param name="firstName">User's first name.</param>
        /// <param name="lastName">User's last name.</param>
        /// <returns>Instance of GaugesNet.Entity.User class.</returns>
        public Entity.User UpdateMe(string firstName, string lastName)
        {
            if (string.IsNullOrEmpty(firstName) && string.IsNullOrEmpty(lastName))
            {
                throw new ArgumentNullException("firstName or lastName required.");
            }

            Dictionary<string, string> data = new Dictionary<string, string>();

            if (!string.IsNullOrEmpty(firstName)) { data.Add("first_name", firstName); }
            if (!string.IsNullOrEmpty(lastName)) { data.Add("last_name", lastName); }

            string response = new Curl().Put("https://secure.gaug.es/me", _token, data);
            return JsonConvert.DeserializeObject<Entity.Me>(response).User;
        }
예제 #4
0
 /// <summary>
 /// Gets user information.
 /// </summary>
 /// <returns>Instance of GaugesNet.Entity.User class.</returns>
 public Entity.User Me()
 {
     string response = new Curl().Get("https://secure.gaug.es/me", _token);
     return JsonConvert.DeserializeObject<Entity.Me>(response).User;
 }
예제 #5
0
 /// <summary>
 /// Gets a list of gauges with recent traffic included.
 /// </summary>
 /// <returns>Instance of GaugesNet.Entity.Gauges class.</returns>
 public Entity.Gauges GetGauges()
 {
     string response = new Curl().Get("https://secure.gaug.es/gauges", _token);
     return JsonConvert.DeserializeObject<Entity.ApiGauges>(response).Gauges;
 }
예제 #6
0
        /// <summary>
        /// Gets details for a gauge.
        /// </summary>
        /// <param name="id">API client key.</param>
        /// <returns>Instance of GaugesNet.Entity.Gauge class.</returns>
        public Entity.Gauge GetGauge(string id)
        {
            if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id required."); }

            string response = new Curl().Get("https://secure.gaug.es/gauges/" + id, _token);
            return JsonConvert.DeserializeObject<Entity.ApiGauges>(response).Gauge;
        }
예제 #7
0
 /// <summary>
 /// Gets API client list.
 /// </summary>
 /// <returns>Instance of GaugesNet.Entity.Clients class.</returns>
 public Entity.Clients GetClients()
 {
     string response = new Curl().Get("https://secure.gaug.es/clients", _token);
     return JsonConvert.DeserializeObject<Entity.ApiClients>(response).Clients;
 }
예제 #8
0
        /// <summary>
        /// Permanently deletes an API client key.
        /// </summary>
        /// <param name="id">API client key.</param>
        /// <returns>Instance of GaugesNet.Entity.Client class.</returns>
        public Entity.Client DeleteClient(string id)
        {
            if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id required."); }

            string response = new Curl().Delete("https://secure.gaug.es/clients/" + id, _token);
            return JsonConvert.DeserializeObject<Entity.ApiClients>(response).Client;
        }