File

projects/congarevenuecloud/ecommerce/src/lib/modules/favorite/services/favorite.service.ts

Description

Favorite service defines a way to save a configuration as favorite or add a saved configuration to active cart.

Extends

AObjectService

Index

Properties
Methods

Methods

addFavorite
addFavorite(favoriteId: string, payload: Array<FavoriteItemRequest> | Array<number>)

This method is a work in progress. The method makes an api call to add the favorite items using the existing favoriteId and returns an observable of list of cartItems which got added to the existing favorite configuration. or Array is an instance of Array with number, consists of linenumber of cartitem, which is part of request payload.

Parameters :
Name Type Optional Description
favoriteId string No

is of type string, pass the favorite Id.

payload Array<FavoriteItemRequest> | Array<number> No

is of type Array which consists of productid and qty information or Array is an instance of Array with number, consists of linenumber of cartitem, which is part of request payload.

Returns : Observable<Array<CartItem>>

an observable of list of cartitems got added to the favorite configuration.

addFavoriteToCart
addFavoriteToCart(favorite: string | Favorite)

This method adds saved favorite configurations to active cart.

Parameters :
Name Type Optional Description
favorite string | Favorite No

favorite record or string identifier of the favorite.

Returns : Observable<boolean>

an observable of boolean based on successful add operation.

createFavorite
createFavorite(payload: Favorite)

The method is responsible for creating new favorite by invoking api callout, and returns an observable of favorite which got created with favorite information.

Parameters :
Name Type Optional Description
payload Favorite No

is instance of favorite

an observable of Favorite which got newly created.

getFavoriteById
getFavoriteById(favoriteId: string)

This method fetches favorite details for a given favorite id.

Parameters :
Name Type Optional Description
favoriteId string No

string value representing favorite identifier to fetch details for.

observable containing the favorite record.

getFavoriteConfguration
getFavoriteConfguration(configurationId: string)

This method is responsible for fetching cart configuration associated to a favorite.

Parameters :
Name Type Optional Description
configurationId string No

string value representing favorite configuration Id to fetch the configuration details for.

Returns : Observable<Cart>

observable of cart configuration associated to the favorite.

getMyFavorites
getMyFavorites()

The method fetches the list of favorites.

Example:

Example :
import { FavoriteService, Favorite } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Array<Favorite>
result$: Observable<Array<Favorite>>;
constructor(private favoriteService: FavoriteService){}

getMyFavorites(): Observable<Array<Favorite>> {
this.favoriteService.getMyFavorites().subscribe(r => this.result = r);
// or
results$ = this.FavoriteService.getMyFavorites();
}
}

An observable containing list of favorites matching the criteria and its total count..

removeFavorite
This method is deprecated on the Conga platform.
removeFavorite(favorite: string | Favorite)

This method removes a given favorite.

Parameters :
Name Type Optional Description
favorite string | Favorite No

favorite record or favorite Id.

observable instance of favorite record.

removeFavorites
removeFavorites(favoriteList: Array<Favorite> | Array<string>)

This method removes multiple list of favorites passed.

Parameters :
Name Type Optional Description
favoriteList Array<Favorite> | Array<string> No

list of favorite records or string identifiers to be removed.

observable containing list of favorites.

updateFavorite
updateFavorite(favorite: Favorite)

This method updates a given favorite. Only Name, Description and Scope of favorite can be updated.

Parameters :
Name Type Optional Description
favorite Favorite No

record to be updated.

observable containing favorite record with updated fields.

Properties

Protected cartService
Type : CartService
Default value : this.injector.get(CartService)
Protected priceListService
Type : PriceListService
Default value : this.injector.get(PriceListService)
type
Default value : Favorite

results matching ""

    No results matching ""