@slmdevs/celeraone
v1.1.9
Published
This is a NPM Package to use for all the CeleraOne interactions.
Downloads
33
Maintainers
Keywords
Readme
This is a NPM Package to use for all the CeleraOne interactions.
Users
Find user
Async function to fetch a specific user from CeleraOne
Parameters
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | contractorId | string | payway-550198b3a67201153c000007 | The users social security number |
Execution
import { findUser } from '@slmdevs/celeraone'
const user = await findUser('payway-550198b3a67201153c000007')
Response
{
"userId": "b16eccba-4016-4968-90b2-3176172c5421",
"login": "[email protected]",
"accountState": "registered",
"socialSecurityNumber": "199009249179",
"firstName": "Sven",
"lastName": "Svensson",
"email": "[email protected]"
}
Update user password (hashed_password)
Async function to update a users hashed_password in CeleraOne
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | userId | string | b16eccba-4016-4968-90b2-3176172c5421 | The userId the user has in CeleraOne | | passwordHash | string | $2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C | The bcrypt hash |
Execution
import { updateUserPassword } from '@slmdevs/celeraone'
const success = await updateUserPassword('b16eccba-4016-4968-90b2-3176172c5421', '$2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C')
Response
true / false
Update user login
Async function to update the users login
Parameters
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | userId | string | b16eccba-4016-4968-90b2-3176172c5421 | The userId the user has in CeleraOne | | newLogin | string | [email protected] | The new login for the user |
Execution
import { updateUserLogin } from '@slmdevs/celeraone'
const success = await updateUserLogin('b16eccba-4016-4968-90b2-3176172c5421', '[email protected]')
Response
true / false
Update the users MasterData
Async function to update the users MasterData in CeleraOne
Parameters
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | userId | string | b16eccba-4016-4968-90b2-3176172c5421 | The userId the user has in CeleraOne | | data | MasterDataInterface | { first_name: 'Sven', last_name: 'Svensson' } | The MasterData properties that you want to update |
Execution
import { updateUserMasterData } from '@slmdevs/celeraone'
const success = await updateUserMasterData('b16eccba-4016-4968-90b2-3176172c5421', {
first_name: 'Sven',
last_name: 'Svensson'
})
Response
true / false
Add user propertyy
Async function to add a property to the user in CeleraOne
Parameters
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | userId | string | b16eccba-4016-4968-90b2-3176172c5421 | The userId the user has in CeleraOne | | name | string | active_prodcuts | The property name | | value | string | 'gp-digital-bas,e-tidning' | The value to be set |
Execution
import { addUserProperty } from '@slmdevs/celeraone'
const success = await addUserProperty('5a9b882c-59e7-4221-b009-736aa3351604', 'active_products', 'hejsan123')
Response
true / false
Import user
Async function to import a user into CeleraOne
Parameters
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | user | UserInterface | { socialSecurityNumber: '199009249179', email: '[email protected]', firstName: 'Sven', lastName: 'Svensson', hashedPassword: '$2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C' } | The user object that will be imported |
Execution
import { importUser } from '@slmdevs/celeraone'
const userId = await importUser({
socialSecurityNumber: '199009249179',
email: '[email protected]',
firstName: 'Sven',
lastName: 'Svensson',
hashedPassword: '$2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C'
})
Response
4dd949a7-1231-4267-8131-c05d93f7936e
Get userId via users session_id
Async function to fetch the userId from the users session_id
Parameters
| Name | Type | Example | Description | | ---- | ---- | ------- | ----------- | | sessionId | string | 76d67999399263996f177f8e08a74677 | The users session_id | | serviceId | ServiceId | ServiceId.GP | The serviceId in CeleraOne |
Execution
import { getUserIdFromSessionId, ServiceId } from `@slmdevs/celeraone`
const userId = await getUserIdFromSessionId('76d67999399263996f177f8e08a74677', ServiceId.GP)
Response
461df36e-9c9e-4049-b7ef-0c3aa39fd704