// TODO: since param
        public async Task <ProfileKeysLrsResponse> RetrieveAgentProfileIdsAsync(Agent agent)
        {
            var queryParams = new Dictionary <string, string>
            {
                { "agent", agent.ToJson(Version) }
            };

            return(await GetProfileKeys("agents/profile", queryParams));
        }
        public async Task <LrsResponse> ClearStateAsync(Activity activity, Agent agent, Guid?registration = null)
        {
            var queryParams = new Dictionary <string, string>
            {
                { "activityId", activity.Id },
                { "agent", agent.ToJson(Version) }
            };

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

            return(await DeleteDocument("activities/state", queryParams));
        }
        // TODO: since param
        public async Task <ProfileKeysLrsResponse> RetrieveStateIdsAsync(Activity activity, Agent agent,
                                                                         Guid?registration = null)
        {
            var queryParams = new Dictionary <string, string>
            {
                { "activityId", activity.Id },
                { "agent", agent.ToJson(Version) }
            };

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

            return(await GetProfileKeys("activities/state", queryParams));
        }
        public async Task <StateLrsResponse> RetrieveStateAsync(string id, Activity activity, Agent agent,
                                                                Guid?registration = null)
        {
            var r = new StateLrsResponse();

            var queryParams = new Dictionary <string, string>
            {
                { "stateId", id },
                { "activityId", activity.Id },
                { "agent", agent.ToJson(Version) }
            };

            var state = new StateDocument
            {
                Id       = id,
                Activity = activity,
                Agent    = agent
            };

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

            var resp = await 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);
        }
        public async Task <AgentProfileLrsResponse> RetrieveAgentProfileAsync(string id, Agent agent)
        {
            var r = new AgentProfileLrsResponse();

            var queryParams = new Dictionary <string, string>
            {
                { "profileId", id },
                { "agent", agent.ToJson(Version) }
            };

            var profile = new AgentProfileDocument
            {
                Id    = id,
                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);
            }

            profile.Content     = resp.Content;
            profile.ContentType = resp.ContentType;
            profile.Etag        = resp.Etag;

            r.Success = true;
            r.Content = profile;

            return(r);
        }