// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from 'rxjs'; import { EventContext } from '../../core/models/log'; import { BaseService } from '../../core/services/base.service'; import { LogService } from '../../core/services/log.service'; import { ServiceProvider } from '../../core/services/service-provider'; import { SearchService } from '../../find'; import { IShoppingCartDto, IShoppingCartEcrDto, IShoppingOffer, IShoppingPart, IShoppingPartDto, ShoppingCart } from '../models/shopping-cart'; import { PaginatedRequestService } from '../../core/services/paginated-request.service'; import { CSARequest } from '../models/csa-request'; interface ecrsData { expert_request_id: string; quantity: number; } interface ShoppingCartEventContext extends EventContext { organizationId?: string; ecrs?: ecrsData[]; searchSessionId?: string; } /** * TODO Apv2 transition * APv2 Service for CRUD functionality on Shopping cart * this services will remove the current Request-list service from sdk * @experimental This service and its API in a beta phase and not stable. It is subject to change and break until marked as stable. */ export interface ShoppingCartService { /** * Returns all carts client has access to. * CSA: depending on org-auth Technician: The single "OPEN" cart they have open or empty if no new cart exists yet * @param urlParams the params to be passed to the request for filtered results * @returns Observable with an array of the Shopping cart of the saved parts. */ getShoppingCarts(urlParams: Object[]): PaginatedRequestService; /** * Creates an empty shopping cart object. * * @returns Observable with an array of the Shopping cart of the saved parts. */ createEmptyShoppingCart(ShoppingCartDto: IShoppingCartDto): Observable; /** * Fetches the Shopping cart by Id. * @param cartId the id of the shopping cart to be fetched * @returns Observable with an Shopping cart object * to the backend. */ getShoppingCart(cartId: string): Observable; /** * Creates a request offer action * Creating an offer leads to an inquiry being created if the cart does not already have a relation to an existing inquiry * @param cartId the id of the shopping cart to be send * @param languageUI the interface language of the shopping cart to be send */ requestShoppingCartOffer(cartId: string, languageUI: string): Observable; /** * Fetches the parts of the Shopping cart. * @param cartId the id of the shopping cart to be fetched * @param urlParams (optional) the params to be passed to the request for filtered results * @returns Observable with an Shopping cart object * to the backend. */ getShoppingCartParts(cartId: string, urlParams?: Object[]): PaginatedRequestService; /** * Saves a group of parts in the shopping cart. * @param cartId the id of the shopping cart to be fetched * @param updatedParts An array of type IShoppingPart of all the requested parts * that are going to be added to the list. * @param shoppingCartEventContext (optional) ShoppingCartEventContext object to add the missing data that will be logged using the log format V2 * @returns Observable with an array of the Shopping cart of the saved parts. */ saveShoppingCartParts(cartId: string, updatedParts: IShoppingPartDto[], shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * Saves a group of ecrs in the shopping cart. * @param updatedEcrs An array of type IShoppingCartEcrDto with the data of the CSARequest that were updated * @param shoppingCartEventContext (optional) ShoppingCartEventContext object to add the missing data that will be logged using the log format V2 * @returns Observable with an array of the Shopping cart of the saved parts. */ saveShoppingCartEcrs(updatedEcr: IShoppingCartEcrDto[], shoppingCartEventContext?: ShoppingCartEventContext): Observable>; /** * Adds a new part to the Shopping cart. * Adds cart contents for one part. If item id already exists, adds quantity to existing one. * @param cartId the id of the shopping cart to be fetched * @param addedPart the part that is going to be added to the list * @param shoppingCartEventContext (optional) ShoppingCartEventContext object to add the missing data that will be logged using the log format V2 * @returns Observable with an array of the parts that resolves with the request * to the backend. */ addPart(cartId: string, addedPart: IShoppingPartDto, shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * Updates the Shopping cart parts part when new quantities are added- * @param cartId the id of the shopping cart to be fetched * @param updatedPart the part that is going to be added to the list * @param shoppingCartEventContext (optional) ShoppingCartEventContext object to add the missing data that will be logged using the log format V2 * @returns Observable with an array of the parts that resolves with the request * to the backend. */ updateShoppingCartPart(cartId: string, updatedPart: IShoppingPartDto, shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * Deletes one part from the requestedList. * @param cartId the id of the shopping cart to be fetched * @param partiumId the id of the part that is going to be removed * @param shoppingCartEventContext (optional) ShoppingCartEventContext object to add the missing data that will be logged using the log format V2 * @returns Observable with a boolean */ deletePart(cartId: string, partiumId: string, shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * Resets the shopping cart parts list to an empty array of parts. * @param cartId the id of the shopping cart to be fetched * @param shoppingCartEventContext (optional) ShoppingCartEventContext object to add the missing data that will be logged using the log format V2 * @returns Observable with a empty Shopping cart parts object that resolves with the * request to the backend. */ resetShoppingCart(cartId: string, shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * Exports the shopping cart as an email. * @param shoppingCartId id of the shopping cart to export * @param recipients comma separated list of recipients * @param subject subject of the email * @param message message of the email * @return an observable that completes when the email is sent */ exportShoppingCartAsEmail(shoppingCartId: string, recipients: string, subject: string, message: string): Observable; } export declare class ShoppingCartServiceImpl extends BaseService implements ShoppingCartService { private httpsService; protected logService: LogService; protected searchService: SearchService; constructor(serviceProvider: ServiceProvider); onCreate(): void; getShoppingCarts(urlParams?: Object[]): PaginatedRequestService; createEmptyShoppingCart(dto: IShoppingCartDto): Observable; getShoppingCart(cartId: string): Observable; getShoppingCartParts(cartId: string, urlParams?: Object[]): PaginatedRequestService; updateShoppingCartPart(cartId: string, updatedPart: IShoppingPartDto, shoppingCartEventContext?: ShoppingCartEventContext): Observable; requestShoppingCartOffer(cartId: string, languageUi: string): Observable; saveShoppingCartEcrs(updatedItems: IShoppingCartEcrDto[], shoppingCartEventContext?: ShoppingCartEventContext): Observable>; saveShoppingCartParts(cartId: string, updatedParts: IShoppingPartDto[], shoppingCartEventContext: ShoppingCartEventContext): Observable; addPart(cartId: string, addedPart: IShoppingPartDto, shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * Resets the requests list to an empty array of parts. */ resetShoppingCart(cartId: string, shoppingCartEventContext?: ShoppingCartEventContext): Observable; /** * DELETE a part from request-list without send entire list to update */ deletePart(cartId: string, partiumId: string, shoppingCartEventContext?: ShoppingCartEventContext): Observable; exportShoppingCartAsEmail(cartId: string, recipients: string, subject: string, message: string): Observable; private dispatchLogService; } export {};