@slmdevs/celeraone
Version:
This is a NPM Package to use for all the CeleraOne interactions.
193 lines (131 loc) • 4.75 kB
Markdown
This is a NPM Package to use for all the CeleraOne interactions.
****
****
Async function to fetch a specific user from CeleraOne
**Parameters**
| Name | Type | Example | Description |
| ---- | ---- | ------- | ----------- |
| contractorId | string | payway-550198b3a67201153c000007 | The users social security number |
**Execution**
```javascript
import { findUser } from '@slmdevs/celeraone'
const user = await findUser('payway-550198b3a67201153c000007')
```
**Response**
```json
{
"userId": "b16eccba-4016-4968-90b2-3176172c5421",
"login": "sven@svensson.com",
"accountState": "registered",
"socialSecurityNumber": "199009249179",
"firstName": "Sven",
"lastName": "Svensson",
"email": "sven@svensson.com"
}
```
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**
```javascript
import { updateUserPassword } from '@slmdevs/celeraone'
const success = await updateUserPassword('b16eccba-4016-4968-90b2-3176172c5421', '$2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C')
```
**Response**
```
true / false
```
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 | example@email.com | The new login for the user |
**Execution**
```javascript
import { updateUserLogin } from '@slmdevs/celeraone'
const success = await updateUserLogin('b16eccba-4016-4968-90b2-3176172c5421', 'example@mail.com')
```
**Response**
```
true / false
```
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**
```javscript
import { updateUserMasterData } from '@slmdevs/celeraone'
const success = await updateUserMasterData('b16eccba-4016-4968-90b2-3176172c5421', {
first_name: 'Sven',
last_name: 'Svensson'
})
```
**Response**
```
true / false
```
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**
```javascript
import { addUserProperty } from '@slmdevs/celeraone'
const success = await addUserProperty('5a9b882c-59e7-4221-b009-736aa3351604', 'active_products', 'hejsan123')
```
**Response**
```
true / false
```
Async function to import a user into CeleraOne
**Parameters**
| Name | Type | Example | Description |
| ---- | ---- | ------- | ----------- |
| user | UserInterface | { socialSecurityNumber: '199009249179', email: 'example@mail.com', firstName: 'Sven', lastName: 'Svensson', hashedPassword: '$2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C' } | The user object that will be imported |
**Execution**
```javascript
import { importUser } from '@slmdevs/celeraone'
const userId = await importUser({
socialSecurityNumber: '199009249179',
email: 'example@mail.com',
firstName: 'Sven',
lastName: 'Svensson',
hashedPassword: '$2a$10$bZlWSl9mMRapbiCdV0qIwuaD52GGfKUPV0hASAerMqeMz2BFlO14C'
})
```
**Response**
```
4dd949a7-1231-4267-8131-c05d93f7936e
```
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**
```javascript
import { getUserIdFromSessionId, ServiceId } from `@slmdevs/celeraone`
const userId = await getUserIdFromSessionId('76d67999399263996f177f8e08a74677', ServiceId.GP)
```
**Response**
```
461df36e-9c9e-4049-b7ef-0c3aa39fd704
```