From 7d124a185e46c86d0d4a4910f3be37b760561bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Dybvik=20Langfors?= Date: Wed, 20 Apr 2022 12:19:49 +0200 Subject: [PATCH] Passthrough values --- src/Altinn.Dan.Plugin.Pensjon/Main.cs | 26 +++-------------- src/Altinn.Dan.Plugin.Pensjon/Metadata.cs | 2 +- .../Models/NorskPensjonResponse.cs | 28 ------------------- 3 files changed, 5 insertions(+), 51 deletions(-) delete mode 100644 src/Altinn.Dan.Plugin.Pensjon/Models/NorskPensjonResponse.cs diff --git a/src/Altinn.Dan.Plugin.Pensjon/Main.cs b/src/Altinn.Dan.Plugin.Pensjon/Main.cs index ac94e73..da4f43d 100644 --- a/src/Altinn.Dan.Plugin.Pensjon/Main.cs +++ b/src/Altinn.Dan.Plugin.Pensjon/Main.cs @@ -53,21 +53,19 @@ public async Task GetNorskPensjon( private async Task> GetEvidenceValuesPensjon(EvidenceHarvesterRequest evidenceHarvesterRequest) { - var content = await MakeRequest(_settings.NorskPensjonUrl, evidenceHarvesterRequest.SubjectParty); + var content = await MakeRequest(_settings.NorskPensjonUrl, evidenceHarvesterRequest.SubjectParty); var ecb = new EvidenceBuilder(new Metadata(), "NorskPensjon"); - ecb.AddEvidenceValue($"default", JsonConvert.SerializeObject(content), Metadata.SOURCE, false); + ecb.AddEvidenceValue($"default", content, Metadata.SOURCE, false); return ecb.GetEvidenceValues(); } - private async Task MakeRequest(string target, Party subject) where T : new() + private async Task MakeRequest(string target, Party subject) { HttpResponseMessage result = null; var requestBody = new NorskPensjonRequest(); requestBody.Fodselsnummer = subject.NorwegianSocialSecurityNumber; - T response = default(T); - try { var request = new HttpRequestMessage(HttpMethod.Post, target); @@ -78,23 +76,7 @@ private async Task> GetEvidenceValuesPensjon(EvidenceHarvest { case HttpStatusCode.OK: { - try - { - response = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()); - } - catch (Exception ex) - { - _logger.LogError($"Could not deserialize response: {ex.Message}"); - - throw new EvidenceSourcePermanentServerException(Metadata.ERROR_CCR_UPSTREAM_ERROR, "Could not deserialize response: " + ex.Message); - } - - if (response == null) - { - throw new EvidenceSourcePermanentServerException(Metadata.ERROR_CCR_UPSTREAM_ERROR, "Did not understand the data model returned from upstream source"); - } - - return response; + return await result.Content.ReadAsStringAsync(); } case HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden: { diff --git a/src/Altinn.Dan.Plugin.Pensjon/Metadata.cs b/src/Altinn.Dan.Plugin.Pensjon/Metadata.cs index 0e9c6c4..73e4ee9 100644 --- a/src/Altinn.Dan.Plugin.Pensjon/Metadata.cs +++ b/src/Altinn.Dan.Plugin.Pensjon/Metadata.cs @@ -39,7 +39,7 @@ public List GetEvidenceCodes() { EvidenceValueName = "default", ValueType = EvidenceValueType.JsonSchema, - JsonSchemaDefintion = JsonSchema.FromType().ToJson(Newtonsoft.Json.Formatting.Indented) + JsonSchemaDefintion = null }, } } diff --git a/src/Altinn.Dan.Plugin.Pensjon/Models/NorskPensjonResponse.cs b/src/Altinn.Dan.Plugin.Pensjon/Models/NorskPensjonResponse.cs deleted file mode 100644 index ce0b282..0000000 --- a/src/Altinn.Dan.Plugin.Pensjon/Models/NorskPensjonResponse.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Altinn.Dan.Plugin.Pensjon.Models -{ - public class NorskPensjonResponse - { - public List InsurancesPolicies { get; set; } - } - - public class InsurancePolicy - { - public DateTimeOffset DisclosureDate { get; set; } - - public string Url { get; set; } - - public string ProductType { get; set; } - - public string PensionScheme { get; set; } - - public string Reference { get; set; } - - public string Description { get; set; } - } -}