From 1aa51264bb29080e43f4ebae5cd2ea0838a8c567 Mon Sep 17 00:00:00 2001 From: Dhanalakshmi Gopalswamy <34273718+acn-dgopa@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:57:00 +0100 Subject: [PATCH] Added partylist endpoint for localtest (#9671) Co-authored-by: acn-dgopa --- .../authorization/resources/Appid_123.json | 13 +++++++-- .../authorization/resources/Appid_400.json | 6 +++- .../authorization/resources/Appid_401.json | 6 +++- .../authorization/resources/Appid_402.json | 6 +++- .../authorization/resources/Appid_403.json | 6 +++- .../authorization/resources/Appid_43.json | 6 +++- src/Controllers/Register/PartiesController.cs | 28 +++++++++++++++++++ .../Register/Implementation/PartiesWrapper.cs | 15 ++++++++++ src/Services/Register/Interface/IParties.cs | 7 +++++ 9 files changed, 86 insertions(+), 7 deletions(-) diff --git a/TestData/authorization/resources/Appid_123.json b/TestData/authorization/resources/Appid_123.json index 909c6719..350ae879 100644 --- a/TestData/authorization/resources/Appid_123.json +++ b/TestData/authorization/resources/Appid_123.json @@ -13,7 +13,11 @@ "validFrom": "2020-03-06T09:41:15.817", "identifier": "appid-123", "isComplete": false, - "description": null, + "description": { + "en": "Automation Regression", + "nb": "Automation Regression", + "nn": "Automation Regression" + }, "resourceType": "MaskinportenSchema", "thematicArea": null, "isPublicService": true, @@ -51,6 +55,11 @@ ], "hasCompetentAuthority": { "orgcode": "SKD", - "organization": "974761076" + "organization": "974761076", + "name": { + "en": "Accenture Norway", + "nb-no": "Accenture Norge", + "nn-no": "Accenture Norge" + } } } \ No newline at end of file diff --git a/TestData/authorization/resources/Appid_400.json b/TestData/authorization/resources/Appid_400.json index 027a56a4..f1b3f792 100644 --- a/TestData/authorization/resources/Appid_400.json +++ b/TestData/authorization/resources/Appid_400.json @@ -13,7 +13,11 @@ "validFrom": "2020-03-04T18:04:27.27", "identifier": "appid-400", "isComplete": false, - "description": null, + "description": { + "en": "Humbug Registry", + "nb": "Tulleregisteret", + "nn": "Tulleregisteret" + }, "resourceType": "MaskinportenSchema", "thematicArea": null, "isPublicService": true, diff --git a/TestData/authorization/resources/Appid_401.json b/TestData/authorization/resources/Appid_401.json index 91cc8253..e46e160a 100644 --- a/TestData/authorization/resources/Appid_401.json +++ b/TestData/authorization/resources/Appid_401.json @@ -13,7 +13,11 @@ "validFrom": "2020-03-04T18:04:27.27", "identifier": "appid-401", "isComplete": false, - "description": null, + "description": { + "en": "The Flowergarden", + "nb": "Blomsterhagen", + "nn": "Blomsterhagen" + }, "resourceType": "MaskinportenSchema", "thematicArea": null, "isPublicService": true, diff --git a/TestData/authorization/resources/Appid_402.json b/TestData/authorization/resources/Appid_402.json index 531c414b..bb1ce84e 100644 --- a/TestData/authorization/resources/Appid_402.json +++ b/TestData/authorization/resources/Appid_402.json @@ -13,7 +13,11 @@ "validFrom": "2020-03-04T18:04:27.27", "identifier": "appid-402", "isComplete": false, - "description": null, + "description": { + "en": "The Magic Closet", + "nb": "Det magiske klesskapet", + "nn": "Det magiske klesskapet" + }, "resourceType": "MaskinportenSchema", "thematicArea": null, "isPublicService": true, diff --git a/TestData/authorization/resources/Appid_403.json b/TestData/authorization/resources/Appid_403.json index b88a463e..17785d24 100644 --- a/TestData/authorization/resources/Appid_403.json +++ b/TestData/authorization/resources/Appid_403.json @@ -13,7 +13,11 @@ "validFrom": "2020-03-04T18:04:27.27", "identifier": "appid-403", "isComplete": false, - "description": null, + "description": { + "en": "The Shortcut", + "nb": "Snarveien", + "nn": "Snarvegen" + }, "resourceType": "MaskinportenSchema", "thematicArea": null, "isPublicService": true, diff --git a/TestData/authorization/resources/Appid_43.json b/TestData/authorization/resources/Appid_43.json index 5c1cc6c9..893c2489 100644 --- a/TestData/authorization/resources/Appid_43.json +++ b/TestData/authorization/resources/Appid_43.json @@ -13,7 +13,11 @@ "validFrom": "2020-03-04T18:04:27.27", "identifier": "appid-43", "isComplete": false, - "description": null, + "description": { + "en": "Aa-registeret OTP API", + "nb": "Aa-registeret OTP API", + "nn": "Aa-registeret OTP API" + }, "resourceType": "MaskinportenSchema", "thematicArea": null, "isPublicService": true, diff --git a/src/Controllers/Register/PartiesController.cs b/src/Controllers/Register/PartiesController.cs index 77271bd8..ffab2905 100644 --- a/src/Controllers/Register/PartiesController.cs +++ b/src/Controllers/Register/PartiesController.cs @@ -71,5 +71,33 @@ public async Task> PostPartyLookup([FromBody]PartyLookup par return Ok(party); } + + /// + /// Gets the party list for the given user. + /// + /// List of partyIds for parties to retrieve. + /// List of parties based on the partyIds. + [HttpPost("partylist")] + public async Task>> GetPartyListForPartyIds([FromBody] List partyIds) + { + + List parties; + + try + { + parties = await _partiesWrapper.GetPartyList(partyIds); + } + catch (Exception e) + { + return BadRequest(e.Message); + } + + if (parties == null || parties.Count < 1) + { + return NotFound(); + } + + return Ok(parties); + } } } diff --git a/src/Services/Register/Implementation/PartiesWrapper.cs b/src/Services/Register/Implementation/PartiesWrapper.cs index 6043cec5..4ad19ce4 100644 --- a/src/Services/Register/Implementation/PartiesWrapper.cs +++ b/src/Services/Register/Implementation/PartiesWrapper.cs @@ -52,6 +52,21 @@ public async Task LookupPartyIdBySSNOrOrgNo(string lookupValue) return party?.PartyId ?? -1; } + /// + public async Task> GetPartyList(List partyIds) + { + var data = await _testDataService.GetTestData(); + List filteredList = new List(); + foreach (int partyId in partyIds.Distinct()) + { + Party? party = data.Register.Party.TryGetValue(partyId.ToString()!, out var value) ? value : null; + await AddPersonOrOrganization(party); + filteredList.Add(party); + } + + return filteredList; + } + private async Task FindParty(string lookupValue) { var data = await _testDataService.GetTestData(); diff --git a/src/Services/Register/Interface/IParties.cs b/src/Services/Register/Interface/IParties.cs index c09b1dd3..8e3dad74 100644 --- a/src/Services/Register/Interface/IParties.cs +++ b/src/Services/Register/Interface/IParties.cs @@ -15,6 +15,13 @@ public interface IParties /// Task GetParty(int partyId); + /// + /// Method that fetches party list based on list of party ids + /// + /// The party id list + /// + Task> GetPartyList(List partyIds); + /// /// Method that looks up a party id based on social security number or organisation number. ///