EvanBcService

Source bc
BCC business center API wrapper. Manages:
  • bc object initialization
  • bc contract creation & loading
  • bc member loading
  • joinLeaveBcQueueId - QueueId: queue id for checking joining / leaving members
  • profileQueueId - QueueId: queue id for applying business center information to the users profile

getCurrentBusinessCenter

bcService.getCurrentBusinessCenter(ensDomain);

Gets the current business center. It is created using the BCBundle.createBC runtime function.

Parameters

  1. ensDomain - string: bc ens domain

Returns

Promise returns any: the initialized business center

  • ensDomain - string: bc ens domain
  • bcAddress - string: bc contract address
  • businessCenter - any: BusinessCenter contract address
  • bcRoles - RightsAndRoles: roles object for the business center
  • ipld - Ipld: ipld for the business center
  • bcProfiles - BusinessCenterProfile: profiles object for the business center
  • description - Description: description object for the business center
  • dataContract - DataContract: dataContract specific for the business center

Example

const businessCenter = await this.bcService.getCurrentBusinessCenter('taskboard.evan');

reloadBc

bcService.reloadBc(ensDomain);

Refresh the data of a loaded business center. Have a look at “getCurrentBusinessCenter”

Parameters

  1. ensDomain - string: ens domain to load the bc for

Returns

Promise returns any: business center object

Example

await this.bcService.reloadBc('taskboard.evan');

getMembers

bcService.getMembers(contract, ensDomain);

load the members for a contract within an business center

Parameters

  1. contract - any: contract id or contract object
  2. ensDomain - string: ens domain of the business center

Returns

Promise returns Array<string>: list of members

Example

this.bcService.getMembers(null, 'taskboard.evan')

getProfiles

bcService.getProfiles(members, ensDomain);

Load profiles for an member array

Parameters

  1. members - Array<any>: members to load the profiles for
  2. ensDomain - string: ens domain to load the contact cards from

Returns

Promise returns void: profiles analogous to addressbook profiles.

Example

const members = await bcService.getMembers(null, ensDomain);
const profiles = await bcService.getProfiles(members);

getProfileQueueId

bcService.getProfileQueueId(ensDomain);

Creates an queue id for users profile within a business center

Parameters

  1. ensDomain - string: ens domain to create the queue id for

Returns

QueueId: The profile queue identifier.

Example

this.queue.addQueueData(this.getProfileQueueId(ensDomain), {
  alias,
  description: loadedBc.description
});

isMember

bcService.isMember(accountId, ensDomain);

Checks if a member is joined to a business center

Parameters

  1. accountId - string: account id to check
  2. ensDomain - string: ens domain of the business center

Returns

Promise returns boolean: True if member, False otherwise.

Example

const isUserMember = bcService.isMember('0x000', 'taskboard.evan');

profileSet

bcService.profileSet(ensDomain);

Check if the user has a business center profile

Parameters

  1. ensDomain - string: ens domain of the business center

Returns

Promise returns boolean: true if profile exists, else false

Example

const isProfileSet = bcService.profileSet(ensDomain);

saveProfile

bcService.saveProfile(arguments);

Save the alias of a user to business center profile

Parameters

  1. alias - string: alias to save
  2. ensDomain - string: ens domain of the business center

Returns

Promise returns void: resolved when done

Example

bcService.saveProfile('cool alias', 'taskboard.evan');

getBCContracts

bcService.getBCContracts(ensDomain);

Get your contracts for a specific business center.

Parameters

  1. ensDomain - string: ens domain of the business center

Returns

Promise returns Array<any>: The bc contracts. ([ this.getBCContract() ])

Example

const bcContracts = bcService.getBCContracts('taskboard.evan');

getBCContract

initializedModule.getBCContract(ensDomain, contract);

load a contract of a business center

Parameters

  1. ensDomain - string: ens domain of the business center
  2. contractId - string: The contract identifier

Returns

Promise returns any: The bc contract.

Example

const bcContract = bcService.getBCContract('taskboard.evan', '0x000');

getJoinLeaveBcQueueId

bcService.getJoinLeaveBcQueueId(ensDomain);

Gets the join leave bc QueueId.

Parameters

  1. ensDomain - string: The ens domain

Returns

QueueId: The join leave bc queue identifier.

Example

const queueId = bcService.getJoinLeaveBcQueueId('taskboard.evan');

joinBcViaQueue

bcService.joinBcViaQueue(ensDomain);

Join a business center using the bc profile QueueId

Parameters

  1. ensDomain - string: The ens domain

Returns

Promise returns void: resolved when done

Example

await joinBcViaQueue('taskboard.evan');

executeOperationOnBc

bcService.executeOperationOnBc(ensDomain, operation);

Run a business-center contract function.

Parameters

  1. ensDomain - string: ens domain of the business center
  2. operation - string: contract function

Returns

Promise returns void: resolved when done

Example

await this.executeOperationOnBC(ensDomain, 'join');

joinBc

bcService.joinBc(ensDomain);

Join a business center

Parameters

  1. ensDomain - string: ens domain of the business center

Returns

Promise returns void: resolved when done

Example

await bcService.joinBc('taskboard.evan');

leaveBc

bcService.leaveBc(ensDomain);

leave a business center

Parameters

  1. ensDomain - string: ens domain of the business center

Returns

Promise returns void: resolved when done

Example

await bcService.leaveBc('taskboard.evan');