Example #1
0
        public static Task <IRootResourceObject> ActorTargets(
            this IHalHttpClientWithRoot client,
            Identifier actor,
            string filter = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (actor == null)
            {
                throw new ArgumentNullException("actor");
            }
            if (!actor.IsValid)
            {
                throw new ArgumentException("Invalid actor", "actor");
            }

            var shortcut = new Shortcut
            {
                Actor  = actor,
                Rel    = LinkRelations.Findsi.ActorTargets,
                Filter = filter
            };

            return(Shortcut(client, shortcut));
        }
Example #2
0
        public static Task <IRootResourceObject> TargetDetail(
            this IHalHttpClientWithRoot client,
            Identifier target)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (!target.IsValid)
            {
                throw new ArgumentException("Invalid target", "target");
            }

            var shortcut = new Shortcut
            {
                Target = target,
                Rel    = LinkRelations.Findsi.TargetDetail
            };

            return(Shortcut(client, shortcut));
        }
Example #3
0
        public static Task <IRootResourceObject> ActorTargets(
            this IHalHttpClientWithRoot client,
            string classification,
            string id,
            string filter = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (classification == null)
            {
                throw new ArgumentNullException("classification");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            var actor = new Identifier
            {
                Classification = classification,
                Id             = id
            };

            return(ActorTargets(client, actor, filter));
        }
Example #4
0
        public static Task <IRootResourceObject> TargetDetail(
            this IHalHttpClientWithRoot client,
            string classification,
            string id)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (classification == null)
            {
                throw new ArgumentNullException("classification");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            var target = new Identifier
            {
                Classification = classification,
                Id             = id
            };

            return(TargetDetail(client, target));
        }
        public static Task <IRootResourceObject> Log(this IHalHttpClientWithRoot client, Actor actor, string action, Target target)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (actor == null)
            {
                throw new ArgumentNullException("actor");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            var log = new Log
            {
                Action = action,
                Actor  = actor,
                Target = target
            };

            return(Log(client, log));
        }
Example #6
0
        public static Task <IRootResourceObject> Shortcut(this IHalHttpClientWithRoot client, Shortcut shortcut)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (shortcut == null)
            {
                throw new ArgumentNullException("shortcut");
            }

            var uri = client.Root.Links[LinkRelations.Findsi.Shortcuts].Single().Href;

            return(client.PostAsync(uri, shortcut));
        }
Example #7
0
        public static Task <IRootResourceObject> TargetRecommendations(
            this IHalHttpClientWithRoot client,
            string actorClassification,
            string actorId,
            string targetClassification,
            string targetId,
            string filter = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (actorClassification == null)
            {
                throw new ArgumentNullException("actorClassification");
            }
            if (actorId == null)
            {
                throw new ArgumentNullException("actorId");
            }
            if (targetClassification == null)
            {
                throw new ArgumentNullException("targetClassification");
            }
            if (targetId == null)
            {
                throw new ArgumentNullException("targetId");
            }

            var actor = new Identifier
            {
                Classification = actorClassification,
                Id             = actorId
            };

            var target = new Identifier
            {
                Classification = targetClassification,
                Id             = targetId
            };

            return(TargetRecommendations(client, actor, target, filter));
        }
        private static Task <IRootResourceObject> Log(IHalHttpClientWithRoot client, Log log)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }
            if (!log.IsValid)
            {
                throw new ArgumentException("Invalid log", "log");
            }

            var uri = client.Root.Links[LinkRelations.Findsi.Logs].Single().Href;

            return(client.PostAsync(uri, log));
        }
        public static Task <IRootResourceObject> TargetList(
            this IHalHttpClientWithRoot client,
            string filter = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            var uri = client.Root.Links[LinkRelations.Findsi.TargetList].Single().Href;

            if (!string.IsNullOrEmpty(filter))
            {
                uri = uri.ToString().Contains("?")
                    ? new Uri(string.Format("{0}&filter={1}", uri, filter))
                    : new Uri(string.Format("{0}?filter={1}", uri, filter));
            }

            return(client.GetAsync(uri));
        }