File

projects/congarevenuecloud/ecommerce/src/lib/modules/abo/services/asset.service.ts

Description

This service is a work in progress.

Assets are the products owned by customers, and a user may wish to renew,terminate, or update existing assets.

  • Usage

import { AssetService, AObjectService} from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
constructor( private assetService: AssetService)
}
// or
export class MyService extends AObjectService {
private assetService: AssetService = this.injector.get(AssetService);
}

Extends

AObjectService

Index

Properties
Methods

Methods

Public amendAssets
amendAssets(assetId: string | Array)

The primary method to amend the existing assets.

Example:

import { AssetService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
lineItemMap: Array<any>;
lineItemMap$: Observable<Array<any>>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.amendAssets(assetIds: Array<string>)subscribe(lineItemMap => {...});
// or
this.lineItemMap$ = this.assetService.amendAssets(assetIds: Array<string>);
}
}
Parameters :
Name Type Optional Description
assetId string | Array<string> No

id of the asset or assets whose configuration is to be amended.

Returns : Observable<Array<AssetLineItemExtended>>

returns an observable list of asset line item records.

Public cancelAssets
cancelAssets(assetIds: Array, cancelDate: Date)

The primary method to terminate the existing assets.

Example:

import { AssetService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
lineItemMap: Array<any>;
lineItemMap$: Observable<Array<any>>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.cancelAssets(assetIds: Array<string>, cancelDate: Date)subscribe(lineItemMap => {...});
// or
this.lineItemMap$ = this.assetService.cancelAssets(assetIds: Array<string>, cancelDate: Date);
}
}
Parameters :
Name Type Optional Description
assetIds Array<string> No

list of asset ids to terminate

cancelDate Date No

cancel date for asset termination

Returns : Observable<Array<CartItem>>

Observable<Array> an observable list of line items of the cart.

getAssetAggregates
getAssetAggregates(account?: Account, aggregateFields?: Array<AggregateFields>, queryFields: Array, groupByFields: Array, filterList: Array<FieldFilter>)

This method returns an aggregate result based on asset aggregate criteria.

Example:

import { AssetService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
resp: any;
resp$: Observable<AggregateResultSet>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.getAssetAggregates(account?: Account, aggregateFields?: Array<AggregateFields>, queryFields: Array<string>, groupByFields: Array<string>, filterList: Array<FieldFilter>).subscribe(resp => {...});
// or
this.resp$ = this.assetService.getAssetAggregates(account?: Account, aggregateFields?: Array<AggregateFields>, queryFields: Array<string>, groupByFields: Array<string>, filterList: Array<FieldFilter>);
}
}

See AggregateFields for more details on the structure and fields required.

Parameters :
Name Type Optional Default value Description
account Account Yes

instance of account object.

aggregateFields Array<AggregateFields> Yes

list of AggregateFields used in query.

queryFields Array<string> No []

list of fields to be part of the query response.

groupByFields Array<string> No []

list of fields to be part of the group by clauses.

filterList Array<FieldFilter> No []

list of FieldFilter objects representing the filters to be applied.

observable containing aggregate response.

getAssetFilters
getAssetFilters(productList?: Array<Product> | Array<string>)

Generates an array of field filters to retrieve assets. This method combines a default set of filters with additional filters derived from the provided product list.

Allows customization of the filter criteria. If provided, the method will generate a filter based on the product IDs.

The filters defined by this method are as follows:

The common/default filters are:

  • LineType: Excludes options with the value 'Option'
  • IsPrimaryLine: Includes only lines that are primary.
  • PriceList.Id: Matches the active price list id.

If the productList is provided with more than one item, a filter is created based on the product IDs using the IN operator else with an EQUAL operator.

Parameters :
Name Type Optional Description
productList Array<Product> | Array<string> Yes
  • Optional list of products or product IDs. If provided, the method will generate a filter based on the product IDs.

The filters defined by this method are as follows:

The common/default filters are:

  • LineType: Excludes options with the value 'Option'
  • IsPrimaryLine: Includes only lines that are primary.
  • PriceList.Id: Matches the active price list id.

If the productList is provided with more than one item, a filter is created based on the product IDs using the IN operator else with an EQUAL operator.

Returns : Array<FieldFilter>

An array of field filters.

Public getAssetLineItemsforProducts
getAssetLineItemsforProducts(productList: Array<Product> | Array<string>, memoizeOptions: MemoizeOptions)
Decorators :
@MemoizeWithHash()

This method can be used to get the asset line items for a given set of products. ABO must be enabled in the storefront to get asset line item records.

Example:

import { AssetService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
assetLineItems: Array<AssetLineItem>;
assetLineItems$: Observable<Array<AssetLineItem>>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.getAssetLineItemsforProducts(products: Array<Product>).subscribe(assetLineItems => {...});
// or
this.assetLineItems$ = this.assetService.getAssetLineItemsforProducts(products: Array<Product>);
}
}

See MemoizeOptions for more details on the structure and fields required.

Parameters :
Name Type Optional Default value Description
productList Array<Product> | Array<string> No

list of product records or list of product ids as string value.

memoizeOptions MemoizeOptions No null

an optional parameter to specify memoization options using MemoizeOptions interface. Defaults to null.

Returns : Observable<Array<AssetLineItemExtended>>

returns an observable list of asset line item records.

Public incrementAssets
incrementAssets(incrementAssetDOs: Array)

The primary method to increment the existing assets.

Example:

import { AssetService, IncrementAssetDO, IncrementLineAction } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
lineItemMap: Array<any>;
lineItemMap$: Observable<Array<any>>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.incrementAssets(incrementAssetDO: Array<IncrementAssetDO>)subscribe(lineItemMap => {...});
// or
this.lineItemMap$ = this.assetService.incrementAssets(incrementAssetDO: Array<IncrementAssetDO>);
}
}

See IncrementAssetDO for more details on the structure and fields required.

Parameters :
Name Type Optional Description
incrementAssetDOs Array<IncrementAssetDO> No

list of increment asset data objects for incrementing the existing assets

Returns : Observable<Array<CartItem>>

an observable list of cart line items records.

Public renewAssets
renewAssets(assetIds: Array, renewEndDate: Date, renewTerm: number, farthestAssetEndDate: boolean)

The primary method to renew the existing assets.

Example:

import { AssetService, AssetLineItemExtended } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
lineItemMap: Array<AssetLineItemExtended>;
lineItemMap$: Observable<Array<AssetLineItemExtended>>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.renewAssets(assetIds: Array<string>, renewEndDate: Date, renewTerm: number, farthestAssetEndDate: boolean)subscribe(lineItemMap => {...});
// or
this.lineItemMap$ = this.assetService.renewAssets(assetIds: Array<string>, renewEndDate: Date, renewTerm: number, farthestAssetEndDate: boolean);
}
}
Parameters :
Name Type Optional Description
assetIds Array<string> No

list of asset ids to renew

renewEndDate Date No

renew end date for asset renewal

renewTerm number No

renew term for asset renewal

farthestAssetEndDate boolean No

farthest asset end date for asset renewal

Returns : Observable<Array<CartItem>>

Observable<Array> an observable list of line items of the cart.

restoreAssetLineItem
restoreAssetLineItem(lineItems: Array)

This method reverts a list of line items to their previous state after they have been canceled.

It changes the status of these line items back to what it was before the cancellation.

Example:

import { AssetService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
resp: Array<any>;
resp$: Observable<Array<CartItem>>;

constructor(private assetService: AssetService){}

ngOnInit(){
this.assetService.restoreAssetLineItem(lineItems: Array<CartItem>).subscribe(resp => {...});
// or
this.resp$ = this.assetService.restoreAssetLineItem(lineItems: Array<CartItem>);
}
}
Parameters :
Name Type Optional Description
lineItems Array<CartItem> No
  • An array of cart line items to be restored, each containing details such as ID, action, line type, and asset information.
Returns : Observable<Array<CartItem>>

An observable that emits the response from the API call, which typically contains updated information about the restored line items.

Properties

Protected accountService
Default value : this.injector.get(AccountService)
apiService
Type : ApiService
Default value : this.injector.get(ApiService)
storefrontService
Type : StorefrontService
Default value : this.injector.get(StorefrontService)
type
Default value : AssetLineItemExtended

results matching ""

    No results matching ""