Repository: DEFRA/trade-imports-data-api
Pull request #42: Endpoints for Associated data
Author: login: t11omas
Created: 2025-04-14T05:11:34Z | Merged: 2025-04-14T16:52:15Z

Added 2 new endpoints

/import-pre-notifications/{ched}/customs-declarations
/customs-declarations/{ched}/import-pre-notifications


Diff:
diff --git a/src/Api.Client/Api.Client.csproj b/src/Api.Client/Api.Client.csproj
index 67449b71..d61e3193 100644
--- a/src/Api.Client/Api.Client.csproj
+++ b/src/Api.Client/Api.Client.csproj
@@ -9,7 +9,7 @@
     <Nullable>enable</Nullable>
     <IsPackable>true</IsPackable>
     <PackageId>Defra.TradeImportsDataApi.Api.Client</PackageId>
-    <VersionPrefix>0.6.0</VersionPrefix>
+    <VersionPrefix>0.7.0</VersionPrefix>
     <PackageDescription>Defra Trade Imports Data Api Client</PackageDescription>
     <Company>DEFRA</Company>
     <RepositoryUrl>https://github.com/DEFRA/trade-imports-data-api</RepositoryUrl>
diff --git a/src/Api.Client/Endpoints.cs b/src/Api.Client/Endpoints.cs
index 8a12bd98..c18d87cc 100644
--- a/src/Api.Client/Endpoints.cs
+++ b/src/Api.Client/Endpoints.cs
@@ -4,7 +4,13 @@ internal static class Endpoints
 {
     public static string ImportPreNotifications(string chedId) => $"/import-pre-notifications/{chedId}";
 
+    public static string CustomsDeclarationsByChed(string chedId) =>
+        $"/import-pre-notifications/{chedId}/customs-declarations";
+
     public static string Gmrs(string gmrId) => $"/gmrs/{gmrId}";
 
     public static string CustomsDeclarations(string mrn) => $"/customs-declarations/{mrn}";
+
+    public static string ImportPreNotificationsByMrn(string mrn) =>
+        $"/customs-declarations/{mrn}/import-pre-notifications";
 }
diff --git a/src/Api.Client/ITradeImportsDataApiClient.cs b/src/Api.Client/ITradeImportsDataApiClient.cs
index a4502df8..b752d886 100644
--- a/src/Api.Client/ITradeImportsDataApiClient.cs
+++ b/src/Api.Client/ITradeImportsDataApiClient.cs
@@ -4,6 +4,11 @@ public interface ITradeImportsDataApiClient
 {
     Task<ImportPreNotificationResponse?> GetImportPreNotification(string chedId, CancellationToken cancellationToken);
 
+    Task<List<CustomsDeclarationResponse>?> GetCustomsDeclarationsByChedId(
+        string chedId,
+        CancellationToken cancellationToken
+    );
+
     Task PutImportPreNotification(
         string chedId,
         Domain.Ipaffs.ImportPreNotification data,
@@ -17,6 +22,11 @@ CancellationToken cancellationToken
 
     Task<CustomsDeclarationResponse?> GetCustomsDeclaration(string mrn, CancellationToken cancellationToken);
 
+    Task<List<ImportPreNotificationResponse>?> GetImportPreNotificationsByMrn(
+        string mrn,
+        CancellationToken cancellationToken
+    );
+
     Task PutCustomsDeclaration(
         string mrn,
         Domain.CustomsDeclaration.CustomsDeclaration data,
diff --git a/src/Api.Client/TradeImportsDataApiClient.cs b/src/Api.Client/TradeImportsDataApiClient.cs
index 98514cc9..8a456a9e 100644
--- a/src/Api.Client/TradeImportsDataApiClient.cs
+++ b/src/Api.Client/TradeImportsDataApiClient.cs
@@ -31,6 +31,22 @@ CancellationToken cancellationToken
         };
     }
 
+    public async Task<List<CustomsDeclarationResponse>?> GetCustomsDeclarationsByChedId(
+        string chedId,
+        CancellationToken cancellationToken
+    )
+    {
+        var response = await Get(Endpoints.CustomsDeclarationsByChed(chedId), cancellationToken);
+        if (response.StatusCode == HttpStatusCode.NotFound)
+            return null;
+
+        response.EnsureSuccessStatusCode();
+
+        var result = await Deserialize<List<CustomsDeclarationResponse>?>(response, cancellationToken);
+
+        return result;
+    }
+
     public async Task PutImportPreNotification(
         string chedId,
         ImportPreNotification data,
@@ -87,6 +103,22 @@ CancellationToken cancellationToken
         };
     }
 
+    public async Task<List<ImportPreNotificationResponse>?> GetImportPreNotificationsByMrn(
+        string mrn,
+        CancellationToken cancellationToken
+    )
+    {
+        var response = await Get(Endpoints.ImportPreNotificationsByMrn(mrn), cancellationToken);
+        if (response.StatusCode == HttpStatusCode.NotFound)
+            return null;
+
+        response.EnsureSuccessStatusCode();
+
+        var result = await Deserialize<List<ImportPreNotificationResponse>?>(response, cancellationToken);
+
+        return result;
+    }
+
     public async Task PutCustomsDeclaration(
         string mrn,
         CustomsDeclaration data,
diff --git a/src/Api/Endpoints/CustomsDeclarations/EndpointRouteBuilderExtensions.cs b/src/Api/Endpoints/CustomsDeclarations/EndpointRouteBuilderExtensions.cs
index f715b221..03e3ffaf 100644
--- a/src/Api/Endpoints/CustomsDeclarations/EndpointRouteBuilderExtensions.cs
+++ b/src/Api/Endpoints/CustomsDeclarations/EndpointRouteBuilderExtensions.cs
@@ -1,5 +1,6 @@
 using System.Diagnostics.CodeAnalysis;
 using Defra.TradeImportsDataApi.Api.Authentication;
+using Defra.TradeImportsDataApi.Api.Endpoints.ImportPreNotifications;
 using Defra.TradeImportsDataApi.Api.Exceptions;
 using Defra.TradeImportsDataApi.Api.Extensions;
 using Defra.TradeImportsDataApi.Api.Services;
@@ -26,6 +27,18 @@ public static void MapCustomsDeclarationEndpoints(this IEndpointRouteBuilder app
 
         AllowAnonymousForDevelopment(isDevelopment, route);
 
+        route = app.MapGet("customs-declarations/{mrn}/import-pre-notifications", GetImportPreNotifications)
+            .WithName("ImportPreNotificationsByMrn")
+            .WithTags("ImportPreNotificationsByMrn")
+            .WithSummary("Get ImportPreNotifications by MRN")
+            .WithDescription("Get associated import pre-notifications by MRN")
+            .Produces<List<ImportPreNotificationResponse>>()
+            .ProducesProblem(StatusCodes.Status400BadRequest)
+            .ProducesProblem(StatusCodes.Status500InternalServerError)
+            .RequireAuthorization(PolicyNames.Read);
+
+        AllowAnonymousForDevelopment(isDevelopment, route);
+
         route = app.MapPut("customs-declarations/{mrn}/", Put)
             .WithName("PutCustomsDeclaration")
             .WithTags("CustomsDeclarations")
@@ -81,6 +94,33 @@ CancellationToken cancellationToken
         );
     }
 
+    /// <param name="mrn">MRN</param>
+    /// <param name="context"></param>
+    /// <param name="importPreNotificationService"></param>
+    /// <param name="customsDeclarationService"></param>
+    /// <param name="cancellationToken"></param>
+    /// <returns></returns>
+    [HttpGet]
+    private static async Task<IResult> GetImportPreNotifications(
+        [FromRoute] string mrn,
+        HttpContext context,
+        [FromServices] IImportPreNotificationService importPreNotificationService,
+        [FromServices] ICustomsDeclarationService customsDeclarationService,
+        CancellationToken cancellationToken
+    )
+    {
+        var importPreNotifications = await importPreNotificationService.GetImportPreNotificationsByMrn(
+            mrn,
+            cancellationToken
+        );
+
+        return Results.Ok(
+            importPreNotifications
+                .Select(x => new ImportPreNotificationResponse(x.ImportPreNotification, x.Created, x.Updated))
+                .ToList()
+        );
+    }
+
     [HttpPut]
     private static async Task<IResult> Put(
         [FromRoute] string mrn,
diff --git a/src/Api/Endpoints/ImportPreNotifications/EndpointRouteBuilderExtensions.cs b/src/Api/Endpoints/ImportPreNotifications/EndpointRouteBuilderExtensions.cs
index 2febd299..897ca9ce 100644
--- a/src/Api/Endpoints/ImportPreNotifications/EndpointRouteBuilderExtensions.cs
+++ b/src/Api/Endpoints/ImportPreNotifications/EndpointRouteBuilderExtensions.cs
@@ -1,5 +1,6 @@
 using System.Diagnostics.CodeAnalysis;
 using Defra.TradeImportsDataApi.Api.Authentication;
+using Defra.TradeImportsDataApi.Api.Endpoints.CustomsDeclarations;
 using Defra.TradeImportsDataApi.Api.Extensions;
 using Defra.TradeImportsDataApi.Api.Services;
 using Defra.TradeImportsDataApi.Api.Utils;
@@ -26,6 +27,18 @@ public static void MapImportPreNotificationEndpoints(this IEndpointRouteBuilder
 
         AllowAnonymousForDevelopment(isDevelopment, route);
 
+        route = app.MapGet("import-pre-notifications/{chedId}/customs-declarations", GetCustomsDeclarations)
+            .WithName("GetImportPreNotificationAndCustomsDeclarationsByChedId")
+            .WithTags("ImportPreNotificationsWithCustomsDeclarations")
+            .WithSummary("Get ImportPreNotification with CustomsDeclarations")
+            .WithDescription("Get an import pre-notification by CHED ID along with the associated customs-declarations")
+            .Produces<List<CustomsDeclarationResponse>>()
+            .ProducesProblem(StatusCodes.Status400BadRequest)
+            .ProducesProblem(StatusCodes.Status500InternalServerError)
+            .RequireAuthorization(PolicyNames.Read);
+
+        AllowAnonymousForDevelopment(isDevelopment, route);
+
         route = app.MapPut("import-pre-notifications/{chedId}/", Put)
             .WithName("PutImportPreNotification")
             .WithTags("ImportPreNotifications")
@@ -81,6 +94,40 @@ CancellationToken cancellationToken
         );
     }
 
+    /// <param name="chedId" example="CHEDA.GB.2024.1020304">CHED ID</param>
+    /// <param name="context"></param>
+    /// <param name="importPreNotificationService"></param>
+    /// <param name="customsDeclarationService"></param>
+    /// <param name="cancellationToken"></param>
+    /// <returns></returns>
+    [HttpGet]
+    private static async Task<IResult> GetCustomsDeclarations(
+        [FromRoute] string chedId,
+        HttpContext context,
+        [FromServices] IImportPreNotificationService importPreNotificationService,
+        [FromServices] ICustomsDeclarationService customsDeclarationService,
+        CancellationToken cancellationToken
+    )
+    {
+        var customsDeclarations = await customsDeclarationService.GetCustomsDeclarationsByChedId(
+            chedId,
+            cancellationToken
+        );
+
+        return Results.Ok(
+            customsDeclarations
+                .Select(customsDeclarationEntity => new CustomsDeclarationResponse(
+                    customsDeclarationEntity.Id,
+                    customsDeclarationEntity.ClearanceRequest,
+                    customsDeclarationEntity.ClearanceDecision,
+                    customsDeclarationEntity.Finalisation,
+                    customsDeclarationEntity.Created,
+                    customsDeclarationEntity.Updated
+                ))
+                .ToList()
+        );
+    }
+
     /// <param name="chedId" example="CHEDA.GB.2024.1020304">CHED ID</param>
     /// <param name="context"></param>
     /// <param name="importPreNotification"></param>
diff --git a/src/Api/Services/CustomsDeclarationService.cs b/src/Api/Services/CustomsDeclarationService.cs
index 7afefb13..a0da7fb4 100644
--- a/src/Api/Services/CustomsDeclarationService.cs
+++ b/src/Api/Services/CustomsDeclarationService.cs
@@ -1,5 +1,7 @@
 using Defra.TradeImportsDataApi.Data;
 using Defra.TradeImportsDataApi.Data.Entities;
+using Defra.TradeImportsDataApi.Domain.CustomsDeclaration;
+using MongoDB.Driver.Linq;
 
 namespace Defra.TradeImportsDataApi.Api.Services;
 
@@ -21,6 +23,17 @@ CancellationToken cancellationToken
         return customsDeclarationEntity;
     }
 
+    public async Task<List<CustomsDeclarationEntity>> GetCustomsDeclarationsByChedId(
+        string chedId,
+        CancellationToken cancellationToken
+    )
+    {
+        var identifier = new ImportDocumentReference(chedId).GetIdentifier();
+        return await dbContext
+            .CustomsDeclarations.Where(x => x.ImportPreNotificationIdentifiers.Contains(identifier))
+            .ToListAsync(cancellationToken: cancellationToken);
+    }
+
     public async Task<CustomsDeclarationEntity> Update(
         CustomsDeclarationEntity customsDeclarationEntity,
         string etag,
diff --git a/src/Api/Services/ICustomsDeclarationService.cs b/src/Api/Services/ICustomsDeclarationService.cs
index a1e178b6..d06c10fa 100644
--- a/src/Api/Services/ICustomsDeclarationService.cs
+++ b/src/Api/Services/ICustomsDeclarationService.cs
@@ -5,6 +5,11 @@ namespace Defra.TradeImportsDataApi.Api.Services;
 public interface ICustomsDeclarationService
 {
     Task<CustomsDeclarationEntity?> GetCustomsDeclaration(string mrn, CancellationToken cancellationToken);
+
+    Task<List<CustomsDeclarationEntity>> GetCustomsDeclarationsByChedId(
+        string chedId,
+        CancellationToken cancellationToken
+    );
     Task<CustomsDeclarationEntity> Insert(
         CustomsDeclarationEntity customsDeclarationEntity,
         CancellationToken cancellationToken
diff --git a/src/Api/Services/IImportPreNotificationService.cs b/src/Api/Services/IImportPreNotificationService.cs
index 7cf270da..ecc8d2e3 100644
--- a/src/Api/Services/IImportPreNotificationService.cs
+++ b/src/Api/Services/IImportPreNotificationService.cs
@@ -5,6 +5,11 @@ namespace Defra.TradeImportsDataApi.Api.Services;
 public interface IImportPreNotificationService
 {
     Task<ImportPreNotificationEntity?> GetImportPreNotification(string chedId, CancellationToken cancellationToken);
+
+    Task<List<ImportPreNotificationEntity>> GetImportPreNotificationsByMrn(
+        string mrn,
+        CancellationToken cancellationToken
+    );
     Task<ImportPreNotificationEntity> Insert(
         ImportPreNotificationEntity importPreNotificationEntity,
         CancellationToken cancellationToken
diff --git a/src/Api/Services/ImportPreNotificationService.cs b/src/Api/Services/ImportPreNotificationService.cs
index 67c16826..c43e75d9 100644
--- a/src/Api/Services/ImportPreNotificationService.cs
+++ b/src/Api/Services/ImportPreNotificationService.cs
@@ -3,6 +3,8 @@
 using Defra.TradeImportsDataApi.Data;
 using Defra.TradeImportsDataApi.Data.Entities;
 using Defra.TradeImportsDataApi.Domain.Events;
+using Defra.TradeImportsDataApi.Domain.Ipaffs;
+using MongoDB.Driver.Linq;
 
 namespace Defra.TradeImportsDataApi.Api.Services;
 
@@ -17,6 +19,21 @@ CancellationToken cancellationToken
         return await dbContext.ImportPreNotifications.Find(chedId, cancellationToken);
     }
 
+    public async Task<List<ImportPreNotificationEntity>> GetImportPreNotificationsByMrn(
+        string mrn,
+        CancellationToken cancellationToken
+    )
+    {
+        var identifiers = await dbContext
+            .CustomsDeclarations.Where(x => x.Id == mrn)
+            .SelectMany(x => x.ImportPreNotificationIdentifiers)
+            .ToListAsync(cancellationToken);
+
+        return await dbContext
+            .ImportPreNotifications.Where(x => identifiers.Contains(x.CustomsDeclarationIdentifier))
+            .ToListAsync(cancellationToken: cancellationToken);
+    }
+
     public async Task<ImportPreNotificationEntity> Insert(
         ImportPreNotificationEntity importPreNotificationEntity,
         CancellationToken cancellationToken
diff --git a/tests/Api.Client.Tests/Api.Client.Tests.csproj b/tests/Api.Client.Tests/Api.Client.Tests.csproj
index e1d1d3c9..36ce4ad8 100644
--- a/tests/Api.Client.Tests/Api.Client.Tests.csproj
+++ b/tests/Api.Client.Tests/Api.Client.Tests.csproj
@@ -23,9 +23,18 @@
   </ItemGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\..\src\Api.Client\Api.Client.csproj"/>
+    <ProjectReference Include="..\..\src\Api.Client\Api.Client.csproj" />
     <ProjectReference Include="..\..\src\Api\Api.csproj" />
     <ProjectReference Include="..\Testing\Testing.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <None Update="Endpoints\CustomsDeclarations\GetImportPreNotificationsTests.GetCustomsDeclaration_WhenFound_ShouldNotBeNull.verified.txt">
+      <DependentUpon>GetImportPreNotificationsTests.cs</DependentUpon>
+    </None>
+    <None Update="Endpoints\ImportPreNotifications\GetCustomsDeclarationsTests.GetImportPreNotification_WhenFound_ShouldNotBeNull.verified.txt">
+      <DependentUpon>GetCustomsDeclarationsTests.cs</DependentUpon>
+    </None>
+  </ItemGroup>
+
 </Project>
diff --git a/tests/Api.Client.Tests/Endpoints/CustomsDeclarations/GetImportPreNotificationsTests.GetCustomsDeclaration_WhenFound_ShouldNotBeNull.verified.txt b/tests/Api.Client.Tests/Endpoints/CustomsDeclarations/GetImportPreNotificationsTests.GetCustomsDeclaration_WhenFound_ShouldNotBeNull.verified.txt
new file mode 100644
index 00000000..f1712cdf
--- /dev/null
+++ b/tests/Api.Client.Tests/Endpoints/CustomsDeclarations/GetImportPreNotificationsTests.GetCustomsDeclaration_WhenFound_ShouldNotBeNull.verified.txt
@@ -0,0 +1,41 @@
+﻿[
+  {
+    ImportPreNotification: {
+      IpaffsId: null,
+      Etag: null,
+      ExternalReferences: null,
+      ReferenceNumber: ched,
+      Version: null,
+      UpdatedSource: null,
+      LastUpdatedBy: null,
+      ImportNotificationType: null,
+      Replaces: null,
+      ReplacedBy: null,
+      Status: null,
+      SplitConsignment: null,
+      ChildNotification: null,
+      JourneyRiskCategorisation: null,
+      IsHighRiskEuImport: null,
+      PartOne: null,
+      DecisionBy: null,
+      DecisionDate: null,
+      PartTwo: null,
+      PartThree: null,
+      OfficialVeterinarian: null,
+      ConsignmentValidations: null,
+      AgencyOrganisationId: null,
+      RiskDecisionLockedOn: null,
+      IsRiskDecisionLocked: null,
+      IsBulkUploadInProgress: null,
+      RequestId: null,
+      IsCdsFullMatched: null,
+      ChedTypeVersion: null,
+      IsGMRMatched: null,
+      CommoditiesSummary: null,
+      Commodities: null
+    },
+    Created: 2025-04-07 11:00 Utc,
+    Updated: 2025-04-07 11:15 Utc,
+    ETag: null
+  }
+]
\ No newline at end of file
diff --git a/tests/Api.Client.Tests/Endpoints/CustomsDeclarations/GetImportPreNotificationsTests.cs b/tests/Api.Client.Tests/Endpoints/CustomsDeclarations/GetImportPreNotificationsTests.cs
new file mode 100644
index 00000000..44f6b6e3
--- /dev/null
+++ b/tests/Api.Client.Tests/Endpoints/CustomsDeclarations/GetImportPreNotificationsTests.cs
@@ -0,0 +1,67 @@
+using Argon;
+using Defra.TradeImportsDataApi.Testing;
+using FluentAssertions;
+using Microsoft.AspNetCore.Http;
+using WireMock.RequestBuilders;
+using WireMock.ResponseBuilders;
+using JsonSerializer = System.Text.Json.JsonSerializer;
+
+namespace Defra.TradeImportsDataApi.Api.Client.Tests.Endpoints.CustomsDeclarations;
+
+public class GetImportPreNotificationsTests : WireMockTestBase<WireMockContext>
+{
+    private TradeImportsDataApiClient Subject { get; }
+
+    private readonly VerifySettings _settings;
+
+    public GetImportPreNotificationsTests(WireMockContext context)
+        : base(context)
+    {
+        Subject = new TradeImportsDataApiClient(context.HttpClient);
+
+        _settings = new VerifySettings();
+        _settings.DontScrubGuids();
+        _settings.DontScrubDateTimes();
+        _settings.AddExtraSettings(settings => settings.DefaultValueHandling = DefaultValueHandling.Include);
+    }
+
+    [Fact]
+    public async Task GetCustomsDeclaration_WhenNotFound_ShouldBeNull()
+    {
+        var result = await Subject.GetImportPreNotificationsByMrn("unknown", CancellationToken.None);
+
+        result.Should().BeNull();
+    }
+
+    [Fact]
+    public async Task GetCustomsDeclaration_WhenFound_ShouldNotBeNull()
+    {
+        const string mrn = "mrn";
+        var created = new DateTime(2025, 4, 7, 11, 0, 0, DateTimeKind.Utc);
+        var updated = created.AddMinutes(15);
+        WireMock
+            .Given(Request.Create().WithPath($"/customs-declarations/{mrn}/import-pre-notifications").UsingGet())
+            .RespondWith(
+                Response
+                    .Create()
+                    .WithBody(
+                        JsonSerializer.Serialize(
+                            new List<Api.Endpoints.ImportPreNotifications.ImportPreNotificationResponse>()
+                            {
+                                new Api.Endpoints.ImportPreNotifications.ImportPreNotificationResponse(
+                                    new Domain.Ipaffs.ImportPreNotification { ReferenceNumber = "ched" },
+                                    created,
+                                    updated
+                                ),
+                            }
+                        )
+                    )
+                    .WithStatusCode(StatusCodes.Status200OK)
+            );
+
+        var result = await Subject.GetImportPreNotificationsByMrn(mrn, CancellationToken.None);
+
+        result.Should().NotBeNull();
+        await Verify(result, _settings);
+    }
+}
diff --git a/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.GetCustomDeclarationsByChed_WhenFound_ShouldNotBeNull.verified.txt b/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.GetCustomDeclarationsByChed_WhenFound_ShouldNotBeNull.verified.txt
new file mode 100644
index 00000000..0382579a
--- /dev/null
+++ b/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.GetCustomDeclarationsByChed_WhenFound_ShouldNotBeNull.verified.txt
@@ -0,0 +1,11 @@
+﻿[
+  {
+    MovementReferenceNumber: null,
+    ClearanceRequest: null,
+    ClearanceDecision: null,
+    Finalisation: null,
+    Created: 0001-01-01,
+    Updated: 0001-01-01,
+    ETag: etag
+  }
+]
\ No newline at end of file
diff --git a/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.GetImportPreNotification_WhenFound_ShouldNotBeNull.verified.txt b/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.GetImportPreNotification_WhenFound_ShouldNotBeNull.verified.txt
new file mode 100644
index 00000000..d4d76281
--- /dev/null
+++ b/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.GetImportPreNotification_WhenFound_ShouldNotBeNull.verified.txt
@@ -0,0 +1,39 @@
+﻿{
+  ImportPreNotification: {
+    IpaffsId: null,
+    Etag: null,
+    ExternalReferences: null,
+    ReferenceNumber: CHED,
+    Version: null,
+    UpdatedSource: null,
+    LastUpdatedBy: null,
+    ImportNotificationType: null,
+    Replaces: null,
+    ReplacedBy: null,
+    Status: null,
+    SplitConsignment: null,
+    ChildNotification: null,
+    JourneyRiskCategorisation: null,
+    IsHighRiskEuImport: null,
+    PartOne: null,
+    DecisionBy: null,
+    DecisionDate: null,
+    PartTwo: null,
+    PartThree: null,
+    OfficialVeterinarian: null,
+    ConsignmentValidations: null,
+    AgencyOrganisationId: null,
+    RiskDecisionLockedOn: null,
+    IsRiskDecisionLocked: null,
+    IsBulkUploadInProgress: null,
+    RequestId: null,
+    IsCdsFullMatched: null,
+    ChedTypeVersion: null,
+    IsGMRMatched: null,
+    CommoditiesSummary: null,
+    Commodities: null
+  },
+  Created: 2025-04-07 11:00 Utc,
+  Updated: 2025-04-07 11:15 Utc,
+  ETag: "etag"
+}
\ No newline at end of file
diff --git a/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.cs b/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.cs
new file mode 100644
index 00000000..21784bf0
--- /dev/null
+++ b/tests/Api.Client.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsTests.cs
@@ -0,0 +1,73 @@
+using Argon;
+using Defra.TradeImportsDataApi.Data.Entities;
+using Defra.TradeImportsDataApi.Domain.CustomsDeclaration;
+using Defra.TradeImportsDataApi.Testing;
+using FluentAssertions;
+using Microsoft.AspNetCore.Http;
+using WireMock.RequestBuilders;
+using WireMock.ResponseBuilders;
+using JsonSerializer = System.Text.Json.JsonSerializer;
+
+namespace Defra.TradeImportsDataApi.Api.Client.Tests.Endpoints.ImportPreNotifications;
+
+public class GetCustomsDeclarationsTests : WireMockTestBase<WireMockContext>
+{
+    private TradeImportsDataApiClient Subject { get; }
+
+    private readonly VerifySettings _settings;
+
+    public GetCustomsDeclarationsTests(WireMockContext context)
+        : base(context)
+    {
+        Subject = new TradeImportsDataApiClient(context.HttpClient);
+
+        _settings = new VerifySettings();
+        _settings.DontScrubGuids();
+        _settings.DontScrubDateTimes();
+        _settings.AddExtraSettings(settings => settings.DefaultValueHandling = DefaultValueHandling.Include);
+    }
+
+    [Fact]
+    public async Task GetImportPreNotification_WhenNotFound_ShouldBeNull()
+    {
+        var result = await Subject.GetCustomsDeclarationsByChedId("unknown", CancellationToken.None);
+
+        result.Should().BeNull();
+    }
+
+    [Fact]
+    public async Task GetCustomDeclarationsByChed_WhenFound_ShouldNotBeNull()
+    {
+        const string chedId = "CHED";
+        var created = new DateTime(2025, 4, 7, 11, 0, 0, DateTimeKind.Utc);
+        var updated = created.AddMinutes(15);
+
+        WireMock
+            .Given(Request.Create().WithPath($"/import-pre-notifications/{chedId}/customs-declarations").UsingGet())
+            .RespondWith(
+                Response
+                    .Create()
+                    .WithBody(
+                        JsonSerializer.Serialize(
+                            new List<CustomsDeclarationEntity>()
+                            {
+                                new()
+                                {
+                                    Id = "123",
+                                    ClearanceRequest = new ClearanceRequest(),
+                                    Created = created,
+                                    Updated = updated,
+                                    ETag = "etag",
+                                },
+                            }
+                        )
+                    )
+                    .WithStatusCode(StatusCodes.Status200OK)
+            );
+
+        var result = await Subject.GetCustomsDeclarationsByChedId(chedId, CancellationToken.None);
+
+        result.Should().NotBeNull();
+        await Verify(result, _settings);
+    }
+}
diff --git a/tests/Api.IntegrationTests/Endpoints/CustomsDeclarationTests.cs b/tests/Api.IntegrationTests/Endpoints/CustomsDeclarationTests.cs
index e044ce36..f611e238 100644
--- a/tests/Api.IntegrationTests/Endpoints/CustomsDeclarationTests.cs
+++ b/tests/Api.IntegrationTests/Endpoints/CustomsDeclarationTests.cs
@@ -1,4 +1,5 @@
 using Defra.TradeImportsDataApi.Domain.CustomsDeclaration;
+using Defra.TradeImportsDataApi.Domain.Ipaffs;
 using FluentAssertions;
 
 namespace Defra.TradeImportsDataApi.Api.IntegrationTests.Endpoints;
@@ -56,4 +57,60 @@ await client.PutCustomsDeclaration(
         result.Should().NotBeNull();
         result.ClearanceRequest?.ExternalVersion.Should().Be(2);
     }
+
+    [Fact]
+    public async Task WhenRelatedImportPreNotificationsExists_ShouldRead()
+    {
+        var client = CreateDataApiClient();
+        var chedRef = "CHEDA.GB.2025.1234567";
+        var mrn = "testmrn123";
+
+        var result = await client.GetImportPreNotification(chedRef, CancellationToken.None);
+
+        if (result is null)
+        {
+            await client.PutImportPreNotification(
+                chedRef,
+                new ImportPreNotification { ReferenceNumber = chedRef, Version = 1 },
+                null,
+                CancellationToken.None
+            );
+        }
+
+        var cdResult = await client.GetCustomsDeclaration(mrn, CancellationToken.None);
+
+        if (cdResult is null)
+        {
+            await client.PutCustomsDeclaration(
+                mrn,
+                new CustomsDeclaration
+                {
+                    ClearanceRequest = new ClearanceRequest
+                    {
+                        ExternalVersion = 1,
+                        Commodities =
+                        [
+                            new Commodity()
+                            {
+                                Documents =
+                                [
+                                    new ImportDocument()
+                                    {
+                                        DocumentReference = new ImportDocumentReference("GBCHD2025.1234567"),
+                                        DocumentCode = "C640",
+                                    },
+                                ],
+                            },
+                        ],
+                    },
+                },
+                null,
+                CancellationToken.None
+            );
+        }
+
+        var actualResult = await client.GetImportPreNotificationsByMrn(mrn, CancellationToken.None);
+        actualResult.Should().NotBeNull();
+        actualResult.Count.Should().Be(1);
+    }
 }
diff --git a/tests/Api.IntegrationTests/Endpoints/ImportPreNotificationTests.cs b/tests/Api.IntegrationTests/Endpoints/ImportPreNotificationTests.cs
index 79f22b8d..72af43c7 100644
--- a/tests/Api.IntegrationTests/Endpoints/ImportPreNotificationTests.cs
+++ b/tests/Api.IntegrationTests/Endpoints/ImportPreNotificationTests.cs
@@ -1,3 +1,4 @@
+using Defra.TradeImportsDataApi.Domain.CustomsDeclaration;
 using Defra.TradeImportsDataApi.Domain.Ipaffs;
 using FluentAssertions;
 
@@ -25,6 +26,27 @@ await client.PutImportPreNotification(
         result.Should().NotBeNull();
     }
 
+    [Fact]
+    public async Task WhenRelatedCustomsDeclarationsDoesNotExist_ShouldCreateAndRead()
+    {
+        var client = CreateDataApiClient();
+        var chedRef = Guid.NewGuid().ToString("N");
+
+        var result = await client.GetImportPreNotification(chedRef, CancellationToken.None);
+        result.Should().BeNull();
+
+        await client.PutImportPreNotification(
+            chedRef,
+            new ImportPreNotification { ReferenceNumber = chedRef, Version = 1 },
+            null,
+            CancellationToken.None
+        );
+
+        var cdResult = await client.GetCustomsDeclarationsByChedId(chedRef, CancellationToken.None);
+        cdResult.Should().NotBeNull();
+        cdResult.Count.Should().Be(0);
+    }
+
     [Fact]
     public async Task WhenExists_ShouldUpdate()
     {
@@ -56,4 +78,60 @@ await client.PutImportPreNotification(
         result.Should().NotBeNull();
         result.ImportPreNotification.Version.Should().Be(2);
     }
+
+    [Fact]
+    public async Task WhenRelatedCustomsDeclarationsExists_ShouldRead()
+    {
+        var client = CreateDataApiClient();
+        var chedRef = "CHEDA.GB.2025.1234567";
+        var mrn = "testmrn123";
+
+        var result = await client.GetImportPreNotification(chedRef, CancellationToken.None);
+
+        if (result is null)
+        {
+            await client.PutImportPreNotification(
+                chedRef,
+                new ImportPreNotification { ReferenceNumber = chedRef, Version = 1 },
+                null,
+                CancellationToken.None
+            );
+        }
+
+        var cdResult = await client.GetCustomsDeclaration(mrn, CancellationToken.None);
+
+        if (cdResult is null)
+        {
+            await client.PutCustomsDeclaration(
+                mrn,
+                new CustomsDeclaration
+                {
+                    ClearanceRequest = new ClearanceRequest
+                    {
+                        ExternalVersion = 1,
+                        Commodities =
+                        [
+                            new Commodity()
+                            {
+                                Documents =
+                                [
+                                    new ImportDocument()
+                                    {
+                                        DocumentReference = new ImportDocumentReference("GBCHD2025.1234567"),
+                                        DocumentCode = "C640",
+                                    },
+                                ],
+                            },
+                        ],
+                    },
+                },
+                null,
+                CancellationToken.None
+            );
+        }
+
+        var actualResult = await client.GetCustomsDeclarationsByChedId(chedRef, CancellationToken.None);
+        actualResult.Should().NotBeNull();
+        actualResult.Count.Should().Be(1);
+    }
 }
diff --git a/tests/Api.Tests/Api.Tests.csproj b/tests/Api.Tests/Api.Tests.csproj
index 3ef182db..98c82666 100644
--- a/tests/Api.Tests/Api.Tests.csproj
+++ b/tests/Api.Tests/Api.Tests.csproj
@@ -23,7 +23,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\..\src\Api\Api.csproj"/>
+    <ProjectReference Include="..\..\src\Api\Api.csproj" />
     <ProjectReference Include="..\Testing\Testing.csproj" />
   </ItemGroup>
 
@@ -31,4 +31,16 @@
     <EmbeddedResource Include="Endpoints\*\*.json" />
   </ItemGroup>
 
+  <ItemGroup>
+    <None Update="Endpoints\ImportPreNotifications\GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent.verified.txt">
+      <DependentUpon>GetCustomsDeclarationsByChedIdTests.cs</DependentUpon>
+    </None>
+    <None Update="Endpoints\ImportPreNotifications\GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent_response.verified.txt">
+      <DependentUpon>GetCustomsDeclarationsByChedIdTests.cs</DependentUpon>
+    </None>
+    <None Update="Endpoints\ImportPreNotifications\GetCustomsDeclarationsByChedIdTests.Get_WhenNotFound_ShouldNotBeFound.verified.txt">
+      <DependentUpon>GetCustomsDeclarationsByChedIdTests.cs</DependentUpon>
+    </None>
+  </ItemGroup>
+
 </Project>
diff --git a/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent.verified.txt b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent.verified.txt
new file mode 100644
index 00000000..38847302
--- /dev/null
+++ b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent.verified.txt
@@ -0,0 +1,26 @@
+﻿[
+  {
+    movementReferenceNumber: 123,
+    clearanceRequest: {
+      externalCorrelationId: null,
+      messageSentAt: 0001-01-01T00:00:00,
+      externalVersion: null,
+      previousExternalVersion: null,
+      declarationUcr: null,
+      declarationPartNumber: null,
+      declarationType: null,
+      arrivesAt: null,
+      submitterTurn: null,
+      declarantId: null,
+      declarantName: null,
+      dispatchCountryCode: null,
+      goodsLocationCode: null,
+      masterUcr: null,
+      commodities: null
+    },
+    clearanceDecision: null,
+    finalisation: null,
+    created: 2025-04-03T10:00:00Z,
+    updated: 2025-04-03T10:15:00Z
+  }
+]
\ No newline at end of file
diff --git a/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent_response.verified.txt b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent_response.verified.txt
new file mode 100644
index 00000000..4fa963da
--- /dev/null
+++ b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenFound_ShouldReturnContent_response.verified.txt
@@ -0,0 +1,31 @@
+﻿{
+  Version: 1.1,
+  Content: {
+    Headers: [
+      {
+        Content-Type: [
+          application/json; charset=utf-8
+        ]
+      }
+    ]
+  },
+  StatusCode: OK,
+  ReasonPhrase: OK,
+  Headers: [],
+  TrailingHeaders: [],
+  RequestMessage: {
+    Version: 1.1,
+    Method: {
+      Method: GET
+    },
+    RequestUri: http://localhost/import-pre-notifications/chedId/customs-declarations,
+    Headers: [
+      {
+        Authorization: [
+          Basic SW50ZWdyYXRpb25UZXN0LVJlYWRXcml0ZTppbnRlZ3JhdGlvbi10ZXN0LXJlYWR3cml0ZQ==
+        ]
+      }
+    ]
+  },
+  IsSuccessStatusCode: true
+}
\ No newline at end of file
diff --git a/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenNotFound_ShouldNotBeFound.verified.txt b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenNotFound_ShouldNotBeFound.verified.txt
new file mode 100644
index 00000000..ad47dbb9
--- /dev/null
+++ b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.Get_WhenNotFound_ShouldNotBeFound.verified.txt
@@ -0,0 +1 @@
+﻿[]
\ No newline at end of file
diff --git a/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.cs b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.cs
new file mode 100644
index 00000000..6a90cff3
--- /dev/null
+++ b/tests/Api.Tests/Endpoints/ImportPreNotifications/GetCustomsDeclarationsByChedIdTests.cs
@@ -0,0 +1,118 @@
+using System.Net;
+using System.Text.Json;
+using AutoFixture;
+using Defra.TradeImportsDataApi.Api.Services;
+using Defra.TradeImportsDataApi.Data.Entities;
+using Defra.TradeImportsDataApi.Domain.CustomsDeclaration;
+using Defra.TradeImportsDataApi.Domain.Gvms;
+using Defra.TradeImportsDataApi.Domain.Ipaffs;
+using Defra.TradeImportsDataApi.Testing;
+using FluentAssertions;
+using Microsoft.Extensions.DependencyInjection;
+using NSubstitute;
+using WireMock.Server;
+using Xunit.Abstractions;
+
+namespace Defra.TradeImportsDataApi.Api.Tests.Endpoints.ImportPreNotifications;
+
+public class GetCustomsDeclarationsByChedIdTests : EndpointTestBase, IClassFixture<WireMockContext>
+{
+    private IImportPreNotificationService MockImportPreNotificationService { get; } =
+        Substitute.For<IImportPreNotificationService>();
+    private ICustomsDeclarationService MockCustomsDeclarationService { get; } =
+        Substitute.For<ICustomsDeclarationService>();
+    private WireMockServer WireMock { get; }
+    private const string ChedId = "chedId";
+    private readonly VerifySettings _settings;
+
+    public GetCustomsDeclarationsByChedIdTests(
+        ApiWebApplicationFactory factory,
+        ITestOutputHelper outputHelper,
+        WireMockContext context
+    )
+        : base(factory, outputHelper)
+    {
+        WireMock = context.Server;
+        WireMock.Reset();
+
+        _settings = new VerifySettings();
+        _settings.ScrubMember("traceId");
+        _settings.DontScrubDateTimes();
+        _settings.DontScrubGuids();
+    }
+
+    protected override void ConfigureTestServices(IServiceCollection services)
+    {
+        base.ConfigureTestServices(services);
+
+        services.AddTransient<IImportPreNotificationService>(_ => MockImportPreNotificationService);
+        services.AddTransient<ICustomsDeclarationService>(_ => MockCustomsDeclarationService);
+    }
+
+    [Fact]
+    public async Task Get_WhenNotFound_ShouldNotBeFound()
+    {
+        var client = CreateClient();
+        MockCustomsDeclarationService
+            .GetCustomsDeclarationsByChedId(ChedId, Arg.Any<CancellationToken>())
+            .Returns(Task.FromResult(new List<CustomsDeclarationEntity>()));
+
+        var response = await client.GetAsync(
+            TradeImportsDataApi.Testing.Endpoints.ImportPreNotifications.GetCustomsDeclarations(ChedId)
+        );
+
+        await VerifyJson(await response.Content.ReadAsStringAsync(), _settings);
+    }
+
+    [Fact]
+    public async Task Get_WhenFound_ShouldReturnContent()
+    {
+        var client = CreateClient();
+        MockCustomsDeclarationService
+            .GetCustomsDeclarationsByChedId(ChedId, Arg.Any<CancellationToken>())
+            .Returns(
+                [
+                    new CustomsDeclarationEntity
+                    {
+                        Id = "123",
+                        ClearanceRequest = new ClearanceRequest(),
+                        Created = new DateTime(2025, 4, 3, 10, 0, 0, DateTimeKind.Utc),
+                        Updated = new DateTime(2025, 4, 3, 10, 15, 0, DateTimeKind.Utc),
+                        ETag = "etag",
+                    },
+                ]
+            );
+
+        var response = await client.GetAsync(
+            TradeImportsDataApi.Testing.Endpoints.ImportPreNotifications.GetCustomsDeclarations(ChedId)
+        );
+
+        await VerifyJson(await response.Content.ReadAsStringAsync(), _settings)
+            .UseMethodName(nameof(Get_WhenFound_ShouldReturnContent));
+        await Verify(response, _settings).UseMethodName($"{nameof(Get_WhenFound_ShouldReturnContent)}_response");
+    }
+
+    [Fact]
+    public async Task Get_WhenUnauthorized_ShouldBeUnauthorized()
+    {
+        var client = CreateClient(addDefaultAuthorizationHeader: false);
+
+        var response = await client.GetAsync(
+            TradeImportsDataApi.Testing.Endpoints.ImportPreNotifications.GetCustomsDeclarations(ChedId)
+        );
+
+        response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
+    }
+
+    [Fact]
+    public async Task Get_WhenWriteOnly_ShouldBeForbidden()
+    {
+        var client = CreateClient(testUser: TestUser.WriteOnly);
+
+        var response = await client.GetAsync(
+            TradeImportsDataApi.Testing.Endpoints.ImportPreNotifications.GetCustomsDeclarations(ChedId)
+        );
+
+        response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
+    }
+}
diff --git a/tests/Api.Tests/OpenApi/OpenApiTests.OpenApi_VerifyAsExpected.verified.txt b/tests/Api.Tests/OpenApi/OpenApiTests.OpenApi_VerifyAsExpected.verified.txt
index 1e882866..649d9e73 100644
--- a/tests/Api.Tests/OpenApi/OpenApiTests.OpenApi_VerifyAsExpected.verified.txt
+++ b/tests/Api.Tests/OpenApi/OpenApiTests.OpenApi_VerifyAsExpected.verified.txt
@@ -410,6 +410,119 @@
           }
         }
       }
+    },
+    "/customs-declarations/{mrn}/import-pre-notifications": {
+      "get": {
+        "tags": [
+          "ImportPreNotificationsByMrn"
+        ],
+        "summary": "Get ImportPreNotifications by MRN",
+        "description": "Get associated import pre-notifications by MRN",
+        "operationId": "ImportPreNotificationsByMrn",
+        "parameters": [
+          {
+            "name": "mrn",
+            "in": "path",
+            "description": "MRN",
+            "required": true,
+            "schema": {
+              "type": "string"
+            }
+          }
+        ],
+        "responses": {
+          "200": {
+            "description": "OK",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "array",
+                  "items": {
+                    "$ref": "#/components/schemas/Defra.TradeImportsDataApi.Api.Endpoints.ImportPreNotifications.ImportPreNotificationResponse"
+                  }
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Bad Request",
+            "content": {
+              "application/problem+json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
+                }
+              }
+            }
+          },
+          "500": {
+            "description": "Internal Server Error",
+            "content": {
+              "application/problem+json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/import-pre-notifications/{chedId}/customs-declarations": {
+      "get": {
+        "tags": [
+          "ImportPreNotificationsWithCustomsDeclarations"
+        ],
+        "summary": "Get ImportPreNotification with CustomsDeclarations",
+        "description": "Get an import pre-notification by CHED ID along with the associated customs-declarations",
+        "operationId": "GetImportPreNotificationAndCustomsDeclarationsByChedId",
+        "parameters": [
+          {
+            "name": "chedId",
+            "in": "path",
+            "description": "CHED ID",
+            "required": true,
+            "schema": {
+              "type": "string"
+            },
+            "example": "CHEDA.GB.2024.1020304"
+          }
+        ],
+        "responses": {
+          "200": {
+            "description": "OK",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "array",
+                  "items": {
+                    "$ref": "#/components/schemas/Defra.TradeImportsDataApi.Api.Endpoints.CustomsDeclarations.CustomsDeclarationResponse"
+                  }
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Bad Request",
+            "content": {
+              "application/problem+json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
+                }
+              }
+            }
+          },
+          "500": {
+            "description": "Internal Server Error",
+            "content": {
+              "application/problem+json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails"
+                }
+              }
+            }
+          }
+        }
+      }
     }
   },
   "components": {
diff --git a/tests/Testing/Endpoints.cs b/tests/Testing/Endpoints.cs
index e27a0bb3..cb1f00f4 100644
--- a/tests/Testing/Endpoints.cs
+++ b/tests/Testing/Endpoints.cs
@@ -17,6 +17,8 @@ public static class ImportPreNotifications
 
         public static string Get(string chedId) => $"{Root}/{chedId}";
 
+        public static string GetCustomsDeclarations(string chedId) => $"{Root}/{chedId}/customs-declarations";
+
         public static string Put(string chedId) => $"{Root}/{chedId}";
     }
 
@@ -26,6 +28,8 @@ public static class CustomsDeclarations
 
         public static string Get(string mrn) => $"{Root}/{mrn}";
 
+        public static string GetImportPreNotifications(string mrn) => $"{Root}/{mrn}/import-pre-notifications";
+
         public static string Put(string mrn) => $"{Root}/{mrn}";
     }
 }


Reviews:
user: login: tjpeel-ee
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T07:42:07Z
user: login: tjpeel-ee
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T07:45:55Z
user: login: TrinhChuongEE
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T14:53:16Z

Review comments:
diff_hunk: @@ -31,6 +31,25 @@ CancellationToken cancellationToken
         };
     }
 
+    public async Task<ImportPreNotificationWithCustomDeclarationsResponse?> GetImportPreNotificationWithCustomsDeclarations(
+        string chedId,
+        CancellationToken cancellationToken
+    )
+    {
+        var response = await Get(Endpoints.ImportPreNotifications(chedId), cancellationToken);
path: src/Api.Client/TradeImportsDataApiClient.cs
user: login: tjpeel-ee
body: This is calling the wrong Endpoints method I think
created_at: 2025-04-14T07:42:07Z
author_association: CONTRIBUTOR
diff_hunk: @@ -87,6 +106,25 @@ CancellationToken cancellationToken
         };
     }
 
+    public async Task<CustomsDeclarationWithImportPreNotificationsResponse?> GetCustomsDeclarationWithImportPreNotification(
+        string mrn,
+        CancellationToken cancellationToken
+    )
+    {
+        var response = await Get(Endpoints.CustomsDeclarations(mrn), cancellationToken);
path: src/Api.Client/TradeImportsDataApiClient.cs
user: login: tjpeel-ee
body: Same, wrong Endpoints method being called
created_at: 2025-04-14T07:45:55Z
author_association: CONTRIBUTOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-04-14T14:19:23Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=DEFRA_trade-imports-data-api&pullRequest=42) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=DEFRA_trade-imports-data-api&pullRequest=42&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=DEFRA_trade-imports-data-api&pullRequest=42&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=DEFRA_trade-imports-data-api&pullRequest=42&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=DEFRA_trade-imports-data-api&pullRequest=42&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=DEFRA_trade-imports-data-api&pullRequest=42&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=DEFRA_trade-imports-data-api&pullRequest=42)


author_association: NONE