File

projects/congarevenuecloud/ecommerce/src/lib/modules/crm/services/account.service.ts

Description

The account service provides methods for interacting with the accounts the user has access to.

Usage

Example :
import { AccountService, AObjectService} from '@congarevenuecloud/ecommerce';

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

Extends

AObjectService

Index

Properties
Methods

Methods

getAccount
getAccount(accountId: string)

Retrieves the account information based on the account id passed.

Example:

Example :
import { AccountService, Account} from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
accountDetails: Account;
accountDetails$: Observable<Account>;

constructor(private accountService: AccountService){}

getAccountDetails(Id: string){
this.accountService.getAccount(Id).subscribe(a => this.accountDetails = a);
// or
this.accountDetails$ = this.accountService.getAccount(Id);
}
}
Parameters :
Name Type Optional Description
accountId string No

string identifier representing the account to be fetched.

an observable instance of Account.

getCurrentAccount
getCurrentAccount()
Decorators :
@MemoizeAll()

Retrieves the current active account in the application

Example:

Example :
import { AccountService, Account} from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
accountDetails: Account;
accountDetails$: Observable<Account>;

constructor(private accountService: AccountService){}

getCurrentAccountDetails(){
this.accountService.getCurrentAccount().subscribe(a => this.accountDetails = a);
// or
this.accountDetails$ = this.accountService.getCurrentAccount();
}
}

an observable containing the account record.

setAccount
setAccount(account: Account | string)

Sets the selected account to be the current active account for order-on-behalf functions. Will store the selected account record in local storage

Example:

Example :
import { AccountService, Account} from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
accountDetails: Account;
accountDetails$: Observable<Account>;

constructor(private accountService: AccountService){}

setAccount(account: Account | string){
this.accountService.setAccount(account).subscribe(a => this.accountDetails = a);
// or
this.accountDetails$ = this.accountService.setAccount(account);
}
}
Parameters :
Name Type Optional Description
account Account | string No

the account record or string identifier of the account to set as active.

an observable containing the account record that was set to active.

Properties

type
Default value : Account

results matching ""

    No results matching ""