• Javascript

  • C#

  • Node

  • .NET

  • Java

Play the profile assigned to zone

function playAssignedProfile(zoneId) {
  $.ajax({
    type: 'PUT',
    url: 'example.com/api/zones/' + zoneId + '/playAssignedProfile'
  });
}

Stop playing a zone

function stopZone(zoneId) {
  $.ajax({
    type: 'PUT',
    url: 'example.com/api/zones/' + zoneId + '/stop'
  });
}

Switch a zone to other source

function switchZone(zoneId) {
  $.ajax({
    type: 'PUT',
    url: 'example.com/api/zones/' + zoneId + '/switch'
  });
}

Make a playlist and play it on a zone

function playVideoList(zoneId) {
  $.ajax({
    type: 'PUT',
    data: JSON.stringify({
       "videolist": [
         "/video/1.mp4",
         "/video/2.mp4"
        ],
        "queue": false,
        "repeat": false,
        "slideshowInterval": 10
    }),
    url: 'example.com/api/zones/' + zoneId + '/playVideoList'
  });
}

Get the session id value

string getSessionId() {
  using (var httpClient = new HttpClient())
  {
      httpClient.BaseAddress = "http://localhost:9000";
      dynamic loginInfo = new ExpandoObject();
      loginInfo.user = "user";
      loginInfo.password = "your password";
      var auth = JsonConvert.SerializeObject(loginInfo);
      var buffer = System.Text.Encoding.UTF8.GetBytes(auth);
      var byteContent = new ByteArrayContent(buffer);
      var ret = httpClient.PostAsync("/api/session", byteContent);
      IEnumerable<string> retval;
      ret.Result.Headers.TryGetValues("Set-Cookie", out retval);
      if (retval != null)
          return retval.FirstOrDefault();
      else
          return null;
  }
}

Get source information

// get the session id first
string cookie = getSessionId();
object GetSourceList() {
  using (var httpClient = new HttpClient())
  httpClient.BaseAddress = "http://localhost:9000";
  var message = new HttpRequestMessage(HttpMethod.Get, "/api/sources");
  // add cookie value to the message header
  message.Headers.Add("cookie", cookie);
  // send to server
  var result = httpClient.SendAsync(message);
  result.Result.EnsureSuccessStatusCode();
  // get json response
  var s = result.Result.Content.ReadAsStringAsync().Result;
  return JsonConvert.DeserializeObject(s);
}
var chargebee = require("chargebee");
chargebee.configure({site : "supercharge-test", api_key : "test_XFZWh2otngDtKBLglQfqknrrTVcuft7Mj"});
chargebee.subscription.create({
  plan_id : "spacebox-spaceplan-10-boxes",
  plan_quantity : 5,
  customer : {
       email : "john@user.com",
       first_name : "John",
       last_name : "Doe",
       phone : "+1-949-999-9999"
  }
}).request(function(error, result){
  if(error){
    console.log(error);
  } else{
    console.log(result);
    var subscription = result.subscription;
    var customer = result.customer;
    var card = result.card;
    var invoice = result.invoice;
  }
})
ApiConfig.Configure("supercharge-test","test_XFZWh2otngDtKBLglQfqknrrTVcuft7Mj");
EntityResult result = Subscription.Create()
    .PlanId("spacebox-spaceplan-10-boxes")
    .PlanQuantity(5)
    .CustomerEmail("john@user.com")
    .CustomerFirstName("John")
    .CustomerLastName("Doe")
    .CustomerPhone("+1-949-999-9999")
    .Request();
Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Environment.configure("supercharge-test","test_XFZWh2otngDtKBLglQfqknrrTVcuft7Mj");
Result result = Subscription.create()
      .planId("spacebox-spaceplan-10-boxes")
      .planQuantity(5)
      .customerEmail("john@user.com")
      .customerFirstName("John")
      .customerLastName("Doe")
      .customerPhone("+1-949-999-9999")
      .request();
Subscription subscription = result.subscription();
Customer customer = result.customer();