Example #1
0
        public async Task <AgentProfileLRSResponse> RetrieveAgentProfile(string id, Agent agent)
        {
            var r = new AgentProfileLRSResponse();

            var queryParams = new Dictionary <string, string>();

            queryParams.Add("profileId", id);
            queryParams.Add("agent", agent.ToJSON(version));

            var profile = new AgentProfileDocument();

            profile.id    = id;
            profile.agent = agent;

            var resp = await GetDocument("agents/profile", queryParams, profile);

            if (resp.status != HttpStatusCode.OK && resp.status != HttpStatusCode.NotFound)
            {
                r.success       = false;
                r.httpException = resp.ex;
                r.SetErrMsgFromBytes(resp.content);
                return(r);
            }

            r.success             = true;
            r.content             = new AgentProfileDocument();
            r.content.content     = resp?.content;
            r.content.contentType = resp?.contentType;
            r.content.etag        = resp?.etag;
            return(r);
        }
Example #2
0
        public StateLRSResponse RetrieveState(String id, Activity activity, Agent agent, Nullable <Guid> registration = null)
        {
            var r = new StateLRSResponse();

            var queryParams = new Dictionary <String, String>();

            queryParams.Add("stateId", id);
            queryParams.Add("activityId", activity.id.ToString());
            queryParams.Add("agent", agent.ToJSON(version));

            var state = new StateDocument();

            state.id       = id;
            state.activity = activity;
            state.agent    = agent;

            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
                state.registration = registration;
            }

            var resp = GetDocument("activities/state", queryParams, state);

            if (resp.status != HttpStatusCode.OK && resp.status != HttpStatusCode.NotFound)
            {
                r.success       = false;
                r.httpException = resp.ex;
                r.SetErrMsgFromBytes(resp.content);
                return(r);
            }
            r.success = true;

            return(r);
        }
Example #3
0
        public async Task <ProfileKeysLRSResponse> RetrieveAgentProfileIds(Agent agent)
        {
            var queryParams = new Dictionary <string, string>();

            queryParams.Add("agent", agent.ToJSON(version));

            return(await GetProfileKeys("agents/profile", queryParams));
        }
Example #4
0
        // TODO: since param
        public ProfileKeysLRSResponse RetrieveAgentProfileIds(Agent agent)
        {
            var queryParams = new Dictionary <String, String>();

            queryParams.Add("agent", agent.ToJSON(version));

            return(GetProfileKeys("agents/profile", queryParams));
        }
Example #5
0
        public void TestEmptyCtr()
        {
            var obj = new Agent();
            Assert.IsInstanceOf<Agent>(obj);
            Assert.IsNull(obj.mbox);

            StringAssert.AreEqualIgnoringCase("{\"objectType\":\"Agent\"}", obj.ToJSON());
        }
Example #6
0
        public async Task <ProfileKeysLRSResponse> RetrieveStateIds(Activity activity, Agent agent, Guid?registration = null)
        {
            var queryParams = new Dictionary <string, string>();

            queryParams.Add("activityId", activity.id);
            queryParams.Add("agent", agent.ToJSON(version));
            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
            }

            return(await GetProfileKeys("activities/state", queryParams));
        }
Example #7
0
        public LRSResponse ClearState(Activity activity, Agent agent, Nullable <Guid> registration = null)
        {
            var queryParams = new Dictionary <String, String>();

            queryParams.Add("activityId", activity.id.ToString());
            queryParams.Add("agent", agent.ToJSON(version));
            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
            }

            return(DeleteDocument("activities/state", queryParams));
        }
Example #8
0
        // TODO: since param
        public ProfileKeysLRSResponse RetrieveStateIds(Activity activity, Agent agent, Nullable <Guid> registration = null)
        {
            var queryParams = new Dictionary <String, String>();

            queryParams.Add("activityId", activity.id.ToString());
            queryParams.Add("agent", agent.ToJSON(version));
            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
            }

            return(GetProfileKeys("activities/state", queryParams));
        }
        /// <summary>
        /// To the parameter map.
        /// </summary>
        /// <param name="version">The version.</param>
        /// <returns>Dictionary&lt;System.String, System.String&gt;.</returns>
        public Dictionary <string, string> ToParameterMap(TCAPIVersion version)
        {
            var result = new Dictionary <string, string>();

            if (Agent != null)
            {
                result.Add("agent", Agent.ToJSON(version));
            }
            if (VerbId != null)
            {
                result.Add("verb", VerbId.ToString());
            }
            if (ActivityId != null)
            {
                result.Add("activity", ActivityId);
            }
            if (Registration != null)
            {
                result.Add("registration", Registration.Value.ToString());
            }
            if (RelatedActivities != null)
            {
                result.Add("related_activities", RelatedActivities.Value.ToString());
            }
            if (RelatedAgents != null)
            {
                result.Add("related_agents", RelatedAgents.Value.ToString());
            }
            if (Since != null)
            {
                result.Add("since", Since.Value.ToString(ISO_DATE_TIME_FORMAT));
            }
            if (Until != null)
            {
                result.Add("until", Until.Value.ToString(ISO_DATE_TIME_FORMAT));
            }
            if (Limit != null)
            {
                result.Add("limit", Limit.ToString());
            }
            if (Format != null)
            {
                result.Add("format", Format.ToString());
            }
            if (Ascending != null)
            {
                result.Add("ascending", Ascending.Value.ToString());
            }

            return(result);
        }
Example #10
0
        public async Task <LRSResponse> ClearState(Activity activity, Agent agent, Guid?registration = null)
        {
            var queryParams = new Dictionary <string, string>();

            queryParams.Add("activityId", activity.id);
            queryParams.Add("agent", agent.ToJSON(version));

            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
            }

            return(await DeleteDocument("activities/state", queryParams));
        }
Example #11
0
        public AgentProfileLRSResponse RetrieveAgentProfile(String id, Agent agent)
        {
            var r = new AgentProfileLRSResponse();

            var queryParams = new Dictionary<String, String>();
            queryParams.Add("profileId", id);
            queryParams.Add("agent", agent.ToJSON(version));

            var profile = new AgentProfileDocument();
            profile.id = id;
            profile.agent = agent;

            var resp = GetDocument("agents/profile", queryParams, profile);
            if (resp.status != HttpStatusCode.OK && resp.status != HttpStatusCode.NotFound)
            {
                r.success = false;
                r.httpException = resp.ex;
                r.SetErrMsgFromBytes(resp.content);
                return r;
            }
            r.success = true;
            r.content = profile;

            return r;
        }
Example #12
0
        // TODO: since param
        public ProfileKeysLRSResponse RetrieveAgentProfileIds(Agent agent)
        {
            var queryParams = new Dictionary<String, String>();
            queryParams.Add("agent", agent.ToJSON(version));

            return GetProfileKeys("agents/profile", queryParams);
        }
Example #13
0
        public LRSResponse ClearState(Activity activity, Agent agent, Nullable<Guid> registration = null)
        {
            var queryParams = new Dictionary<String, String>();
            queryParams.Add("activityId", activity.id.ToString());
            queryParams.Add("agent", agent.ToJSON(version));
            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
            }

            return DeleteDocument("activities/state", queryParams);
        }
Example #14
0
        public StateLRSResponse RetrieveState(String id, Activity activity, Agent agent, Nullable<Guid> registration = null)
        {
            var r = new StateLRSResponse();

            var queryParams = new Dictionary<String, String>();
            queryParams.Add("stateId", id);
            queryParams.Add("activityId", activity.id.ToString());
            queryParams.Add("agent", agent.ToJSON(version));

            var state = new StateDocument();
            state.id = id;
            state.activity = activity;
            state.agent = agent;

            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
                state.registration = registration;
            }

            var resp = GetDocument("activities/state", queryParams, state);
            if (resp.status != HttpStatusCode.OK && resp.status != HttpStatusCode.NotFound)
            {
                r.success = false;
                r.httpException = resp.ex;
                r.SetErrMsgFromBytes(resp.content);
                return r;
            }
            r.success = true;
            r.content = state;

            return r;
        }
Example #15
0
        // TODO: since param
        public ProfileKeysLRSResponse RetrieveStateIds(Activity activity, Agent agent, Nullable<Guid> registration = null)
        {
            var queryParams = new Dictionary<String, String>();
            queryParams.Add("activityId", activity.id.ToString());
            queryParams.Add("agent", agent.ToJSON(version));
            if (registration != null)
            {
                queryParams.Add("registration", registration.ToString());
            }

            return GetProfileKeys("activities/state", queryParams);
        }