Following is an example of how to create a custom console application or form based control panel using our .NET wrapper also available in Nuget repository.

Console Application

  1. References and dependencies

             using System;
             using System.Linq;
             using System.Text;
             using System.IO;
             using System.Data;
             using System.Globalization;
             using System.Threading;
             using System.Web;
             using MaxCDN;
          
  2. Install MaxCDN.dll

    1. Open nuget package manager to add reference to MaxCDN.dll:
    2. Search repository for maxcdn and install it from nuget package manager:
  3. Manage account details
    Methods used: GET, PUT.

              //Address
              Console.Write(api.Get("/account.json/address"));
    
              //Edit
              Console.Write("Enter property to edit (): \n");
              string prop = Console.ReadLine();
              Console.Write("Enter new value: \n");
              string val = Console.ReadLine();
    
              api.Put("/account.json/", prop + "=" + val);
          
  4. Manage Zones
    Methods used: GET, PUT, POST, DELETE.

          namespace MaxCDN_dll
          {
              class Zones
              {
                  public void ManageZones(int requestTimeout)
                  {
                      
                      var api = new MaxCDN.Api("ALIAS", "KEY", "SECRET", requestTimeout);
    
                      Console.Write("1. List\n2. Create\n3. Edit\n4. Delete\n\n");
                      int choice = Convert.ToInt32(Console.ReadLine());
                      switch (choice)
                      {
                          case 1:
                          Console.Write("Zone Type? (pull/push/vod)\n");
                          string list = Console.ReadLine();
                          Console.Write(api.Get("/zones/" + list + ".json"));
                          break;
                          case 2:
                          Console.Write("Zone Type? (pull/push/vod)\n");
                          string create = Console.ReadLine();
                          Console.Write("Zone Name: \n");
                          string ZoneName = Console.ReadLine();
                          string param = "";
                          if (create == "pull")
                          {
                              Console.Write("Origin URL (starting with http://): \n");
                              string url = Console.ReadLine();
                              param = "url=" + url + "&name=" + ZoneName;
                          }
                          if(create != "pull")
                          {
                              Console.Write("Password: \n");
                              string password = Console.ReadLine();
                              param = "password=" + password + "&name=" + ZoneName;
                          }
                          
                          api.Post("/zones/" + create + ".json", param);
                          break;
                          case 3:
                          Console.Write("Zone Type: (pull/push/vod)");
                          string edit = Console.ReadLine();
                          if (edit == "pull")
                          {
                              Console.Write("Zone ID: \n");
                              int zoneID = Convert.ToInt32(Console.ReadLine());
                              Console.Write("Choose property: compress, url, use_stale,... full list: https://docs.maxcdn.com\n");
                              string prop = Console.ReadLine();
                              Console.Write("New Value: \n");
                              string val = Console.ReadLine();
                              api.Put("/zones/" + edit + ".json/" + zoneID, prop + "=" + val);
                          }
                          break;
                          case 4:
                          Console.Write("Zone Type: (pull/push/vod)");
                          string delete = Console.ReadLine();
                          Console.Write("Zone ID: \n");
                              int zID = Convert.ToInt32(Console.ReadLine());
                          api.Delete("/zones/" + delete + ".json/" + zID);
                          break;
                      }
                      
                  }
    
                  internal void ListZones()
                  {
                      throw new NotImplementedException();
                  }
              }
          }
          
  5. Manage Custom Domains
    Methods used: GET, PUT, POST, DELETE.

             namespace MaxCDN_dll
             {
                 class CDomains
                 {
                     public void ManageCDoms(int requestTimeout)
                     {
                         var api = new MaxCDN.Api("ALIAS", "KEY", "SECRET", requestTimeout);
    
                         Console.Write("1. List\n2. Create\n3. Edit\n4. Delete\n\n");
                         int choice = Convert.ToInt32(Console.ReadLine());
                         switch (choice)
                         {
                             case 1:
                                 Console.Write("Zone Type? (pull/push/vod)\n");
                                 string list = Console.ReadLine();
                                 Console.Write("Zone ID: \n");
                                 int czid = Convert.ToInt32(Console.ReadLine());
                                 Console.Write(api.Get("/zones/pull/" + czid + "/customdomains.json"));
                                 break;
                             case 2:
                                 Console.Write("Zone Type? (pull/push/vod)\n");
                                 string create = Console.ReadLine();
                                 Console.Write("Custom Domain: \n");
                                 string cdname = Console.ReadLine();
                                 Console.Write("Zone ID: \n");
                                 string cdzid = Console.ReadLine();
                                 string param = "";
                                 param = "custom_domain=" + cdname;
    
                                 Console.Write(api.Post("/zones/pull/" + cdzid + "/customdomains.json", param));
                                 break;
                             case 3:
                                 Console.Write("Zone Type: (pull/push/vod)\n");
                                 string edit = Console.ReadLine();
                                 Console.Write("Zone ID: \n");
                                 int zoneID = Convert.ToInt32(Console.ReadLine());
                                 Console.Write(api.Get("/zones/" + edit + "/" + zoneID + "/customdomains.json") + "\n");
                                 Console.Write("Custom Domain ID: \n");
                                 int cid = Convert.ToInt32(Console.ReadLine());
                                 Console.Write("New Value: \n");
                                 string val = Console.ReadLine();
    
                                 api.Put("/zones/" + edit + "/" + zoneID + "/customdomains.json/" + cid, "custom_domain=" + val);
                                 
                                 break;
                             case 4:
                                 Console.Write("Zone Type: (pull/push/vod)\n");
                                 string delete = Console.ReadLine();
                                 Console.Write("Zone ID: \n");
                                 int zID = Convert.ToInt32(Console.ReadLine());
                                 Console.Write(api.Get("/zones/" + delete + "/" + zID + "/customdomains.json") + "\n");
                                 Console.Write("Custom Domain ID: \n");
                                 int ciddel = Convert.ToInt32(Console.ReadLine());
                                 api.Delete("/zones/pull/" + zID + "/customdomains.json/" + ciddel);
                                 break;
                         }
                     }
                 }
             }
          
  6. Manage Cache
    Methods used: DELETE, PURGE.

             namespace MaxCDN_dll
             {
                 class Purge
                 {
                     public void ManageCache(int requestTimeout)
                     {
                         var api = new MaxCDN.Api("ALIAS", "KEY", "SECRET", requestTimeout);
    
                         Console.Write("1. All\n2. File\n3. Multiple Files\n");
                         int choice = Convert.ToInt32(Console.ReadLine());
                         Console.Write("Zone ID: \n");
                         int zID = Convert.ToInt32(Console.ReadLine());
                         switch (choice)
                         {
                             case 1:
                                 api.Delete("/zones/pull.json/" + zID + "/cache");
                                 break;
                             case 2:
                                 Console.Write("File path to purge (relative path -> /file.ext): \n");
                                 string path = Console.ReadLine();
    
                                 api.Purge("/zones/pull.json/" + zID + "/cache", path);
                                 break;
                             case 3:
                                 Console.Write("How Many? \n");
                                 int loop = Convert.ToInt32(Console.ReadLine());
                                 Console.Write("Enter File Paths to Purge (relative paths): \n");
                                 string files = "";
                                 for (int i = 0; i < loop; i++)
                                 {
                                     Console.Write(i + 1 + ": \n");
                                     string File = Console.ReadLine();
                                     files += "file[" + i + "]=" + File + "&";
                                 }
    
                                 api.Purge("/zones/pull.json/" + zID + "/cache", files);
                                 break;
                         }
                     }
                 }
             }
          
  7. Form Application

    1. Reporting
      Due to a need for visualization, reporting presentation should be handled by Windows Form application in order to draw charts you require. Below is an example of how to use built in control called Chart:
      Methods used: GET.
      References and dependencies

            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Windows.Forms;
            using System.Windows.Forms.DataVisualization.Charting;
            using MaxCDN;
            using Newtonsoft;
            using Newtonsoft.Json;
            using Newtonsoft.Json.Linq;
            
    2. Visualization
      Controls used: Chart.

                  var requestTimeout = 30;
                  var alias = Properties.Settings.Default._alias;
                  var consumer_key = Properties.Settings.Default._consumer_key;
                  var consumer_secret = Properties.Settings.Default._consumer_secret;
                  var api = new MaxCDN.Api(alias, consumer_key, consumer_secret, requestTimeout);
                  var res = api.Get(("/reports/statsbyzone.json/monthly"));
                  string result = Convert.ToString(JObject.Parse(res));
                  dynamic jsondes = JsonConvert.DeserializeObject(result);
                  string requests = jsondes.data.summary.hit;
                  string hits = jsondes.data.summary.cache_hit;
                  string misses = jsondes.data.summary.noncache_hit;
      
                  string[] seriesArray = { "Requests", "Hits", "Misses" };
                  int[] pointsArray = {Convert.ToInt32(requests), Convert.ToInt32(hits), Convert.ToInt32(misses) };
                  this.chart2.Palette = ChartColorPalette.SeaGreen;
                  this.chart2.Titles.Add("Summary");
                  for (int i = 0; i < seriesArray.Length; i++)
                  {
                      Series series = this.chart2.Series.Add(seriesArray[i]);
                      series.Points.Add(pointsArray[i]);
                  }
            
    3. Raw Logs
      Methods used: GET.
      Controls used: ListView, MonthCalendar.

                     listView1.Items.Clear();
                     string append = "&status=200";
                     var requestTimeout = 30;
                     var alias = Properties.Settings.Default._alias;
                     var consumer_key = Properties.Settings.Default._consumer_key;
                     var consumer_secret = Properties.Settings.Default._consumer_secret;
                     var api = new MaxCDN.Api(alias, consumer_key, consumer_secret, requestTimeout);
                     var start = monthCalendar1.SelectionStart.Date.Year + "-" + monthCalendar1.SelectionStart.Date.Month + "-" + monthCalendar1.SelectionStart.Date.Day;
                     var end = monthCalendar2.SelectionEnd.Year + "-" + monthCalendar2.SelectionStart.Date.Month + "-" + monthCalendar2.SelectionStart.Date.Day;
                     var res = api.Get("/v3/reporting/logs.json?limit=1000&start=" + start + "&end=" + end + append);
                     string result = Convert.ToString(JObject.Parse(res));
                     dynamic jsondes = JsonConvert.DeserializeObject(result);
                     
                     var list = jsondes.records;
                     JArray items = (JArray)jsondes["records"];
                     int count = items.Count;
      
                     for (int i = 0; i < count; i++)
                     {
                         string time = list[i].time;
                         string location = list[i].client_city + ", " + list[i].client_country;
                         string host = list[i].hostname;
                         string uri = list[i].uri;
                         string referer = list[i].referer;
                         string status = list[i].status;
                         string cachestatus = list[i].cache_status;
                         ListViewItem line = new ListViewItem(new[] { time, location, host, uri, referer, status, cachestatus });
                         this.listView1.Items.Add(line);
                     }