public async Task CreateResourceProperty(int id, string key, string value) { var req = new ApiResourcePropertyApiDto(0, key, value); var result = await apiKYC.CreateResourceProperty(id, req); Assert.True(result); }
public async Task <IActionResult> PostProperty(int id, [FromBody] ApiResourcePropertyApiDto apiPropertyApi) { var apiResourcePropertiesDto = apiPropertyApi.ToApiResourceApiModel <ApiResourcePropertiesDto>(); apiResourcePropertiesDto.ApiResourceId = id; await _apiResourceService.AddApiResourcePropertyAsync(apiResourcePropertiesDto); return(Ok()); }
public async Task <bool> CreateResourceProperty(int?id, ApiResourcePropertyApiDto 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.ResourceUri + $"/{id.Value}/Properties", stringContent); return(response.IsSuccessStatusCode); }