File

projects/apttus/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.

Extends

AObjectService

Index

Properties
Methods

Methods

getAccountById
getAccountById(accountId: string)

Retrieves the Account information based on the accound id passed.

Parameters :
Name Type Optional
accountId string No

an observable containing the account record.

getCurrentAccount
getCurrentAccount()

Retrieves the current active account (used for order-on-behalf functions)

Example:

import { AccountService, Account } from '@apttus/ecommerce';
import { Observable } from 'rxjs/Observable';

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

    constructor(private accountService: AccountService){}

    ngOnInit(){
        this.accountService.getCurrentAccount().subscribe(a => this.account = a);
        // or
        this.account$ + this.accountService.getCurrentAccount();
    }
}

an observable containing the account record

getMyAccount
getMyAccount()

Retrieves the account associated with the current user. For guest user it retrieves the account associated with the storefront object.

Example:

import { AccountService, Account } from '@apttus/ecommerce';
import { Observable } from 'rxjs/Observable';

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

    constructor(private accountService: AccountService){}

    ngOnInit(){
        this.accountService.getMyAccount().subscribe(a => this.account = a);
        // or
        this.account$ + this.accountService.getMyAccount();
    }
}

an observable containing the account record

setAccount
setAccount(account: Account | string, useLocalStorage: boolean)

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:

import { AccountService, Account } from '@apttus/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
    constructor(private accountService: AccountService){}

    setAccount(account: Account){
        this.accountService.setAccount(account, true)
            .subscribe(
                a => {...},
                err => {...}
            );
    }
}
Parameters :
Name Type Optional Default value Description
account Account | string No

the account record to set active

useLocalStorage boolean No false

an observable containing the account record that was set to active

Properties

type
Default value : Account

result-matching ""

    No results matching ""