npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@plasma-platform/service-users

v4.0.2

Published

Users Service API

Downloads

28

Readme

version nextVersion downloads license dependency


Full documentation
install:
npm i @plasma-platform/service-users -S

Short documentation

Table of Contents

UsersService

Users Micro Service API

Parameters

  • url string service url
  • token (string | null) user access tocken if available (optional, default null)

messages

Object with class service messages

Type: object

getUserById

User - Request public user information by user id

Parameters

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

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
    • params.userId String users id in AuthClient.
    • params.client String AuthClient name(facebook, google etc.).

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

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

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

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 object
    • params.login String User login
    • params.password String User password
    • params.subscription Boolean Subscribe user to newsletter
    • params.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
    • params.token String User confirm email token.
    • params.scope String List of oauth scopes divided by space (optional).

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
    • params.token String User confirm ip token.
    • params.scope String List of oauth scopes divided by space (optional).

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

  • params object
    • params.page Number Page number.
    • params.perPage Number Number of users in one page.

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
    • params.refreshToken String Refresh token.
    • params.scope String Set of scopes divided by space symbol.

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

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 object
    • params.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 object
    • params.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 confirm
    • params.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 object
    • params.login String User login.
    • params.password String User password.
    • params.country String 2 symbol code of country
    • params.state String 2 symbol code of state (XX if there are no states in this country)
    • params.firstname String
    • params.lastname String
    • params.birthday Number
    • params.phone String
    • params.website String
    • params.company String
    • params.avatar String
    • params.sex Number
    • params.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
    • params.email String User email. (required)
    • params.expand String List of additional data to be returned (e.g. authClients) (optional).

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
    • params.email String User email.
    • params.locale String email language. (optional, 'en' by default)

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
    • params.login String User email.
    • params.password String New password to set.
    • params.locale String email language. (optional, 'en' by default)

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
    • params.login String User email.
    • params.locale String email language. (optional, 'en' by default)

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
    • params.login String User email.
    • params.locale String email language. (optional, 'en' by default)

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
    • params.ids String search by few id divided by comma (e.g. ?ids=124088,123456)
    • params.login String search by e-mail address

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
    • params.token String User change email token.
    • params.scope String List of oauth scopes divided by space.

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
    • params.token String User change email token.
    • params.scope String List of oauth scopes divided by space.

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
    • params.token String User change email token.
    • params.scope String List of oauth scopes divided by space.
    • params.password String List of oauth scopes divided by space.

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

  • params object
    • params.segmentOptionId Number Segment option ID.

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

  • params object
    • params.userId Number User ID.
    • params.segmentOptionId Number Segment option ID.

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 object
    • params.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
    • params.login string users email.
    • params.roles array Roles list (ticketSupport, reviewSupport, uploadSupport).

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
    • params.login string users email.
    • params.roles array Roles list (ticketSupport, reviewSupport, uploadSupport).

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>