Profile

A comprehensive guide on how to use all profile-related API calls with the LearnCard Network Plugin

Profile Core

1. Create a Profile

To create a new profile, use the createProfile method. This method accepts an object containing the profile information, excluding the did and isServiceProfile properties.

const profile = {
  displayName: 'John Smith',
  profileId: 'johnsmith',
  image: 'https://example.com/avatar.jpg',
};

await  learnCard.invoke.createProfile(profile);

2. Create a Service Profile

To create a new service profile, use the createServiceProfile method. This method accepts an object containing the profile information, excluding the did and isServiceProfile properties.

const serviceProfile = {
  dipslayName: 'Learning Platform',
  profileId: 'learningplatform',
  image: 'https://example.com/service-avatar.jpg',
};

await learnCard.invoke.createServiceProfile(serviceProfile);

3. Update a Profile

To update an existing profile, use the updateProfile method. This method accepts an object containing the profile information that you want to update, excluding the did and isServiceProfile properties.

const updatedProfile = {
  displayName: 'Jane Smith',
};

await learnCard.invoke.updateProfile(updatedProfile);

4. Delete a Profile

To delete an existing profile, use the deleteProfile method. This method does not require any parameters.

await learnCard.invoke.deleteProfile();

5. Get a Profile

To retrieve a specific profile, use the getProfile method. This method accepts an optional profileId parameter. If no profileId is provided, it returns the current user's profile.

const profileId = 'johnsmith';

await learnCard.invoke.getProfile(profileId);

6. Search Profiles

To search for profiles, use the searchProfiles method. This method accepts an optional profileId parameter and an options object. The options object can contain the following properties:

  • limit: Maximum number of profiles to return.

  • includeSelf: Whether to include the current user's profile in the results.

  • includeConnectionStatus: Whether to include connection status in the results.

const profileId = 'johnsmith';
const options = { limit: 10, includeSelf: false, includeConnectionStatus: true };

learnCard.invoke.searchProfiles(profileId, options);

These are all the profile-related API calls available with the LearnCard Network Plugin. Use these methods to manage and interact with user profiles on the LearnCard Network.

Connections Management

1. Connect with a Profile

To send a connection request to another profile, use the connectWith method. This method accepts a profileId parameter.

const profileId = 'janesmith';

await learnCard.invoke.connectWith(profileId);

2. Connect with a Profile using an Invite

To connect with another profile using an invite, use the connectWithInvite method. This method accepts a profileId and a challenge parameter.

const profileId = 'janesmith';
const challenge = 'your_challenge';

await learnCard.invoke.connectWithInvite(profileId, challenge);

3. Cancel a Connection Request

To cancel a pending connection request, use the cancelConnectionRequest method. This method accepts a profileId parameter.

const profileId = 'janesmith';

await learnCard.invoke.cancelConnectionRequest(profileId);

4. Disconnect with a Profile

To disconnect from an existing connection, use the disconnectWith method. This method accepts a profileId parameter.

const profileId = 'janesmith';

await learnCard.invoke.disconnectWith(profileId);

5. Accept a Connection Request

To accept a connection request from another profile, use the acceptConnectionRequest method. This method accepts a profileId parameter.

const profileId = 'janesmith';

await learnCard.invoke.acceptConnectionRequest(profileId);

6. Get Connections

To retrieve all connections, use the getConnections method. This method does not require any parameters.

await learnCard.invoke.getConnections();

7. Get Pending Connections

To retrieve all pending connections, use the getPendingConnections method. This method does not require any parameters.

await learnCard.invoke.getPendingConnections();

8. Get Connection Requests

To retrieve all connection requests, use the getConnectionRequests method. This method does not require any parameters.

await learnCard.invoke.getConnectionRequests();

9. Generate an Invite

To generate an invite, use the generateInvite method. This method accepts an optional challenge parameter.

const challenge = 'your_challenge';

await learnCard.invoke.generateInvite(challenge);

These are all the connection-related API calls available with the LearnCard Network Plugin. Use these methods to manage and interact with connections on the LearnCard Network.

User Blocking

1. Block a Profile

To block a profile, use the blockProfile method. This method accepts a profileId parameter.

const profileId = 'janesmith';

await learnCard.invoke.blockProfile(profileId);

2. Unblock a Profile

To unblock a profile, use the unblockProfile method. This method accepts a profileId parameter.

const profileId = 'janesmith';

await learnCard.invoke.unblockProfile(profileId);

3. Get Blocked Profiles

To retrieve all blocked profiles, use the getBlockedProfiles method. This method does not require any parameters.

await learnCard.invoke.getBlockedProfiles();

These are all the user-blocking related API calls available with the LearnCard Network Plugin. Use these methods to manage and control user-blocking on the LearnCard Network.

Last updated