Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

--------------------------------------------------------------------------------

BrightProductsController is meant to expose Exposes a single read endpoint that returns the price products and / tariffs for atied to

specific one customer and service + one service (metering point / EAN number) within a date range, .

The data is read from the SonWin /(Sonlinc) contract tables;

The query selects the contract "lines" for the requested EAN numbersystem, shaped into the "Bright" product contract. On any thrown exception logs the error and returns HTTP 500 with the exception message in the body.

--------------------------------------------------------------------------------

...

--------------------------------------------------------------------------------

1) GetProducts

   Route:    GET / bright/products

   Auth:     [Authorize] (controller-level)

   Params:  

  • customerId (
  • required
  • query)
  • serviceId (
  • required
  • query)
  • DateFrom (
  • required
  • query DateTime)
  •             
  • DateTo (
  • required
  • query DateTime)
  •   
  • (CancellationToken)
  • CancellationToken ct

   Body:     none

   Returns: 

  • 200 OK -> IEnumerable<BrightProduct>
  • 400
  • BadRequest   
  • BadRequest (declared
  • ; see note below
  • , never produced - see NOTE)
  • 401 Unauthorized (from auth middleware, not the action)

   What it does:

     Return the list of price products/tariffs for a given customer

     and service that are valid within the requested date range.

     It first validates the customer exists , then asks

     the repository for the matching DbProduct rows, groups them by ServiceId,

...

  • Validates the customer
  • validates the inputs
  • queries active contracts for the customer + EAN within the date range
  • validates that every returned row belongs to the requested serviceId
  • Groups by AftageNr
  • Maps each group to a BrightProduct with a

...

  • list of BrightPrice lines.

   Validation that affects the result (all ALL failures surface as HTTP 500 with a message:

     Customer validation (AccountValidator.ValidateAccountGetOutput):

    Customer not found           
  •        no customer row              -> "No customer found with Id '
  • {id}
  • <id>'."
  • More
  •        more than one
  • active customer 
  • row            -> "Unique active customer could not be identified. Id:
  • '{id}'."

...

  • '<id>'."
  •        row has empty CustomerId     -> "The customer returned did not have any CustomerId."
  •        returned id != requested     -> "Returned customer '<x>' does not match requested '<id>'."

     Input validation (ProductsValidator.ValidateGetProductsAsyncInput):       

  • customerId blank             -> "Missing parameter 'CustomerId'."
  •        serviceId blank              -> "Missing parameter 'ServiceId'."
  •        serviceId non-digit          -> "Parameter 'ServiceId' must contain digits only."
  •        DateFrom == default          -> "Missing parameter 'DateFrom'."
  •        DateTo == default            -> "Missing parameter 'DateTo'."
  •        DateFrom >= DateTo           -> "'DateFrom' must be before 'DateTo'."

Output validation (ProductsValidator.ValidateGetProductsAsyncOutput):

  • Any row.AftageNr != serviceId -> "Products belong to wrong ServiceId(s):
  • <ids>. Expected ServiceId: <id>.
  • CustomerId <id>, daterange: <from>-<to>"

--------------------------------------------------------------------------------

 RESPONSE STRUCTURE (IEnumerable<BrightProduct>)

--------------------------------------------------------------------------------

Top level is a JSON array of BrightProduct. One element per distinct AftageNr

(EAN). Because the query filters on a single @EanNumber, in practice there is

one group, and each contract row becomes one entry in that group's Prices list.

Code Block
[
  {
    "ValidFrom": null,             // Hardcoded null 
    "ValidTo": null,               // Hardcoded null 
    "ServiceId": "<serviceId>",    // Echo of request serviceId param (MeteringPointId)
    "Prices": [
      {
        "Value": 0,                // Hardcoded 0 
        "Type": "kWh",             // Hardcoded "kWh" 
        "Note": null,              // Hardcoded null 
        "Name": "kWhPrice",        // Hardcoded "kWhPrice" 
        "ValidFrom": "<datetime>", // Data: AFORBKONTR.FRADATO (DbProduct.ContractActiveFrom)
        "ValidTo": "<datetime>",   // Data: AFORBKONTR.TILDATO (DbProduct.ContractActiveTo); null = open-ended
        "ValidHours": [],          // Not mapped 
        "ValidMonth": [],          // Not mapped 
        "ValidPart": null,         // Not mapped 
        "ValidFraction": null,     // Not mapped 
        "SubtractMeasurement": null// Not mapped 
      }
    ]
  }
]