• Create order handler

    Parameters

    • config: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
      }

      Authenticate configuration

      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
    • userServiceAPI: UserDefaultAdapterAPI

      injected API use to handle user related operations

    • catalogServiceAPI: CatalogDefaultAdapterAPI

      injected API use to handle catalog related operations

    • organizationServiceAPI: OrganizationDefaultAdapterAPI

      injected API use to handle organization related operations

    • orderService: OrderDataService

      injected service use to handle order related operations

      • createOrder
      • getOneOrder
    • taxRate: Decimal

      tax rate in decimal

    • orderCustomFieldDefinitions: CustomField[]
    • logger: Logger

      injected logger use to handle logging

    • context: AdapterHandlerContext

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

    Returns Promise<{
        data: ExpandedOrder;
        status: StatusCodes;
    }>

    201 Status Create

    • data: order data

    Description

    This handler is used to create order by applying the following steps in sequence:

    1. Get userId from authorization token

    2. Validates that the organization exists

    3. Checks that the provided products and variants exist for this organization

    4. Creates the order (orderService.createOrder)

    5. Fetches the order (orderService.getOneOrder)

    6. Return order data (expand if any)

    Throws

    400 NBError Bad Request

    • wrong variant

    Throws

    500 NBError Internal Server Error

    • operation failed to create order

Generated using TypeDoc