async Task <AzureDevOpsIdentityDto[]> GetIdentitiesFromApiAsync(Uri collectionUri, Guid[] identityIds)
        {
            var connection = await ConnectionAccessor.GetConnectionAsync(collectionUri);

            var client = await connection.GetClientAsync <IdentityHttpClient>();

            var identitiesCollection = await client.ReadIdentitiesAsync(identityIds, QueryMembership.ExpandedDown);

            if (identitiesCollection != null)
            {
                return(ObjectMapper.Map <IdentitiesCollection, AzureDevOpsIdentityDto[]>(identitiesCollection));
            }

            return(null);
        }
        public async Task <IdentityImageDto> DownloadIdentityImageAsync(Uri collectionUri, Guid identityId)
        {
            using (var client = await ConnectionAccessor.CreateHttpClientAsync(collectionUri))
            {
                using (var response = await client.GetAsync("_api/_common/identityImage?id=" + identityId))
                {
                    response.EnsureSuccessStatusCode();

                    var payload = await response.Content.ReadAsByteArrayAsync();

                    return(new IdentityImageDto
                    {
                        Payload = payload,
                        MediaType = response.Content.Headers.ContentType.MediaType
                    });
                }
            }
        }
        public async Task <IdentityImageDto> DownloadGraphAvatarAsync(Uri collectionUri, string descriptor)
        {
            var connection = await ConnectionAccessor.GetConnectionAsync(collectionUri);

            using (var client = await connection.GetClientAsync <CaptainHookGraphHttpClient>())
            {
                var avatar = await client.GetAvatarAsync(descriptor, AvatarSize.Medium);

                if (avatar.ImageData != null)
                {
                    return(new IdentityImageDto
                    {
                        Payload = avatar.ImageData,
                        MediaType = avatar.ImageType
                    });
                }
                return(null);
            }
        }