Jump to content

How to use IService endpoint?


chef

Recommended Posts

chef

Could someone please tell me what in the world I'm missing for this IService Endpoint Class. It is unaccessible in my plugin and I honestly can't figure out why:


using MediaBrowser.Controller.Devices;
using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using System.Collections.Generic;

namespace VeraHomeAutomation
{
//To many repetitive devices in a normal List<DeviceInfo> so weed out the duplicates
//CHROME YOU ARE TO BLAME! quit changing the last four characters in your ID's!!!!

[Route("Vera/SortedDevices", "GET", Summary = "Sorted Device List End Point")]

public class SortedDeviceService : IService
{
public IDeviceManager DeviceManager { get; set; }
public IJsonSerializer JsonSerializer { get; set; }

public EmbyDeviceService(IDeviceManager dM, IJsonSerializer jS)
{
DeviceManager = dM;
JsonSerializer = jS;

}

public string Get()
{
var deviceInfo = DeviceManager.GetDevices(new DeviceQuery());

var deviceList = new List<DeviceInfo>();

foreach (var device in deviceInfo.Items)
{
if (!deviceList.Exists(x => x.Name.ToLower() == device.Name.ToLower() && x.AppName.ToLower() == device.AppName.ToLower()))
{
deviceList.Add(device);
}
}

return JsonSerializer.SerializeToString(deviceList);

}
}
}

Thank you.

Edited by chef
Link to comment
Share on other sites

chef

Thank you,

 

Yes the I understand now about the routing class, and also also a note that the route must start with a "/".

 

It now works.

Edited by chef
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...