Skip to content

Commit

Permalink
Added partylist endpoint for localtest (#9671)
Browse files Browse the repository at this point in the history
Co-authored-by: acn-dgopa <acn-dgopa@dev-acn-tje-14>
  • Loading branch information
acn-dgopa and acn-dgopa authored Jan 30, 2023
1 parent d63d9a3 commit 1aa5126
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 7 deletions.
13 changes: 11 additions & 2 deletions TestData/authorization/resources/Appid_123.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -51,6 +55,11 @@
],
"hasCompetentAuthority": {
"orgcode": "SKD",
"organization": "974761076"
"organization": "974761076",
"name": {
"en": "Accenture Norway",
"nb-no": "Accenture Norge",
"nn-no": "Accenture Norge"
}
}
}
6 changes: 5 additions & 1 deletion TestData/authorization/resources/Appid_400.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion TestData/authorization/resources/Appid_401.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion TestData/authorization/resources/Appid_402.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion TestData/authorization/resources/Appid_403.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion TestData/authorization/resources/Appid_43.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 28 additions & 0 deletions src/Controllers/Register/PartiesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,33 @@ public async Task<ActionResult<Party>> PostPartyLookup([FromBody]PartyLookup par

return Ok(party);
}

/// <summary>
/// Gets the party list for the given user.
/// </summary>
/// <param name="partyIds">List of partyIds for parties to retrieve.</param>
/// <returns>List of parties based on the partyIds.</returns>
[HttpPost("partylist")]
public async Task<ActionResult<List<Party>>> GetPartyListForPartyIds([FromBody] List<int> partyIds)
{

List<Party> 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);
}
}
}
15 changes: 15 additions & 0 deletions src/Services/Register/Implementation/PartiesWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ public async Task<int> LookupPartyIdBySSNOrOrgNo(string lookupValue)
return party?.PartyId ?? -1;
}

/// <inheritdoc />
public async Task<List<Party>> GetPartyList(List<int> partyIds)
{
var data = await _testDataService.GetTestData();
List<Party> filteredList = new List<Party>();
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<Party?> FindParty(string lookupValue)
{
var data = await _testDataService.GetTestData();
Expand Down
7 changes: 7 additions & 0 deletions src/Services/Register/Interface/IParties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public interface IParties
/// <returns></returns>
Task<Party?> GetParty(int partyId);

/// <summary>
/// Method that fetches party list based on list of party ids
/// </summary>
/// <param name="partyIds">The party id list</param>
/// <returns></returns>
Task<List<Party?>> GetPartyList(List<int> partyIds);

/// <summary>
/// Method that looks up a party id based on social security number or organisation number.
/// </summary>
Expand Down

0 comments on commit 1aa5126

Please sign in to comment.