public async Task <TestCallResult> GetTestCallScoreAsync(Guid participantId)
        {
            _logger.LogInformation("Retrieving test call score for participant {participantId} at {KinlySelfTestApiUrl}", participantId, _servicesConfigOptions.KinlySelfTestApiUrl);

            var requestUri = $"{_servicesConfigOptions.KinlySelfTestApiUrl}/testcall/{participantId}";
            var request    = new HttpRequestMessage
            {
                RequestUri = new Uri(requestUri),
                Method     = HttpMethod.Get,
                Properties = { { "participantId", participantId } }
            };

            var responseMessage = await _httpClient.SendAsync(request);

            if (responseMessage.StatusCode == HttpStatusCode.NotFound)
            {
                _logger.LogWarning(" {StatusCode} : Failed to retrieve self test score for participant {participantId}", responseMessage.StatusCode, participantId);
                return(null);
            }

            var content = await responseMessage.Content.ReadAsStringAsync();

            var testCall = ApiRequestHelper.Deserialise <Testcall>(content);

            _logger.LogWarning(" {StatusCode} : Successfully retrieved self test score for participant {participantId}", responseMessage.StatusCode, participantId);

            return(new TestCallResult(testCall.Passed, (TestScore)testCall.Score));
        }
        public async Task <IEnumerable <JudiciaryPersonModel> > GetLeaversAsync(DateTime updatedSince, int page = 1, int perPage = 100)
        {
            var response = await _httpClient.GetAsync
                           (
                $"{BaseUrl}api/leavers?updated_since={updatedSince:yyyy-MM-dd}&page={page}&per_page={perPage}"
                           );

            await HandleUnsuccessfulResponse(response);

            return(ApiRequestHelper.Deserialise <List <JudiciaryPersonModel> >(await response.Content.ReadAsStringAsync()));
        }
        public void Should_get_Jwtoken_when_requested_with_correct_participantid()
        {
            var responseMessage = SendGetRequestAsync($"/participants/{Guid.NewGuid()}/jwtoken").Result;

            var receiveStream = responseMessage.Content.ReadAsStreamAsync().Result;
            var readStream    = new StreamReader(receiveStream, Encoding.UTF8);
            var json          = readStream.ReadToEnd();
            var tokenResponse = ApiRequestHelper.Deserialise <TokenResponse>(json);

            responseMessage.StatusCode.Should().Be(HttpStatusCode.OK);
            tokenResponse.Should().NotBeNull();
            tokenResponse.Token.Should().NotBeEmpty();
        }
示例#4
0
        public async Task <IEnumerable <JudiciaryPersonModel> > GetPeopleAsync(DateTime updatedSince, int page = 1, int perPage = 100)
        {
            var response = await _httpClient.GetAsync
                           (
                $"{BaseUrl}/people?updated_since={updatedSince:yyyy-MM-dd}&page={page}&per_page={perPage}"
                           );

            await ResponseHandler.HandleUnsuccessfulResponse(response);

            var model = ApiRequestHelper.Deserialise <PeopleResults>(await response.Content.ReadAsStringAsync());

            return(model.Results);
        }