@plasma-platform/service-users
v4.0.2
Published
Users Service API
Downloads
212
Readme
Full documentation
install:npm i @plasma-platform/service-users -S
Short documentation
Table of Contents
- UsersService
- Parameters
- messages
- getUserById
- requestAuthenticatedUserInformation
- getListOfUsersAuthClient
- linkAuthClientToUser
- requestAuthClientInformation
- requestAuthClientInfoWithoutId
- unlinkAuthClientFromUser
- getCitiesByIpAddresses
- getCitiesByZipAndCountryCode
- getCitiesByZipCodes
- getCityByIpAddress
- getListOfCountries
- getListOfSegmentOptions
- getListOfSegments
- getListOfStateProvinces
- addNewUser
- confirmEmail
- confirmIp
- getLinkForAvatarUpload
- getListOfUsers
- getPaginationMetadata
- getSegmentOptionForUserByToken
- getSegmentOptionByUserId
- refreshToken
- loginProfile
- modifyAuthorizedUserInformation
- modifyUserInformationByUserId
- registerConfirmedUser
- requestUserEmailExistInformation
- requestUserInformationByUserId
- requestChangeEmail
- requestChangePasswordEmail
- requestForPasswordResetEmail
- requestForRegistrationEmail
- requestPublicUsersInformation
- setNewEmailUsingEmailToken
- setNewPasswordToUserUsingChangePasswordToken
- setNewPasswordByResetToken
- setSegmentOptionByToken
- setSegmentOptionByUserId
- signinSignupViaAuthClient
- subscribeUserToNewsletters
- requestUserTokenInformation
- getPublicUsersCount
- setSupportRoles
- deleteSupportRoles
- getAuthorsSupportRoles
UsersService
Users Micro Service API
Parameters
url
string service urltoken
(string | null) user access tocken if available (optional, defaultnull
)
messages
Object with class service messages
Type: object
getUserById
User - Request public user information by user id
Parameters
userId
number User ID
Examples
Get user profile by Id
(async () => {
const users = new UsersService('//api.templatemonsterdev.com/users/v1/');
const profile = await users.getUserById(1);
})();
Returns user User profile
requestAuthenticatedUserInformation
Request authenticated user information
Parameters
data
object any expand
Examples
Get current user profile
(async () => {
const users = new UsersService('//api.templatemonsterdev.com/users/v1/');
const profile = await users.getProfile(true);
})();
Returns user Current user profile
getListOfUsersAuthClient
AuthClient - Get list of users AuthClient
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.getListOfUsersAuthClient({
userId: 12940,
page: 1,
});
})();
Returns Promise<listOfUsers>
linkAuthClientToUser
AuthClient - Link AuthClient to user
Parameters
params
Object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.linkAuthClientToUser({
userId: '12940',
client: 'John',
});
})();
Returns Promise<userInfo>
requestAuthClientInformation
AuthClient - Request AuthClient information
Parameters
id
Number users id in AuthClient.
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.requestAuthClientInformation(12940);
})();
Returns Promise<userInfo>
requestAuthClientInfoWithoutId
AuthClient - Request AuthClient information
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.requestAuthClientInfoWithoutId();
})();
Returns Promise<userInfo>
unlinkAuthClientFromUser
AuthClient - Unlink AuthClient from user
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.unlinkAuthClientFromUser(params);
})();
Returns Boolean
getCitiesByIpAddresses
Cities - Get cities by ip addresses
Parameters
ips
array IP addresses.
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getCitiesByIpAddresses(["192.168.2.59"]);
})();
Returns Promise<cityInfo>
getCitiesByZipAndCountryCode
Cities - Get cities by zip and country code
Parameters
zip
String Zip code.zip
countryCode Country code (2 chars, optional).
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getCitiesByZipAndCountryCode({zip:'02070'});
})();
Returns Promise<cityInfo>
getCitiesByZipCodes
Cities - Get cities by zip codes
Parameters
zips
array Zip codes.
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getCitiesByZipCodes(["54000"]);
})();
Returns Promise<cityInfo>
getCityByIpAddress
Cities - Get city by ip address
Parameters
ip
String IP address.
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getCityByIpAddress('192.168.2.59');
})();
Returns Promise<cityInfo>
getListOfCountries
Countries - Get list of countries
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getListOfCountries();
})();
Returns Promise<countriesInfo>
getListOfSegmentOptions
SegmentOptions - Get list of segment options
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getListOfSegmentOptions();
})();
Returns Promise<segmentOptionsInfo>
getListOfSegments
Segments - Get list of segments
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getListOfSegments();
})();
Returns Promise<segmentOptionsInfo>
getListOfStateProvinces
StateProvinces - Get list of state provinces
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getListOfStateProvinces();
})();
Returns Promise<segmentOptionsInfo>
addNewUser
User - Add new user
Parameters
params
objectparams.login
String User loginparams.password
String User passwordparams.subscription
Boolean Subscribe user to newsletterparams.locale
String 2 char locale (if not specified default 'en' will be used)params.country
String Country code (2 chars)params.state
String State code (2 chars)params.segmentOptionId
String Subscription segment option (if not specified default 4 will be used)
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.addNewUser({
login: '[email protected]',
password: 'qweqwe',
segmentoption_id: 4
});
})();
Returns Promise<userInfo>
confirmEmail
User - Confirm email
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.confirmEmail(params);
})();
Returns Promise<userInfo>
confirmIp
User - Confirm ip
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.confirmIp(params);
})();
Returns Promise<userInfo>
getLinkForAvatarUpload
User - Get link for avatar upload
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.getLinkForAvatarUpload(params);
})();
Returns Promise<imageLink>
getListOfUsers
User - Get list of users
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.getListOfUsers(params);
})();
Returns Promise<imageLink>
getPaginationMetadata
User - Get pagination metadata for Users {get} /users api call
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getPaginationMetadata();
})();
Returns Promise<paginationData>
getSegmentOptionForUserByToken
User - Get segment option for user identified by access token
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.getSegmentOptionForUserByToken(params);
})();
Returns Promise<userInfo>
getSegmentOptionByUserId
User - Get segment option for user identified by user id
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.getSegmentOptionByUserId(params);
})();
Returns Promise<userInfo>
refreshToken
User - Issue access token using refresh token
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.refreshToken(params);
})();
Returns Promise<userInfo>
loginProfile
User - Issue access token
Parameters
params
object
Examples
Request Issue access token
(async () => {
const users = new UsersService('//api.templatemonsterdev.com/users/v1/');
const tokenInfo = await users.loginProfile({
login: '[email protected]',
password: '123123',
scope: 'memberships,services'
});
})();
Returns object User token information
modifyAuthorizedUserInformation
User - Modify authorized user information
Parameters
params
objectparams.password
String User password.params.firstname
String User first name.params.lastname
String User last name.params.phone
String User phone.params.avatar
String User avatar.params.billingInfo
Array Billing info array with following fields [firstname, lastname, city, email, postalcode, billingphone, country, state, contactphone, address]params.settings
Array cookie settings info [cookieNecessary, cookieAnalytics, cookieTargeting]params.expand
Array expand for method
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.modifyAuthorizedUserInformation(params);
})();
Returns Promise<userInfo>
modifyUserInformationByUserId
User - Modify user information by user id
Parameters
params
objectparams.userId
Number User unique ID.params.firstname
String User first name.params.lastname
String User last name.params.phone
String User phone.params.stateId
Number User status ID: 1 - Waiting, 2 - Normal, 3 - Disabled, 4 - Without confirm, 5 - With confirm, 6 - Required confirmparams.billingInfo
Array Billing info array with following fields [firstname, lastname, city, email, postalcode, billingphone, country, state, contactphone, address]
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.modifyUserInformationByUserId(params);
})();
Returns Promise<userInfo>
registerConfirmedUser
User - Register confirmed user
Parameters
params
objectparams.login
String User login.params.password
String User password.params.country
String 2 symbol code of countryparams.state
String 2 symbol code of state (XX if there are no states in this country)params.firstname
Stringparams.lastname
Stringparams.birthday
Numberparams.phone
Stringparams.website
Stringparams.company
Stringparams.avatar
Stringparams.sex
Numberparams.expand
String List of additional data to be returned, may contain following fields divided by comma - billingInfo, segmentOptions, token(this will create new access token), optional.params.sendEmail
Boolean Flag that indicates if registration email should be sent, optional.params.segmentOptionId
Number Id of segment option, optional.params.scope
String List of oauth scopes divided by space.params.billingInfo
Array User billing info, optional.
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.registerConfirmedUser(params);
})();
Returns Promise<userInfo>
requestUserEmailExistInformation
User - Request User email exist information
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.requestUserEmailExistInformation(params);
})();
Returns Promise<userInfo>
requestUserInformationByUserId
User - Request User information by user id
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.requestUserInformationByUserId(params);
})();
Returns Promise<userInfo>
requestChangeEmail
User - Request change email
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.requestChangeEmail(params);
})();
Returns Boolean
requestChangePasswordEmail
User - Request change password email
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.requestChangePasswordEmail(params);
})();
Returns Boolean
requestForPasswordResetEmail
User - Request for password reset email
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.requestForPasswordResetEmail(params);
})();
Returns Boolean
requestForRegistrationEmail
User - Request for registration email
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.requestForRegistrationEmail(params);
})();
Returns Boolean
requestPublicUsersInformation
User - Request public users information based on request params
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.requestPublicUsersInformation(params);
})();
Returns Promise<userInfo>
setNewEmailUsingEmailToken
User - Set new email to user using change email token
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.setNewEmailUsingEmailToken(params);
})();
Returns Promise<userInfo>
setNewPasswordToUserUsingChangePasswordToken
User - Set new password to user using change password token
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.setNewPasswordToUserUsingChangePasswordToken(params);
})();
Returns Promise<userInfo>
setNewPasswordByResetToken
User - Set new password to user using reset token
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.setNewPasswordByResetToken(params);
})();
Returns Promise<userInfo>
setSegmentOptionByToken
User - Set segment option for user identified by access token
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/, token');
const request = await service.setSegmentOptionByToken(params);
})();
Returns Boolean
setSegmentOptionByUserId
User - Set segment option for user identified by user id
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/, token');
const request = await service.setSegmentOptionByUserId(params);
})();
Returns Boolean
signinSignupViaAuthClient
User - Signin or signup via external auth client
Parameters
params
objectparams.clientName
String Name of external auth client - facebook, google, etc..params.token
String OAuth access token from external auth provider.params.scope
String List of oauth scopes divided by space.params.segmentOptionId
String Segment option id.params.subscription
Boolean Subscribe user to newsletter.params.locale
String Subscription locale (if not specified default 'en' will be used).
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.signinSignupViaAuthClient(params);
})();
Returns Promise<userInfo>
subscribeUserToNewsletters
User - Subscribe user to newsletters
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/, token');
const request = await service.subscribeUserToNewsletters(params);
})();
Returns Boolean
requestUserTokenInformation
UserToken - Request User Token information
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.requestUserTokenInformation(params);
})();
Returns Promise<listOfUsers>
getPublicUsersCount
User - Get users total count {get} /users api call
Parameters
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/');
const request = await service.getPublicUsersCount();
})();
Returns Promise<usersCountData>
setSupportRoles
RBAC - Add or change roles for support user
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.setSupportRoles(params);
})();
Returns Promise<info>
deleteSupportRoles
RBAC - Delete roles that have been registered for the user
Parameters
params
object
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.deleteSupportRoles(params);
})();
Returns Promise<info>
getAuthorsSupportRoles
RBAC - Get roles that have been registered to the author
Examples
(async () => {
const service = new Service('//api.templatemonsterdev.com/users/v1/', token);
const request = await service.getAuthorsSupportRoles(params);
})();
Returns Promise<info>