Пример #1
0
        public override object RequestAction(string action, IDictionary <string, string> query)
        {
            // Return early if there is not an API key
            if (Settings.ApiKey.IsNullOrWhiteSpace())
            {
                return(new
                {
                    devices = new List <object>()
                });
            }

            if (action == "getProfiles")
            {
                Settings.Validate().Filter("ApiKey").ThrowOnError();

                var profiles = _sonarrV3Proxy.GetProfiles(Settings);

                return(new
                {
                    options = profiles.OrderBy(d => d.Name, StringComparer.InvariantCultureIgnoreCase)
                              .Select(d => new
                    {
                        id = d.Id,
                        name = d.Name
                    })
                });
            }

            if (action == "getTags")
            {
                var tags = _sonarrV3Proxy.GetTags(Settings);

                return(new
                {
                    options = tags.OrderBy(d => d.Label, StringComparer.InvariantCultureIgnoreCase)
                              .Select(d => new
                    {
                        id = d.Id,
                        name = d.Label
                    })
                });
            }

            return(new { });
        }