Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Altinn.App.Api/Controllers/InstancesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ await instance.WithOnlyAccessibleDataElements(_dataElementAccessChecker),
/// </summary>
/// <param name="org">unique identifier of the organisation responsible for the app</param>
/// <param name="app">application identifier which is unique within an organisation</param>
/// <param name="instansiationInstance">instansiation information</param>
/// <param name="InstantiationInstance">instansiation information</param>
/// <param name="language">The currently active user language</param>
/// <returns>The new instance</returns>
[HttpPost("create")]
Expand All @@ -450,7 +450,7 @@ await instance.WithOnlyAccessibleDataElements(_dataElementAccessChecker),
public async Task<ActionResult<InstanceResponse>> PostSimplified(
[FromRoute] string org,
[FromRoute] string app,
[FromBody] InstansiationInstance instansiationInstance,
[FromBody] InstantiationInstance InstantiationInstance,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters and other local variables should be camelCased.

[FromQuery] string? language = null
)
{
Expand All @@ -464,7 +464,7 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(
return BadRequest("The path parameter 'app' cannot be empty");
}

bool isCopyRequest = !string.IsNullOrEmpty(instansiationInstance.SourceInstanceId);
bool isCopyRequest = !string.IsNullOrEmpty(InstantiationInstance.SourceInstanceId);

ApplicationMetadata application = await _appMetadata.GetApplicationMetadata();
if (VerifyInstantiationPermissions(application, org, app, isCopy: isCopyRequest) is { } verificationResult)
Expand All @@ -479,7 +479,7 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(
);
}

InstanceOwner lookup = instansiationInstance.InstanceOwner;
InstanceOwner lookup = InstantiationInstance.InstanceOwner;

if (
lookup == null
Expand All @@ -494,8 +494,8 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(
Party party;
try
{
party = await LookupParty(instansiationInstance.InstanceOwner) ?? throw new Exception("Unknown party");
instansiationInstance.InstanceOwner = InstantiationHelper.PartyToInstanceOwner(party);
party = await LookupParty(InstantiationInstance.InstanceOwner) ?? throw new Exception("Unknown party");
InstantiationInstance.InstanceOwner = InstantiationHelper.PartyToInstanceOwner(party);
}
catch (Exception partyLookupException)
{
Expand All @@ -513,7 +513,7 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(
if (
isCopyRequest
&& party.PartyId.ToString(CultureInfo.InvariantCulture)
!= instansiationInstance.SourceInstanceId.Split("/")[0]
!= InstantiationInstance.SourceInstanceId.Split("/")[0]
)
{
return BadRequest("It is not possible to copy instances between instance owners.");
Expand All @@ -536,9 +536,9 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(

Instance instanceTemplate = new()
{
InstanceOwner = instansiationInstance.InstanceOwner,
VisibleAfter = instansiationInstance.VisibleAfter,
DueBefore = instansiationInstance.DueBefore,
InstanceOwner = InstantiationInstance.InstanceOwner,
VisibleAfter = InstantiationInstance.VisibleAfter,
DueBefore = InstantiationInstance.DueBefore,
Org = application.Org,
};

Expand All @@ -564,7 +564,7 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(
{
Instance = instanceTemplate,
User = User,
Prefill = instansiationInstance.Prefill,
Prefill = InstantiationInstance.Prefill,
};

processResult = await _processEngine.GenerateProcessStartEvents(request);
Expand All @@ -573,7 +573,7 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(

if (isCopyRequest)
{
string[] sourceSplit = instansiationInstance.SourceInstanceId.Split("/");
string[] sourceSplit = InstantiationInstance.SourceInstanceId.Split("/");
Guid sourceInstanceGuid = Guid.Parse(sourceSplit[1]);

try
Expand Down Expand Up @@ -604,7 +604,7 @@ public async Task<ActionResult<InstanceResponse>> PostSimplified(
instance = await _instanceClient.GetInstance(instance);
await _processEngine.HandleEventsAndUpdateStorage(
instance,
instansiationInstance.Prefill,
InstantiationInstance.Prefill,
processResult.ProcessStateChange?.Events
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Altinn.App.Api/Models/InstansiationInstance.cs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be renamed to match the class name.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Altinn.App.Api.Models;
/// <summary>
/// Specialized model for instansiation of instances
/// </summary>
public class InstansiationInstance
public class InstantiationInstance
{
/// <summary>
/// Gets or sets the instance owner information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2702,17 +2702,17 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InstansiationInstance"
"$ref": "#/components/schemas/InstantiationInstance"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/InstansiationInstance"
"$ref": "#/components/schemas/InstantiationInstance"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/InstansiationInstance"
"$ref": "#/components/schemas/InstantiationInstance"
}
}
}
Expand Down Expand Up @@ -8334,7 +8334,7 @@
},
"additionalProperties": false
},
"InstansiationInstance": {
"InstantiationInstance": {
"type": "object",
"properties": {
"instanceOwner": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ namespace Altinn.App.Api.Controllers
[Microsoft.AspNetCore.Mvc.ProducesResponseType(400)]
[Microsoft.AspNetCore.Mvc.ProducesResponseType(typeof(Altinn.App.Api.Models.InstanceResponse), 201)]
[Microsoft.AspNetCore.Mvc.RequestSizeLimit(2097152000)]
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<Altinn.App.Api.Models.InstanceResponse>> PostSimplified([Microsoft.AspNetCore.Mvc.FromRoute] string org, [Microsoft.AspNetCore.Mvc.FromRoute] string app, [Microsoft.AspNetCore.Mvc.FromBody] Altinn.App.Api.Models.InstansiationInstance instansiationInstance, [Microsoft.AspNetCore.Mvc.FromQuery] string? language = null) { }
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<Altinn.App.Api.Models.InstanceResponse>> PostSimplified([Microsoft.AspNetCore.Mvc.FromRoute] string org, [Microsoft.AspNetCore.Mvc.FromRoute] string app, [Microsoft.AspNetCore.Mvc.FromBody] Altinn.App.Api.Models.InstantiationInstance InstantiationInstance, [Microsoft.AspNetCore.Mvc.FromQuery] string? language = null) { }
[Microsoft.AspNetCore.Authorization.Authorize]
[Microsoft.AspNetCore.Mvc.HttpPut("{instanceOwnerPartyId:int}/{instanceGuid:guid}/substatus")]
[Microsoft.AspNetCore.Mvc.Produces("application/json", new string[0])]
Expand Down Expand Up @@ -1028,9 +1028,9 @@ namespace Altinn.App.Api.Models
public required System.DateTime? VisibleAfter { get; init; }
public override string ToString() { }
}
public class InstansiationInstance
public class InstantiationInstance
{
public InstansiationInstance() { }
public InstantiationInstance() { }
public System.DateTime? DueBefore { get; set; }
public Altinn.Platform.Storage.Interface.Models.InstanceOwner InstanceOwner { get; set; }
public System.Collections.Generic.Dictionary<string, string> Prefill { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions test/Altinn.App.Integration.Tests/Basic/BasicAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ TestCase testCase
{
TestCase.SimplifiedNoPrefill => await fixture.Instances.PostSimplified(
token,
new InstansiationInstance { InstanceOwner = new InstanceOwner { PartyId = "501337" } }
new InstantiationInstance { InstanceOwner = new InstanceOwner { PartyId = "501337" } }
),
TestCase.SimplifiedWithPrefill => await fixture.Instances.PostSimplified(
token,
new InstansiationInstance
new InstantiationInstance
{
InstanceOwner = new InstanceOwner { PartyId = "501337" },
Prefill = new() { { "property1", "1" }, { "property2", "1" } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task Instantiate(string partyId)

using var response = await fixture.Instances.PostSimplified(
token,
new InstansiationInstance { InstanceOwner = new InstanceOwner { PartyId = partyId } }
new InstantiationInstance { InstanceOwner = new InstanceOwner { PartyId = partyId } }
);

using var data = await response.Read<Instance>();
Expand Down
4 changes: 2 additions & 2 deletions test/Altinn.App.Integration.Tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class MyIntegrationTests(ITestOutputHelper output) : IAsyncLifetime

using var response = await fixture.Instances.PostSimplified(
token,
new InstansiationInstance { InstanceOwner = new InstanceOwner { PartyId = "501337" } }
new InstantiationInstance { InstanceOwner = new InstanceOwner { PartyId = "501337" } }
);

var readResponse = await response.Read<Instance>();
Expand Down Expand Up @@ -147,7 +147,7 @@ The `ApiResponse` pattern provides structured HTTP response handling:
```csharp
using var response = await fixture.Instances.PostSimplified(
token,
new InstansiationInstance { InstanceOwner = new InstanceOwner { PartyId = "501337" } }
new InstantiationInstance { InstanceOwner = new InstanceOwner { PartyId = "501337" } }
);

// Read typed response data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal sealed class InstancesOperations(AppFixture fixture)
{
private readonly AppFixture _fixture = fixture;

public async Task<ApiResponse> PostSimplified(string token, InstansiationInstance instansiation)
public async Task<ApiResponse> PostSimplified(string token, InstantiationInstance instansiation)
{
var client = _fixture.GetAppClient();
var endpoint = $"/ttd/{_fixture._app}/instances/create";
Expand Down