Peer services are for sharing data and functionality across several apps. A common use case would have one app (peer service app) to store all tokens bought by a user so that they can be used across several different apps (peer client apps).

Set Peer App

  • If you did not set up an app as peer service, on Design | Core App Info | Peer Publish page, click [Edit] to start modifying the peer information. For more information about these options, refer to the docs of Peer Publish.
  1. Check the Enable As Peer Service option.
  2. Select an option for service visibility.
  3. Select an option for API usage.
  4. On the Directory tab, add readable information on your peer.
  • On Design | Marketplace | Virtual Currencies page, add a virtual currency by clicking the plus icon and set a name for the currency.
  • Switch to another app, on the Design | Integrations | Peer Services page, you will find the peer app service shows on More Services section. Choose the peer service you just created by clicking the plus icon to connect it.
  • From Configure Peer Service dialog, enter a name at the Service code input box. (This value is used when making API calls against the peer via the current app.) Then click Save.
  • You will find your selected peer service is listed under the Connected Services section now.
  • Go to Design | Marketplace | Virtual Currencies page, the peer app currencies should show up under Peer Currencies section

Test the Peer App Data

  • Call AttachPeerProfile() API of Identity service with the peer service code (here is "PeerApp") and the current login user credential as parameters on API Explorer page.
  • Check the returned response:
  • From Monitoring | User Monitoring | User Summary page, you will find the peer relation shows up under the Relations list.
  • Back to API Explorer page, call AwardPeerCurrency() API of VirtualCurrency service, set parameters virtual currency id with the name you defined on peer app, a value for the amount and the peer service code.
  • Check the returned response:
  • Switch to the peer service app (here is "PeerApp"). From Monitoring | User Monitoring | User Summary page, you will find the peer client info (the virtual currency you added from the peer client app and the relations to the client apps under the Relations section).

Test with hooks

  • Go to the peer service app Design | Core App Info | Peer Publish page, link a script for Validate Config from Hooks tab.

Note: this createEntity script will take a parameter of profileId and create a user entity as below.

var response ={};
var profileId = "";
profileId = data.profileId;
var session = bridge.getSessionForProfile(profileId);
var entityProxy = bridge.getEntityServiceProxy(session);
var entityType = "address";
var entityData = { "street" : "1309 Carling" };
var acl = { "other": 0 };
response = entityProxy.createEntity(entityType, entityData, acl);
response;
  • Switch to a peer client app Monitoring | User Monitoring | User Summary page, select one user who has attached peer identity to the peer service app. Copy a profileId of the Peer service.
  • Go to Design | Integrations | Peer Services page, find this peer app server and click Edit of Actions from the Connected Services list. Enter the profileId and paste the value of profileId you just copied as a parameter to the Configuration Parameters box. Click Validate.
  • Switch back to the peer service app on page Monitoring | User Monitoring | User Entities, you should find the user entity is listed here. It was created from a peer client app.

Call Peer scripts

  • Navigate to the peer service app on page Design| Cloud Code | Scripts, Create or import some scripts, make sure Peer is checked under Client Callable of the script editor dialogue.
  • Switch to a peer client app Monitoring | User Monitoring | User Summary page, select one user who has attached peer identity to the peer service app. Hit [Login As User] button under the user avator.
  • Call RunPeerScript() API of ScriptService service with the peer service code (here is "PeerApp") and other respective parameters on the API Explorer page.
Did this answer your question?