Enroll Users
Enrolling users is a crucial functionality provided by the edeXa Token engine SDK. To enroll a new user, you can utilize the enrollUser
method.
Prerequisites
- Authenticate the client using the edeXa SDK. For authentication details, see the authentication method.
Sample Code Snippet
Here is a JavaScript code snippet demonstrating the use of the enrollUser
method:
// SDK.js
import { ERC20, Network } from 'edeXa-sdk';
async function enrollUser() {
const erc20 = new ERC20({
...settings,
authorization: `Bearer ${token}`,
});
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};
const dataToEnrollUser = {
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
};
try {
const enrollUserResponse = await erc20.enrollUser(dataToEnrollUser);
// Handle success
} catch (error) {
// Handle error
}
}
Important Notes
- Authentication Token: Replace the
token
in theauthorization
header with your actual authentication token. - Asynchronous Execution: The
enrollUser
function is anasync
function, usingawait
to pause execution until theerc20.enrollUser
promise resolves. If successful, the response will be logged. Errors are caught and logged withconsole.error
. - User Information: Provide the necessary user information in the
dataToEnrollUser
object.
Request Parameters
The dataToEnrollUser
object requires the following parameters:
Parameter | Required | Type | Description |
---|---|---|---|
email | Yes | String | The email of the user |
firstName | Yes | String | The first name of the user |
lastName | Yes | String | The last name of the user |
Response Format
The response from the enrollUser
method includes the following attributes:
Key | Type | Description |
---|---|---|
firstName | String | First name of the user |
lastName | String | Last name of the user |
uuid | String | Unique identifier of the user |
email | String | Email address of the user |
_id | String | Database ID of the user |