Пример #1
0
        public async Task CreateClientProperty(int id, string key, string value)
        {
            var req = new ClientPropertyApiDto(0, key, value);

            var result = await apiKYC.CreateClientProperty(id, req);

            Assert.True(result);
        }
Пример #2
0
        public async Task <IActionResult> PostProperty(int id, [FromBody] ClientPropertyApiDto clientPropertyApi)
        {
            var clientPropertiesDto = clientPropertyApi.ToClientApiModel <ClientPropertiesDto>();

            clientPropertiesDto.ClientId = id;

            await _clientService.AddClientPropertyAsync(clientPropertiesDto);

            return(Ok());
        }
Пример #3
0
        public async Task <bool> CreateClientProperty(int?id, ClientPropertyApiDto property)
        {
            // discover endpoints from metadata
            var client = new HttpClient();
            var disco  = await client.GetDiscoveryDocumentAsync(IdentityEndpoint.Discovery);

            if (disco.IsError)
            {
                return(false);
            }

            // request token
            var req = new PasswordTokenRequest
            {
                Address = disco.TokenEndpoint,

                ClientId     = IdentityEndpoint.ClientID,
                ClientSecret = IdentityEndpoint.Secret,
                Scope        = IdentityEndpoint.Scopes,
                UserName     = IdentityEndpoint.UserName,
                Password     = IdentityEndpoint.Password
            };
            var tokenResponse = await client.RequestPasswordTokenAsync(req);

            if (tokenResponse.IsError)
            {
                return(false);
            }

            var apiClient = new HttpClient();

            apiClient.SetBearerToken(tokenResponse.AccessToken);

            var dataJson      = JsonSerializer.Serialize(property);
            var stringContent = new StringContent(dataJson, Encoding.UTF8, "application/json");

            var response = await apiClient.PostAsync(IdentityEndpoint.ClientUri + $"/{id.Value}/Properties", stringContent);

            return(response.IsSuccessStatusCode);
        }