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); }
public async Task <IActionResult> PostProperty(int id, [FromBody] ClientPropertyApiDto clientPropertyApi) { var clientPropertiesDto = clientPropertyApi.ToClientApiModel <ClientPropertiesDto>(); clientPropertiesDto.ClientId = id; await _clientService.AddClientPropertyAsync(clientPropertiesDto); return(Ok()); }
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); }