• Order belongs to organization validator

    Parameters

    • orderService: Pick<OrderDataService, "getOneOrder">

      injected order service to get order

    • organizationAPI: Pick<OrganizationDefaultAdapterAPI, "getOrganizationById">

      injected API use to get organization

    • orgIdTargetField: TargetField

      injected targetField use to get orgId

    • orderIdTargetField: TargetField

      injected targetField use to get orderId

    • logger: Logger

      injected logger use to handle logging

    • context: AdapterHandlerContext

      request context [headers, body, params, query].

    Returns Promise<StatusCodes>

    200 Status OK

    Description

    This validator checks if the order belongs to the organization by applying the following steps in sequence:

    1. Get orgId from targetField context

    2. Check if organization exists

    3. Get orderId from targetField context

    4. Check if order exists

    5. Check if order has the same organization ID as the organization in targetField

    Throws

    403 NBError Forbidden

    • order does not belong to organization

    Throws

    404 NBError Not Found

    • orgId ${orgId} cannot be found
    • orderId ${orderId} cannot be found

Generated using TypeDoc